Package lupos.engine.operators.index

Examples of lupos.engine.operators.index.Root


  @Override
  protected void replace(HashMap<Class<?>, HashSet<BasicOperator>> _startNodes) {
    /*
     * Get the root of the first SubgraphContainer
     */
    Root root = sg1.getRootOfSubgraph();
    try {
      /*
       * get the both BasicIndexScan's
       */
      BasicIndexScan bis1 = getIndexScan(sg1.getRootOfSubgraph());
      BasicIndexScan bis2 = getIndexScan(sg2.getRootOfSubgraph());
      if (bis1 == null | bis2==null) return;
     
      log .debug(String.format("Rule %s: Move %s into %s",this.ruleName,sg2,sg1));
     
      /*
       * Join both TriplePattern and store them in the first SubgraphContainer
       */
      Collection<TriplePattern> patterns = bis1.getTriplePattern();
      patterns.addAll(bis2.getTriplePattern());
      bis1.setTriplePatterns(patterns);
      /*
       * remove the 2nd SubgraphContainer
       */
      root.removeSucceedingOperator(sg2);
      sg2.removeFromOperatorGraph();
      Root r = bis1.getRoot();
      r.removeSucceedingOperator(sg2);
       
      //remove the second sg-container
      u2.removePrecedingOperator(sg2);
     
    } catch (Exception e) {
View Full Code Here


    for (BasicOperator ops : pred) {
      ops.removeSucceedingOperator(sg1);
      ops.removeSucceedingOperator(sg2);
    }

    Root root = sg1.getRootOfSubgraph();
    SubgraphContainer sgc;
    try {
      sgc = new SubgraphContainer(root, keySg1, subgraphExecutor);

      /*
       * connect subgraph preceding
       */
      for (BasicOperator p : pred) {
        p.addSucceedingOperator(sgc);
      }

      /*
       * connect sg2 root's precedings to sg1's root as succeding operator
       */
      for (OperatorIDTuple t : sg2.getRootOfSubgraph()
          .getSucceedingOperators()) {
        root.addSucceedingOperator(t);
      }

      /*
       * get the two results, remove them, and add the join
       */
      Result r1 = getResult(root);
      for (BasicOperator p : r1.getPrecedingOperators()) {
        p.removeSucceedingOperator(r1);
        // p.addSucceedingOperator(join);
      }
      Result r2 = getResult(root);
      for (BasicOperator p : r2.getPrecedingOperators()) {
        p.removeSucceedingOperator(r2);
        // p.addSucceedingOperator(join);
      }

      for (BasicOperator p : r1.getPrecedingOperators()) {
        p.addSucceedingOperator(join);
      }
      for (BasicOperator p : r2.getPrecedingOperators()) {
        p.addSucceedingOperator(join);
      }

      /*
       * succedings of the join will be the succedings of the subgraph
       * container
       */
      sgc.setSucceedingOperators(join.getSucceedingOperators());
      /*
       * the join in the subgraph container will return the result
       */
      join.setSucceedingOperator(new OperatorIDTuple(new Result(), 0));

      root.removeSucceedingOperator(sg1);
      root.removeSucceedingOperator(sg2);

     
     
    } catch (JSONException e) {
      e.printStackTrace();
View Full Code Here

   * @throws JSONException in case of any parse exceptions
   */
  public static Tuple<QueryResult, Set<Variable>> evaluateSubgraph(final String subgraphSerializedAsJSONString, final Dataset dataset, final IOperatorCreator operatorCreator) throws JSONException {
    final CollectResult collectResult = new CollectResult(true);
    final SubgraphContainerFormatter formatter = new SubgraphContainerFormatter(dataset, operatorCreator, collectResult);
    final Root root = formatter.deserialize(new JSONObject(subgraphSerializedAsJSONString));

    // some initializations
    root.deleteParents();
    root.setParents();
    root.detectCycles();
    root.sendMessage(new BoundVariablesMessage());

    Class<? extends Bindings> instanceClass = null;
    if (Bindings.instanceClass == BindingsArrayVarMinMax.class
        || Bindings.instanceClass == BindingsArrayPresortingNumbers.class) {
      // is BindingsArrayVarMinMax or BindingsArrayPresortingNumbers
      // necessary? Or is only BindingsArray sufficient?
      @SuppressWarnings("serial")
      final SimpleOperatorGraphVisitor sogv = new SimpleOperatorGraphVisitor() {
        public boolean found = false;

        @Override
        public Object visit(final BasicOperator basicOperator) {
          if (basicOperator instanceof FastSort) {
            this.found = true;
          }
          return null;
        }

        @Override
        public boolean equals(final Object o) {
          if (o instanceof Boolean) {
            return this.found == (Boolean) o;
          } else {
            return super.equals(o);
          }
        }
      };
      root.visit(sogv);
      if (sogv.equals(false)) {
        instanceClass = Bindings.instanceClass;
        Bindings.instanceClass = BindingsArray.class;
      }
    }

    final BindingsFactory bindingsFactory= BindingsFactory.createBindingsFactory(CommonCoreQueryEvaluator.getAllVariablesOfQuery(root));
    root.sendMessage(new BindingsFactoryMessage(bindingsFactory));

    // evaluate subgraph!
    root.sendMessage(new StartOfEvaluationMessage());
    root.startProcessing();
    root.sendMessage(new EndOfEvaluationMessage());

    if (instanceClass != null) {
      Bindings.instanceClass = instanceClass;
    }
    return new Tuple<QueryResult, Set<Variable>>(collectResult.getResult(), new HashSet<Variable>(LocalExecutor.getVariables(root)));
View Full Code Here

  private static Tuple<QueryResult, Set<Variable>> evaluateSubgraph(
      final String subgraphSerializedAsJSONString, final Dataset dataset,
      final IOperatorCreator operatorCreator, final ISubgraphExecutor<?> sgExecuter) throws JSONException {
    final CollectResult collectResult = new CollectResult(true);
    final SubgraphContainerFormatter formatter = new SubgraphContainerFormatter(dataset, operatorCreator, collectResult,sgExecuter);
    final Root root = formatter.deserialize(new JSONObject(subgraphSerializedAsJSONString));

    // some initializations
    root.deleteParents();
    root.setParents();
    root.detectCycles();
    root.sendMessage(new BoundVariablesMessage());


    Class<? extends Bindings> instanceClass = null;
    if (Bindings.instanceClass == BindingsArrayVarMinMax.class
        || Bindings.instanceClass == BindingsArrayPresortingNumbers.class) {
      // is BindingsArrayVarMinMax or BindingsArrayPresortingNumbers
      // necessary? Or is only BindingsArray sufficient?
      @SuppressWarnings("serial")
      final SimpleOperatorGraphVisitor sogv = new SimpleOperatorGraphVisitor() {
        public boolean found = false;

        @Override
        public Object visit(final BasicOperator basicOperator) {
          if (basicOperator instanceof FastSort) {
            this.found = true;
          }
          return null;
        }

        @Override
        public boolean equals(final Object o) {
          if (o instanceof Boolean) {
            return this.found == (Boolean) o;
          } else {
            return super.equals(o);
          }
        }
      };
      root.visit(sogv);
      if (sogv.equals(false)) {
        instanceClass = Bindings.instanceClass;
        Bindings.instanceClass = BindingsArray.class;
      }
    }


    root.physicalOptimization();
    root.deleteParents();
    root.setParents();
    root.detectCycles();
    //MoveFilter to SubgraphContainer rule
    final AfterPhysicalOptimizationDistributedRulePackage refie = new AfterPhysicalOptimizationDistributedRulePackage();
    refie.applyRules(root);

    // evaluate subgraph!
    final BindingsFactory bindingsFactory= BindingsFactory.createBindingsFactory(CommonCoreQueryEvaluator.getAllVariablesOfQuery(root));
    root.sendMessage(new BindingsFactoryMessage(bindingsFactory));

    root.sendMessage(new StartOfEvaluationMessage());
    root.startProcessing();
    root.sendMessage(new EndOfEvaluationMessage());

    if (instanceClass != null) {
      Bindings.instanceClass = instanceClass;
    }
    //Result is back ..
View Full Code Here

      if (n instanceof ASTExists || n instanceof ASTNotExists) {
        // TODO support also stream-based evaluators!
        if(this.indexScanCreator instanceof IndexScanCreator_BasicIndex){
          final IndexScanCreator_BasicIndex isc = (IndexScanCreator_BasicIndex) this.indexScanCreator;

          final Root collectionClone = (Root) isc.getRoot().clone();
          collectionClone.setSucceedingOperators(new LinkedList<OperatorIDTuple>());

          this.indexScanCreator = new IndexScanCreator_BasicIndex(collectionClone);

          final Result newResult = new Result();
          final OperatorConnection connection = new OperatorConnection(newResult);
          this.visit((ASTGroupConstraint) n.jjtGetChild(0), connection, graphConstraint);

          collectionClone.deleteParents();
          collectionClone.setParents();
          collectionClone.detectCycles();
          collectionClone.sendMessage(new BoundVariablesMessage());
          final CorrectOperatorgraphRulePackage recog = new CorrectOperatorgraphRulePackage();
          recog.applyRules(collectionClone);

          filter.getCollectionForExistNodes().put((SimpleNode) n, collectionClone);
View Full Code Here

    final BasicOperator oldRoot = evaluator.getRootNode();
    final Result oldResult = evaluator.getResultOperator();
    final Map<Variable, Integer> oldBindingsFactory = evaluator.getBindingsFactory().getPosVariables();

    final Root collectionClone = (Root) collection.deepClone();
    collectionClone.visit(new SimpleOperatorGraphVisitor() {
;
      @Override
      public Object visit(final BasicOperator basicOperator) {

        if (basicOperator instanceof BasicIndexScan) {
View Full Code Here

TOP

Related Classes of lupos.engine.operators.index.Root

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.