source: sample/hadoop-0.17/tw/org/nchc/util/LocalTupleRecordWriter.java

Last change on this file was 20, checked in by waue, 16 years ago

將改完的 hadoop 0.17版package 放來備份
目前繼續開發 hadoop 0.16 + hbase 1.3

File size: 941 bytes
Line 
1package tw.org.nchc.util;
2
3import java.io.IOException;
4
5import org.apache.hadoop.fs.FileSystem;
6import org.apache.hadoop.fs.Path;
7import org.apache.hadoop.io.LongWritable;
8import org.apache.hadoop.io.SequenceFile;
9import org.apache.hadoop.mapred.JobConf;
10
11import tw.org.nchc.tuple.Tuple;
12
13public class LocalTupleRecordWriter {
14
15  private LongWritable mLong = new LongWritable();
16
17  private long mCnt = 0;
18
19  private SequenceFile.Writer writer;
20
21  public LocalTupleRecordWriter(String file) throws IOException {
22    JobConf config = new JobConf();
23
24    writer = SequenceFile.createWriter(FileSystem.get(config), config,
25        new Path(file), LongWritable.class, Tuple.class);
26  }
27
28  public void add(Tuple tuple) throws IOException {
29    mLong.set(mCnt);
30    writer.append(mLong, tuple);
31    mCnt++;
32  }
33
34  public long getRecordCount() {
35    return mCnt;
36  }
37
38  public void close() throws IOException {
39    writer.close();
40  }
41}
Note: See TracBrowser for help on using the repository browser.