/** Common work of the constructors. */ private void initialize(Path filename, FSDataInputStream in, long start, long length, Configuration conf, boolean tempReader) throws IOException { if (in == null) { throw new IllegalArgumentException("in == null"); } this.filename = filename == null ? "<unknown>" : filename.toString(); this.in = in; this.conf = conf; boolean succeeded = false; try { seek(start); this.end = this.in.getPos() + length; // if it wrapped around, use the max if (end < length) { end = Long.MAX_VALUE; } init(tempReader); succeeded = true; } finally { if (!succeeded) { IOUtils.cleanupWithLogger(LOG, this.in); } } }
/** Return the value for the named key, or null if none exists. */ public Writable get(WritableComparable key, Writable val) throws IOException { long position = findPosition(key); if (position >= 0) { SequenceFile.Reader threadLocalData = data.get(); threadLocalData.seek(position); threadLocalData.getCurrentValue(val); return val; } else return null; }
protected synchronized void seek(long pos) throws IOException { in.seek(pos); } public synchronized void close() throws IOException { in.close(); }
protected synchronized void seek(long pos) throws IOException { in.seek(pos); } public synchronized void close() throws IOException { in.close(); }
/** Re-positions the reader before its first key. */ public synchronized void reset() throws IOException { data.seek(firstPosition); }
/** * Set the current byte position in the input file. * <p/> * <p>The position passed must be a position returned by {@link * TupleFile.Writer#getLength()} when writing this file. To seek to an arbitrary * position, use {@link TupleFile.Reader#sync(long)}. */ public synchronized void seek(long position) throws IOException { innerReader.seek(position); }
@Override protected void seekOnFs(long pos) throws IOException { try { reader.seek(pos); } catch (IOException ioe) { throw addFileInfoToException(ioe); } }
protected synchronized void seek(long pos) throws IOException { in.seek(pos); } public synchronized void close() throws IOException { in.close(); }
/** Re-positions the reader before its first key. */ public synchronized void reset() throws IOException { data.seek(firstPosition); }
protected synchronized void seek(long pos) throws IOException { in.seek(pos); } public synchronized void close() throws IOException { in.close(); }
@Override protected void readRecord(RecordId rid) throws IOException { reader.seek(rid.getOffset()); reader.next(key, value); }
private Reader(FileSystem fs, Path file, int bufferSize, long start, long length, Configuration conf, boolean tempReader) throws IOException { this.file = file; this.in = openFile(fs, file, bufferSize, length); this.conf = conf; seek(start); this.end = in.getPos() + length; init(tempReader); }
/** * Set the current byte position in the input file. * <p/> * <p>The position passed must be a position returned by {@link * TupleFile.Writer#getLength()} when writing this file. To seek to an arbitrary * position, use {@link TupleFile.Reader#sync(long)}. */ public synchronized void seek(long position) throws IOException { innerReader.seek(position); }
private Reader(FileSystem fs, Path file, int bufferSize, long start, long length, Configuration conf, boolean tempReader) throws IOException { this.file = file; this.in = openFile(fs, file, bufferSize, length); this.conf = conf; seek(start); this.end = in.getPos() + length; init(tempReader); }
/** Re-positions the reader before its first key. */ public synchronized void reset() throws IOException { data.seek(firstPosition); }
/** Reads the final key from the file. * * @param key key to read into */ public synchronized void finalKey(WritableComparable key) throws IOException { long originalPosition = data.getPosition(); // save position try { readIndex(); // make sure index is valid if (count > 0) { data.seek(positions[count-1]); // skip to last indexed entry } else { reset(); // start at the beginning } while (data.next(key)) {} // scan to eof } finally { data.seek(originalPosition); // restore position } }
/** Re-positions the reader before its first key. */ public synchronized void reset() throws IOException { data.seek(firstPosition); }
public void setOffset(long offset) throws IOException { reader.seek(offset); }