Package lupos.engine.operators.multiinput.join

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


    }
    // 2. Joins erstellen
    BasicOperator headOperator = null;
    final Iterator<BasicOperator> opIt = operands.iterator();
    if (operands.size() > 1) {
      Join bottomJoin = new IndexJoinWithDuplicateElimination();
      final BasicOperator op1 = opIt.next();
      for(final OperatorIDTuple opID: op1.getSucceedingOperators()){
        opID.getOperator().removePrecedingOperator(op1);
      }
      op1.getSucceedingOperators().clear();
      op1.addSucceedingOperator(new OperatorIDTuple(bottomJoin, 0));
      bottomJoin.addPrecedingOperator(op1);
      final BasicOperator op2 = opIt.next();
      for(final OperatorIDTuple opID: op2.getSucceedingOperators()){
        opID.getOperator().removePrecedingOperator(op2);
      }
      op2.getSucceedingOperators().clear();
      op2.addSucceedingOperator(new OperatorIDTuple(bottomJoin, 1));
      bottomJoin.addPrecedingOperator(op2);
      if(arg!=null){
        bottomJoin.setSucceedingOperator((OperatorIDTuple) arg);
        ((OperatorIDTuple) arg).getOperator().addPrecedingOperator(bottomJoin);
      }
      while (opIt.hasNext()) {
        final Join tempJoin = new IndexJoinWithDuplicateElimination();
        final BasicOperator operand = opIt.next();
        for(final OperatorIDTuple opID: operand.getSucceedingOperators()){
          opID.getOperator().removePrecedingOperator(operand);
        }
        operand.getSucceedingOperators().clear();
        operand.setSucceedingOperator(new OperatorIDTuple(tempJoin, 0));
        tempJoin.addPrecedingOperator(operand);
        for(final OperatorIDTuple opID: bottomJoin.getSucceedingOperators()){
          opID.getOperator().removePrecedingOperator(bottomJoin);
        }
        bottomJoin.getSucceedingOperators().clear();
        bottomJoin.setSucceedingOperator(new OperatorIDTuple(tempJoin, 1));
        tempJoin.addPrecedingOperator(bottomJoin);
        if(arg!=null){
          tempJoin.setSucceedingOperator((OperatorIDTuple) arg);
          ((OperatorIDTuple) arg).getOperator().addPrecedingOperator(tempJoin);
        }
        bottomJoin = tempJoin;
      }
      headOperator = bottomJoin;
View Full Code Here


public class RuleFactorOutUnionInJoin extends Rule {

  @Override
  protected void init() {
    final Union union = new Union();
    final Join join = new Join();

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

    subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(union, "union");
    subGraphMap.put(join, "join");
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 Union union = (Union) mso.get("union");
    final Join join = (Join) mso.get("join");
    final int id = union.getOperatorIDTuple(join).getId();
    final List<BasicOperator> unionOperands = union.getPrecedingOperators();
    union.setPrecedingOperator(join);
    union.setSucceedingOperators(join.getSucceedingOperators());
    for (final OperatorIDTuple oid : join.getSucceedingOperators()) {
      oid.getOperator().removePrecedingOperator(join);
      oid.getOperator().addPrecedingOperator(union);
    }
    final List<OperatorIDTuple> precedingOperatorsJoin = new LinkedList<OperatorIDTuple>();
    for (final BasicOperator bo : join.getPrecedingOperators()) {
      if (!(bo.equals(union))) {
        precedingOperatorsJoin.add(new OperatorIDTuple(bo, bo
            .getOperatorIDTuple(join).getId()));
      }
    }
    boolean firstTime = true;
    for (final BasicOperator toMove : unionOperands) {
      Join joinNew;
      if (firstTime) {
        // use existing join operator
        joinNew = join;
        joinNew.removePrecedingOperator(union);
        firstTime = false;
      } else {
        // clone join operator plus its other operands
        joinNew = new Join();
        added.add(joinNew);
        union.addPrecedingOperator(joinNew);

        for (final OperatorIDTuple oid : precedingOperatorsJoin) {
          final BasicOperator toClone = oid.getOperator();
          final BasicOperator clone = toClone.clone();
          added.add(clone);
          clone.setSucceedingOperator(new OperatorIDTuple(joinNew,
              oid.getId()));
          joinNew.addPrecedingOperator(clone);
          cloneFurther(clone, toClone, added);
        }

      }
      joinNew.setSucceedingOperator(new OperatorIDTuple(union, union
          .getPrecedingOperators().size() - 1));
      joinNew.addPrecedingOperator(toMove);

      final LinkedList<Variable> intersectionVariables = new LinkedList<Variable>();
      final LinkedList<Variable> unionVariables = new LinkedList<Variable>();
      intersectionVariables.addAll(joinNew.getPrecedingOperators().get(0)
          .getUnionVariables());
      for (final BasicOperator bo : joinNew.getPrecedingOperators()) {
        unionVariables.addAll(bo.getUnionVariables());
        intersectionVariables.retainAll(bo.getUnionVariables());
      }
      joinNew.setIntersectionVariables(intersectionVariables);
      joinNew.setUnionVariables(unionVariables);

      toMove.setSucceedingOperator(new OperatorIDTuple(joinNew, id));
    }
    if (deleted.size() > 0 || added.size() > 0)
      return new Tuple<Collection<BasicOperator>, Collection<BasicOperator>>(
View Full Code Here

public class RuleConstantPropagationOverJoin extends Rule {

  @Override
  protected void init() {
    final AddBinding add = new AddBinding(null, null);
    final Join join = new Join();

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

    subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(add, "add");
    subGraphMap.put(join, "join");
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 AddBinding add = (AddBinding) mso.get("add");
    final Join join = (Join) mso.get("join");
    boolean afterJoin = true;
    final List<BasicOperator> joinPrec = new LinkedList<BasicOperator>();
    joinPrec.addAll(join.getPrecedingOperators());
    for (final BasicOperator bo : joinPrec) {
      // check if Filter(Add.Var = Add.Constant) must be put to a join
      // operand in order to fulfill the join condition
      if (!bo.equals(add)
          && bo.getUnionVariables().contains(add.getVar())) {
        try {
          final Filter filter = new Filter("FILTER( "
              + add.getVar().toString() + " = "
              + add.getLiteral().toString() + " )");
          filter.setIntersectionVariables(bo.getUnionVariables());
          filter.setUnionVariables(bo.getUnionVariables());
          // we assume that
          filter.setSucceedingOperators(bo.getSucceedingOperators());
          bo.setSucceedingOperator(new OperatorIDTuple(filter, 0));
          join.removePrecedingOperator(bo);
          join.addPrecedingOperator(filter);
          filter.setPrecedingOperator(bo);
          afterJoin = false;
          added.add(filter);
        } catch (final ParseException e) {
          System.err.println(e);
          e.printStackTrace();
        }
      }
    }
    // remove add
    for (final BasicOperator bo : add.getPrecedingOperators()) {
      bo.removeSucceedingOperator(add);
      bo.addSucceedingOperators(add.getSucceedingOperators());
      join.addPrecedingOperator(bo);
    }
    join.removePrecedingOperator(add);
    join.getIntersectionVariables().remove(add.getVar());
    // must add be put after the join?
    if (afterJoin) {
      add.setSucceedingOperators(join.getSucceedingOperators());
      add.setPrecedingOperator(join);
      join.setSucceedingOperator(new OperatorIDTuple(add, 0));
      for (final OperatorIDTuple oid : add.getSucceedingOperators()) {
        oid.getOperator().removePrecedingOperator(join);
        oid.getOperator().addPrecedingOperator(add);
      }
    } else
View Full Code Here



  @Override
  protected BasicOperator generateJoin(final InnerNodePlan inp, final Root root, final BasicOperator left, final BasicOperator right, final Collection<Variable> sortCriterium, final Map<TriplePattern, Map<Variable, VarBucket>> selectivity){
    final Join join = new Join();
    join.setEstimatedCardinality(inp.getCardinality());

    // TODO check if necessary (or is it just necessary for RDF3X???)!

    if (!(inp.getLeft() instanceof InnerNodePlan && ((InnerNodePlan) inp.getLeft()).getJoinType() == JoinType.DEFAULT)
        && (inp.getRight() instanceof InnerNodePlan && ((InnerNodePlan) inp.getRight()).getJoinType() == JoinType.DEFAULT)
        || (inp.getLeft() instanceof LeafNodePlan && inp.getRight() instanceof InnerNodePlan)) {
      this.moveToLeft(inp.getRight().getTriplePatterns(), root);
    } else if (!(inp.getRight() instanceof InnerNodePlan && ((InnerNodePlan) inp.getRight()).getJoinType() == JoinType.DEFAULT)
        && (inp.getLeft() instanceof InnerNodePlan && ((InnerNodePlan) inp.getLeft()).getJoinType() == JoinType.DEFAULT)
        || (inp.getRight() instanceof LeafNodePlan && inp.getLeft() instanceof InnerNodePlan)) {
      this.moveToLeft(inp.getLeft().getTriplePatterns(), root);
    } else if (inp.getLeft().getCost() > inp.getRight().getCost()) {
      System.out
          .println("Card. of joins with estimated lower cost vs. est. higher cost:"
              + inp.getRight().getCardinality() + "<->" + inp.getLeft().getCardinality());
      System.out
          .println("Cost of joins with estimated lower cost vs. est. higher cost:"
              + inp.getRight().getCost() + "<->" + inp.getLeft().getCost());
      this.moveToLeft(inp.getRight().getTriplePatterns(), root);
    } else {
      System.out
          .println("Card. of joins with estimated lower cost vs. est. higher cost:"
              + inp.getLeft().getCardinality() + "<->" + inp.getRight().getCardinality());
      System.out
          .println("Cost of joins with estimated lower cost vs. est. higher cost:"
              + inp.getLeft().getCost() + "<->" + inp.getRight().getCost());
      this.moveToLeft(inp.getLeft().getTriplePatterns(), root);
    }

    join.setIntersectionVariables(inp.getJoinPartner());
    join.setUnionVariables(inp.getVariables());
    left.setSucceedingOperator(new OperatorIDTuple(join, 0));
    right.setSucceedingOperator(new OperatorIDTuple(join, 1));
    join.addPrecedingOperator(left);
    join.addPrecedingOperator(right);
    return join;
  }
View Full Code Here

  }

  @Override
  protected void init() {
    // Define left side of rule
    final Operator a = new Join();

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

    startNode = a;
View Full Code Here

    startNode = a;
  }

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

    if (join.getNumberOfOperands() > 2)
      return true;
    else
      return false;
  }
View Full Code Here

  protected Tuple<Collection<BasicOperator>, Collection<BasicOperator>> transformOperatorGraph(
      final Map<String, BasicOperator> mso,
      final BasicOperator rootOperator) {
    final Collection<BasicOperator> deleted = new LinkedList<BasicOperator>();
    final Collection<BasicOperator> added = new LinkedList<BasicOperator>();
    final Join join = (Join) mso.get("join");
    final List<BasicOperator> ctp = join.getPrecedingOperators();
    final BasicOperator finalJoin = getBinaryJoin(ctp, added);
    finalJoin.setSucceedingOperators(join.getSucceedingOperators());
    rootOperator.deleteParents();
    rootOperator.setParents();
    rootOperator.detectCycles();
    rootOperator.sendMessage(new BoundVariablesMessage());
    deleted.add(join);
View Full Code Here

    while (itp.hasNext()) {

      final BasicOperator first = itp.next();
      if (itp.hasNext()) {
        final Join newJoin = new Join();
        added.add(newJoin);
        first.setSucceedingOperator(new OperatorIDTuple(newJoin, 0));
        final BasicOperator second = itp.next();
        second.setSucceedingOperator(new OperatorIDTuple(newJoin, 1));
        final HashSet<Variable> hv = new HashSet<Variable>();
        hv.addAll(first.getUnionVariables());
        hv.addAll(second.getUnionVariables());
        newJoin.setUnionVariables(hv);
        remainingJoins.add(newJoin);
      } else {
        remainingJoins.add(first);
      }
    }

    while (remainingJoins.size() > 1) {
      // choose best combination
      final Collection<BasicOperator> co = getNextJoin(remainingJoins);
      final Iterator<BasicOperator> io = co.iterator();
      final BasicOperator first = io.next();
      final BasicOperator second = io.next();
      final Join join = new Join();
      added.add(join);

      join.setIntersectionVariables(new HashSet<Variable>());
      join.setUnionVariables(new HashSet<Variable>());
      join.getUnionVariables().addAll(first.getUnionVariables());
      join.getUnionVariables().addAll(second.getUnionVariables());
      first.setSucceedingOperator(new OperatorIDTuple(join, 0));
      second.setSucceedingOperator(new OperatorIDTuple(join, 1));
      remainingJoins.remove(first);
      remainingJoins.remove(second);
      remainingJoins.add(join);
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.