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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations