Last change
on this file since 57 was
20,
checked in by waue, 16 years ago
|
將改完的 hadoop 0.17版package 放來備份
目前繼續開發 hadoop 0.16 + hbase 1.3
|
File size:
953 bytes
|
Rev | Line | |
---|
[20] | 1 | package tw.org.nchc.util; |
---|
| 2 | |
---|
| 3 | import java.io.IOException; |
---|
| 4 | |
---|
| 5 | import org.apache.hadoop.fs.FileSystem; |
---|
| 6 | import org.apache.hadoop.fs.Path; |
---|
| 7 | import org.apache.hadoop.io.LongWritable; |
---|
| 8 | import org.apache.hadoop.io.SequenceFile; |
---|
| 9 | import org.apache.hadoop.mapred.JobConf; |
---|
| 10 | |
---|
| 11 | import tw.org.nchc.tuple.Tuple; |
---|
| 12 | |
---|
| 13 | public class LocalTupleRecordReader { |
---|
| 14 | private LongWritable mKey = new LongWritable(); |
---|
| 15 | private SequenceFile.Reader mReader; |
---|
| 16 | |
---|
| 17 | private long cnt = 0; |
---|
| 18 | |
---|
| 19 | public LocalTupleRecordReader(String file) throws IOException { |
---|
| 20 | JobConf config = new JobConf(); |
---|
| 21 | |
---|
| 22 | mReader = new SequenceFile.Reader(FileSystem.get(config), |
---|
| 23 | new Path(file), config); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | public boolean read(Tuple tuple) throws IOException { |
---|
| 27 | if (mReader.next(mKey, tuple) == true) { |
---|
| 28 | cnt++; |
---|
| 29 | } else { |
---|
| 30 | return false; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | return true; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | public long getRecordCount() { |
---|
| 37 | return cnt; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | public void close() throws IOException { |
---|
| 41 | mReader.close(); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.