@Test public void testLoadIndexV2() throws Exception { Buffer buffer = Buffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5).putInt(6).put((byte) 0) .putLong(7).putLong(8).putInt(9).putInt(10).putInt(11).putInt(12).put((byte) 1) .putInt(0xE2138EB4) .putInt(2) .putInt(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE) .putInt(IndexLoaderV2.MAGIC); Index index = loadIndex(buffer); assertNotNull(index); assertEquals(2, index.count()); assertEntry(index.entry(0), 1, 2, 3, 4, 5, 6, false); assertEntry(index.entry(1), 7, 8, 9, 10, 11, 12, true); }
public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } }
IndexLoader { public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } } }
IndexLoader { public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } } private  IndexLoader(int blockSize); }
IndexLoader { public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } } private  IndexLoader(int blockSize); static IndexLoader newIndexLoader(int blockSize); Index loadIndex(ReaderAtEnd reader); }
IndexLoader { public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } } private  IndexLoader(int blockSize); static IndexLoader newIndexLoader(int blockSize); Index loadIndex(ReaderAtEnd reader);  }