Search in sources :

Example 1 with TupleIndex

use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.

the class DebugTDB method getIndex.

public static TupleIndex getIndex(String idxName, DatasetGraphTDB dsg) {
    System.out.println(idxName);
    TupleIndex[] indexes1 = dsg.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes();
    TupleIndex[] indexes2 = dsg.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes();
    TupleIndex idx = null;
    for (TupleIndex i : indexes1) {
        if (i.getName().equals(idxName))
            return i;
    }
    for (TupleIndex i : indexes2) {
        if (i.getName().equals(idxName))
            return i;
    }
    return null;
}
Also used : TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex)

Example 2 with TupleIndex

use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.

the class DebugTDB method dumpInternals.

public static void dumpInternals(DatasetGraphTDB dsg, boolean includeNamedGraphs) {
    dumpNodeTable("Nodes", dsg);
    TupleIndex[] indexes1 = dsg.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes();
    TupleIndex[] indexes2 = dsg.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes();
    for (TupleIndex idx : indexes1) {
        System.out.println(idx.getName());
        dumpIndex(idx);
    }
    if (!includeNamedGraphs)
        return;
    for (TupleIndex idx : indexes2) {
        System.out.println(idx.getName());
        dumpIndex(idx);
    }
}
Also used : TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex)

Example 3 with TupleIndex

use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.

the class ProcIndexCopy method exec.

// Ideas:
// Copy to buffer, sort, write in sequential clumps.
// Profile code for hotspots
// Maybe be worth opening the data file (the leaves) as a regular, 
// non-memory mapped file as we read it through once, in natural order,
// and it may be laid out in increasing block order on-disk, e.g. repacked
// and in increasing order with occassional oddities if SPO from the bulk loader.
public static void exec(String locationStr1, String indexName1, String locationStr2, String indexName2) {
    // Argument processing
    Location location1 = Location.create(locationStr1);
    Location location2 = Location.create(locationStr2);
    int keyLength = SystemTDB.SizeOfNodeId * indexName1.length();
    int valueLength = 0;
    // The name is the order.
    String primary = "SPO";
    String indexOrder = indexName2;
    String label = indexName1 + " => " + indexName2;
    TupleIndex index1 = Build.openTupleIndex(location1, indexName1, primary, indexName1, 10, 10, keyLength, valueLength);
    TupleIndex index2 = Build.openTupleIndex(location2, indexName2, primary, indexOrder, 10, 10, keyLength, valueLength);
    tupleIndexCopy(index1, index2, label);
    index1.close();
    index2.close();
}
Also used : TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) Location(org.apache.jena.tdb.base.file.Location)

Example 4 with TupleIndex

use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.

the class LoaderNodeTupleTable method copyIndex.

static void copyIndex(Iterator<Tuple<NodeId>> srcIter, TupleIndex[] destIndexes, String label, LoadMonitor monitor) {
    monitor.startIndex(label);
    long counter = 0;
    for (; srcIter.hasNext(); ) {
        counter++;
        Tuple<NodeId> tuple = srcIter.next();
        monitor.indexItem();
        for (TupleIndex destIdx : destIndexes) {
            if (destIdx != null)
                destIdx.add(tuple);
        }
    }
    monitor.finishIndex(label);
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex)

Example 5 with TupleIndex

use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.

the class BuilderSecondaryIndexesParallel method createSecondaryIndexes.

@Override
public void createSecondaryIndexes(TupleIndex primaryIndex, TupleIndex[] secondaryIndexes) {
    monitor.print("** Parallel index building");
    Timer timer = new Timer();
    timer.startTimer();
    int semaCount = 0;
    Semaphore sema = new Semaphore(0);
    for (TupleIndex index : secondaryIndexes) {
        if (index != null) {
            Runnable builder = setup(sema, primaryIndex, index, index.getMapping());
            new Thread(builder).start();
            semaCount++;
        }
    }
    try {
        sema.acquire(semaCount);
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
    long time = timer.readTimer();
    timer.endTimer();
    monitor.print("Time for parallel indexing: %.2fs\n", time / 1000.0);
}
Also used : Timer(org.apache.jena.atlas.lib.Timer) Semaphore(java.util.concurrent.Semaphore) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex)

Aggregations

TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)28 NodeId (org.apache.jena.tdb.store.NodeId)20 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)19 BaseTest (org.apache.jena.atlas.junit.BaseTest)18 Test (org.junit.Test)18 Location (org.apache.jena.tdb.base.file.Location)3 Timer (org.apache.jena.atlas.lib.Timer)2 RangeIndex (org.apache.jena.tdb.index.RangeIndex)2 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)2 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)2 Iterator (java.util.Iterator)1 Set (java.util.Set)1 Semaphore (java.util.concurrent.Semaphore)1 FileSet (org.apache.jena.tdb.base.file.FileSet)1 Record (org.apache.jena.tdb.base.record.Record)1 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)1 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)1 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)1 NodeTupleTable (org.apache.jena.tdb.store.nodetupletable.NodeTupleTable)1 NodeTupleTableConcrete (org.apache.jena.tdb.store.nodetupletable.NodeTupleTableConcrete)1