当前位置:网站首页>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
}
}
边栏推荐
- Useful win11 tips
- MSE API learning
- Force buckle 989 Integer addition in array form
- 图扑数字孪生煤矿开采系统,打造采煤“硬实力”
- ASP. Net learning & ASP's one word
- How C language determines whether it is a 32-bit system or a 64 bit system
- With st7008, the Bluetooth test is completely grasped
- LeetCode_ 7_ five
- 恢复持久卷上的备份数据
- Get webkitformboundary post login
猜你喜欢
随机推荐
网络原理(1)——基础原理概述
Creation of kubernetes mysql8
Kubernetes -- detailed usage of kubectl command line tool
Mrs offline data analysis: process OBS data through Flink job
《数字图像处理原理与实践(MATLAB版)》一书之代码Part2[通俗易懂]
Mongodb由浅入深学习
Chapter 20 using work queue manager (3)
Force buckle 88 Merge two ordered arrays
POJ 1742 Coins ( 单调队列解法 )「建议收藏」
Gorilla official: sample code for golang to open websocket client
Implement secondary index with Gaussian redis
开发那些事儿:Go加C.free释放内存,编译报错是什么原因?
vulnhub之tre1
Force buckle 1790 Can two strings be equal by performing string exchange only once
使用 BR 备份 TiDB 集群数据到 Azure Blob Storage
力扣599. 两个列表的最小索引总和
gorilla官方:golang开websocket client的示例代码
力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
Meta Force原力元宇宙系统开发佛萨奇模式
让这个CRMEB单商户微信商城系统火起来,太好用了!