private void beginBlock(BlockWriter.Entry entry) throws BlockSizeTooSmallException { byte blockType = entry.blockType(); int bs = out.bytesAvailableInBlock(); cur = new BlockWriter(blockType, idx.keyType, bs, restartInterval); cur.mustAdd(entry); }
private void writeMultiLevelIndex(List<IndexEntry> keys) throws IOException { levels = 1; while (maxIndexLevels == 0 || levels < maxIndexLevels) { keys = writeOneLevel(keys); if (keys == null) { return; } levels++; } // When maxIndexLevels has restricted the writer, write one // index block with the entire remaining set of keys. BlockWriter b = new BlockWriter( INDEX_BLOCK_TYPE, keyType, MAX_BLOCK_SIZE, Math.max(restartInterval, keys.size() / MAX_RESTARTS)); for (Entry e : keys) { b.mustAdd(e); } rootPosition = out.size(); b.writeTo(out); }
int estimateBytes(long curBlockPos) { BlockWriter b = new BlockWriter( INDEX_BLOCK_TYPE, keyType, MAX_BLOCK_SIZE, Math.max(restartInterval, entries.size() / MAX_RESTARTS)); try { for (Entry e : entries) { b.mustAdd(e); } if (cur != null) { b.mustAdd(new IndexEntry(cur.lastKey(), curBlockPos)); } } catch (BlockSizeTooSmallException e) { return b.currentSize(); } return b.currentSize(); }
private void beginBlock(BlockWriter.Entry entry) throws BlockSizeTooSmallException { byte blockType = entry.blockType(); int bs = out.bytesAvailableInBlock(); cur = new BlockWriter(blockType, idx.keyType, bs, restartInterval); cur.mustAdd(entry); }
private void writeMultiLevelIndex(List<IndexEntry> keys) throws IOException { levels = 1; while (maxIndexLevels == 0 || levels < maxIndexLevels) { keys = writeOneLevel(keys); if (keys == null) { return; } levels++; } // When maxIndexLevels has restricted the writer, write one // index block with the entire remaining set of keys. BlockWriter b = new BlockWriter( INDEX_BLOCK_TYPE, keyType, MAX_BLOCK_SIZE, Math.max(restartInterval, keys.size() / MAX_RESTARTS)); for (Entry e : keys) { b.mustAdd(e); } rootPosition = out.size(); b.writeTo(out); }
int estimateBytes(long curBlockPos) { BlockWriter b = new BlockWriter( INDEX_BLOCK_TYPE, keyType, MAX_BLOCK_SIZE, Math.max(restartInterval, entries.size() / MAX_RESTARTS)); try { for (Entry e : entries) { b.mustAdd(e); } if (cur != null) { b.mustAdd(new IndexEntry(cur.lastKey(), curBlockPos)); } } catch (BlockSizeTooSmallException e) { return b.currentSize(); } return b.currentSize(); }