use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.
the class LoaderMain method finishBulk.
@Override
public void finishBulk() {
// Close off the data pipeline
BulkProcesses.finish(dataProcess);
boolean doTriples = countTriples() != 0;
boolean doQuads = countQuads() != 0;
if (doTriples) {
TupleIndex srcIdx3 = PhasedOps.findInIndexMap(loaderPlan.primaryLoad3()[0], indexMap);
TupleIndex[][] indexSets3 = PhasedOps.indexSetsFromNames(loaderPlan.secondaryIndex3(), indexMap);
executeSecondary(srcIdx3, indexSets3, dsgtdb, output);
}
if (doQuads) {
TupleIndex srcIdx4 = PhasedOps.findInIndexMap(loaderPlan.primaryLoad4()[0], indexMap);
TupleIndex[][] indexSets4 = PhasedOps.indexSetsFromNames(loaderPlan.secondaryIndex4(), indexMap);
executeSecondary(srcIdx4, indexSets4, dsgtdb, output);
}
super.finishBulk();
dsgtdb.getTxnSystem().getTxnMgr().finishExclusiveMode();
}
use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.
the class TDB2StorageBuilder method buildPrefixTable.
private StoragePrefixesTDB buildPrefixTable(NodeTable prefixNodes) {
String primary = params.getPrimaryIndexPrefix();
String[] indexes = params.getPrefixIndexes();
TupleIndex[] prefixIndexes = makeTupleIndexes(primary, indexes);
if (prefixIndexes.length != 1)
error(log, "Wrong number of triple table tuples indexes: " + prefixIndexes.length);
// No cache - the prefix mapping is a cache
// NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1, -1);
NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(), prefixIndexes, prefixNodes);
StoragePrefixesTDB x = new StoragePrefixesTDB(txnSystem, prefixTable);
// DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable);
log.debug("Prefixes: " + primary + " :: " + String.join(",", indexes));
return x;
}
use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.
the class TDB2StorageBuilder method makeTupleIndex.
private TupleIndex makeTupleIndex(String primary, String index, String name) {
TupleMap cmap = TupleMap.create(primary, index);
RecordFactory rf = new RecordFactory(SystemTDB.SizeOfNodeId * cmap.length(), 0);
RangeIndex rIdx = makeRangeIndex(rf, index);
TupleIndex tIdx = new TupleIndexRecord(primary.length(), cmap, index, rf, rIdx);
return tIdx;
}
use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.
the class BuilderSecondaryIndexes method createSecondaryIndexes.
public static void createSecondaryIndexes(MonitorOutput output, TupleIndex primaryIndex, TupleIndex[] secondaryIndexes) {
boolean printTiming = true;
for (TupleIndex index : secondaryIndexes) {
String msg = primaryIndex.getName() + "->" + index.getName();
if (index != null) {
ProgressMonitor monitor = ProgressMonitorOutput.create(output, msg, LoaderSequential.IndexTickPoint, LoaderSequential.IndexSuperTick);
monitor.startMessage(msg);
monitor.start();
LoaderOps.copyIndex(primaryIndex.all(), new TupleIndex[] { index }, monitor);
monitor.finish();
monitor.finishMessage(index.getName() + " indexing: ");
}
}
}
use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.
the class ProcBuildIndexX method indexBuilder.
private static long indexBuilder(DatasetGraph dsg, InputStream input, String indexName) {
long tickPoint = BulkLoaderX.DataTick;
int superTick = BulkLoaderX.DataSuperTick;
// Location of storage, not the DB.
DatasetGraphTDB dsgtdb = TDBInternal.getDatasetGraphTDB(dsg);
Location location = dsgtdb.getLocation();
int keyLength = SystemTDB.SizeOfNodeId * indexName.length();
int valueLength = 0;
// The name is the order.
String primary = indexName;
String primaryOrder;
int dftKeyLength;
int dftValueLength;
int tupleLength = indexName.length();
TupleIndex index;
if (tupleLength == 3) {
primaryOrder = Names.primaryIndexTriples;
dftKeyLength = SystemTDB.LenIndexTripleRecord;
dftValueLength = 0;
// Find index.
index = findIndex(dsgtdb.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes(), indexName);
} else if (tupleLength == 4) {
primaryOrder = Names.primaryIndexQuads;
dftKeyLength = SystemTDB.LenIndexQuadRecord;
dftValueLength = 0;
index = findIndex(dsgtdb.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes(), indexName);
} else {
throw new TDBException("Index name: " + indexName);
}
TupleMap colMap = TupleMap.create(primaryOrder, indexName);
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);
BufferChannel blkState = FileFactory.createBufferChannel(destination, Names.extBptState);
BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.extBptTree, blockSizeNodes, readCacheSize, writeCacheSize);
BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.extBptRecords, blockSizeRecords, readCacheSize, writeCacheSize);
int rowBlock = 1000;
Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
// ProgressMonitor.
ProgressMonitor monitor = ProgressMonitorOutput.create(BulkLoaderX.LOG_Index, indexName, tickPoint, superTick);
ProgressIterator<Record> iter2 = new ProgressIterator<>(iter, monitor);
monitor.start();
BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter2, bptParams, recordFactory, blkState, blkMgrNodes, blkMgrRecords);
bpt2.close();
monitor.finish();
// [BULK] End stage.
long count = monitor.getTicks();
return count;
}
Aggregations