org.apache.jena.sparql.engine.ExecutionContext.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中org.apache.jena.sparql.engine.ExecutionContext.<init>()方法的一些代码示例,展示了ExecutionContext.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext.<init>()方法的具体详情如下:
包路径:org.apache.jena.sparql.engine.ExecutionContext
类名称:ExecutionContext
方法名:<init>

ExecutionContext.<init>介绍

[英]Clone
[中]克隆

代码示例

代码示例来源:origin: apache/jena

/** 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) ;
}

代码示例来源:origin: apache/jena

/** 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) ;
}

代码示例来源:origin: rdfhdt/hdt-java

/** 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) ;
}

代码示例来源:origin: apache/jena

private QueryIterator specialcase(Node gn, Op subOp, QueryIterator input) {
  // This is a placeholder for code to specially handle explicitly named
  // default graph and union graph.
  if (Quad.isDefaultGraph(gn)) {
    ExecutionContext cxt2 = new ExecutionContext(execCxt, execCxt.getDataset().getDefaultGraph()) ;
    return execute(subOp, input, cxt2) ;
  }
  // Bad news -- if ( Lib.equals(gn, Quad.tripleInQuad) ) {}
  return null ;
}

代码示例来源:origin: apache/jena

@Override
protected QueryIterator createQueryIter(List<Binding> data) {
  QueryIterator qIter = new QueryIterPlainWrapper(data.iterator()) ;
  Context cxt = new Context() ;
  cxt.set(ARQ.spillToDiskThreshold, 2L);
  return new QueryIterDistinct(qIter, new ExecutionContext(cxt, null, null, null)) ;
}

代码示例来源:origin: apache/jena

public static NodeValue eval(Expr expr, Binding binding)
{
  Context context = ARQ.getContext().copy() ;
  context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ;
  FunctionEnv env = new ExecutionContext(context, null, null, null) ; 
  NodeValue r = expr.eval(binding, env) ;
  return r ;
}

代码示例来源:origin: apache/jena

@Override
protected QueryIterator createQueryIter(List<Binding> data) {
  QueryIterator qIter = new QueryIterPlainWrapper(data.iterator()) ;
  return new QueryIterDistinctMem(qIter, new ExecutionContext(new Context(), null, null, null)) ;
}

代码示例来源:origin: apache/jena

@Override
public QueryIterator eval(Op op, DatasetGraph dsg, Binding binding, Context context)
{
  if ( binding.vars().hasNext() )
    op = Substitute.substitute(op, binding) ;
  ExecutionContext execCxt = new ExecutionContext(context, dsg.getDefaultGraph(), dsg, QC.getFactory(context)) ;
  Evaluator eval = EvaluatorFactory.create(execCxt) ;
  Table table = Eval.eval(eval, op) ;
  QueryIterator qIter = table.iterator(execCxt) ;
  return QueryIteratorCheck.check(qIter, execCxt) ;
}

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-cache

/**
 * This is partly a repetition of private functions in QC
 * @param op
 * @param context
 * @return
 */
public static QueryIterator execute(Op op, Context context) {
  DatasetGraph dg = DatasetGraphFactory.create();
  OpExecutorFactory opExecutorFactory = QC.getFactory(context);
  ExecutionContext execCxt = new ExecutionContext(context, dg.getDefaultGraph(), dg, opExecutorFactory);
  QueryIterator qIter = QueryIterRoot.create(execCxt);
  OpExecutor opExecutor = opExecutorFactory.create(execCxt);
  QueryIterator result = opExecutor.executeOp(op, qIter);
  return result;
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

/**
 * This is partly a repetition of private functions in QC
 * @param op
 * @param context
 * @return
 */
public static QueryIterator execute(Op op, Context context) {
  DatasetGraph dg = DatasetGraphFactory.create();
  OpExecutorFactory opExecutorFactory = QC.getFactory(context);
  ExecutionContext execCxt = new ExecutionContext(context, dg.getDefaultGraph(), dg, opExecutorFactory);
  QueryIterator qIter = QueryIterRoot.create(execCxt);
  OpExecutor opExecutor = opExecutorFactory.create(execCxt);
  QueryIterator result = opExecutor.executeOp(op, qIter);
  return result;
}

代码示例来源:origin: apache/jena

@Override
public QueryIterator eval(Op op, DatasetGraph dsg, Binding input, Context context)
{
  ExecutionContext execCxt = new ExecutionContext(context, dsg.getDefaultGraph(), dsg, QC.getFactory(context)) ;
  QueryIterator qIter1 = 
    ( input.isEmpty() ) ? QueryIterRoot.create(execCxt) 
              : QueryIterRoot.create(input, execCxt);
  QueryIterator qIter = QC.execute(op, qIter1, execCxt) ;
  // Wrap with something to check for closed iterators.
  qIter = QueryIteratorCheck.check(qIter, execCxt) ;
  // Need call back.
  if ( context.isTrue(ARQ.enableExecutionTimeLogging) )
    qIter = QueryIteratorTiming.time(qIter) ;
  return qIter ;
}

代码示例来源:origin: apache/jena

private static List<Binding> eval(Graph graph, Node start, String pathStr, Node finish)
{
  Path path = SSE.parsePath(pathStr, pmap) ;
  QueryIterator qIter = PathLib.execTriplePath(BindingFactory.root(), start, path, finish, new ExecutionContext(ARQ.getContext(), graph, null, null)) ;
  return Iter.toList(qIter) ;
}

代码示例来源:origin: apache/jena

@Test 
public void testCloseClosesSourceIterator() {
  Context context = new Context() ;
  ExecutionContext ec = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
  QueryIterSort qis = new QueryIterSort(iterator, comparator, ec);
  qis.close();
  assertTrue("source iterator should have been closed", iterator.isClosed());
}

代码示例来源:origin: apache/jena

@Test 
public void testTopNCloseClosesSource() {
  long numItems = 3;
  boolean distinct = false;
  Context context = new Context() ;
  ExecutionContext ec = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
  QueryIterTopN tn = new QueryIterTopN(iterator, comparator, numItems, distinct, ec);
  tn.close();
  assertTrue(iterator.isClosed());
}

代码示例来源:origin: apache/jena

private NodeValue cast(String input$) {
    Expr input = ExprUtils.parse(input$) ;
    ARQ.getContext().set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ;
    FunctionEnv env = new ExecutionContext(ARQ.getContext(), null, null, null) ; 
    return input.eval(null, env) ;
  }
}

代码示例来源:origin: apache/jena

protected static QueryIterator buildIterator(Binding binding, Node graphNode, Op opExec, ExecutionContext outerCxt) {
  if ( !graphNode.isURI() && !graphNode.isBlank() )
    // e.g. variable bound to a literal or blank node.
    throw new ARQInternalErrorException("QueryIterGraphInner.buildIterator: Not a URI or blank node: "+graphNode) ;
  
  // We can't just use DatasetGraph.getGraph because it may 
  // "auto-create" graphs. Use the containsGraph function.
  boolean syntheticGraph = ( Quad.isDefaultGraph(graphNode) || Quad.isUnionGraph(graphNode) ) ;
  if ( ! syntheticGraph && ! outerCxt.getDataset().containsGraph(graphNode) )
    return null ;
  Graph g = outerCxt.getDataset().getGraph(graphNode) ;
  // And the contains was true??!!!!!!
  if ( g == null )
    return null ;
    //throw new ARQInternalErrorException(".containsGraph was true but .getGraph is null") ;
  
  ExecutionContext cxt2 = new ExecutionContext(outerCxt, g) ;
  QueryIterator subInput = QueryIterSingleton.create(binding, cxt2) ;
  return QC.execute(opExec, subInput, cxt2) ;
}

代码示例来源:origin: apache/jena

@Test 
public void testExhaustionClosesSourceIterator() {
  iterator.setCallback(() -> {});
  Context context = new Context() ;
  ExecutionContext ec = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
  QueryIterSort qis = new QueryIterSort(iterator, comparator, ec);
  while (qis.hasNext()) qis.next();
  assertTrue("source iterator should have been closed", iterator.isClosed());
}

代码示例来源:origin: apache/jena

public QueryIterator iterator()
{
  SDBRequest request = new SDBRequest(store, null) ;
  String tableName = desc.getTableName() ;
  
  SQLBridge b = store.getSQLBridgeFactory().create(request, sqlTable, vars) ;
  b.build() ;
  try {
    String sqlStr = store.getSQLGenerator().generateSQL(request, b.getSqlNode()) ;
    //System.out.println(sqlStr) ;
    ResultSetJDBC tableData = store.getConnection().execQuery(sqlStr) ;
    ExecutionContext execCxt = new ExecutionContext(new Context(), null, null, null) ;
    return b.assembleResults(tableData, BindingRoot.create(), execCxt) ;
  } catch (SQLException ex)
  { throw new SDBExceptionSQL(ex) ; }
}

代码示例来源:origin: apache/jena

@Test 
public void testCancelClosesSourceIterator() {
  Context context = new Context() ;
  ExecutionContext ec = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
  QueryIterSort qis = new QueryIterSort(iterator, comparator, ec);
  try {
    while (qis.hasNext()) qis.next();
    fail("query should have been cancelled by trigger");
  } catch (QueryCancelledException q) {
    assertTrue("source iterator should have been closed", iterator.isClosed());
  }
}

代码示例来源:origin: apache/jena

@Test 
public void testTopNExhaustionClosesSource() {
  iterator.setCallback(() -> {});
  long numItems = 3;
  boolean distinct = false;
  Context context = new Context() ;
  ExecutionContext ec = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
  QueryIterTopN tn = new QueryIterTopN(iterator, comparator, numItems, distinct, ec);
  while (tn.hasNext()) tn.next();
  assertTrue(iterator.isClosed());
}

相关文章