当前位置:网站首页>Spark 判断DF为空
Spark 判断DF为空
2022-07-07 18:15:00 【南风知我意丿】
不同方案性能测试
我有同样的问题,并且测试了3个主要解决方案:
df!= null df.count> 0
df.head(1).isEmpty()
df.rdd.isEmpty
大约需要9366ms
大约需要5607毫秒
大约需要1921ms
当然这3种有效,但是就性能而言,这是我在执行时间方面在我的机器的同一DF上执行这些方法时发现的
更新另一种方法
/** * 判断DataFrame是否为空 * @param df DataFrame * @return true 表示为空 or false 表示非空 */
def isEmpty(df: DataFrame): Boolean ={
try{
df.head()
false
}catch {
case e: NoSuchElementException =>
println(e.getMessage)
true
}
}
边栏推荐
- 《数字图像处理原理与实践(MATLAB版)》一书之代码Part2[通俗易懂]
- CJSON内存泄漏的注意事项
- Graduation season | regretful and lucky graduation season
- Gorilla official: sample code for golang to open websocket client
- vulnhub之school 1
- 基于深度学习的目标检测的更新迭代总结(持续更新ing)
- Boot 和 Cloud 的版本选型
- Force buckle 1790 Can two strings be equal by performing string exchange only once
- 力扣 912.排序数组
- 【mysql篇-基础篇】事务
猜你喜欢
随机推荐
Data island is the first danger encountered by enterprises in their digital transformation
Force buckle 989 Integer addition in array form
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
整型int的拼接和拆分
让这个CRMEB单商户微信商城系统火起来,太好用了!
vulnhub之Funfox2
力扣 599. 两个列表的最小索引总和
Micro service remote debug, nocalhost + rainbow micro service development second bullet
Sword finger offer II 013 Sum of two-dimensional submatrix
Traversée des procédures stockées Oracle
One click deployment of any version of redis
Cuda版本不一致,编译apex报错
使用camunda做工作流设计,驳回操作
Equals method
有用的win11小技巧
【解决】package ‘xxxx‘ is not in GOROOT
Read PG in data warehouse in one article_ stat
c语言如何判定是32位系统还是64位系统
CSDN syntax description
831. KMP string









