use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPlusTree method deleteAndReturnOld.
public Record deleteAndReturnOld(Record record) {
startUpdateBlkMgr();
BPTreeNode root = getRootWrite();
Record r = BPTreeNode.delete(root, record);
releaseRootWrite(root);
finishUpdateBlkMgr();
return r;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPlusTree method minKey.
@Override
public Record minKey() {
startReadBlkMgr();
BPTreeNode root = getRootRead();
Record r = BPTreeNode.minRecord(root);
releaseRootRead(root);
finishReadBlkMgr();
return r;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPlusTree method clear.
@Override
public void clear() {
Record[] records = new Record[SLICE];
while (true) {
Iterator<Record> iter = iterator();
int i = 0;
for (i = 0; i < SLICE; i++) {
if (!iter.hasNext())
break;
Record r = iter.next();
records[i] = r;
}
if (i == 0)
break;
for (int j = 0; j < i; j++) {
delete(records[j]);
records[j] = null;
}
}
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPTreeNode method internalDelete.
// ============ DELETE
/*
* Delete
* Descend, making sure that the node is not minimum size at each descend.
* If it is, rebalenace.
*/
@Override
final Record internalDelete(AccessPath path, Record rec) {
if (logging(log))
log(log, ">> internalDelete(%s) : %s", rec, this);
internalCheckNode();
int x = findSlot(rec);
int y = apply(x);
BPTreePage page = get(y);
trackPath(path, this, y, page);
if (page.isMinSize()) {
// Ensure that a node is at least min+1 so a delete can happen.
// Can't be the root - we descended in the get().
// Ignore return - need to re-find.
rebalance(path, page, y);
// TODO But rebalance may have freed this?
page.release();
// Rebalance may have moved the record due to shuffling.
x = findSlot(rec);
y = apply(x);
page = get(y);
promote1(page, this, y);
resetTrackPath(path, this, y, page);
if (BPT.CheckingNode) {
internalCheckNode();
page.checkNode();
}
this.write();
// Needed in case the record being deleted is not in the
// tree, which mean there is no work done and
// this page is not written.
page.write();
}
// Go to bottom
// Need to return the deleted key/value.
Record r2 = page.internalDelete(path, rec);
if (x >= 0) {
// And hence r2 != null.
// The deleted key was in the tree as well as the records.
// Change to the new key for the subtree.
// Path is already promoted by the delete.
// promote1(this, ??, ??);
Record mx = page.maxRecord();
records.set(x, keyRecord(mx));
this.write();
}
if (logging(log))
log(log, "<< internalDelete(%s) : %s", rec, this);
page.release();
return r2;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPTreeNode method internalMaxRecord.
@Override
protected Record internalMaxRecord(AccessPath path) {
BPTreePage page = get(count);
trackPath(path, this, count, page);
Record r = page.internalMaxRecord(path);
page.release();
return r;
}
Aggregations