use of org.apache.jena.tdb2.TDBException in project jena by apache.
the class PatternMatchTDB2 method execute.
// The worker. Callers choose the NodeTupleTable.
// graphNode may be Node.ANY, meaning we should make triples unique.
// graphNode may be null, meaning default graph
private static QueryIterator execute(NodeTupleTable nodeTupleTable, Node graphNode, BasicPattern pattern, QueryIterator input, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
if (Quad.isUnionGraph(graphNode))
graphNode = Node.ANY;
if (Quad.isDefaultGraph(graphNode))
graphNode = null;
List<Triple> triples = pattern.getList();
boolean anyGraph = (graphNode == null ? false : (Node.ANY.equals(graphNode)));
int tupleLen = nodeTupleTable.getTupleTable().getTupleLen();
if (graphNode == null) {
if (3 != tupleLen)
throw new TDBException("SolverLib: Null graph node but tuples are of length " + tupleLen);
} else {
if (4 != tupleLen)
throw new TDBException("SolverLib: Graph node specified but tuples are of length " + tupleLen);
}
// Convert from a QueryIterator (Bindings of Var/Node) to BindingNodeId
NodeTable nodeTable = nodeTupleTable.getNodeTable();
Iterator<BindingNodeId> chain = Iter.map(input, SolverLibTDB.convFromBinding(nodeTable));
List<Abortable> killList = new ArrayList<>();
for (Triple triple : triples) {
Tuple<Node> patternTuple = null;
if (graphNode == null)
// 3-tuples
patternTuple = TupleFactory.create3(triple.getSubject(), triple.getPredicate(), triple.getObject());
else
// 4-tuples.
patternTuple = TupleFactory.create4(graphNode, triple.getSubject(), triple.getPredicate(), triple.getObject());
// Plain RDF, no RDF-star
// chain = solve(nodeTupleTable, tuple, anyGraph, chain, filter, execCxt)
// ;
// RDF-star SA
chain = matchQuadPattern(chain, graphNode, triple, nodeTupleTable, patternTuple, anyGraph, filter, execCxt);
chain = makeAbortable(chain, killList);
}
Iterator<Binding> iterBinding = SolverLibTDB.convertToNodes(chain, nodeTable);
// "killList" will be aborted on timeout.
return new QueryIterAbortable(iterBinding, killList, input, execCxt);
}
use of org.apache.jena.tdb2.TDBException in project jena by apache.
the class NodeIdFactory method create.
private static NodeId create(int v1, long v2) {
if (!BitsInt.isSet(v1, 32))
return createPtrLong(v1, v2);
int t = v1 >> 24;
NodeIdType type = NodeIdType.intToEnum(t);
if (type == NodeIdType.SPECIAL)
throw new TDBException(String.format("Attempt to create a special from a long: 0x%016", v2));
return createNew(type, 0, v2);
}
use of org.apache.jena.tdb2.TDBException in project jena by apache.
the class NodeIdFactory method create64.
// ---- Create from binary.
// 64 bit create
private static NodeId create64(long value2) {
if (!BitsLong.isSet(value2, 63))
return createPtr(value2);
// Inline.
long v2 = value2;
if (BitsLong.isSet(v2, 62)) {
// XSD_DOUBLE
v2 = DoubleNode62.removeType(v2);
return NodeId.createRaw(NodeIdType.XSD_DOUBLE, v2);
}
// 7 bits
int t = (int) BitsLong.unpack(v2, 56, 63);
v2 = BitsLong.clear(v2, 56, 64);
NodeIdType type = NodeIdType.intToEnum(t);
if (type == NodeIdType.SPECIAL)
throw new TDBException(String.format("Attempt to create a special from a long: 0x%016", v2));
return NodeId.createRaw(type, v2);
}
use of org.apache.jena.tdb2.TDBException in project jena by apache.
the class StoreParamsCodec method getStringArray.
private static String[] getStringArray(JsonObject json, String key) {
if (!json.hasKey(key))
throw new TDBException("StoreParamsCodec.getStringArray: no such key: " + key);
JsonArray a = json.get(key).getAsArray();
String[] x = new String[a.size()];
for (int i = 0; i < a.size(); i++) {
x[i] = a.get(i).getAsString().value();
}
return x;
}
use of org.apache.jena.tdb2.TDBException in project jena by apache.
the class NodeTableCache method testForConsistency.
private void testForConsistency() {
Iterator<Node> iter1 = Iter.toList(node2id_Cache.keys()).iterator();
for (; iter1.hasNext(); ) {
Node n = iter1.next();
NodeId nId = node2id_Cache.getIfPresent(n);
if (!id2node_Cache.containsKey(nId))
throw new TDBException("Inconsistent: " + n + " => " + nId);
if (notPresent.containsKey(n))
throw new TDBException("Inconsistent: " + n + " in notPresent cache (1)");
}
Iterator<NodeId> iter2 = Iter.toList(id2node_Cache.keys()).iterator();
for (; iter2.hasNext(); ) {
NodeId nId = iter2.next();
Node n = id2node_Cache.getIfPresent(nId);
if (!node2id_Cache.containsKey(n))
throw new TDBException("Inconsistent: " + nId + " => " + n);
if (notPresent.containsKey(n))
throw new TDBException("Inconsistent: " + n + " in notPresent cache (2)");
}
}
Aggregations