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