Search in sources :

Example 66 with Record

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

the class BPlusTreeRewriterUtils method printDataBlocks.

private static Iterator<Pair<Integer, Record>> printDataBlocks(Iterator<Pair<Integer, Record>> iter, RecordBufferPageMgr recordPageMgr) {
    divider();
    List<Pair<Integer, Record>> x = Iter.toList(iter);
    System.out.printf(">>Packed data blocks\n");
    for (Pair<Integer, Record> pair : x) {
        System.out.printf("  %s\n", pair);
        RecordBufferPage rbp = recordPageMgr.getRead(pair.car());
        // System.out.printf("RecordBufferPage[id=%d,link=%d] %d\n", rbp.getId(), rbp.getLink(), rbp.getCount() ) ;
        System.out.println(rbp);
        recordPageMgr.release(rbp);
    }
    System.out.printf("<<Packed data blocks\n");
    System.out.printf("Blocks: %d\n", x.size());
    return x.iterator();
}
Also used : Record(org.apache.jena.tdb.base.record.Record) Pair(org.apache.jena.atlas.lib.Pair) RecordBufferPage(org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)

Example 67 with Record

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

the class ExtHash method split.

private HashBucket split(int bucketId, HashBucket bucket) {
    // idx is the array offset to the lower of the bucket point pair.
    if (logging()) {
        log("split: Bucket %d : size: %d; Bucket bitlength %d", bucketId, bucket.getCount(), bucket.getTrieBitLen());
        log("split: %s", bucket);
    }
    // Create new bucket, which will be the upper bucket.
    // Low bucket will have the old hash value,
    // Lengthen the hash; the new will be one more.
    bucket.incTrieBitLen();
    // Bucket hash value is kept in index-order (i.e. high bits are most significant).
    int hash1 = bucket.getTrieValue() << 1;
    int hash2 = (bucket.getTrieValue() << 1) | 0x1;
    // Reset, now it's longer
    bucket.setTrieValue(hash1);
    if (logging())
        log("split: bucket hashes 0x%04X 0x%04X", hash1, hash2);
    // // New bucket
    HashBucket bucket2 = hashBucketMgr.create(hash2, bucket.getTrieBitLen());
    if (logging())
        log("New bucket: %s", bucket2);
    // bucket2.setTrieValue(hash2) ;
    RecordBuffer rBuff1 = bucket.getRecordBuffer();
    RecordBuffer rBuff2 = bucket2.getRecordBuffer();
    // Destination indexes into the above
    int idx1 = 0;
    int idx2 = 0;
    for (int i = 0; i < rBuff1.size(); i++) {
        Record r = rBuff1.get(i);
        // Incremented bit length
        int x = trieKey(r, bucket.getTrieBitLen());
        if (x == hash1) {
            if (logging())
                log("Allocate index %d to bucket1", i);
            // We're shifting down records that saty in this bucket.
            if (idx1 != i)
                rBuff1.set(idx1, r);
            idx1++;
        } else if (x == hash2) {
            if (logging())
                log("Allocate index %d to bucket2", i);
            rBuff2.add(r);
            idx2++;
        } else
            error("Bad trie for allocation to split buckets");
    }
    if (true)
        rBuff1.clear(idx1, bucket.getCount() - idx1);
    rBuff1.setSize(idx1);
    if (logging()) {
        log("split: Lower bucket: %s", bucket);
        log("split: Upper bucket: %s", bucket2);
    }
    // Check with splitAndReorganise()
    hashBucketMgr.put(bucket);
    hashBucketMgr.put(bucket2);
    return bucket2;
}
Also used : Record(org.apache.jena.tdb.base.record.Record) RecordBuffer(org.apache.jena.tdb.base.buffer.RecordBuffer)

Example 68 with Record

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

the class ExtHash method find.

@Override
public Record find(Record key) {
    if (logging())
        log(">> get(%s)", key);
    int blockId = bucketId(key, bitLen);
    HashBucket bucket = hashBucketMgr.get(blockId);
    Record value = bucket.find(key);
    if (logging())
        log("<< get(%s) -> %s", key.getKey(), value);
    return value;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 69 with Record

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

the class RangeIndexLogger method find.

@Override
public Record find(Record record) {
    log.info("Find: " + record);
    Record r2 = super.find(record);
    log.info("Find: " + record + " ==> " + r2);
    return r2;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 70 with Record

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

the class BPTreeNode method shiftLeft.

@Override
Record shiftLeft(BPTreePage other, Record splitKey) {
    BPTreeNode node = cast(other);
    if (CheckingNode) {
        if (count == 0)
            error("Node is empty - can't shift a slot out");
        if (isFull())
            error("Destination node is full");
    }
    Record r = node.records.getLow();
    // Records: promote moving element, replace with splitKey
    this.records.add(splitKey);
    node.records.shiftDown(0);
    // Pointers just shift
    this.ptrs.shiftLeft(node.ptrs);
    this.count++;
    node.count--;
    return r;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Aggregations

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