Search in sources :

Example 1 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class TupleIndex method scan.

public static Iterator<Tuple<NodeId>> scan(Iterator<Tuple<NodeId>> iter, Tuple<NodeId> pattern) {
    int tupleLength = pattern.len();
    Predicate<Tuple<NodeId>> filter = new Predicate<Tuple<NodeId>>() {

        @Override
        public boolean test(Tuple<NodeId> item) {
            // Check on pattern and item (both in natural order)
            for (int i = 0; i < tupleLength; i++) {
                NodeId n = pattern.get(i);
                // The pattern must be null/Any or match the tuple being tested.
                if (!NodeId.isAny(n))
                    if (!item.get(i).equals(n))
                        return false;
            }
            return true;
        }
    };
    return Iter.filter(iter, filter);
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) Predicate(java.util.function.Predicate)

Example 2 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class TupleTable method find.

/** Find all matching tuples - a slot of NodeId.NodeIdAny (or null) means match any */
public Iterator<Tuple<NodeId>> find(Tuple<NodeId> pattern) {
    if (tupleLen != pattern.len())
        throw new TDBException(format("Mismatch: finding tuple of length %d in a table of tuples of length %d", pattern.len(), tupleLen));
    int numSlots = 0;
    // Canonical form. 
    for (int i = 0; i < tupleLen; i++) {
        NodeId x = pattern.get(i);
        if (!NodeId.isAny(x))
            numSlots++;
    }
    if (numSlots == 0)
        return scanAllIndex.all();
    int indexNumSlots = 0;
    TupleIndex index = null;
    for (TupleIndex idx : indexes) {
        if (idx != null) {
            int w = idx.weight(pattern);
            if (w > indexNumSlots) {
                indexNumSlots = w;
                index = idx;
            }
        }
    }
    if (index == null)
        // No index at all.  Scan.
        index = indexes[0];
    return index.find(pattern);
}
Also used : TDBException(org.apache.jena.tdb.TDBException) NodeId(org.apache.jena.tdb.store.NodeId)

Example 3 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class NodeTableTrans method allocate.

private NodeId allocate(Node node) {
    NodeId nodeId = nodeTableJournal.getAllocateNodeId(node);
    nodeId = mapFromJournal(nodeId);
    return nodeId;
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId)

Example 4 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class DebugTDB method lookup.

public static NodeId lookup(DatasetGraphTDB dsg, Node n) {
    NodeTable nt = dsg.getTripleTable().getNodeTupleTable().getNodeTable();
    NodeId nid = nt.getNodeIdForNode(n);
    return nid;
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Example 5 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class NodeTableTrans method allocOffset.

@Override
public NodeId allocOffset() {
    if (passthrough)
        return base.allocOffset();
    // If we have done the append stage, this is invalid as the base may change under our feet
    // Would need to track base operations.
    NodeId x1 = nodeTableJournal.allocOffset();
    NodeId x2 = mapFromJournal(x1);
    return x2;
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId)

Aggregations

NodeId (org.apache.jena.tdb.store.NodeId)76 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)29 BaseTest (org.apache.jena.atlas.junit.BaseTest)28 Test (org.junit.Test)28 TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)20 Node (org.apache.jena.graph.Node)18 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)10 Pair (org.apache.jena.atlas.lib.Pair)5 Var (org.apache.jena.sparql.core.Var)5 TDBException (org.apache.jena.tdb.TDBException)5 Record (org.apache.jena.tdb.base.record.Record)5 StatsCollectorNodeId (org.apache.jena.tdb.solver.stats.StatsCollectorNodeId)5 NodeTableTrans (org.apache.jena.tdb.transaction.NodeTableTrans)5 Transaction (org.apache.jena.tdb.transaction.Transaction)5 Predicate (java.util.function.Predicate)2 Location (org.apache.jena.tdb.base.file.Location)2 RangeIndex (org.apache.jena.tdb.index.RangeIndex)2 StatsResults (org.apache.jena.tdb.solver.stats.StatsResults)2 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)2 Hash (org.apache.jena.tdb.store.Hash)2