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 ...
随机推荐
- datatable转json
//将datatable转化为json public string DataTableToJSON(DataTable dt) { JavaScriptSerializer jss = new Jav ...
- unity发布ios游戏总结
自己做了几个ios的小游戏,因此总结了一点经验 判断按钮要用unity里面的button不要用OnMouseDown()之类的函数,否则拒绝原因为缺少ios特征 排行榜之类的本地存储数据,不要用本地本 ...
- Java validator整理
Java validator整理 因为想对方法的入参和出参作简单的非空或者非空字符做校验,所以找了下相关的@NotNull注解 类 | 说明 --- | --- javax.validation.co ...
- 谱曲软件-MuseScore
谱曲软件-MuseScore 参考: 1.MuseScore官网 2.免费乐谱制作软体MuseScore
- NOIP200701
题是这样的: 试题描述 某小学最近得到了一笔赞助,打算拿出其中一部分为学习成绩优秀的前5名学生发奖学金.期末,每个学生都有3门课的成绩:语文.数学.英语.先按总分从高到低排序,如果两个同学总分相同,再 ...
- Fire Net
Fire Net Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Subm ...
- jQuery—一些常见方法(3)【width(),innerWidth(),outerWidth()】
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- jQuery1.8以上,ajaxSend,ajaxStart等一系列事件要绑定在document上才有效果
jQuery1.8以上,ajaxSend,ajaxStart等一系列事件要绑定在document上才有效果
- std::string和int类型的相互转换(C/C++)
字符串和数值之前转换,是一个经常碰到的类型转换. 之前字符数组用的多,std::string的这次用到了,还是有点区别,这里提供C++和C的两种方式供参考: 优缺点:C++的stringstream智 ...
- ?Object-C获取手机设备信息
一.获取UiDevice设备信息 // 获取设备名称 NSString *name = [[UIDevice currentDevice] name]; // 获取设备系统名称 NSString *s ...