@Test public void testGetArray() throws Exception { ArrayRandomAccessSource source1 = new ArrayRandomAccessSource(data); ArrayRandomAccessSource source2 = new ArrayRandomAccessSource(data); ArrayRandomAccessSource source3 = new ArrayRandomAccessSource(data); RandomAccessSource[] inputs = new RandomAccessSource[]{ source1, source2, source3 }; GroupedRandomAccessSource grouped = new GroupedRandomAccessSource(inputs); byte[] out = new byte[500]; Assert.assertEquals(300, grouped.get(0, out, 0, 300)); assertArrayEqual(rangeArray(0, 100), 0, out, 0, 100); assertArrayEqual(rangeArray(0, 100), 0, out, 100, 100); assertArrayEqual(rangeArray(0, 100), 0, out, 200, 100); Assert.assertEquals(300, grouped.get(0, out, 0, 301)); assertArrayEqual(rangeArray(0, 100), 0, out, 0, 100); assertArrayEqual(rangeArray(0, 100), 0, out, 100, 100); assertArrayEqual(rangeArray(0, 100), 0, out, 200, 100); Assert.assertEquals(100, grouped.get(150, out, 0, 100)); assertArrayEqual(rangeArray(50, 50), 0, out, 0, 50); assertArrayEqual(rangeArray(0, 50), 0, out, 50, 50); }
public int get(long position) throws IOException { SourceEntry entry = getSourceEntryForOffset(position); if (entry == null) return -1; return entry.source.get(entry.offsetN(position)); }
GroupedRandomAccessSource implements RandomAccessSource { public int get(long position) throws IOException { SourceEntry entry = getSourceEntryForOffset(position); if (entry == null) return -1; return entry.source.get(entry.offsetN(position)); } }
GroupedRandomAccessSource implements RandomAccessSource { public int get(long position) throws IOException { SourceEntry entry = getSourceEntryForOffset(position); if (entry == null) return -1; return entry.source.get(entry.offsetN(position)); } GroupedRandomAccessSource(RandomAccessSource[] sources); }
GroupedRandomAccessSource implements RandomAccessSource { public int get(long position) throws IOException { SourceEntry entry = getSourceEntryForOffset(position); if (entry == null) return -1; return entry.source.get(entry.offsetN(position)); } GroupedRandomAccessSource(RandomAccessSource[] sources); int get(long position); int get(long position, byte[] bytes, int off, int len); long length(); void close(); }
GroupedRandomAccessSource implements RandomAccessSource { public int get(long position) throws IOException { SourceEntry entry = getSourceEntryForOffset(position); if (entry == null) return -1; return entry.source.get(entry.offsetN(position)); } GroupedRandomAccessSource(RandomAccessSource[] sources); int get(long position); int get(long position, byte[] bytes, int off, int len); long length(); void close();  }