@Override
  @Nullable
  public DataBuffer readChunk() throws IOException {
    int index = (int) (mPosToRead / mChunkSize);
    DataBuffer chunk = mCachedDataReader.readChunk(index);
    if (chunk == null) {
      return null;
    }
    ByteBuffer bb = chunk.getReadOnlyByteBuffer();
    // Force the buffer to align to chunk size
    bb.position((int) (mPosToRead % mChunkSize));
    mPosToRead += mChunkSize - mPosToRead % mChunkSize;

    return new NioDataBuffer(bb, bb.remaining());
  }
@Test
  public void singleThreadReadFullFile() throws Exception {
    SharedGrpcDataReader sharedReader
        = new SharedGrpcDataReader(mReadRequest, mBufferCachingDataReader);
    for (int i = 0; i < getChunkNum(mBlockSize); i++) {
      Assert.assertTrue(mBufferCachingDataReader.validateBuffer(i, sharedReader.readChunk()));
    }
    Assert.assertNull(sharedReader.readChunk());
  }