use of io.datarouter.filesystem.snapshot.block.branch.BranchBlock in project datarouter by hotpads.
the class SnapshotIdReader method leafBlock.
private LeafBlock leafBlock(long recordId) {
BlockKey rootBranchBlockKey = rootBlock.rootBranchBlockKey(snapshotKey);
BranchBlock branchBlock = blockLoader.branch(rootBranchBlockKey);
for (int level = rootBlock.maxBranchLevel() - 1; level >= 0; --level) {
int childBlockIndex = branchBlock.findChildBlockIndex(recordId);
int childBlockId = branchBlock.childBlock(childBlockIndex);
BlockKey branchBlockKey = branchBlock.childBranchBlockKey(snapshotKey, childBlockId);
branchBlock = blockLoader.branch(branchBlockKey);
}
int leafBlockIndex = branchBlock.findChildBlockIndex(recordId);
int leafBlockId = branchBlock.childBlock(leafBlockIndex);
BlockKey leafBlockKey = branchBlock.leafBlockKey(snapshotKey, leafBlockId);
return blockLoader.leaf(leafBlockKey);
}
use of io.datarouter.filesystem.snapshot.block.branch.BranchBlock in project datarouter by hotpads.
the class ScanningBlockReader method scanLeafBlockKeys.
private Scanner<BlockKey> scanLeafBlockKeys(long fromRecordIdInclusive) {
BlockKey topBranchBlockKey = rootBlock.rootBranchBlockKey(snapshotKey);
BranchBlock topBranchBlock = blockLoader.branch(topBranchBlockKey);
return scanDescendantBranchBlocks(topBranchBlock, fromRecordIdInclusive).include(branchBlock -> branchBlock.level() == 0).concat(branchBlock -> {
return Scanner.iterate(0, i -> i + 1).limit(branchBlock.numRecords()).include(index -> branchBlock.recordId(index) >= fromRecordIdInclusive).map(branchBlock::childBlock).map(leafBlockId -> branchBlock.leafBlockKey(snapshotKey, leafBlockId));
});
}
use of io.datarouter.filesystem.snapshot.block.branch.BranchBlock in project datarouter by hotpads.
the class SnapshotKeyReader method leafBlock.
public LeafBlock leafBlock(byte[] searchKey) {
BlockKey rootBranchBlockKey = rootBlock.rootBranchBlockKey(snapshotKey);
BranchBlock branchBlock = blockLoader.branch(rootBranchBlockKey);
for (int level = rootBlock.maxBranchLevel() - 1; level >= 0; --level) {
int childBlockIndex = branchBlock.findChildBlockIndex(searchKey);
int childBlockId = branchBlock.childBlock(childBlockIndex);
BlockKey branchBlockKey = branchBlock.childBranchBlockKey(snapshotKey, childBlockId);
branchBlock = blockLoader.branch(branchBlockKey);
}
int leafBlockIndex = branchBlock.findChildBlockIndex(searchKey);
int leafBlockId = branchBlock.childBlock(leafBlockIndex);
BlockKey leafBlockKey = branchBlock.leafBlockKey(snapshotKey, leafBlockId);
return blockLoader.leaf(leafBlockKey);
}
Aggregations