use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPTreeNode method shiftRight.
@Override
Record shiftRight(BPTreePage other, Record splitKey) {
BPTreeNode node = cast(other);
if (BPT.CheckingNode) {
if (count == 0)
BPT.error("Node is empty - can't shift a slot out");
if (node.isFull())
BPT.error("Destination node is full");
}
// Records: promote moving element, replace with splitKey
Record r = this.records.getHigh();
this.records.removeTop();
node.records.add(0, splitKey);
// Pointers just shift
this.ptrs.shiftRight(node.ptrs);
this.count--;
node.count++;
this.internalCheckNode();
node.internalCheckNode();
return r;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPTreeNode method search.
// ---------- Public calls.
// None of these are called recursively.
/**
* Find a record, using the active comparator
*/
public static Record search(BPTreeNode root, Record rec) {
root.internalCheckNodeDeep();
if (!root.isRoot())
throw new BPTreeException("Search not starting from the root: " + root);
AccessPath path = new AccessPath(root);
Record r = root.internalSearch(path, rec);
return r;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPTreeNode method insert.
/**
* Insert a record - return existing value if any, else null
*/
public static Record insert(BPTreeNode root, Record record) {
if (logging(log)) {
log(log, "** insert(%s) / root=%d", record, root.getId());
if (DumpTree)
root.dump();
}
if (!root.isRoot())
throw new BPTreeException("Insert begins but this is not the root");
if (root.isFull()) {
// Root full - root split is a special case.
splitRoot(root);
if (DumpTree)
root.dump();
}
AccessPath path = new AccessPath(root);
// Root ready - call insert proper.
Record result = root.internalInsert(path, record);
root.internalCheckNodeDeep();
if (logging(log)) {
log(log, "** insert(%s) / finish", record);
if (DumpTree)
root.dump();
}
return result;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPTreeRecords method getSplitKey.
@Override
public Record getSplitKey() {
int splitIdx = rBuff.size() / 2 - 1;
Record r = rBuff.get(splitIdx);
return r;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPTreeRecords method split.
/**
* Split: place old high half in 'other'. Return the new (upper)
* BPTreeRecords(BPTreePage).
* Split is the high end of the low page.
*/
@Override
public BPTreePage split() {
BPTreeRecords other = insertNewPage();
int splitIdx = rBuff.size() / 2 - 1;
// Only need key for checking later.
Record r = rBuff.get(splitIdx);
// Number to move.
int moveLen = rBuff.size() - (splitIdx + 1);
// Copy high end to new.
rBuff.copy(splitIdx + 1, other.getRecordBufferPage().getRecordBuffer(), 0, moveLen);
rBuff.clear(splitIdx + 1, moveLen);
rBuff.setSize(splitIdx + 1);
if (CheckingNode) {
if (!Record.keyEQ(r, maxRecord())) {
error("BPTreeRecords.split: Not returning expected record");
}
}
return other;
}
Aggregations