Exemplo n.º 1
0
 @Override
 public long next(HdfsInputStream hdfsistr, Holder<Object> key, Holder<Object> value) {
   try {
     ArrayFile.Reader reader = (ArrayFile.Reader) hdfsistr.getIn();
     Holder<Integer> valueSize = new Holder<Integer>();
     Writable valueWritable =
         (Writable) ReflectionUtils.newInstance(reader.getValueClass(), new Configuration());
     if (reader.next(valueWritable) != null) {
       value.value = getObject(valueWritable, valueSize);
       return valueSize.value;
     } else {
       return 0;
     }
   } catch (Exception ex) {
     throw new RuntimeCamelException(ex);
   }
 }
Exemplo n.º 2
0
  public static void main(String argv[]) throws Exception {

    String usage = "Content (-local | -dfs <namenode:port>) recno segment";

    if (argv.length < 3) {
      System.out.println("usage:" + usage);
      return;
    }
    Options opts = new Options();
    Configuration conf = NutchConfiguration.create();

    GenericOptionsParser parser = new GenericOptionsParser(conf, opts, argv);

    String[] remainingArgs = parser.getRemainingArgs();
    FileSystem fs = FileSystem.get(conf);

    try {
      int recno = Integer.parseInt(remainingArgs[0]);
      String segment = remainingArgs[1];

      Path file = new Path(segment, DIR_NAME);
      System.out.println("Reading from file: " + file);

      ArrayFile.Reader contents = new ArrayFile.Reader(fs, file.toString(), conf);

      Content content = new Content();
      contents.get(recno, content);
      System.out.println("Retrieved " + recno + " from file " + file);

      System.out.println(content);

      contents.close();
    } finally {
      fs.close();
    }
  }