use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class tdbgenindex method main.
public static void main(String... argv) {
// Usage: srcLocation indexName dstLocation indexName
if (argv.length != 4) {
System.err.println("Usage: " + Lib.classShortName(tdbgenindex.class) + " srcLocation srcIndex dstLocation dstIndex");
System.exit(1);
}
Location srcLoc = Location.create(argv[0]);
String srcIndexName = argv[1];
Location dstLoc = Location.create(argv[2]);
String dstIndexName = argv[3];
int readCacheSize = 0;
int writeCacheSize = -1;
if (srcIndexName.length() != dstIndexName.length()) {
System.err.println("srcIndexName.length() != dstIndexName.length() " + srcIndexName + " :: " + dstIndexName);
System.exit(1);
}
String primary;
int dftKeyLength;
int dftValueLength;
if (srcIndexName.length() == 3) {
primary = Names.primaryIndexTriples;
dftKeyLength = SystemTDB.LenIndexTripleRecord;
dftValueLength = 0;
} else if (srcIndexName.length() == 4) {
primary = Names.primaryIndexQuads;
dftKeyLength = SystemTDB.LenIndexQuadRecord;
dftValueLength = 0;
} else {
System.err.println("indexlength != 3 or 4");
System.exit(1);
primary = null;
dftKeyLength = 0;
dftValueLength = 0;
}
TupleIndex srcIdx = SetupTDB.makeTupleIndex(srcLoc, primary, srcIndexName, srcIndexName, dftKeyLength);
TupleIndex dstIdx = SetupTDB.makeTupleIndex(dstLoc, primary, dstIndexName, dstIndexName, dftKeyLength);
Iterator<Tuple<NodeId>> iter = srcIdx.all();
for (; iter.hasNext(); ) {
Tuple<NodeId> tuple = iter.next();
dstIdx.add(tuple);
}
srcIdx.close();
dstIdx.close();
}
use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class BuilderSecondaryIndexesSequential method createSecondaryIndexes.
// Create each secondary indexes, doing one at a time.
@Override
public void createSecondaryIndexes(TupleIndex primaryIndex, TupleIndex[] secondaryIndexes) {
Timer timer = new Timer();
timer.startTimer();
for (TupleIndex index : secondaryIndexes) {
if (index != null) {
long time1 = timer.readTimer();
LoaderNodeTupleTable.copyIndex(primaryIndex.all(), new TupleIndex[] { index }, index.getMapping(), monitor);
long time2 = timer.readTimer();
// if ( printTiming )
// printf("Time for %s indexing: %.2fs\n", index.getLabel(), (time2-time1)/1000.0) ;
// if ( printTiming )
// printer.println() ;
}
}
}
use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class DatasetBuilderStd method makePrefixTable.
protected DatasetPrefixesTDB makePrefixTable(Location location, DatasetControl policy, StoreParams params) {
String primary = params.getPrimaryIndexPrefix();
String[] indexes = params.getPrefixIndexes();
TupleIndex[] prefixIndexes = makeTupleIndexes(location, primary, indexes, new String[] { params.getIndexPrefix() }, params);
if (prefixIndexes.length != 1)
error(log, "Wrong number of triple table tuples indexes: " + prefixIndexes.length);
String pnNode2Id = params.getPrefixNode2Id();
String pnId2Node = params.getPrefixId2Node();
// No cache - the prefix mapping is a cache
NodeTable prefixNodes = makeNodeTableNoCache(location, pnNode2Id, pnId2Node, params);
NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(), prefixIndexes, prefixNodes, policy);
DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable);
log.debug("Prefixes: " + primary + " :: " + String.join(",", indexes));
return prefixes;
}
use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class AbstractTestTupleIndex method TupleIndexRecordSPO_8.
@Test
public void TupleIndexRecordSPO_8() {
TupleIndex index = createIndex("SPO");
add(index, n1, n2, n3);
add(index, n2, n3, n4);
{
Tuple<NodeId> tuple2 = TupleFactory.tuple(n1, NodeId.NodeIdAny, NodeId.NodeIdAny);
Iterator<Tuple<NodeId>> iter = index.find(tuple2);
Set<Tuple<NodeId>> x = Iter.toSet(iter);
assertEquals(1, x.size());
assertTrue(x.contains(TupleFactory.tuple(n1, n2, n3)));
}
{
Tuple<NodeId> tuple2 = TupleFactory.tuple(n2, NodeId.NodeIdAny, NodeId.NodeIdAny);
Iterator<Tuple<NodeId>> iter = index.find(tuple2);
Set<Tuple<NodeId>> x = Iter.toSet(iter);
assertEquals(1, x.size());
assertTrue(x.contains(TupleFactory.tuple(n2, n3, n4)));
}
}
use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.
the class AbstractTestTupleIndex method TupleIndexRecordSPO_4.
@Test
public void TupleIndexRecordSPO_4() {
TupleIndex index = createIndex("SPO");
add(index, n1, n2, n3);
Tuple<NodeId> tuple2 = TupleFactory.tuple(n1, NodeId.NodeIdAny, NodeId.NodeIdAny);
Iterator<Tuple<NodeId>> iter = index.find(tuple2);
assertTrue(iter.hasNext());
iter.next();
assertFalse(iter.hasNext());
}
Aggregations