use of org.apache.jena.tdb.base.record.RecordFactory in project jena by apache.
the class dumpbpt method exec.
@Override
protected void exec() {
List<String> tripleIndexes = Arrays.asList(Names.tripleIndexes);
List<String> quadIndexes = Arrays.asList(Names.quadIndexes);
Location loc = modLocation.getLocation();
// The name is the order.
for (String indexName : super.getPositional()) {
String primary;
if (indexName.length() == 3) {
primary = Names.primaryIndexTriples;
} else if (indexName.length() == 4) {
primary = Names.primaryIndexQuads;
} else {
cmdError("Wrong length: " + indexName);
primary = null;
}
int keySubLen = SystemTDB.SizeOfNodeId;
int keyUnitLen = indexName.length();
int keyLength = keySubLen * keyUnitLen;
int valueLength = 0;
RecordFactory rf = new RecordFactory(keyLength, valueLength);
RangeIndex rIndex = IndexFactory.buildRangeIndex(loc, indexName, rf);
BPlusTree bpt = (BPlusTree) rIndex;
if (false) {
System.out.println("---- Index structure");
bpt.dump();
}
if (true) {
System.out.println("---- Index contents");
Iterator<Record> iter = bpt.iterator();
if (!iter.hasNext())
System.out.println("<<Empty>>");
for (; iter.hasNext(); ) {
Record r = iter.next();
printRecord("", System.out, r, keyUnitLen);
}
}
// Check.
Iterator<Record> iterCheck = bpt.iterator();
Record r1 = null;
int i = 0;
for (; iterCheck.hasNext(); ) {
Record r2 = iterCheck.next();
i++;
if (r1 != null) {
if (!Record.keyLT(r1, r2)) {
System.err.println("key error@ " + i);
printRecord(" ", System.err, r1, keyUnitLen);
printRecord(" ", System.err, r2, keyUnitLen);
}
}
r1 = r2;
}
if (false) {
// Dump in tuple order.
TupleIndex tupleIndex = new TupleIndexRecord(primary.length(), new ColumnMap(primary, indexName), indexName, rIndex.getRecordFactory(), rIndex);
if (true) {
System.out.println("---- Tuple contents");
Iterator<Tuple<NodeId>> iter2 = tupleIndex.all();
if (!iter2.hasNext())
System.out.println("<<Empty>>");
for (; iter2.hasNext(); ) {
Tuple<NodeId> row = iter2.next();
System.out.println(row);
}
}
}
}
}
use of org.apache.jena.tdb.base.record.RecordFactory in project jena by apache.
the class BPlusTreeTools method bpt_scan_record_buffer.
/*public*/
private static void bpt_scan_record_buffer(BlockMgr blkMgr, boolean verbose) {
RecordFactory f = SystemTDB.indexRecordTripleFactory;
RecordBufferPageMgr recordPageMgr = new RecordBufferPageMgr(f, blkMgr);
bpt_scan_record_buffer(recordPageMgr, verbose);
}
use of org.apache.jena.tdb.base.record.RecordFactory in project jena by apache.
the class TestExtHash method makeIndex.
@Override
protected Index makeIndex(int kLen, int vLen) {
RecordFactory factory = new RecordFactory(kLen, vLen);
BlockMgr mgr = BlockMgrFactory.createMem("EXT", 32);
ExtHash eHash = new ExtHash(new PlainFileMem(), factory, mgr);
return eHash;
}
use of org.apache.jena.tdb.base.record.RecordFactory in project jena by apache.
the class TestBPTreeRecords method beforeClass.
@BeforeClass
public static void beforeClass() {
oldNullOut = SystemTDB.NullOut;
SystemTDB.NullOut = true;
oldCheckingNode = BPlusTreeParams.CheckingNode;
BPlusTreeParams.CheckingNode = true;
oldCheckingBTree = BPlusTreeParams.CheckingTree;
BPlusTreeParams.CheckingTree = true;
// Which is 6 int records
blockSize = 4 * 8;
recordFactory = new RecordFactory(4, 0);
bufSizeRecord = RecordBufferPage.calcRecordSize(recordFactory, blockSize);
blkMgrRecords = BlockMgrFactory.createMem("BPTreeRecords", blockSize);
recordBufferPageMgr = new RecordBufferPageMgr(recordFactory, blkMgrRecords);
// B+Tree order does not matter.
bPlusTree = BPlusTree.attach(new BPlusTreeParams(3, recordFactory), null, blkMgrRecords);
}
use of org.apache.jena.tdb.base.record.RecordFactory in project jena by apache.
the class CmdTestBPlusTreeRewriter method main.
public static void main(String... argv) {
// Usage: maxOrder maxSize NumTests
if (argv.length != 3) {
System.err.println("Usage: " + Lib.classShortName(CmdTestBPlusTreeRewriter.class) + " maxOrder maxSize NumTests");
System.exit(1);
}
SystemTDB.NullOut = true;
boolean debug = false;
int MaxOrder = -1;
int MinOrder = 2;
int MinSize = 0;
int MaxSize = -1;
int NumTest = -1;
try {
MaxOrder = Integer.parseInt(argv[0]);
} catch (NumberFormatException ex) {
System.err.println("Bad number for MaxOrder");
System.exit(1);
}
try {
MaxSize = Integer.parseInt(argv[1]);
} catch (NumberFormatException ex) {
System.err.println("Bad number for MaxSize");
System.exit(1);
}
try {
NumTest = Integer.parseInt(argv[2]);
} catch (NumberFormatException ex) {
System.err.println("Bad number for NumTest");
System.exit(1);
}
// int MaxOrder = 10 ;
// int MinOrder = 2 ;
// int MinSize = 0 ;
// int MaxSize = 1000 ;
// int NumTest = 10000 ; //10*1000 ;
int KeySize = 4;
int ValueSize = 8;
RecordFactory recordFactory = new RecordFactory(KeySize, ValueSize);
int successes = 0;
int failures = 0;
int[] orders = null;
int[] sizes = null;
if (false) {
// Specific test case.
orders = new int[] { 2 };
sizes = new int[] { 20 };
NumTest = sizes.length;
SystemTDB.NullOut = true;
debug = true;
BPlusTreeRewriter.debug = true;
} else {
orders = new int[NumTest];
sizes = new int[NumTest];
for (int i = 0; i < orders.length; i++) {
int order = (MinOrder == MaxOrder) ? MinOrder : MinOrder + RandomLib.random.nextInt(MaxOrder - MinOrder);
int size = (MinSize == MaxSize) ? MinSize : MinSize + RandomLib.random.nextInt(MaxSize - MinSize);
orders[i] = order;
sizes[i] = size;
}
}
int numOnLine = 50;
int testsPerTick = 500;
int testCount = 1;
for (testCount = 1; testCount <= orders.length; testCount++) {
if (testCount % testsPerTick == 0)
System.out.print(".");
if (testCount % (testsPerTick * numOnLine) == 0)
System.out.println();
int idx = testCount - 1;
int order = orders[idx];
int size = sizes[idx];
try {
TestBPlusTreeRewriter.runOneTest(order, size, recordFactory, debug);
successes++;
} catch (RuntimeException ex) {
System.err.printf("-- Fail: (order=%d, size=%d)\n", order, size);
ex.printStackTrace(System.err);
System.err.printf("--------------------------\n");
failures++;
}
}
if (testCount % (testsPerTick * numOnLine) != 0)
System.out.println();
System.err.flush();
System.out.flush();
System.out.printf("DONE : %,d tests : Success=%,d, Failures=%,d\n", NumTest, successes, failures);
}
Aggregations