write & read a sequence file(基于全新2.2.0API)
write & read a sequence file
write & read a sequence file
import java.io.IOException;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.SequenceFile.Writer;
import org.apache.hadoop.io.SequenceFile.Reader;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration;
public class MySequenceFile {
static private final String[] DATA = {
"this is the first",
"this is the second",
"this is the third",
"this is the forth"
};
public static void main(String[] args) throws IOException {
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
Path path = new Path(args[0]);
IntWritable key = new IntWritable();
Text value = new Text();
SequenceFile.Writer writer = null;
writer = SequenceFile.createWriter(conf, Writer.file(path), Writer.keyClass(key.getClass()), Writer.valueClass(value.getClass()));
for( int i = 0; i < 1000; i++ ) {
key.set(i + 1);
value.set(DATA[i % DATA.length]);
writer.append(key,value);
}
writer.close();
SequenceFile.Reader reader = new SequenceFile.Reader(conf, Reader.file(path));
while( reader.next(key, value) ) {
String syncSeen = reader.syncSeen() ? "*" : "#";
System.err.println(key + "\t" + value + "\t" + reader.getPosition()+ "\t" + syncSeen);
}
reader.close();
}
}
write & read a sequence file(基于全新2.2.0API)的更多相关文章
- MapReduce——计算温度最大值 (基于全新2.2.0API)
MapReduce——计算温度最大值 (基于全新2.2.0API) deprecated: Job类的所有Constructors, 新的API用静态方法getInstance(conf)来去的Job ...
- write & read a MapFile(基于全新2.2.0API)
write & read a MapFile import java.io.IOException; import org.apache.hadoop.io.IntWritable; imp ...
- Configurataion Printer(基于全新2.2.0API)
Configurataion Printer import java.util.Map.Entry; import org.apache.hadoop.conf.Configuration; impo ...
- Combine small files to Sequence file
Combine small files to sequence file or avro files are a good method to feed hadoop. Small files in ...
- Predicting effects of noncoding variants with deep learning–based sequence model | 基于深度学习的序列模型预测非编码区变异的影响
Predicting effects of noncoding variants with deep learning–based sequence model PDF Interpreting no ...
- Flume性能测试报告(翻译Flume官方wiki报告)
因使用flume的时候总是会对其性能有所调研,网上找的要么就是自测的这里找到一份官方wiki的测试报告供大家参考 https://cwiki.apache.org/confluence/display ...
- Hadoop IO基于文件的数据结构详解【列式和行式数据结构的存储策略】
Charles所有关于hadoop的文章参考自hadoop权威指南第四版预览版 大家可以去safari免费阅读其英文预览版.本人也上传了PDF版本在我的资源中可以免费下载,不需要C币,点击这里下载. ...
- 基于docker快速搭建hbase集群
一.概述 HBase是一个分布式的.面向列的开源数据库,该技术来源于 Fay Chang 所撰写的Google论文"Bigtable:一个结构化数据的分布式存储系统".就像Bigt ...
- The Kernel Newbie Corner: Kernel Debugging with proc "Sequence" Files--Part 3
转载:https://www.linux.com/learn/linux-career-center/44184-the-kernel-newbie-corner-kernel-debugging-w ...
随机推荐
- C#基础总复习01
马上就快毕业了,准备把这几个月所学到的知识梳理一下,这儿所写的都是一些C#中最基础的东西(大牛不要笑话我,这也是我记录的一些笔记等等),希望能帮到一些正在学习这方面的知识的人,如果有写的不对的地方,望 ...
- java异常练习2
/*有一个圆形和长方形都可以获取面积,对于面积,如果出现非法数值,视为获取面积出现问题问题通过异常来表示.先要对这个程序进行基本的设置 *//*首先想一下,怎么写这个程序基本属性是肯定要的求面积呢?1 ...
- 谱曲软件-MuseScore
谱曲软件-MuseScore 参考: 1.MuseScore官网 2.免费乐谱制作软体MuseScore
- 双人五子棋对战(需要EasyX图像库)
实训要做项目呐.天天坐在电脑面前累死了.最近题刷的少.大多数都挺水.就不挨个编辑发上来了.发发白天写的项目吧.可能好几天更一下.实训结束恢复正常. 这个游戏需要EasyX的图像库.有兴趣的可以下一个图 ...
- Executors 构建线程池
Executors包含一系列静态方法,可以用于构建线程池. 返回实现了 ExecutorService 接口的对象: newCachedThreadPool newFixedThreadPool(in ...
- React Native在虚拟运行app时,报错RCTRootView not found,怎么解决?
报错: 解决方案:
- PHP初学留神(三)
星期一进行面试结束后,意味着我的考研日子也结束了,以及我的2013.在好好总结之后还不能停止学习,心想着要把算法继续学下去,还有Linux.不过呢,始终都要记住尼采老师的这句当头棒喝:“不加选择的知识 ...
- PHP学习心得(九)——函数
一个函数可由以下的语法来定义.任何有效的 PHP 代码都有可能出现在函数内部,甚至包括其它函数和类定义. 函数名和 PHP 中的其它标识符命名规则相同.有效的函数名以字母或下划线打头,后面跟字母,数字 ...
- VB-获取本机计算机名,登录名、ip地址
真的是很简单,执行结果:Computer:不平凡总在于坚持 User:Administrator IP:192.168.0.111 '获取计算机名.用户名.本机ip Dim Loc ...
- Delphi新语法和ifthen的扩展联想
Delphi之前已经重载了好多个ifthen函数 Math单元 ): Integer; overload; inline; ): Int64; overload; inline; ): UInt64; ...