获取几行HDFS数据 [英] Get few lines of HDFS data

查看:149
本文介绍了获取几行HDFS数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 HDFS 中有 2 GB 数据。

是否可以随机获取这些数据。
就像我们在Unix命令行中一样

Is it possible to get that data randomly. Like we do in the Unix command line

cat iris2.csv |head -n 50


推荐答案

原生

hadoop fs -cat /your/file | head

在这里很有效,因为cat会在 head 会完成所有行的阅读。

is efficient here, as cat will close the stream as soon as head will finish reading all the lines.

要获取尾部,hadoop中会有一个特殊的有效命令:

To get the tail there is a special effective command in hadoop:

hadoop fs -tail /your/file

不幸的是它会返回数据的最后一个千字节,而不是给定数量的行。

Unfortunately it returns last kilobyte of the data, not a given number of lines.

这篇关于获取几行HDFS数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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