@Test public void get() { when(posReader.get(0)).thenReturn(10L); when(lenReader.get(0)).thenReturn(3); when(dataReader.get(10)).thenReturn((byte) 1); when(dataReader.get(11)).thenReturn((byte) 2); when(dataReader.get(12)).thenReturn((byte) 3); assertArrayEquals(new byte[]{1, 2, 3}, new BaseByteArrayReader(dataReader, posReader, lenReader).get(0)); }
@Override public byte[] get(long pos) { long start = posReader.get(pos); int size = lenReader.get(pos); byte[] bytes = new byte[size]; for (int i = 0; i < size; i++) { bytes[i] = dataReader.get(start + i); } return bytes; }
BaseByteArrayReader implements ByteArrayReader { @Override public byte[] get(long pos) { long start = posReader.get(pos); int size = lenReader.get(pos); byte[] bytes = new byte[size]; for (int i = 0; i < size; i++) { bytes[i] = dataReader.get(start + i); } return bytes; } }
BaseByteArrayReader implements ByteArrayReader { @Override public byte[] get(long pos) { long start = posReader.get(pos); int size = lenReader.get(pos); byte[] bytes = new byte[size]; for (int i = 0; i < size; i++) { bytes[i] = dataReader.get(start + i); } return bytes; } BaseByteArrayReader(ByteReader dataReader, LongReader posReader, IntReader lenReader); }
BaseByteArrayReader implements ByteArrayReader { @Override public byte[] get(long pos) { long start = posReader.get(pos); int size = lenReader.get(pos); byte[] bytes = new byte[size]; for (int i = 0; i < size; i++) { bytes[i] = dataReader.get(start + i); } return bytes; } BaseByteArrayReader(ByteReader dataReader, LongReader posReader, IntReader lenReader); @Override boolean isReadable(); @Override byte[] get(long pos); @Override InputStream getStream(long pos); @Override void release(); }
BaseByteArrayReader implements ByteArrayReader { @Override public byte[] get(long pos) { long start = posReader.get(pos); int size = lenReader.get(pos); byte[] bytes = new byte[size]; for (int i = 0; i < size; i++) { bytes[i] = dataReader.get(start + i); } return bytes; } BaseByteArrayReader(ByteReader dataReader, LongReader posReader, IntReader lenReader); @Override boolean isReadable(); @Override byte[] get(long pos); @Override InputStream getStream(long pos); @Override void release();  }