@Test public void testLoadIndexV1() throws Exception { Buffer buffer = Buffer.allocate(2 * IndexEntryV1.SIZE + IndexV1.FOOTER_SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5) .putLong(6).putLong(7).putInt(8).putInt(9).putInt(10) .putInt(0x3F5F40E9) .putInt(2) .putInt(2 * IndexEntryV1.SIZE + IndexV1.FOOTER_SIZE) .putInt(IndexLoaderV1.MAGIC); Index index = loadIndex(buffer); assertNotNull(index); assertEquals(2, index.count()); assertEntry(index.entry(0), 1, 2, 3, 4, 5, 5, true); assertEntry(index.entry(1), 6, 7, 8, 9, 10, 10, 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);  }