@Nullable
  public DataBuffer readChunk(int index) throws IOException {
    if (index >= mDataBuffers.length) {
      return null;
    }

    if (index >= mBufferCount.get()) {
      try (LockResource ignored = new LockResource(mBufferLocks.writeLock())) {
        while (index >= mBufferCount.get()) {
          DataBuffer buffer = readChunk();
          mDataBuffers[mBufferCount.get()] = buffer;
          mBufferCount.incrementAndGet();
        }
      }
    }

    return mDataBuffers[index];
  }
@Test
  public void testDataCache() throws Exception {
    int index = 2;
    DataBuffer buffer = mDataReader.readChunk(index);
    Assert.assertEquals(index + 1, mDataReader.getReadChunkNum());
    Assert.assertTrue(mDataReader.validateBuffer(index, buffer));

    index = 1;
    buffer = mDataReader.readChunk(index);
    Assert.assertEquals(3, mDataReader.getReadChunkNum());
    Assert.assertTrue(mDataReader.validateBuffer(index, buffer));

    index = 0;
    buffer = mDataReader.readChunk(index);
    Assert.assertEquals(3, mDataReader.getReadChunkNum());
    Assert.assertTrue(mDataReader.validateBuffer(index, buffer));

    index = 3;
    buffer = mDataReader.readChunk(index);
    Assert.assertEquals(index + 1, mDataReader.getReadChunkNum());
    Assert.assertTrue(mDataReader.validateBuffer(index, buffer));
  }