当前位置:网站首页>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
边栏推荐
- QT signal and slot
- Enterprises do not want to replace the old system that has been used for ten years
- 企業不想換掉用了十年的老系統
- asp读取oracle数据库问题
- Les entreprises ne veulent pas remplacer un système vieux de dix ans
- Cocoscreator+typescripts write an object pool by themselves
- 浅谈网络安全之文件上传
- Word2vec (skip gram and cbow) - pytorch
- 欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质
- [compilation principle] LR (0) analyzer half done
猜你喜欢
借助这个宝藏神器,我成为全栈了
Why are some people still poor and living at the bottom of society even though they have been working hard?
Improving Multimodal Accuracy Through Modality Pre-training and Attention
Dockermysql modifies the root account password and grants permissions
金融人士必读书籍系列之六:权益投资(基于cfa考试内容大纲和框架)
企业不想换掉用了十年的老系统
【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件
Word2vec (skip gram and cbow) - pytorch
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
Let's see through the network i/o model from beginning to end
随机推荐
Custom swap function
Puppeter connects to the existing Chrome browser
Extern keyword
On the problems of born charge and non analytical correction in phonon and heat transport calculations
mysql连接vscode成功了,但是报这个错
石墨文档:4大对策解决企业文件信息安全问题
Dayu200 experience officer homepage AITO video & Canvas drawing dashboard (ETS)
POJ 1258 Agri-Net
Aardio - does not declare the method of directly passing float values
MySQL ---- first acquaintance with MySQL
How big is the empty structure?
Mysql 身份认证绕过漏洞(CVE-2012-2122)
Aardio - construct a multi button component with customplus library +plus
Uniapp setting background image effect demo (sorting)
AcWing 4300. Two operations (minimum number of BFS searches)
【全网首发】Redis系列3:高可用之主从架构的
Volatile keyword
面试题:AOF重写机制,redis面试必问!!!
[untitled]
2014阿里巴巴web前实习生项目分析(1)