Package lupos.distributed.operator

Examples of lupos.distributed.operator.SubgraphContainer


        final Root rootNodeOfSubGraph = rootNodeOfOuterGraph
            .newInstance(rootNodeOfOuterGraph.dataset);
        /*
         * create subgraph
         */
        final SubgraphContainer container = new SubgraphContainer(
            rootNodeOfSubGraph, key, subgraphExecutor);
       
        /*
         * store new basic index scan instead of using it n-times, because same object used
         */
        BasicIndexScan indexScan = new QueryClientIndexScan(_indexScan.getRoot(),_indexScan.getTriplePattern());
       
        /*
         * store variables
         */
        final HashSet<Variable> variables = new HashSet<Variable>(
            _indexScan.getIntersectionVariables());
        container.setUnionVariables(variables);
        container.setIntersectionVariables(variables);

       
        // generate new connections...
        final Filter filter = this.getFilterFromIndexScan(indexScan);
        if (filter != null) {
          if (indexScan.getUnionVariables().containsAll(
              filter.getUsedVariables())) {
            Filter newFilter;
            try {
              newFilter = new Filter(filter.toString().substring(
                  0, filter.toString().length() - 2));
              indexScan
                  .setSucceedingOperator(new OperatorIDTuple(
                      newFilter, 0));
              newFilter
                  .setSucceedingOperator(new OperatorIDTuple(
                      new Result(), 0));
            } catch (final ParseException e) {
              e.printStackTrace();
            }

          } else {
            indexScan.setSucceedingOperator(new OperatorIDTuple(
                new Result(), 0));
          }
        } else {
          indexScan.setSucceedingOperator(new OperatorIDTuple(
              new Result(), 0));
        }

        // indexScan.setSucceedingOperator(new OperatorIDTuple(new
        // Result(),
        // 0));
       
        //connect indexScan in subgraph container
        rootNodeOfSubGraph.setSucceedingOperator(new OperatorIDTuple(
            indexScan, countingSubgraphs));
        rootNodeOfSubGraph.deleteParents();
        rootNodeOfSubGraph.setParents();

        // original connections set at new graph
        /*
         * create Operator for union of all subgraphs
         */
        OperatorIDTuple unionIDOperator = new OperatorIDTuple(union, countingSubgraphs++);
        container.setSucceedingOperator(unionIDOperator);
       
        /*
         * store this subgraph
         */
        subgraphs.add(container);
 
View Full Code Here


      // TODO: 1) for several keys: union of different SubgraphContainer!
      Object[] keys = distribution.getKeysForQuerying(indexScan
          .getTriplePattern().iterator().next());
      // TODO: 2) catch TriplePatternNotSupportedError and make union of
      // SubgraphContainer to all possible nodes...
      final SubgraphContainer container = new SubgraphContainer(
          rootNodeOfSubGraph, keys[0], subgraphExecutor);
      final HashSet<Variable> variables = new HashSet<Variable>(
          indexScan.getIntersectionVariables());

      container.setUnionVariables(variables);
      container.setIntersectionVariables(variables);

      // remember original connections and connect new graph with these
      // connections
      final Collection<BasicOperator> preds = indexScan
          .getPrecedingOperators();
      final List<OperatorIDTuple> succs = indexScan
          .getSucceedingOperators();

      for (final BasicOperator pred : preds) {
        pred.getOperatorIDTuple(indexScan).setOperator(container);
      }

      // generate new connections...

      final Filter filter = this.getFilterFromIndexScan(indexScan);

      if (filter != null) {
        if (indexScan.getUnionVariables().containsAll(
            filter.getUsedVariables())) {
          Filter newFilter;
          try {
            newFilter = new Filter(filter.toString().substring(0,
                filter.toString().length() - 2));
            indexScan.setSucceedingOperator(new OperatorIDTuple(
                newFilter, 0));
            newFilter.setSucceedingOperator(new OperatorIDTuple(
                new Result(), 0));
          } catch (final ParseException e) {
            e.printStackTrace();
          }

        } else {
          indexScan.setSucceedingOperator(new OperatorIDTuple(
              new Result(), 0));
        }
      } else {
        indexScan.setSucceedingOperator(new OperatorIDTuple(
            new Result(), 0));
      }

      // indexScan.setSucceedingOperator(new OperatorIDTuple(new Result(),
      // 0));
      rootNodeOfSubGraph.setSucceedingOperator(new OperatorIDTuple(
          indexScan, 0));

      rootNodeOfSubGraph.setParents();

      // original connections set at new graph
      container.setSucceedingOperators(succs);

      // iterate through the new predecessors of the successors of the
      // original index scan operators and set new SubgraphContainer
      for (final OperatorIDTuple succ : succs) {
        succ.getOperator().removePrecedingOperator(indexScan);
View Full Code Here

            continue;
          match = true;
          /*
           * store with better variable name
           */
          SubgraphContainer sg1 = (SubgraphContainer) prec;
          SubgraphContainer sg2 = (SubgraphContainer) prec2;

          // remove succedding UNION-operator for both subgraphs
          for (OperatorIDTuple eachSucc : prec
              .getSucceedingOperators()) {
            prec.removeSucceedingOperator(eachSucc);
            eachSucc.getOperator().removePrecedingOperator(prec);
          }
          for (OperatorIDTuple eachSucc : prec2
              .getSucceedingOperators()) {
            prec2.removeSucceedingOperator(eachSucc);
            eachSucc.getOperator().removePrecedingOperator(prec2);
          }

          // remove 2nd sg
          for (BasicOperator bo : sg2.getPrecedingOperators()) {
            bo.removeSucceedingOperator(sg2);
            sg2.removePrecedingOperator(bo);
          }

          /*
           * join with is to be included into the subgraph container
           */
          Join smallJoin = new Join();
          smallJoin.cloneFrom(join_new);

          // remove so that the for-loop will end!
          union1.removePrecedingOperator(prec);
          union2.removePrecedingOperator(prec2);

          /*
           * get the index scan in first subgraph
           */
          BasicIndexScan bis = getIndexScan(sg1.getRootOfSubgraph());
          if (bis == null)
            continue;
          /*
           * you have to clone this list, because if changing
           * something, the list is updated immediately, but we want
           * to access the removed items later!
           */
          List<OperatorIDTuple> _bisSucc = bis
              .getSucceedingOperators();
          List<OperatorIDTuple> bisSucc = new ArrayList<>(
              _bisSucc.size());
          for (OperatorIDTuple toClone : _bisSucc) {
            bisSucc.add(toClone);
          }

          /*
           * now add the 2nd subgraph container in the first subgraph
           * container
           */
          sg1.getRootOfSubgraph().addSucceedingOperator(sg2);

          /*
           * remove old connections of the 2nd subgraph (because it
           * should be included into the subgraph)
           */
          for (OperatorIDTuple op : bisSucc) {
            bis.removeSucceedingOperator(op);
            op.getOperator().removePrecedingOperator(bis);
          }
          /*
           * connect the basic index scan and the 2nd subgraph
           * container in the join-operator in the 1st subgraph
           * container
           */
          bis.addSucceedingOperator(smallJoin, 0);
          smallJoin.addPrecedingOperator(sg2);
          sg2.addSucceedingOperator(smallJoin, 1);
          smallJoin.addPrecedingOperator(bis);
          /*
           * now connect the join with the succeeding operators of the
           * old basic index scan (here we use the hack, to clone the
           * succeeding list of the index scan, because when we
           * removed the connection and added the join, the list would
           * have no content)
           */
          for (OperatorIDTuple op : bisSucc) {
            smallJoin.addSucceedingOperator(op);
            op.getOperator().addPrecedingOperator(smallJoin);
          }
          /*
           * now connect the UNION with the result of the 1st subgraph
           * container. In this UNION all partitions are to be
           * combined.
           */
          union_new.addPrecedingOperator(sg1);
          OperatorIDTuple unionIDOperator = new OperatorIDTuple(
              union_new, countingUnions++);
          sg1.addSucceedingOperator(unionIDOperator);

          /*
           * this is to be executed, if the 2nd subgraph is directly
           * added as succeeding of the root, because in this case,
           * the 2nd subgraph container has no preceding (i don't know
           * why this is done this way)
           */
          if (this.root != null) {
            this.root.removeSucceedingOperator(sg2);
          }

          /*
           * add the intersections variables of the 2nd sg to the
           * first one
           */
          Collection<Variable> sg1interSection = sg1
              .getIntersectionVariables();
          Collection<Variable> sg2interSection = sg2
              .getIntersectionVariables();
          if (sg1interSection == null)
            sg1interSection = new HashSet<>();
          if (sg2interSection != null)
            sg1interSection.addAll(sg2interSection);
          sg1.setIntersectionVariables(sg1interSection);
          /*
           * add the union variables of the 2nd sg to the first one
           */
          Collection<Variable> sg1union = sg1.getUnionVariables();
          Collection<Variable> sg2union = sg2.getUnionVariables();
          if (sg1union == null)
            sg1union = new HashSet<>();
          if (sg2union != null)
            sg1union.addAll(sg2union);
          sg1.setUnionVariables(sg1union);
View Full Code Here

      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));

View Full Code Here

TOP

Related Classes of lupos.distributed.operator.SubgraphContainer

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.