use of org.apache.jena.graph.Triple in project jena by apache.
the class TriplesToQuadsConstantGraphMapperTest method generateData.
protected void generateData(MapDriver<LongWritable, TripleWritable, LongWritable, QuadWritable> driver, int num) {
for (int i = 0; i < num; i++) {
Triple t = new Triple(NodeFactory.createURI("http://subjects/" + i), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger));
Quad q = new Quad(Quad.defaultGraphNodeGenerated, t);
driver.addInput(new LongWritable(i), new TripleWritable(t));
driver.addOutput(new LongWritable(i), new QuadWritable(q));
}
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class WhereProcessor method list.
/**
* Create a list node from a list of objects as per RDF Collections.
*
* http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#collections
*
* @param objs
* the list of objects for the list.
* @return the first blank node in the list.
*/
public Node list(Object... objs) {
Node retval = NodeFactory.createBlankNode();
Node lastObject = retval;
for (int i = 0; i < objs.length; i++) {
Node n = AbstractQueryBuilder.makeNode(objs[i], prefixHandler.getPrefixes());
addWhere(new TriplePath(new Triple(lastObject, RDF.first.asNode(), n)));
if (i + 1 < objs.length) {
Node nextObject = NodeFactory.createBlankNode();
addWhere(new TriplePath(new Triple(lastObject, RDF.rest.asNode(), nextObject)));
lastObject = nextObject;
} else {
addWhere(new TriplePath(new Triple(lastObject, RDF.rest.asNode(), RDF.nil.asNode())));
}
}
return retval;
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class AbstractRewriter method rewrite.
/**
* Rewrite a triple path.
* @param t The triple path to rewrite.
* @return the triple path after rewriting.
*/
protected final TriplePath rewrite(TriplePath t) {
if (t.getPath() == null) {
return new TriplePath(new Triple(changeNode(t.getSubject()), changeNode(t.getPredicate()), changeNode(t.getObject())));
} else {
PathRewriter transform = new PathRewriter(values);
t.getPath().visit(transform);
return new TriplePath(changeNode(t.getSubject()), transform.getResult(), changeNode(t.getObject()));
}
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class StageGeneratorAlt method execute.
@Override
public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt) {
// Test :: execCxt.getActiveGraph()
if (!(execCxt.getActiveGraph() instanceof GraphBase))
// not based on GraphBase (which most Graph implementations are).
return other.execute(pattern, input, execCxt);
System.err.println("MyStageGenerator.compile:: triple patterns = " + pattern.size());
// Stream the triple matches together, one triple matcher at a time.
QueryIterator qIter = input;
for (Triple triple : pattern.getList()) qIter = new QueryIterTriplePattern(qIter, triple, execCxt);
return qIter;
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class container method execEvaluatedConcrete.
// Ask directly.
private QueryIterator execEvaluatedConcrete(Binding binding, Node containerNode, Node predicate, Node member, ExecutionContext execCxt) {
QueryIterator input = QueryIterSingleton.create(binding, execCxt);
Graph graph = execCxt.getActiveGraph();
QueryIterator qIter = new QueryIterTriplePattern(input, new Triple(containerNode, predicate, member), execCxt);
return qIter;
}
Aggregations