当前位置:网站首页>Spark Tuning (II): UDF reduces joins and judgments
Spark Tuning (II): UDF reduces joins and judgments
2022-07-06 23:09:00 【InfoQ】
1. cause
2. Optimization starts
2.1 Change to java Code writing program
2.2 Use UDF
public class UDF implements UDF2<Long, Long, Long> {
Map<Long, TreeMap<Long, Long>> map;
public TripUDF(Broadcast<Map<Long, TreeMap<Long, Long>>> bmap) {
this.map = bmap.getValue();
}
@Override
public Long call(Long id, Long time) throws Exception {
if (map.containsKey(terminalId)) {
Map.Entry<Long, Long> a = map.get(id).floorEntry(time);
Map.Entry<Long, Long> b = map.get(id).ceilingEntry(time);
if (null != a && null != b) {
if (a.getValue().equals(b.getValue())) {
return a.getValue();
}
}
}
return -1L;
}
}
tablea join tableb
on tablea.id=tableb.id and
tablea.time >= tableb.timeStart and
tablea.time <= tableb.timeEnd
String udfMethod = "structureMap";
spark.udf().register(udfMethod, new UDF(broadcast1), DataTypes.StringType);
select id,time,structureMap(id,time) as tag from tablea
Conclusion
边栏推荐
- Word2vec (skip gram and cbow) - pytorch
- OpenNMS分离数据库
- Extern keyword
- Redis persistence mechanism
- (shuttle) navigation return interception: willpopscope
- 金融人士必读书籍系列之六:权益投资(基于cfa考试内容大纲和框架)
- Financial professionals must read book series 6: equity investment (based on the outline and framework of the CFA exam)
- Method of canceling automatic watermarking of uploaded pictures by CSDN
- The application of machine learning in software testing
- 企業不想換掉用了十年的老系統
猜你喜欢
Traversal of a tree in first order, middle order, and then order
Word2vec (skip gram and cbow) - pytorch
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
为了交通安全,可以做些什么?
Machine test question 1
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
UE4 blueprint learning chapter (IV) -- process control forloop and whileloop
MySQL authentication bypass vulnerability (cve-2012-2122)
监控界的最强王者,没有之一!
随机推荐
Les entreprises ne veulent pas remplacer un système vieux de dix ans
On file uploading of network security
What are the specific steps and schedule of IELTS speaking?
儿童睡衣(澳大利亚)AS/NZS 1249:2014办理流程
Demonstration of the development case of DAPP system for money deposit and interest bearing financial management
Flutter life cycle
面试题:AOF重写机制,redis面试必问!!!
Word2vec (skip gram and cbow) - pytorch
memcached
Method of canceling automatic watermarking of uploaded pictures by CSDN
金融人士必读书籍系列之六:权益投资(基于cfa考试内容大纲和框架)
Slide the uniapp to a certain height and fix an element to the top effect demo (organize)
docker启动mysql及-eMYSQL_ROOT_PASSWORD=my-secret-pw问题解决
借助这个宝藏神器,我成为全栈了
DevSecOps软件研发安全实践——发布篇
POJ 1094 sorting it all out
AcWing 4300. Two operations (minimum number of BFS searches)
TypeScript获取函数参数类型
浅谈网络安全之文件上传
poj 1094 Sorting It All Out (拓扑排序)