@SuppressWarnings("Duplicates")
  public byte[] get(int index) {
    assert index < _numValues;

    int offsetBufferIndex = index >>> OFFSET_BUFFER_SHIFT_OFFSET;
    PinotDataBuffer offsetBuffer = _offsetBuffers.get(offsetBufferIndex);
    int offsetIndex = index & OFFSET_BUFFER_MASK;
    int previousValueEndOffset = offsetBuffer.getInt(offsetIndex << 2);
    int valueEndOffset = offsetBuffer.getInt((offsetIndex + 1) << 2);

    if (previousValueEndOffset == valueEndOffset) {
      return EMPTY_BYTES;
    }

    int valueBufferIndex = (valueEndOffset - 1) >>> VALUE_BUFFER_SHIFT_OFFSET;
    int startOffsetInValueBuffer;
    int valueLength;
    if ((previousValueEndOffset - 1) >>> VALUE_BUFFER_SHIFT_OFFSET != valueBufferIndex) {
      // The first value in the value buffer
      startOffsetInValueBuffer = 0;
      valueLength = valueEndOffset & VALUE_BUFFER_MASK;
    } else {
      // Not the first value in the value buffer
      startOffsetInValueBuffer = previousValueEndOffset & VALUE_BUFFER_MASK;
      valueLength = valueEndOffset - previousValueEndOffset;
    }

    byte[] value = new byte[valueLength];
    _valueBuffers.get(valueBufferIndex).copyTo(startOffsetInValueBuffer, value);
    return value;
  }
@Test
  public void testGet()
      throws Exception {
    try (OffHeapMutableBytesStore offHeapMutableBytesStore = new OffHeapMutableBytesStore(_memoryManager, null)) {
      for (int i = 0; i < NUM_VALUES; i++) {
        offHeapMutableBytesStore.add(_values[i]);
      }
      for (int i = 0; i < NUM_VALUES; i++) {
        int index = RANDOM.nextInt(NUM_VALUES);
        assertTrue(Arrays.equals(offHeapMutableBytesStore.get(index), _values[index]));
      }
    }
  }