@Test public void seekTest() throws IOException { for (int k = MIN_LEN + DELTA; k <= MAX_LEN; k += DELTA) { WriteType op = WriteType.THROUGH; int fileId = TestUtils.createByteFile(mTfs, "/root/testFile_" + k + "_" + op, op, k); TachyonFile file = mTfs.getFile(fileId); InStream is = file.getInStream(ReadType.NO_CACHE); if (k == 0) { Assert.assertTrue(is instanceof EmptyBlockInStream); } else { Assert.assertTrue(is instanceof RemoteBlockInStream); } Assert.assertEquals(0, is.read()); is.seek(k / 3); Assert.assertEquals(k / 3, is.read()); is.seek(k / 2); Assert.assertEquals(k / 2, is.read()); is.seek(k / 4); Assert.assertEquals(k / 4, is.read()); is.close(); } }
@Override public void seek(long pos) throws IOException { if (pos < 0) { throw new IOException("pos is negative: " + pos); } mRecache = false; if (mCurrentBuffer != null) { mReadByte = pos; if (mBufferStartPosition <= pos && pos < mBufferStartPosition + mCurrentBuffer.limit()) { mCurrentBuffer.position((int) (pos - mBufferStartPosition)); } else { mBufferStartPosition = pos; updateCurrentBuffer(); } } else { if (mCheckpointInputStream != null) { mCheckpointInputStream.close(); } setupStreamFromUnderFs(mBlockInfo.offset + pos, mUFSConf); } }
RemoteBlockInStream extends BlockInStream { @Override public void seek(long pos) throws IOException { if (pos < 0) { throw new IOException("pos is negative: " + pos); } mRecache = false; if (mCurrentBuffer != null) { mReadByte = pos; if (mBufferStartPosition <= pos && pos < mBufferStartPosition + mCurrentBuffer.limit()) { mCurrentBuffer.position((int) (pos - mBufferStartPosition)); } else { mBufferStartPosition = pos; updateCurrentBuffer(); } } else { if (mCheckpointInputStream != null) { mCheckpointInputStream.close(); } setupStreamFromUnderFs(mBlockInfo.offset + pos, mUFSConf); } } }
RemoteBlockInStream extends BlockInStream { @Override public void seek(long pos) throws IOException { if (pos < 0) { throw new IOException("pos is negative: " + pos); } mRecache = false; if (mCurrentBuffer != null) { mReadByte = pos; if (mBufferStartPosition <= pos && pos < mBufferStartPosition + mCurrentBuffer.limit()) { mCurrentBuffer.position((int) (pos - mBufferStartPosition)); } else { mBufferStartPosition = pos; updateCurrentBuffer(); } } else { if (mCheckpointInputStream != null) { mCheckpointInputStream.close(); } setupStreamFromUnderFs(mBlockInfo.offset + pos, mUFSConf); } } RemoteBlockInStream(TachyonFile file, ReadType readType, int blockIndex);   RemoteBlockInStream(TachyonFile file, ReadType readType, int blockIndex, Object ufsConf); }
RemoteBlockInStream extends BlockInStream { @Override public void seek(long pos) throws IOException { if (pos < 0) { throw new IOException("pos is negative: " + pos); } mRecache = false; if (mCurrentBuffer != null) { mReadByte = pos; if (mBufferStartPosition <= pos && pos < mBufferStartPosition + mCurrentBuffer.limit()) { mCurrentBuffer.position((int) (pos - mBufferStartPosition)); } else { mBufferStartPosition = pos; updateCurrentBuffer(); } } else { if (mCheckpointInputStream != null) { mCheckpointInputStream.close(); } setupStreamFromUnderFs(mBlockInfo.offset + pos, mUFSConf); } } RemoteBlockInStream(TachyonFile file, ReadType readType, int blockIndex);   RemoteBlockInStream(TachyonFile file, ReadType readType, int blockIndex, Object ufsConf); @Override void close(); @Override int read(); @Override int read(byte b[]); @Override int read(byte b[], int off, int len); @Override void seek(long pos); @Override long skip(long n); }
RemoteBlockInStream extends BlockInStream { @Override public void seek(long pos) throws IOException { if (pos < 0) { throw new IOException("pos is negative: " + pos); } mRecache = false; if (mCurrentBuffer != null) { mReadByte = pos; if (mBufferStartPosition <= pos && pos < mBufferStartPosition + mCurrentBuffer.limit()) { mCurrentBuffer.position((int) (pos - mBufferStartPosition)); } else { mBufferStartPosition = pos; updateCurrentBuffer(); } } else { if (mCheckpointInputStream != null) { mCheckpointInputStream.close(); } setupStreamFromUnderFs(mBlockInfo.offset + pos, mUFSConf); } } RemoteBlockInStream(TachyonFile file, ReadType readType, int blockIndex);   RemoteBlockInStream(TachyonFile file, ReadType readType, int blockIndex, Object ufsConf); @Override void close(); @Override int read(); @Override int read(byte b[]); @Override int read(byte b[], int off, int len); @Override void seek(long pos); @Override long skip(long n);  }