@Override public void visit(OpService opService) { opService.getSubOp().visit(this); push(new OpService(changeNode(opService.getService()), pop(), opService.getSilent())); }
@Override public void visit(OpService op) { // Visit the op itself but not the subOp. if ( opVisitor != null ) op.visit(opVisitor) ; } }
@Override public Op transform(OpService op, Op sub) { Node n = substitute(op.getService(), binding); return new OpService(n, sub, op.getSilent()); } }
@Override public boolean equalTo(Op other, NodeIsomorphismMap labelMap) { if ( ! (other instanceof OpService) ) return false ; OpService opService = (OpService)other ; if ( ! ( serviceNode.equals(opService.serviceNode) ) ) return false ; if ( opService.getSilent() != getSilent() ) return false ; return getSubOp().equalTo(opService.getSubOp(), labelMap) ; }
@Override public void visit(OpService opService) { // Hmm - if the subnode has been optimized, we may fail. Op op = opService.getSubOp() ; Element x = asElement(opService.getSubOp()) ; Element elt = new ElementService(opService.getService(), x, opService.getSilent()) ; currentGroup().addElement(elt) ; }
result = new OpService(x.getService(), replacement, x.getServiceElement(), x.getSilent()); } else if(subOp instanceof OpProject) { OpProject x = (OpProject)subOp;
@Override public Op1 copy(Op newOp) { return new OpService(serviceNode, newOp, silent) ; } @Override
@Override protected QueryIterator execute(OpService opService, QueryIterator input) { Node serviceNode = opService.getService(); String serviceUri = serviceNode.getURI(); logger.debug("Intercepted execution of:\n" + opService); Op subOp = opService.getSubOp();
.map(op -> ((OpService)op).getService()) .collect(Collectors.toSet()); Op serviceOp = new OpService(serviceNode, OpNull.create(), false);
/** * Substitute cache references either with the cached data or - * if that is not completely available - substitute with the original expression. * * @param op * @param tree * @return */ public static boolean isView(Op op) { boolean result = op instanceof OpService && isView(((OpService)op).getService()); return result; }
@Override protected QueryIterator nextStage(Binding outerBinding) { Op op = QC.substitute(opService, outerBinding) ; boolean silent = opService.getSilent() ; QueryIterator qIter ; try { qIter = Service.exec((OpService)op, getExecContext().getContext()) ; // This iterator is materialized already otherwise we may end up // not servicing the HTTP connection as needed. // In extremis, can cause a deadlock when SERVICE loops back to this server. // Add tracking. qIter = QueryIter.makeTracked(qIter, getExecContext()) ; } catch (RuntimeException ex) { if ( silent ) { Log.warn(this, "SERVICE <" + opService.getService().toString() + ">: " + ex.getMessage()) ; // Return the input return QueryIterSingleton.create(outerBinding, getExecContext()) ; } throw ex ; } // Need to put the outerBinding as parent to every binding of the service call. // There should be no variables in common because of the OpSubstitute.substitute QueryIterator qIter2 = new QueryIterCommonParent(qIter, outerBinding, getExecContext()) ; return qIter2 ; } }
@Override public int hashCode() { return serviceNode.hashCode() ^ getSubOp().hashCode() ; }
@Override public void visit(OpService opService) { // Hmm - if the subnode has been optimized, we may fail. Op op = opService.getSubOp() ; Element x = asElement(opService.getSubOp()) ; Element elt = new ElementService(opService.getService(), x, opService.getSilent()) ; currentGroup().addElement(elt) ; }
result = new OpService(x.getService(), replacement, x.getServiceElement(), x.getSilent()); } else if(subOp instanceof OpProject) { OpProject x = (OpProject)subOp;
/** * Wrap a node with a caching operation * * @param subOp * @param cacheRef The cache entry to create and where the result set will be stored * * @return */ public static Op createCachingOp(Op subOp, Node storageRef) { boolean silent = false; //Query subQuery = OpAsQuery.asQuery(subOp); //Element subElement = new ElementSubQuery(subQuery); //ElementService elt = new ElementService(storageRef, subElement, silent); OpService result = new OpService(storageRef, subOp, silent); return result; }
@Override protected QueryIterator execute(OpService opService, QueryIterator input) { Node serviceNode = opService.getService(); String serviceUri = serviceNode.getURI(); logger.debug("Intercepted execution of:\n" + opService); Op subOp = opService.getSubOp();
.map(op -> ((OpService)op).getService()) .collect(Collectors.toSet()); Op serviceOp = new OpService(serviceNode, OpNull.create(), false);
/** * Substitute cache references either with the cached data or - * if that is not completely available - substitute with the original expression. * * @param op * @param tree * @return */ public static boolean isView(Op op) { boolean result = op instanceof OpService && isView(((OpService)op).getService()); return result; }
@Override public void visit(OpService opService) { mergeVars(opService.getSubOp()) ; }
@Override public void visit(OpService opService) { start(opService, NoNL) ; if ( opService.getSilent() ) out.println("silent ") ; out.println(FmtUtils.stringForNode(opService.getService(), sContext)) ; opService.getSubOp().visit(this) ; finish(opService) ; }