@Test public void testLoad() throws IOException { ByteArraySeekableFile seekableFile = makeEntryIndexFileContent(3, 4); EntryIndexFile file = new EntryIndexFile(seekableFile); Assert.assertEquals(3, file.getMinEntryIndex()); Assert.assertEquals(4, file.getMaxEntryIndex()); Assert.assertEquals(2, file.getEntryIndexCount()); EntryIndexItem item = file.get(3); Assert.assertNotNull(item); Assert.assertEquals(30L, item.getOffset()); Assert.assertEquals(1, item.getKind()); Assert.assertEquals(3, item.getTerm()); item = file.get(4); Assert.assertNotNull(item); Assert.assertEquals(40L, item.getOffset()); Assert.assertEquals(1, item.getKind()); Assert.assertEquals(4, item.getTerm()); }
private void load() throws IOException { if (seekableFile.size() == 0L) { entryIndexCount = 0; return; } minEntryIndex = seekableFile.readInt(); maxEntryIndex = seekableFile.readInt(); updateEntryIndexCount(); long offset; int kind; int term; for (int i = minEntryIndex; i <= maxEntryIndex; i++) { offset = seekableFile.readLong(); kind = seekableFile.readInt(); term = seekableFile.readInt(); entryIndexMap.put(i, new EntryIndexItem(i, offset, kind, term)); } }
EntryIndexFile implements Iterable<EntryIndexItem> { private void load() throws IOException { if (seekableFile.size() == 0L) { entryIndexCount = 0; return; } minEntryIndex = seekableFile.readInt(); maxEntryIndex = seekableFile.readInt(); updateEntryIndexCount(); long offset; int kind; int term; for (int i = minEntryIndex; i <= maxEntryIndex; i++) { offset = seekableFile.readLong(); kind = seekableFile.readInt(); term = seekableFile.readInt(); entryIndexMap.put(i, new EntryIndexItem(i, offset, kind, term)); } } }
EntryIndexFile implements Iterable<EntryIndexItem> { private void load() throws IOException { if (seekableFile.size() == 0L) { entryIndexCount = 0; return; } minEntryIndex = seekableFile.readInt(); maxEntryIndex = seekableFile.readInt(); updateEntryIndexCount(); long offset; int kind; int term; for (int i = minEntryIndex; i <= maxEntryIndex; i++) { offset = seekableFile.readLong(); kind = seekableFile.readInt(); term = seekableFile.readInt(); entryIndexMap.put(i, new EntryIndexItem(i, offset, kind, term)); } } EntryIndexFile(File file);  EntryIndexFile(SeekableFile seekableFile); }
EntryIndexFile implements Iterable<EntryIndexItem> { private void load() throws IOException { if (seekableFile.size() == 0L) { entryIndexCount = 0; return; } minEntryIndex = seekableFile.readInt(); maxEntryIndex = seekableFile.readInt(); updateEntryIndexCount(); long offset; int kind; int term; for (int i = minEntryIndex; i <= maxEntryIndex; i++) { offset = seekableFile.readLong(); kind = seekableFile.readInt(); term = seekableFile.readInt(); entryIndexMap.put(i, new EntryIndexItem(i, offset, kind, term)); } } EntryIndexFile(File file);  EntryIndexFile(SeekableFile seekableFile); boolean isEmpty(); int getMinEntryIndex(); int getMaxEntryIndex(); int getEntryIndexCount(); void appendEntryIndex(int index, long offset, int kind, int term); void clear(); void removeAfter(int newMaxEntryIndex); long getOffset(int entryIndex); @Nonnull EntryIndexItem get(int entryIndex); @Override @Nonnull Iterator<EntryIndexItem> iterator(); void close(); }
EntryIndexFile implements Iterable<EntryIndexItem> { private void load() throws IOException { if (seekableFile.size() == 0L) { entryIndexCount = 0; return; } minEntryIndex = seekableFile.readInt(); maxEntryIndex = seekableFile.readInt(); updateEntryIndexCount(); long offset; int kind; int term; for (int i = minEntryIndex; i <= maxEntryIndex; i++) { offset = seekableFile.readLong(); kind = seekableFile.readInt(); term = seekableFile.readInt(); entryIndexMap.put(i, new EntryIndexItem(i, offset, kind, term)); } } EntryIndexFile(File file);  EntryIndexFile(SeekableFile seekableFile); boolean isEmpty(); int getMinEntryIndex(); int getMaxEntryIndex(); int getEntryIndexCount(); void appendEntryIndex(int index, long offset, int kind, int term); void clear(); void removeAfter(int newMaxEntryIndex); long getOffset(int entryIndex); @Nonnull EntryIndexItem get(int entryIndex); @Override @Nonnull Iterator<EntryIndexItem> iterator(); void close();  }