Search in sources :

Example 46 with Record

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;
}
Also used : Record(org.apache.jena.dboe.base.record.Record)

Example 47 with Record

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;
}
Also used : Record(org.apache.jena.dboe.base.record.Record)

Example 48 with Record

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;
}
Also used : Record(org.apache.jena.dboe.base.record.Record)

Example 49 with Record

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;
}
Also used : Record(org.apache.jena.dboe.base.record.Record)

Example 50 with Record

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;
}
Also used : Record(org.apache.jena.dboe.base.record.Record)

Aggregations

Record (org.apache.jena.dboe.base.record.Record)71 RecordLib.intToRecord (org.apache.jena.dboe.test.RecordLib.intToRecord)6 Pair (org.apache.jena.atlas.lib.Pair)5 NoSuchElementException (java.util.NoSuchElementException)3 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)3 FileSet (org.apache.jena.dboe.base.file.FileSet)3 RecordBufferPage (org.apache.jena.dboe.base.recordbuffer.RecordBufferPage)3 BPTreeNode (org.apache.jena.dboe.trans.bplustree.BPTreeNode)3 BPlusTree (org.apache.jena.dboe.trans.bplustree.BPlusTree)3 BPlusTreeParams (org.apache.jena.dboe.trans.bplustree.BPlusTreeParams)3 NodeId (org.apache.jena.tdb2.store.NodeId)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 StorageException (org.apache.jena.dboe.base.StorageException)2 BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)2 RecordBuffer (org.apache.jena.dboe.base.buffer.RecordBuffer)2 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)2 Index (org.apache.jena.dboe.index.Index)2 RangeIndex (org.apache.jena.dboe.index.RangeIndex)2 TDBException (org.apache.jena.tdb2.TDBException)2