Package lupos.engine.operators.multiinput.join

Examples of lupos.engine.operators.multiinput.join.Join


              if (basicOperator.getPrecedingOperators().size() == 1
                  && !(basicOperator.getPrecedingOperators().get(0) instanceof SIPFilterOperator)
                      && basicOperator.getSucceedingOperators().size() == 1) {
                if (basicOperator.getSucceedingOperators().get(0)
                    .getOperator() instanceof Join) {
                  final Join join = (Join) basicOperator
                  .getSucceedingOperators().get(0)
                  .getOperator();
                  int min = -1;
                  int minIndex = -1;
                  int i = 0;
                  for (final BasicOperator bo : join
                      .getPrecedingOperators()) {
                    final TriplePattern tp = determineTriplePatterns(
                        join,
                        new LinkedList<TriplePattern>(),
                        new HashSet<BasicOperator>())
                        .get(0);
                    int current = 0;
                    for (final OperatorIDTuple oid : root
                        .getSucceedingOperators()) {
                      if (oid.getOperator() instanceof BasicIndexScan) {
                        if (((BasicIndexScan) oid.getOperator())
                            .getTriplePattern()
                            .contains(tp)) {
                          if (min == -1 || min > current) {
                            min = current;
                            minIndex = i;
                          }
                        }
                      }
                      current++;
                    }
                    i++;
                  }
                  final BasicOperator bo = join.getPrecedingOperators().get(minIndex);
                  if (bo != null
                      && bo instanceof FastSort
                      && bo.getPrecedingOperators().size() == 1
                      && !(bo.getPrecedingOperators().get(0) instanceof SIPFilterOperator)) {
                    if (!this.severalTimesQueryResults(bo,
                        new HashSet<BasicOperator>())) {
                      List<TriplePattern> tpsOfOthers = null;
                      for (final BasicOperator others : join
                          .getPrecedingOperators()) {
                        if (!others.equals(bo)) {
                          if (tpsOfOthers == null) {
                            tpsOfOthers = determineTriplePatterns(
                                others,
                                new LinkedList<TriplePattern>(),
                                new HashSet<BasicOperator>());
                          } else {
                            tpsOfOthers
                            .addAll(determineTriplePatterns(
                                others,
                                new LinkedList<TriplePattern>(),
                                new HashSet<BasicOperator>()));
                          }
                        }
                      }
                      this.tpsOfSucceedingJoins(join, tpsOfOthers);
                      final SIPFilterOperator sip_op =
                        // (replacements
                        // .get(Join.class) ==
                        // HashMapIndexJoin.class) ?
                        new SIPFilterOperatorIterator(
                            tpsOfOthers,
                            join.getIntersectionVariables())
                      // : new
                      // SIPFilterOperator(tpsOfOthers,join
                      // .getIntersectionVariables())
                      ;
                      final List<Variable> intersectionVariables = new LinkedList<Variable>();
                      final List<Variable> unionVariables = new LinkedList<Variable>();
                      intersectionVariables.addAll(bo.getIntersectionVariables());
                      unionVariables.addAll(bo.getUnionVariables());
                      sip_op.setIntersectionVariables(intersectionVariables);
                      sip_op.setUnionVariables(unionVariables);
                      if (bo instanceof FastSort) {
                        final BasicOperator bo2 = bo
                        .getPrecedingOperators()
                        .get(0);
                        sip_op.addSucceedingOperators(bo2
                            .getSucceedingOperators());
                        sip_op.setPrecedingOperator(bo2);
                        bo2
                        .setSucceedingOperator(new OperatorIDTuple(
                            sip_op, 0));
                        bo.removePrecedingOperator(bo2);
                        bo.addPrecedingOperator(sip_op);
                      } else {
                        sip_op.addSucceedingOperators(bo.getSucceedingOperators());
                        sip_op.setPrecedingOperator(bo);
                        bo.setSucceedingOperator(new OperatorIDTuple(sip_op, 0));
                        join.removePrecedingOperator(bo);
                        join.addPrecedingOperator(sip_op);
                      }
                    }
                  }
                }
              }
View Full Code Here


      group.addSucceedingOperator(federatedQuery);
      sso.addSucceedingOperator(sort);
    } else {
      sso.addSucceedingOperator(federatedQuery);
    }
    Join join = new Join();
    federatedQuery.addSucceedingOperator(join, 1);
    sso.addSucceedingOperator(join, 0);
    connection.connect(join);
    connection.setOperatorConnection(sso);
  }
View Full Code Here

 
  @Override
  public void insertFederatedQueryOperator(final ASTService node, final OperatorConnection connection){
    Node child0 = node.jjtGetChild(0);
    if (child0 instanceof ASTVar) {
      Join join = new Join();
      connection.connect(join);
      SeveralSucceedingOperators sso = new SeveralSucceedingOperators();
      sso.addSucceedingOperator(join, 0);
      FederatedQueryTrivialApproach federatedQuery = new FederatedQueryTrivialApproach(node);
      Projection projection = new Projection();
View Full Code Here

    if (union1.getPrecedingOperators().size() != union2
        .getPrecedingOperators().size())
      return;

    // add new operators...
    Join join_new = new lupos.engine.operators.multiinput.join.Join();
    join_new.setIntersectionVariables(join1.getIntersectionVariables());
    join_new.setUnionVariables(union1.getUnionVariables());

    Union union_new = new lupos.engine.operators.multiinput.Union();
    union_new.setIntersectionVariables(union1.getIntersectionVariables());
    union_new.setUnionVariables(union1.getUnionVariables());

    int countingUnions = 0;
    firstLoop: for (;;) {
      // for each 1st sg container
      for (BasicOperator prec : union1.getPrecedingOperators()) {
        boolean match = false;
        // find the matching second one
        for (BasicOperator prec2 : union2.getPrecedingOperators()) {
          if (!compareBothSubgraphContainer((SubgraphContainer) prec,
              (SubgraphContainer) prec2))
            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
View Full Code Here

    BLOCKWISE = blockwise;
  }

  @Override
  protected void init() {
    final Operator a = new Join();

    subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(a, "join");

    startNode = a;
View Full Code Here

public class RuleReplaceLitOverJoin extends Rule {

  @Override
  protected void init() {
    final ReplaceLit replaceLit = new ReplaceLit();
    final Join join = new Join();

    replaceLit.setSucceedingOperator(new OperatorIDTuple(join, -1));
    join.setPrecedingOperator(replaceLit);

    subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(replaceLit, "replaceLit");
    subGraphMap.put(join, "join");
View Full Code Here

    startNode = replaceLit;
  }

  @Override
  protected boolean checkPrecondition(final Map<String, BasicOperator> mso) {
    final Join join = (Join) mso.get("join");
    final ReplaceLit replaceLit = (ReplaceLit) mso.get("replaceLit");

    // final Object[] joinVars = join.getIntersectionVariables().toArray();
    final Object[] joinVars = join.getUnionVariables().toArray();
    final LinkedList<Variable> v = replaceLit.getSubstitutionsLiteralLeft();

    // If there is minimum one substitution which can be pulled down
    for (int i = 0; i < v.size(); i++) {
      // Otherwise join could trigger after transformation
View Full Code Here

      final Map<String, BasicOperator> mso,
      final BasicOperator rootOperator) {
    final Collection<BasicOperator> deleted = new LinkedList<BasicOperator>();
    final Collection<BasicOperator> added = new LinkedList<BasicOperator>();
    final ReplaceLit replaceLit = (ReplaceLit) mso.get("replaceLit");
    final Join join = (Join) mso.get("join");

    final ReplaceLit replaceLitUnder = new ReplaceLit();
    final Collection<Variable> vars = new HashSet<Variable>();
    vars.addAll(join.getIntersectionVariables());
    replaceLitUnder.setIntersectionVariables(vars);
    replaceLitUnder.setUnionVariables(vars);

    final Object[] joinVars = join.getIntersectionVariables().toArray();
    final LinkedList<Variable> replaceLitLeft = replaceLit
        .getSubstitutionsLiteralLeft();
    final LinkedList<Literal> replaceLitRight = replaceLit
        .getSubstitutionsLiteralRight();
    Variable var;
    Literal lit;
    for (int i = replaceLitLeft.size() - 1; i >= 0; i--) {
      var = replaceLitLeft.get(i);
      // Split ReplaceLit and pull only not intersection variables
      // downwards
      if (!arrayContains(joinVars, var)) {
        lit = replaceLitRight.get(i);
        replaceLitUnder.addSubstitution(var, lit);
        replaceLit.removeSubstitutionVars(i);
        replaceLitUnder.getIntersectionVariables().add(var); // var is
        // also
        // added
        // to
        // unionVariables
        // as
        // they
        // are
        // the
        // same
        // objects
        // !
      }
    }

    final LinkedList<BasicOperator> pres = (LinkedList<BasicOperator>) replaceLit
        .getPrecedingOperators();
    final LinkedList<OperatorIDTuple> succs = (LinkedList<OperatorIDTuple>) join
        .getSucceedingOperators();
    final int index = replaceLit.getOperatorIDTuple(join).getId();

    // If everything could be pushed downwards, the old ReplaceLit can be
    // deleted
    if (replaceLit.getSubstitutionsLiteralLeft().size() == 0) {
      BasicOperator pre;
      for (int i = 0; i < pres.size(); i++) {
        pre = pres.get(i);
        pre.addSucceedingOperator(new OperatorIDTuple(join, index));
        pre.removeSucceedingOperator(replaceLit);
        join.addPrecedingOperator(pre);
      }
      join.removePrecedingOperator(replaceLit);
      deleted.add(replaceLit);
    }

    // Insert the new ReplaceLit under the Join
    // (only if there is not already an equivalent ReplaceLit!)
    if (!((join.getSucceedingOperators().size() == 1)
        && (join.getSucceedingOperators().get(0).getOperator() instanceof ReplaceLit) && (replaceLitUnder
        .equals(join.getSucceedingOperators().get(0).getOperator())))) {
      join.setSucceedingOperator(new OperatorIDTuple(replaceLitUnder, 0));

      replaceLitUnder.setPrecedingOperator(join);
      replaceLitUnder.setSucceedingOperators(succs);
      added.add(replaceLitUnder);
    }
View Full Code Here

public class RuleReplaceVarUnderJoin extends Rule {

  @Override
  protected void init() {
    final Join join = new Join();
    final ReplaceVar replaceVar = new ReplaceVar();

    join.setSucceedingOperator(new OperatorIDTuple(replaceVar, 0));
    replaceVar.setPrecedingOperator(join);

    subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(join, "join");
    subGraphMap.put(replaceVar, "replaceVar");
View Full Code Here

    startNode = join;
  }

  @Override
  protected boolean checkPrecondition(final Map<String, BasicOperator> mso) {
    final Join join = (Join) mso.get("join");
    final ReplaceVar replaceVar = (ReplaceVar) mso.get("replaceVar");

    final LinkedList<Variable> replaceRightVars = replaceVar
        .getSubstitutionsVariableRight();
    final Object[] joinVars = join.getIntersectionVariables().toArray();
    // Only interesting if minimum one right ReduceEnv-Variable is not join
    // partner
    for (int i = 0; i < replaceRightVars.size(); i++) {
      if (!arrayContains(joinVars, replaceRightVars.get(i))) {
        // Because of complexity transform only joins which have only
        // the ReplaceVar as successor
        if (join.getSucceedingOperators().size() == 1) {
          return true;
        }
      }
    }
    return false;
View Full Code Here

TOP

Related Classes of lupos.engine.operators.multiinput.join.Join

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.