use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class AbstractTestTupleIndex method TupleIndexRecordFindNot_1.
@Test
public void TupleIndexRecordFindNot_1() {
TupleIndex index = createIndex("SPO");
add(index, n1, n2, n3);
Tuple<NodeId> tuple2 = TupleFactory.tuple(n4, n5, n6);
Iterator<Tuple<NodeId>> iter = index.find(tuple2);
assertNotNull(iter);
assertFalse(iter.hasNext());
}
use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class AbstractTestTupleIndex method TupleIndexRecordPOS_3.
@Test
public void TupleIndexRecordPOS_3() {
TupleIndex index = createIndex("POS");
add(index, n1, n2, n3);
Tuple<NodeId> tuple2 = TupleFactory.tuple(null, n2, n3);
Iterator<Tuple<NodeId>> iter = index.find(tuple2);
assertTrue("Can't find tuple", iter.hasNext());
iter.next();
assertFalse(iter.hasNext());
}
use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class AbstractTestTupleIndex method TupleIndexRecordPOS_1.
@Test
public void TupleIndexRecordPOS_1() {
TupleIndex index = createIndex("POS");
add(index, n1, n2, n3);
Tuple<NodeId> tuple2 = TupleFactory.tuple(n1, n2, n3);
Iterator<Tuple<NodeId>> iter = index.find(tuple2);
assertTrue("Can't find tuple", iter.hasNext());
iter.next();
assertFalse(iter.hasNext());
}
use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class AbstractTestTupleIndex method TupleIndex_1.
@Test
public void TupleIndex_1() {
TupleIndex index = createIndex("SPO");
add(index, n1, n2, n3);
}
use of org.apache.jena.tdb.store.tupletable.TupleIndex 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);
}
}
}
}
}
Aggregations