Search in sources :

Example 11 with Record

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

the class BPTreeRecords method internalInsert.

@Override
public Record internalInsert(Record record) {
    // [TxTDB:PATCH-UP]
    promote();
    int i = rBuff.find(record);
    Record r2 = null;
    if (i < 0) {
        i = decodeIndex(i);
        if (rBuff.size() >= rBuff.maxSize())
            throw new StorageException("RecordBlock.put overflow");
        rBuff.add(i, record);
    } else {
        r2 = rBuff.get(i);
        if (Record.compareByKeyValue(record, r2) != 0)
            // Replace : return old
            rBuff.set(i, record);
    }
    write();
    return r2;
}
Also used : Record(org.apache.jena.tdb.base.record.Record) StorageException(org.apache.jena.tdb.base.StorageException)

Example 12 with Record

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

the class BPlusTree method deleteAndReturnOld.

public Record deleteAndReturnOld(Record record) {
    startUpdateBlkMgr();
    BPTreeNode root = getRoot();
    Record r = BPTreeNode.delete(root, record);
    if (CheckingTree)
        root.checkNodeDeep();
    releaseRoot(root);
    finishUpdateBlkMgr();
    return r;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 13 with Record

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

the class BPlusTree method minKey.

@Override
public Record minKey() {
    startReadBlkMgr();
    BPTreeNode root = getRoot();
    Record r = root.minRecord();
    releaseRoot(root);
    finishReadBlkMgr();
    return r;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 14 with Record

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

the class ExtHash method performCheck.

private void performCheck(int idx, HashBucket bucket) {
    if (bucket.getTrieBitLen() > bitLen)
        error("[%d] Bucket %d has bit length longer than the dictionary's (%d, %d)", idx, bucket.getId(), bucket.getTrieBitLen(), bitLen);
    // Check the bucket hash against the slot it's in.
    // Convert directory index to bucket hash
    int tmp = (idx >>> (bitLen - bucket.getTrieBitLen()));
    if (tmp != bucket.getTrieValue())
        error("[%d] Bucket %d : hash prefix 0x%X, expected 0x%X : %s", idx, bucket.getId(), bucket.getTrieValue(), tmp, bucket);
    // Check the contents.
    Record prevKey = Record.NO_REC;
    for (int i = 0; i < bucket.getCount(); i++) {
        Record rec = bucket.get(i);
        if (prevKey != Record.NO_REC && Record.keyLT(rec, prevKey))
            error("[%d] Bucket %d: Not sorted (slot %d) : %s", idx, bucket.getId(), i, bucket);
        prevKey = rec;
        int x = trieKey(rec, bucket.getTrieBitLen());
        // Check the key is bucket-compatible.
        if (x != bucket.getTrieValue())
            error("[%d] Bucket %d: Key (0x%04X) does not match the hash (0x%04X) : %s", idx, bucket.getId(), x, bucket.getTrieValue(), bucket);
    }
    if (SystemTDB.NullOut) {
        for (int i = bucket.getCount(); i < bucket.getMaxSize(); i++) {
            if (!bucket.getRecordBuffer().isClear(i))
                error("[%d] Bucket %d : overspill at [%d]: %s", idx, bucket.getId(), i, bucket);
        }
    }
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 15 with Record

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

the class HashBucket method put.

// Return true is added a new value 
public final boolean put(Record record) {
    int i = findIndex(record);
    if (i < 0)
        i = decodeIndex(i);
    else {
        Record recordOrig = getRecordBuffer().get(i);
        if (record.equals(recordOrig))
            return false;
        // Same key, different values. Replace.
        getRecordBuffer().set(i, record);
        return true;
    }
    if (getRecordBuffer().isFull())
        throw new StorageException("Bucket overflow");
    getRecordBuffer().add(i, record);
    return true;
}
Also used : Record(org.apache.jena.tdb.base.record.Record) StorageException(org.apache.jena.tdb.base.StorageException)

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