如何在Apache Spark sql数据帧中找到每个行的大小,并发现大小超过阈值大小的行(千字节) [英] How can find size of each Row in Apache spark sql dataframe and discrad the rows having size more than a threshold size in Kilobyte

查看:85
本文介绍了如何在Apache Spark sql数据帧中找到每个行的大小,并发现大小超过阈值大小的行(千字节)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Scala的Apache Spark SQL的新手.

I am new in apache spark sql in scala.

如何在Apache spark sql数据帧中找到每个行的大小,并发现大小超过阈值大小(以千字节为单位)的行.我正在寻找Scala解决方案.

How can find size of each Row in Apache spark sql dataframe and discrad the rows having size more than a threshold size in Kilobyte. I am looking for scala solution.

推荐答案

这实际上是一个棘手的问题.Spark SQL使用列式数据存储,因此考虑单个行的大小并不是很自然的事情.我们当然可以从那里调用.rdd,您可以使用计算Java中对象的大小以确定对象的大小,然后可以使用RContext of Rows并使用SQLContext将其转换回DataFrame.

This is actually kind of a tricky problem. Spark SQL uses columnar data Storage so thinking of individual row sizes isn't super natural. We can of course call .rdd on from there you can filter the resulting RDD using the techniques as from Calculate size of Object in Java to determine the object size, and then you can take your RDD of Rows and convert it back to a DataFrame using your SQLContext.

这篇关于如何在Apache Spark sql数据帧中找到每个行的大小,并发现大小超过阈值大小的行(千字节)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆