Package lupos.engine.operators.multiinput.optional

Examples of lupos.engine.operators.multiinput.optional.OptionalResult


  public OptionalResult joinBeforeEndOfStream() {
    if (!this.operands[0].isEmpty()) {
      if (!this.operands[1].isEmpty()) {
        return this.joinOptionalResult(this.operands[0].getQueryResult(), this.operands[1].getQueryResult());
      } else {
        final OptionalResult or = new OptionalResult();
        final QueryResult left = this.operands[0].getQueryResult();
        left.materialize();
        or.setJoinPartnerFromLeftOperand(left);
        or.setJoinResult(left);
      }
    }
    return null;
  }
View Full Code Here


    // smaller bag
    final NodeInPartitionTree rootLarger = this.buildPartitionsOfLargerBag(larger, rootSmaller, hashFunctions, 0);
    // II) Probing phase: now join the corresponding partitions of the
    // smaller with the larger bag...
    // Resources are released during probing...
    final OptionalResult or = new OptionalResult(new QueryResult(0), new QueryResult(0));
    this.probeOptional(rootSmaller, rootLarger, left.size() < right.size(), or);
    return or;
  }
View Full Code Here

  }

  @Override
  public OptionalResult processJoin(final QueryResult bindings,
      final int operandID) {
    final OptionalResult or = new OptionalResult();
    final QueryResult qr = QueryResult.createInstance();
    final QueryResult joinPartnerFromLeftOperand = QueryResult
        .createInstance();
    this.lba[operandID].addAll(bindings);

    for (final Bindings binding : bindings) {

      for (int i = 0; i < this.getNumberOfOperands(); i++) {
        if (this.lba[i].isEmpty()) {
          return or;
        }
      }
      // like qr.addAll(combineAndProcess(operandID, binding , 0,
      // QueryResult.createInstance())), but for determining the
      // joinPartnerFromLeftOperand
      if (operandID == 0) {
        final QueryResult bl = QueryResult.createInstance();
        bl.add(binding);
        final QueryResult qr2 = combineAndProcess(operandID, binding,
            1, bl);
        qr.addAll(qr2);
        if (qr2 != null && qr2.size() > 0)
          joinPartnerFromLeftOperand.add(binding);
      } else {
        final Iterator<Bindings> it = this.lba[0].iterator();
        while (it.hasNext()) {
          final Bindings b = it.next();
          final QueryResult bl = QueryResult.createInstance();
          bl.add(b);
          final QueryResult joinResult = combineAndProcess(operandID,
              binding, 1, bl);
          if (joinResult.size() > 0) {
            qr.addAll(joinResult);
            joinPartnerFromLeftOperand.add(b);
          }
        }
      }
    }
    or.setJoinPartnerFromLeftOperand(joinPartnerFromLeftOperand);
    or.setJoinResult(qr);
    return or;
  }
View Full Code Here

  @Override
  public synchronized OptionalResult processJoin(final QueryResult bindings,
      final int operandID) {
    // different from process:
    final OptionalResult or = new OptionalResult();
    // different from process:
    final QueryResult joinPartnerFromLeftOperand = this.createQueryResult();
    final QueryResult result = this.createQueryResult();
    int otherOperand = 1-operandID;
    final Iterator<Bindings> itbindings = bindings.oneTimeIterator();
    while (itbindings.hasNext()) {
      final Bindings binding = itbindings.next();
      String keyJoin = "";
      final Iterator<Variable> it = this.intersectionVariables.iterator();
      while (it.hasNext()) {
        final Literal literal = binding.get(it.next());
        if (literal == null) {
          boolean added = this.cartesianProduct[operandID].add(binding);
          if(added || !isDuplicateEliminationEnabled()){
            // build the cartesian product
            for (final Bindings b2 : this.cartesianProduct[otherOperand]) {
              if(joinBindings(result, binding.clone(), b2)){
                if (operandID == 1) {
                  joinPartnerFromLeftOperand.add(b2);
                } else {
                  joinPartnerFromLeftOperand.add(binding);
                }             
              }
            }
 
            for (final QueryResult qr : this.lba[otherOperand].values()) {
              for (final Bindings b2 : qr) {
                if(joinBindings(result, binding.clone(), b2)){
                  if (operandID == 1) {
                    joinPartnerFromLeftOperand.add(b2);
                  } else {
                    joinPartnerFromLeftOperand.add(binding);
                  }               
                }
              }
            }
          }

          keyJoin = null;
          break;
        }
        keyJoin += "|" + literal.getKey();
      }

      if (keyJoin == null)
        continue;
     
      QueryResult lb = this.lba[operandID].get(keyJoin);
      if (lb == null){
        lb = this.createQueryResult();
      }
      boolean added = lb.add(binding);
      if(added || !isDuplicateEliminationEnabled()){
        this.lba[operandID].put(keyJoin, lb);
 
        final QueryResult toJoin = this.lba[otherOperand].get(keyJoin);
        if (toJoin != null) {
 
          final Iterator<Bindings> itb = toJoin.iterator();
          while (itb.hasNext()) {
            final Bindings b2 = itb.next();
 
            // different from process:
            if (joinBindings(result, binding.clone(), b2)) {
              if (operandID == 1) {
                joinPartnerFromLeftOperand.add(b2);
              } else {
                joinPartnerFromLeftOperand.add(binding);
              }
            }
          }
        }
        // build cartesian product
        for (final Bindings b2 : this.cartesianProduct[otherOperand]) {
          if(joinBindings(result, binding.clone(), b2)){
            if (operandID == 1) {
              joinPartnerFromLeftOperand.add(b2);
            } else {
              joinPartnerFromLeftOperand.add(binding);
            }
          }
        }
      }
    }
    // different from process:
    or.setJoinPartnerFromLeftOperand(joinPartnerFromLeftOperand);
    // different from process:
    or.setJoinResult(result);
    // different from process:
    return or;
  }
View Full Code Here

  @Override
  public OptionalResult joinBeforeEndOfStream() {
    if (this.left != null && this.right != null) {
      this.comp.setVariables(this.intersectionVariables);
      final OptionalResult or = this.mergeJoinOptionalResult(this.left, this.right, this.comp);
      this.left.clear();
      this.right.clear();
      return or;
    } else {
      return null;
View Full Code Here

        || ssb2.size() == 0) {
      return null;
    }

    // different from mergeJoin:
    final OptionalResult or = new OptionalResult();
    final QueryResult joinPartnerFromLeftOperand = QueryResult
        .createInstance();

    final QueryResult result = QueryResult.createInstance();
    final Iterator<Bindings> ssb1it = ssb1.iterator();
    final Iterator<Bindings> ssb2it = ssb2.iterator();
    Bindings b1 = ssb1it.next();
    Bindings b2 = ssb2it.next();
    boolean processFurther = true;
    do {
      final int compare = comp.compare(b1, b2);
      if (compare == 0) {

        final Collection<Bindings> bindings1 = new CollectionImplementation<Bindings>(MergeJoin.MEMORYLIMIT);
        final Collection<Bindings> bindings2 = new CollectionImplementation<Bindings>(MergeJoin.MEMORYLIMIT);

        final Bindings bindings = b1;
        int left = 0;
        while (comp.compare(b1, bindings) == 0) {
          bindings1.add(b1);

          // different from mergeJoin:
          joinPartnerFromLeftOperand.add(b1);

          left++;
          if (!ssb1it.hasNext()) {
            processFurther = false;
            break;
          }
          b1 = ssb1it.next();
        }
        int right = 0;
        while (comp.compare(b2, bindings) == 0) {
          bindings2.add(b2);
          right++;
          if (!ssb2it.hasNext()) {
            processFurther = false;
            break;
          }
          b2 = ssb2it.next();
        }
        for (final Bindings zb1 : bindings1) {
          for (final Bindings zb2 : bindings2) {
            final Bindings bnew = zb1.clone();
            bnew.addAll(zb2);
            bnew.addAllTriples(zb2);
            bnew.addAllPresortingNumbers(zb2);
            result.add(bnew);
          }
        }
      } else if (compare < 0) {
        if (ssb1it.hasNext()) {
          b1 = ssb1it.next();
        } else {
          processFurther = false;
        }
      } else if (compare > 0) {
        if (ssb2it.hasNext()) {
          b2 = ssb2it.next();
        } else {
          processFurther = false;
        }
      }
    } while (processFurther == true);

    // different from mergeJoin:
    or.setJoinPartnerFromLeftOperand(joinPartnerFromLeftOperand);
    or.setJoinResult(result);
    return or;
  }
View Full Code Here

TOP

Related Classes of lupos.engine.operators.multiinput.optional.OptionalResult

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.