1 2 3 4 package net.nutch.io; 5 6 import java.io.*; 7 8 import net.nutch.fs.*; 9 import net.nutch.util.*; 10 11 12 public class SetFile extends MapFile { 13 14 protected SetFile() {} 16 17 public static class Writer extends MapFile.Writer { 18 19 20 public Writer(NutchFileSystem nfs, String dirName, Class keyClass) throws IOException { 21 super(nfs, dirName, keyClass, NullWritable.class); 22 } 23 24 25 public Writer(NutchFileSystem nfs, String dirName, WritableComparator comparator) 26 throws IOException { 27 super(nfs, dirName, comparator, NullWritable.class); 28 } 29 30 32 public void append(WritableComparable key) throws IOException{ 33 append(key, NullWritable.get()); 34 } 35 } 36 37 38 public static class Reader extends MapFile.Reader { 39 40 41 public Reader(NutchFileSystem nfs, String dirName) throws IOException { 42 super(nfs, dirName); 43 } 44 45 46 public Reader(NutchFileSystem nfs, String dirName, WritableComparator comparator) 47 throws IOException { 48 super(nfs, dirName, comparator); 49 } 50 51 public boolean seek(WritableComparable key) 53 throws IOException { 54 return super.seek(key); 55 } 56 57 59 public boolean next(WritableComparable key) 60 throws IOException { 61 return next(key, NullWritable.get()); 62 } 63 64 66 public WritableComparable get(WritableComparable key) 67 throws IOException { 68 if (seek(key)) { 69 next(key); 70 return key; 71 } else 72 return null; 73 } 74 } 75 76 } 77 | Popular Tags |