use of org.apache.jena.tdb.base.record.Record in project jena by apache.
the class TestBPTreeRecords method bpt_records_6.
@Test
public void bpt_records_6() {
BPTreeRecords bpr = make();
fill(bpr);
// No match.
assertNull(bpr.internalSearch(RecordLib.intToRecord(0x20)));
Record r = RecordLib.intToRecord(0x32);
Record r2 = search(bpr, r);
assertTrue(Record.keyEQ(r, r2));
r = bpr.getLowRecord();
r2 = search(bpr, r);
assertTrue(Record.keyEQ(r, r2));
r = bpr.getHighRecord();
r2 = search(bpr, r);
assertTrue(Record.keyEQ(r, r2));
bpr.release();
}
use of org.apache.jena.tdb.base.record.Record in project jena by apache.
the class TestBPlusTreeRewriter method scanComparision.
public static void scanComparision(List<Record> originaldata, BPlusTree bpt2) {
// ** Scan comparison
Iterator<Record> iter1 = originaldata.iterator();
Iterator<Record> iter2 = bpt2.iterator();
long count = 0;
for (; iter1.hasNext(); ) {
count++;
Record r1 = iter1.next();
if (!iter2.hasNext())
error("Deviation: new B+Tree is smaller");
Record r2 = iter2.next();
if (!Record.equals(r1, r2))
error("Deviation in iteration record %d: %s : %s", count, r1, r2);
}
if (iter2.hasNext())
error("New B+Tree larger than original");
}
use of org.apache.jena.tdb.base.record.Record in project jena by apache.
the class ExtHashTestBase method create.
public static ExtHash create(int... recs) {
ExtHash extHash = make();
for (int i : recs) {
Record r = intToRecord(i);
extHash.add(r);
if (false)
extHash.dump();
}
return extHash;
}
use of org.apache.jena.tdb.base.record.Record in project jena by apache.
the class ProcIndexBuild method exec.
public static void exec(String locationStr, String indexName, String dataFile) {
// Argument processing
Location location = Location.create(locationStr);
// InputStream input = System.in ;
InputStream input = IO.openFile(dataFile);
int keyLength = SystemTDB.SizeOfNodeId * indexName.length();
int valueLength = 0;
// The name is the order.
String primary = indexName;
// Scope for optimization:
// Null column map => no churn.
// Do record -> record copy, not Tuple, Tuple copy.
String primaryOrder;
int dftKeyLength;
int dftValueLength;
int tupleLength = indexName.length();
if (tupleLength == 3) {
primaryOrder = Names.primaryIndexTriples;
dftKeyLength = SystemTDB.LenIndexTripleRecord;
dftValueLength = 0;
} else if (tupleLength == 4) {
primaryOrder = Names.primaryIndexQuads;
dftKeyLength = SystemTDB.LenIndexQuadRecord;
dftValueLength = 0;
} else {
throw new AtlasException("Index name: " + indexName);
}
ColumnMap colMap = new ColumnMap(primaryOrder, indexName);
// -1? Write only.
// Also flush cache every so often => block writes (but not sequential so boring).
int readCacheSize = 10;
int writeCacheSize = 100;
int blockSize = SystemTDB.BlockSize;
RecordFactory recordFactory = new RecordFactory(dftKeyLength, dftValueLength);
int order = BPlusTreeParams.calcOrder(blockSize, recordFactory);
BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
int blockSizeNodes = blockSize;
int blockSizeRecords = blockSize;
FileSet destination = new FileSet(location, indexName);
BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize);
BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize);
int rowBlock = 1000;
Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter, bptParams, recordFactory, blkMgrNodes, blkMgrRecords);
bpt2.close();
}
use of org.apache.jena.tdb.base.record.Record in project jena by apache.
the class RecordsFromInput method next.
@Override
public Record next() {
if (!hasNext())
throw new NoSuchElementException();
Record r = slot;
slot = null;
return r;
}
Aggregations