Package lupos.datastructures.queryresult

Examples of lupos.datastructures.queryresult.QueryResult


  @SuppressWarnings("unchecked")
  @Override
  public QueryResult process(final QueryResult bindings, final int operandID) {
    bindings.materialize();
    this.comp.setVariables(this.intersectionVariables);
    final QueryResult oldLeft = this.left;
    final QueryResult oldRight = this.right;
    if (operandID == 0) {
      if (this.left == null) {
        this.left = bindings;
      } else {
        this.left = QueryResult.createInstance(new MergeIterator<Bindings>(this.comp, this.left.iterator(), bindings.iterator()));
      }
    } else if (operandID == 1) {
      if (this.right == null) {
        this.right = bindings;
      } else {
        this.right = QueryResult.createInstance(new MergeIterator<Bindings>(this.comp, this.right.iterator(), bindings.iterator()));
      }
    } else {
      System.err.println("MergeJoin is a binary operator, but received the operand number "
              + operandID);
    }
    if (this.left != null && this.right != null) {
      this.left.materialize();
      this.right.materialize();

      final Iterator<Bindings> leftIterator = (operandID == 0 && oldLeft != null) ? new MinusIterator(
          bindings.iterator(), oldLeft.iterator())
          : this.left.iterator();
      final QueryResult rightLocal = (operandID == 1 && oldRight != null) ? QueryResult
          .createInstance(new MinusIterator(bindings.iterator(),
              oldRight.iterator()))
          : this.right;


      final ParallelIterator<Bindings> currentResult = (this.intersectionVariables
          .size() == 0) ? MergeJoin.cartesianProductIterator(
          leftIterator, rightLocal) : MergeJoin.mergeJoinIterator(
          leftIterator, rightLocal.iterator(), this.comp,
          this.intersectionVariables, this.bindingsFactory);
      if (currentResult != null && currentResult.hasNext()) {
        final QueryResult result = QueryResult
            .createInstance(new ParallelIterator<Bindings>() {

              int number = 0;

              @Override
View Full Code Here


  @Override
  public void consume(final Triple triple) {
    final Bindings b = this.process(triple, false);
    if (b != null) {
      // System.out.println(b+" result of "+tp[i]);
      final QueryResult ll = QueryResult.createInstance();
      ll.add(b);
      for (final OperatorIDTuple op : this.getSucceedingOperators()) {
        ((Operator) op.getOperator()).processAll(ll, op.getId());
      }
    }
  }
View Full Code Here

  @Override
  public void deleteTriple(final Triple triple) {
    final Bindings b = this.process(triple, false);
    if (b != null) {
      // System.out.println(b+" result of "+tp[i]);
      final QueryResult ll = QueryResult.createInstance();
      ll.add(b);
      for (final OperatorIDTuple op : this.getSucceedingOperators()) {
        ((Operator) op.getOperator()).deleteAll(ll, op.getId());
      }
    }
  }
View Full Code Here

  @Override
  public void consumeDebug(final Triple triple, final DebugStep debugstep) {
    final Bindings b = this.process(triple, false);
    if (b != null) {
      // System.out.println(b+" result of "+tp[i]);
      final QueryResult ll = QueryResult.createInstance();
      ll.add(b);
      for (final OperatorIDTuple op : this.getSucceedingOperators()) {
        debugstep.step(this, op.getOperator(), b);
        ((Operator) op.getOperator()).processAllDebug(ll, op.getId(),
            debugstep);
      }
View Full Code Here

  @Override
  public void deleteTripleDebug(final Triple triple, final DebugStep debugstep) {
    final Bindings b = this.process(triple, false);
    if (b != null) {
      // System.out.println(b+" result of "+tp[i]);
      final QueryResult ll = QueryResult.createInstance();
      ll.add(b);
      for (final OperatorIDTuple op : this.getSucceedingOperators()) {
        debugstep.stepDelete(this, op.getOperator(), b);
        ((Operator) op.getOperator()).deleteAllDebug(ll, op.getId(),
            debugstep);
      }
View Full Code Here

    return msg;
  }

  public void trigger(){
    if (this.firstTime) {
      final QueryResult ll = QueryResult.createInstance();
      if(this.addEmptyBindings) {
        ll.add(this.bindingsFactory.createInstance());
      }
      for (final OperatorIDTuple op : this.getSucceedingOperators()) {
        ((Operator) op.getOperator()).processAll(ll, op.getId());
      }
      this.firstTime = false;
View Full Code Here

          QueryResult.createInstance(this.left.iterator()), QueryResult
              .createInstance(this.right.iterator())) : MergeJoin
          .mergeJoinIterator(this.left.iterator(), this.right.iterator(), this.comp,
              this.intersectionVariables, this.bindingsFactory);
      if (currentResult != null && currentResult.hasNext()) {
        final QueryResult result = QueryResult
            .createInstance(new ParallelIterator<Bindings>() {

              int number = 0;

              @Override
              public void close() {
                currentResult.close();
              }

              @Override
              public boolean hasNext() {
                if (!currentResult.hasNext()) {
                  MergeJoin.this.realCardinality = this.number;
                  this.close();
                }
                return currentResult.hasNext();
              }

              @Override
              public Bindings next() {
                final Bindings b = currentResult.next();
                if (!currentResult.hasNext()) {
                  MergeJoin.this.realCardinality = this.number;
                  this.close();
                }
                if (b != null) {
                  this.number++;
                }
                return b;
              }

              @Override
              public void remove() {
                currentResult.remove();
              }

              @Override
              public void finalize() {
                this.close();
              }
            });

        if (this.succeedingOperators.size() > 1) {
          result.materialize();
        }
        for (final OperatorIDTuple opId : this.succeedingOperators) {
          opId.processAll(result);
        }
      } else {
View Full Code Here

    if ((ssb1it == null) || (ssb2it == null) || !ssb1it.hasNext()
        || !ssb2it.hasNext()) {
      return null;
    }

    final QueryResult result = QueryResult.createInstance();
    Bindings b1 = ssb1it.next();
    Bindings b2 = ssb2it.next();
    boolean processFurther = true;
    do {
      final int compare = comp.compare(b1, b2);
      // System.out.println("compare:"+compare+" b1:"+b1+" b2:"+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;
        do {
          bindings1.add(b1);
          left++;
          if (!ssb1it.hasNext()) {
            processFurther = false;
            break;
          }
          b1 = ssb1it.next();
        } while (comp.compare(b1, bindings) == 0);
        int right = 0;
        do {
          bindings2.add(b2);
          right++;
          if (!ssb2it.hasNext()) {
            processFurther = false;
            break;
          }
          b2 = ssb2it.next();
        } while (comp.compare(b2, bindings) == 0);
        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);
    if (result.size() > 0) {
      return result;
    } else {
      return null;
    }
  }
View Full Code Here

      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();
View Full Code Here

  public static ParallelIterator<Bindings> cartesianProductIterator(
      final QueryResult left, final QueryResult right) {
    if (left == null || right == null) {
      return null;
    }
    final QueryResult smaller;
    final QueryResult larger;
    // if (left.size() < right.size()) {
    // smaller = left;
    // larger = right;
    // } else {
    // smaller = right;
View Full Code Here

TOP

Related Classes of lupos.datastructures.queryresult.QueryResult

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.