本文整理汇总了Java中org.apache.jena.sparql.algebra.Op类的典型用法代码示例。如果您正苦于以下问题:Java Op类的具体用法?Java Op怎么用?Java Op使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Op类属于org.apache.jena.sparql.algebra包,在下文中一共展示了Op类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: plainExecute
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
/** Execute without modification of the op - does <b>not</b> apply special graph name translations */
private static QueryIterator plainExecute(Op op, QueryIterator input, ExecutionContext execCxt)
{
// -- Execute
// Switch to a non-reordering executor
// The Op may be a sequence due to TransformFilterPlacement
// so we need to do a full execution step, not go straight to the SolverLib.
ExecutionContext ec2 = new ExecutionContext(execCxt) ;
ec2.setExecutor(plainFactory) ;
// Solve without going through this executor again.
// There would be issues of nested patterns but this is only a
// (filter (bgp...)) or (filter (quadpattern ...)) or sequences of these.
// so there are no nested patterns to reorder.
return QC.execute(op, input, ec2) ;
}
开发者ID:LinkedDataFragments,项目名称:Client.Java,代码行数:18,代码来源:OpExecutorLDF.java
示例2: buildSyntax
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
private QueryIterator buildSyntax(QueryIterator input, Node nodeVar, String pattern, ExecutionContext execCxt)
{
Var var2 = createNewVar() ;
// Triple patterns for ?x rdfs:label ?hiddenVar
ElementTriplesBlock elementBGP = new ElementTriplesBlock();
Triple t = new Triple(nodeVar, RDFS.label.asNode(), var2) ;
elementBGP.addTriple(t) ;
// Regular expression for regex(?hiddenVar, "pattern", "i")
Expr regex = new E_Regex(new ExprVar(var2.getName()), pattern, "i") ;
ElementGroup elementGroup = new ElementGroup() ;
elementGroup.addElement(elementBGP) ;
elementGroup.addElement(new ElementFilter(regex)) ;
// Compile it.
// The better design is to build the Op structure programmatically,
Op op = Algebra.compile(elementGroup) ;
op = Algebra.optimize(op, execCxt.getContext()) ;
return QC.execute(op, input, execCxt) ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:21,代码来源:labelSearch.java
示例3: main
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
public static void main(String []args)
{
String s = "SELECT DISTINCT ?s { ?s ?p ?o }";
// Parse
Query query = QueryFactory.create(s) ;
System.out.println(query) ;
// Generate algebra
Op op = Algebra.compile(query) ;
op = Algebra.optimize(op) ;
System.out.println(op) ;
// Execute it.
QueryIterator qIter = Algebra.exec(op, ExQuerySelect1.createModel()) ;
// Results
for ( ; qIter.hasNext() ; )
{
Binding b = qIter.nextBinding() ;
System.out.println(b) ;
}
qIter.close() ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:25,代码来源:AlgebraEx.java
示例4: parseQuery
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
private static String parseQuery(String s) {
String q = getQuery(s);
try {
Query query = QueryFactory.create(q);
Op op = Algebra.compile(query);
TripleCollector tc = new TripleCollector();
OpWalker.walk(op, tc);
Set<Triple> triples = tc.getTriples();
return _toGViz(triples, query.getPrefixMapping());
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
开发者ID:xgfd,项目名称:ASPG,代码行数:16,代码来源:viz.java
示例5: parseToOp
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
static List parseToOp(String q) {
try {
Query query = QueryFactory.create(q);
Op op = Algebra.compile(query);
// System.out.println(toComment(q));
return Arrays.asList(q, op);
} catch (Exception e) {
// System.out.println(toComment(q));
//e.printStackTrace();
return null;
}
}
开发者ID:xgfd,项目名称:ASPG,代码行数:14,代码来源:Usewod.java
示例6: convertToGremlinTraversal
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
GraphTraversal<Vertex, ?> convertToGremlinTraversal(final Query query) {
final Op op = Algebra.compile(query);
OpWalker.walk(op, this);
if (!query.isQueryResultStar()) {
final List<String> vars = query.getResultVars();
switch (vars.size()) {
case 0:
throw new IllegalStateException();
case 1:
if (query.isDistinct()) {
traversal = traversal.dedup(vars.get(0));
}
traversal = traversal.select(vars.get(0));
break;
case 2:
if (query.isDistinct()) {
traversal = traversal.dedup(vars.get(0), vars.get(1));
}
traversal = traversal.select(vars.get(0), vars.get(1));
break;
default:
final String[] all = new String[vars.size()];
vars.toArray(all);
if (query.isDistinct()) {
traversal = traversal.dedup(all);
}
final String[] others = Arrays.copyOfRange(all, 2, vars.size());
traversal = traversal.select(vars.get(0), vars.get(1), others);
break;
}
} else {
if (query.isDistinct()) {
traversal = traversal.dedup();
}
}
return traversal;
}
开发者ID:dkuppitz,项目名称:sparql-gremlin,代码行数:38,代码来源:SparqlToGremlinCompiler.java
示例7: main
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
public static void main(String...argv) {
JenaSystem.init();
Table table = new PFbyTable.Table() ;
add(table, ":s1", ":o1") ;
add(table, ":s1", ":o2") ;
add(table, ":s2", ":o1") ;
add(table, ":s2", ":o2") ;
add(table, ":s2", ":o3") ;
Dataset ds = DatasetFactory.create() ;
PropertyFunctionFactory pff = (uri)->new PFbyTable() ;
// rdf:rest is special to property functions!
String iri = "http://example/trans" ;
PFbyTable.addTable(NodeFactory.createURI(iri), table);
PropertyFunctionRegistry.get().put(iri, pff) ;
String x = StrUtils.strjoinNL
("PREFIX : <http://example/>"
,"PREFIX rdf: <"+RDF.getURI()+">"
,"PREFIX rdfs: <"+RDFS.getURI()+">"
//,"SELECT * { ?s ?p ?o . ?s rdfs:member :o1 . ?s rdf:rest :o1 }"
//,"SELECT * { ?s rdfs:member :o1 }"
,"SELECT * { { ?s :trans :o1 } UNION { :s2 :trans ?o } UNION { ?X :trans ?Y } }"
) ;
Query query = QueryFactory.create(x) ;
System.out.println(query);
Op op = Algebra.compile(query) ;
Op op1 = Algebra.optimize(op) ;
System.out.println(op1);
SSE.write(op1);
QueryExecution qExec = QueryExecutionFactory.create(query, ds) ;
QueryExecUtils.executeQuery(qExec);
}
开发者ID:afs,项目名称:jena-inf-engine,代码行数:38,代码来源:DevPF.java
示例8: eval
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public QueryIterator eval(Op op, DatasetGraph dsg, Binding initial, Context context)
{
// Extension point: access possible to all the parameters for execution.
// Be careful to deal with initial bindings.
Transform transform = new MyTransform() ;
op = Transformer.transform(transform, op) ;
return super.eval(op, dsg, initial, context) ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:10,代码来源:MyQueryEngine.java
示例9: modifyOp
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
protected Op modifyOp(Op op)
{
// Extension point: possible place to alter the algebra expression.
// Alternative to eval().
op = super.modifyOp(op) ;
// op = Algebra.toQuadForm(op) ;
return op ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:10,代码来源:MyQueryEngine.java
示例10: accept
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public boolean accept(Op op, DatasetGraph dataset, Context context) {
return false;
}
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:5,代码来源:MarkLogicQueryEngine.java
示例11: create
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public Plan create(Op op, DatasetGraph dataset, Binding inputBinding,
Context context) {
return null;
}
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:6,代码来源:MarkLogicQueryEngine.java
示例12: LinkedDataFragmentEngine
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
public LinkedDataFragmentEngine(Op op, DatasetGraph dataset, Binding input, Context context) {
super(op, dataset, input, context);
}
开发者ID:LinkedDataFragments,项目名称:Client.Java,代码行数:4,代码来源:LinkedDataFragmentEngine.java
示例13: accept
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public boolean accept(Op op, DatasetGraph dataset, Context context) {
// Refuse to accept algebra expressions directly.
return false;
}
开发者ID:LinkedDataFragments,项目名称:Client.Java,代码行数:6,代码来源:LinkedDataFragmentEngine.java
示例14: create
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public Plan create(Op op, DatasetGraph dataset, Binding inputBinding, Context context) {
// Should not be called because accept/Op is false
throw new ARQInternalErrorException("LDFQueryEngine: factory called directly with an algebra expression");
}
开发者ID:LinkedDataFragments,项目名称:Client.Java,代码行数:6,代码来源:LinkedDataFragmentEngine.java
示例15: main
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
public static void main (String[] argv)
{
String BASE = "http://example/" ;
BasicPattern bp = new BasicPattern() ;
Var var_x = Var.alloc("x") ;
Var var_z = Var.alloc("z") ;
// ---- Build expression
bp.add(new Triple(var_x, NodeFactory.createURI(BASE+"p"), var_z)) ;
Op op = new OpBGP(bp) ;
//Expr expr = ExprUtils.parse("?z < 2 ") ;
Expr expr = new E_LessThan(new ExprVar(var_z), NodeValue.makeNodeInteger(2)) ;
op = OpFilter.filter(expr, op) ;
// ---- Example setup
Model m = makeModel() ;
m.write(System.out, "TTL") ;
System.out.println("--------------") ;
System.out.print(op) ;
System.out.println("--------------") ;
// ---- Execute expression
QueryIterator qIter = Algebra.exec(op, m.getGraph()) ;
// -------- Either read the query iterator directly ...
if ( false )
{
for ( ; qIter.hasNext() ; )
{
Binding b = qIter.nextBinding() ;
Node n = b.get(var_x) ;
System.out.println(NodeFmtLib.displayStr(n)) ;
System.out.println(b) ;
}
qIter.close() ;
}
else
{
// -------- Or make ResultSet from it (but not both - reading an
// iterator consumes the current solution)
List<String> varNames = new ArrayList<String>() ;
varNames.add("x") ;
varNames.add("z") ;
ResultSet rs = new ResultSetStream(varNames, m, qIter);
ResultSetFormatter.out(rs) ;
qIter.close() ;
}
System.exit(0) ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:50,代码来源:AlgebraExec.java
示例16: exec
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public QueryIterator exec(QueryIterator input, PropFuncArg argSubject, Node predicate, PropFuncArg argObject, ExecutionContext execCxt)
{
// No real need to check the pattern arguments because
// the replacement triple pattern and regex will cope
// but we illustrate testing here.
Node nodeVar = argSubject.getArg() ;
String pattern = NodeUtils.stringLiteral(argObject.getArg()) ;
if ( pattern == null )
{
Log.warn(this, "Pattern must be a plain literal or xsd:string: "+argObject.getArg()) ;
return QueryIterNullIterator.create(execCxt) ;
}
if ( false )
// Old (ARQ 1) way - not recommended.
return buildSyntax(input, nodeVar, pattern, execCxt) ;
// Better
// Build a SPARQL algebra expression
Var var2 = createNewVar() ; // Hidden variable
BasicPattern bp = new BasicPattern() ;
Triple t = new Triple(nodeVar, RDFS.label.asNode(), var2) ;
bp.add(t) ;
OpBGP op = new OpBGP(bp) ;
Expr regex = new E_Regex(new ExprVar(var2.getName()), pattern, "i") ;
Op filter = OpFilter.filter(regex, op) ;
// ---- Evaluation
if ( true )
{
// Use the reference query engine
// Create a table for the input stream (so it uses working memory at this point,
// which is why this is not the preferred way).
// Then join to expression for this stage.
Table table = TableFactory.create(input) ;
Op op2 = OpJoin.create(OpTable.create(table), filter) ;
return Algebra.exec(op2, execCxt.getDataset()) ;
}
// Use the default, optimizing query engine.
return QC.execute(filter, input, execCxt) ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:47,代码来源:labelSearch.java
示例17: transform
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public Op transform(OpBGP opBGP) { return opBGP ; }
开发者ID:xcurator,项目名称:xcurator,代码行数:3,代码来源:MyQueryEngine.java
示例18: accept
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public boolean accept(Op op, DatasetGraph dataset, Context context)
{ // Refuse to accept algebra expressions directly.
return false ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:6,代码来源:MyQueryEngine.java
示例19: create
import org.apache.jena.sparql.algebra.Op; //导入依赖的package包/类
@Override
public Plan create(Op op, DatasetGraph dataset, Binding inputBinding, Context context)
{ // Shodul notbe called because acceept/Op is false
throw new ARQInternalErrorException("MyQueryEngine: factory calleddirectly with an algebra expression") ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:6,代码来源:MyQueryEngine.java
注:本文中的org.apache.jena.sparql.algebra.Op类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论