当前位置:网站首页>Spark 判断DF为空
Spark 判断DF为空
2022-07-25 15:10: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
}
}
边栏推荐
- Implement a simple restful API server
- Bridge NF call ip6tables is an unknown key exception handling
- 瀑布流布局
- Client error: invalid param endpoint is blank
- [C topic] Li Kou 88. merge two ordered arrays
- SublimeText-win10光标跟随问题
- 32 chrome调试工具的使用
- About RDBMS and non RDBMS [database system]
- MySQL sort
- [C题目]牛客 链表中倒数第k个结点
猜你喜欢

Add the jar package under lib directory to the project in idea

Leo-sam: tightly coupled laser inertial odometer with smoothing and mapping

一个程序最多可以使用多少内存?

41 picture background synthesis - colorful navigation map

Share a department design method that avoids recursion

Realsense ROS installation configuration introduction and problem solving

43 盒子模型

ice 100G 网卡分片报文 hash 问题

System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏

45padding不会撑开盒子的情况
随机推荐
Share a department design method that avoids recursion
给VS2010自动设置模板,加头注释
Deployment and simple use of PostgreSQL learning
反射-笔记
vscode 插件篇收集
图片的懒加载
万能通用智能JS表单验证
Thymeleaf notes
了解一下new的过程发生了什么
ice 100G 网卡分片报文 hash 问题
【微信小程序】小程序宿主环境详解
QT connect, signal, slot and lambda comparison
I2C device driver hierarchy
iframe嵌套其它网站页面 全屏设置
解决asp.net上传文件时文件太大导致的错误
32 use of chrome debugging tools
Content type corresponding to office file
dpdk 收发包问题案例:使用不匹配的收发包函数触发的不收包问题定位
我的创作纪念日
npm的nexus私服 E401 E500错误处理记录