当前位置:网站首页>spark调优(二):UDF减少JOIN和判断
spark调优(二):UDF减少JOIN和判断
2022-07-06 15:38:00 【InfoQ】
1. 起因
2. 优化开始
2.1 改成java代码编写程序
2.2 使用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
结束语
边栏推荐
- [launched in the whole network] redis series 3: high availability of master-slave architecture
- Thinkphp5 multi table associative query method join queries two database tables, and the query results are spliced and returned
- European Bioinformatics Institute 2021 highlights report released: nearly 1million proteins have been predicted by alphafold
- Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
- Les entreprises ne veulent pas remplacer un système vieux de dix ans
- Const keyword
- UDP programming
- 华为云GaussDB(for Redis)揭秘第21期:使用高斯Redis实现二级索引
- 案例推荐丨安擎携手伙伴,保障“智慧法院”更加高效
- Some suggestions for foreign lead2022 in the second half of the year
猜你喜欢

On the problems of born charge and non analytical correction in phonon and heat transport calculations

MySQL ---- first acquaintance with MySQL

室内LED显示屏应该怎么选择?这5点注意事项必须考虑在内

Dayu200 experience officer homepage AITO video & Canvas drawing dashboard (ETS)

Hard core observation 545 50 years ago, Apollo 15 made a feather landing experiment on the moon

European Bioinformatics Institute 2021 highlights report released: nearly 1million proteins have been predicted by alphafold

DR-Net: dual-rotation network with feature map enhancement for medical image segmentation

关于声子和热输运计算中BORN电荷和non-analytic修正的问题

Dayu200 experience officer runs the intelligent drying system page based on arkui ETS on dayu200
The problem that dockermysql cannot be accessed by the host machine is solved
随机推荐
mysql查看表结构的三种方法总结
Dayu200 experience officer runs the intelligent drying system page based on arkui ETS on dayu200
The application of machine learning in software testing
(shuttle) navigation return interception: willpopscope
Mysql 身份认证绕过漏洞(CVE-2012-2122)
poj 1094 Sorting It All Out (拓扑排序)
允许全表扫描 那个语句好像不生效set odps.sql.allow.fullscan=true;我
Signed and unsigned keywords
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
Sword finger offer question brushing record 1
ICLR 2022 | pre training language model based on anti self attention mechanism
MySQL authentication bypass vulnerability (cve-2012-2122)
dockermysql修改root账号密码并赋予权限
docker中mysql开启日志的实现步骤
Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
Uniapp setting background image effect demo (sorting)
UVa 11732 – strcmp() Anyone?
How does crmeb mall system help marketing?
How to choose the server system
How to achieve text animation effect