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

查看:116
本文介绍了获取几行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

在这里很有效,因为猫只要 head 完成所有行的读取就会关闭流.

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

要获取 tail ,在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天全站免登陆