Search in sources :

Example 56 with Record

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

Example 57 with Record

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

Example 58 with Record

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

Example 59 with Record

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

Example 60 with Record

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;
}
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