Examples of NFSDataInputStream


Examples of net.nutch.fs.NFSDataInputStream

    final long start = split.getStart();
    final long end = start + split.getLength();

    // open the file and seek to the start of the split
    final NFSDataInputStream in =
      new NFSDataInputStream(split.getFileSystem().open(split.getFile()));
    in.seek(start);
   
    if (start != 0) {
      while (in.getPos() < end) {    // scan to the next newline in the file
        char c = (char)in.read();    // bug: this assumes eight-bit characters.
        if (c == '\r' || c == '\n') {
          break;
        }
      }
    }

    return new RecordReader() {

        /** Keys are longs. */
        public Writable createKey() { return new LongWritable(); }

        /** Values are lines. */
        public Writable createValue() { return new UTF8(); }

        /** Read a line. */
        public boolean next(Writable key, Writable value) throws IOException {
          long pos = in.getPos();
          if (pos >= end)
            return false;

          ((LongWritable)key).set(pos);           // key is position
          ((UTF8)value).set(readLine(in));        // value is line
View Full Code Here

Examples of org.apache.nutch.fs.NFSDataInputStream

    final long start = split.getStart();
    final long end = start + split.getLength();

    // open the file and seek to the start of the split
    final NFSDataInputStream in =
      new NFSDataInputStream(fs.open(split.getFile()));
    in.seek(start);
   
    if (start != 0) {
      while (in.getPos() < end) {    // scan to the next newline in the file
        char c = (char)in.read();
        if (c == '\r' || c == '\n') {
          break;
        }
      }
    }

    return new RecordReader() {
        /** Read a line. */
        public boolean next(Writable key, Writable value) throws IOException {
          long pos = in.getPos();
          if (pos >= end)
            return false;

          ((LongWritable)key).set(pos);           // key is position
          ((UTF8)value).set(readLine(in));        // value is line
          return true;
        }
       
        public long getPos() throws IOException { return in.getPos(); }

        public void close() throws IOException { in.close(); }

      };
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.