@Override public NativeUnixIndexInput clone() { try { return new NativeUnixIndexInput(this); } catch (IOException ioe) { throw new RuntimeException("IOException during clone: " + this, ioe); } }
@Override public void readBytes(byte[] dst, int offset, int len) throws IOException { int toRead = len; //System.out.println("\nX readBytes len=" + len + " fp=" + getFilePointer() + " size=" + length() + " this=" + this); while(true) { final int left = bufferSize - bufferPos; if (left < toRead) { //System.out.println(" copy " + left); buffer.get(dst, offset, left); toRead -= left; offset += left; refill(); } else { //System.out.println(" copy " + toRead); buffer.get(dst, offset, toRead); bufferPos += toRead; //System.out.println(" readBytes done"); break; } } }
@Override public void readBytes(byte[] dst, int offset, int len) throws IOException { int toRead = len; //System.out.println("\nX readBytes len=" + len + " fp=" + getFilePointer() + " size=" + length() + " this=" + this); while(true) { final int left = bufferSize - bufferPos; if (left < toRead) { //System.out.println(" copy " + left); buffer.get(dst, offset, left); toRead -= left; offset += left; refill(); } else { //System.out.println(" copy " + toRead); buffer.get(dst, offset, toRead); bufferPos += toRead; //System.out.println(" readBytes done"); break; } } }
@Override public void readBytes(byte[] dst, int offset, int len) throws IOException { int toRead = len; //System.out.println("\nX readBytes len=" + len + " fp=" + getFilePointer() + " size=" + length() + " this=" + this); while(true) { final int left = bufferSize - bufferPos; if (left < toRead) { //System.out.println(" copy " + left); buffer.get(dst, offset, left); toRead -= left; offset += left; refill(); } else { //System.out.println(" copy " + toRead); buffer.get(dst, offset, toRead); bufferPos += toRead; //System.out.println(" readBytes done"); break; } } }
@Override public void seek(long pos) throws IOException { if (pos != getFilePointer()) { final long alignedPos = pos & ALIGN_NOT_MASK; filePos = alignedPos-bufferSize; final int delta = (int) (pos - alignedPos); if (delta != 0) { refill(); buffer.position(delta); bufferPos = delta; } else { // force refill on next read bufferPos = bufferSize; } } }
@Override public void seek(long pos) throws IOException { if (pos != getFilePointer()) { final long alignedPos = pos & ALIGN_NOT_MASK; filePos = alignedPos-bufferSize; final int delta = (int) (pos - alignedPos); if (delta != 0) { refill(); buffer.position(delta); bufferPos = delta; } else { // force refill on next read bufferPos = bufferSize; } } }
@Override public void seek(long pos) throws IOException { if (pos != getFilePointer()) { final long alignedPos = pos & ALIGN_NOT_MASK; filePos = alignedPos-bufferSize; final int delta = (int) (pos - alignedPos); if (delta != 0) { refill(); buffer.position(delta); bufferPos = delta; } else { // force refill on next read bufferPos = bufferSize; } } }
public NativeUnixIndexInput(NativeUnixIndexInput other) throws IOException { super(other.toString()); this.fis = null; channel = other.channel; this.bufferSize = other.bufferSize; buffer = ByteBuffer.allocateDirect(bufferSize); filePos = -bufferSize; bufferPos = bufferSize; isOpen = true; isClone = true; //System.out.println("D clone this=" + this); seek(other.getFilePointer()); }
@Override public byte readByte() throws IOException { // NOTE: we don't guard against EOF here... ie the // "final" buffer will typically be filled to less // than bufferSize if (bufferPos == bufferSize) { refill(); } assert bufferPos == buffer.position() : "bufferPos=" + bufferPos + " vs buffer.position()=" + buffer.position(); bufferPos++; return buffer.get(); }
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); if (context.context != Context.MERGE || context.mergeInfo.estimatedMergeBytes < minBytesDirect || fileLength(name) < minBytesDirect) { return delegate.openInput(name, context); } else { return new NativeUnixIndexInput(getDirectory().resolve(name), mergeBufferSize); } }
@Override public byte readByte() throws IOException { // NOTE: we don't guard against EOF here... ie the // "final" buffer will typically be filled to less // than bufferSize if (bufferPos == bufferSize) { refill(); } assert bufferPos == buffer.position() : "bufferPos=" + bufferPos + " vs buffer.position()=" + buffer.position(); bufferPos++; return buffer.get(); }
@Override public byte readByte() throws IOException { // NOTE: we don't guard against EOF here... ie the // "final" buffer will typically be filled to less // than bufferSize if (bufferPos == bufferSize) { refill(); } assert bufferPos == buffer.position() : "bufferPos=" + bufferPos + " vs buffer.position()=" + buffer.position(); bufferPos++; return buffer.get(); }
@Override public NativeUnixIndexInput clone() { try { return new NativeUnixIndexInput(this); } catch (IOException ioe) { throw new RuntimeException("IOException during clone: " + this, ioe); } }
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); if (context.context != Context.MERGE || context.mergeInfo.estimatedMergeBytes < minBytesDirect || fileLength(name) < minBytesDirect) { return delegate.openInput(name, context); } else { return new NativeUnixIndexInput(getDirectory().resolve(name), mergeBufferSize); } }
public NativeUnixIndexInput(NativeUnixIndexInput other) throws IOException { super(other.toString()); this.fis = null; channel = other.channel; this.bufferSize = other.bufferSize; buffer = ByteBuffer.allocateDirect(bufferSize); filePos = -bufferSize; bufferPos = bufferSize; isOpen = true; isClone = true; //System.out.println("D clone this=" + this); seek(other.getFilePointer()); }
@Override public NativeUnixIndexInput clone() { try { return new NativeUnixIndexInput(this); } catch (IOException ioe) { throw new RuntimeException("IOException during clone: " + this, ioe); } }
public NativeUnixIndexInput(NativeUnixIndexInput other) throws IOException { super(other.toString()); this.fis = null; channel = other.channel; this.bufferSize = other.bufferSize; buffer = ByteBuffer.allocateDirect(bufferSize); filePos = -bufferSize; bufferPos = bufferSize; isOpen = true; isClone = true; //System.out.println("D clone this=" + this); seek(other.getFilePointer()); }
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); if (context.context != Context.MERGE || context.mergeInfo.estimatedMergeBytes < minBytesDirect || fileLength(name) < minBytesDirect) { return delegate.openInput(name, context); } else { return new NativeUnixIndexInput(getDirectory().resolve(name), mergeBufferSize); } }