Search in sources :

Example 16 with Record

use of org.apache.jena.tdb.base.record.Record in project jena by apache.

the class BPTreeNode method minRecord.

@Override
protected Record minRecord() {
    BPTreePage page = get(0, READ);
    Record r = page.minRecord();
    page.release();
    return r;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 17 with Record

use of org.apache.jena.tdb.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.id != 0)
        throw new BPTreeException("Search not starting from the root: " + root);
    Record r = root.internalSearch(rec);
    return r;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 18 with Record

use of org.apache.jena.tdb.base.record.Record in project jena by apache.

the class BPTreeNode method internalSearch.

// ============ SEARCH
/* 
     * Do a (binary) search of the node to find the record.
     *   Returns: 
     *     +ve or 0 => the index of the record 
     *     -ve => The insertion point : the immediate higher record or length as (-i-1)
     *  Convert to +ve and decend to find the RecordBuffer with the record in it. 
     */
@Override
final Record internalSearch(Record rec) {
    if (CheckingNode)
        internalCheckNode();
    BPTreePage page = findHere(rec);
    Record r = page.internalSearch(rec);
    page.release();
    return r;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 19 with Record

use of org.apache.jena.tdb.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(Record rec) {
    internalCheckNode();
    if (logging())
        log.debug(format("internalDelete(%s) : %s", rec, this));
    int x = findSlot(rec);
    // If x is >= 0, may need to adjust this 
    int y = convert(x);
    BPTreePage page = get(y, READ);
    boolean thisWriteNeeded = false;
    if (// Can't be root - we decended in the get(). 
    page.isMinSize()) {
        promote();
        page = rebalance(page, y);
        thisWriteNeeded = true;
        // May have moved/removed at x.  Find again. YUK.
        x = findSlot(rec);
        if (CheckingNode) {
            internalCheckNode();
            page.checkNode();
        }
        this.write();
    }
    // Go to bottom
    // Need to return the new key.
    Record r2 = page.internalDelete(rec);
    if (x >= 0) {
        promote();
        // YUK
        records.set(x, keyRecord(page.maxRecord()));
        this.write();
    }
    page.release();
    return r2;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 20 with Record

use of org.apache.jena.tdb.base.record.Record in project jena by apache.

the class BPTreeNode method getSplitKey.

@Override
final Record getSplitKey() {
    int ix = params.SplitIndex;
    Record split = records.get(ix);
    return split;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Aggregations

Record (org.apache.jena.tdb.base.record.Record)96 BaseTest (org.apache.jena.atlas.junit.BaseTest)25 Test (org.junit.Test)25 RecordLib.intToRecord (org.apache.jena.tdb.base.record.RecordLib.intToRecord)20 RecordBuffer (org.apache.jena.tdb.base.buffer.RecordBuffer)15 RangeIndex (org.apache.jena.tdb.index.RangeIndex)8 BPTreeRecords (org.apache.jena.tdb.index.bplustree.BPTreeRecords)5 NodeId (org.apache.jena.tdb.store.NodeId)5 NoSuchElementException (java.util.NoSuchElementException)4 Pair (org.apache.jena.atlas.lib.Pair)4 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)4 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)4 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)3 StorageException (org.apache.jena.tdb.base.StorageException)3 FileSet (org.apache.jena.tdb.base.file.FileSet)3 Location (org.apache.jena.tdb.base.file.Location)3 RecordBufferPage (org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)3 Index (org.apache.jena.tdb.index.Index)3 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)3 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)3