Package lupos.datastructures.queryresult

Examples of lupos.datastructures.queryresult.QueryResult


  private OptionalResult joinOptionalResult(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;
      larger = left;
    }
    // I) building phase
    // Ia) now build partitions of the smaller bag
    final LinkedList<HashFunction> hashFunctions = new LinkedList<HashFunction>();
    final NodeInPartitionTree rootSmaller = this.buildPartitionsOfSmallerBag(smaller, hashFunctions, 0);
    // Ib) now build partitions of the larger bag in the same way as the
    // 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 Message preProcessMessageDebug(final EndOfEvaluationMessage msg,
      final DebugStep debugstep) {
    if (!this.operands[0].isEmpty() && !this.operands[1].isEmpty()) {
      final QueryResult qr = this.join(this.operands[0].getQueryResult(), this.operands[1].getQueryResult());
      if (qr != null) {
        this.realCardinality = qr.size();
        for (final OperatorIDTuple opId : this.succeedingOperators) {
          final QueryResultDebug qrDebug = new QueryResultDebug(qr, debugstep, this, opId.getOperator(), true);
          ((Operator) opId.getOperator()).processAllDebug(qrDebug, opId.getId(), debugstep);
        }
      }
View Full Code Here

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

              int number = 0;

              @Override
View Full Code Here

    init();
  }

  @Override
  public QueryResult process(final QueryResult bindings, final int operandID) {
    final QueryResult qr = QueryResult.createInstance();
    final Iterator<Bindings> itb = bindings.oneTimeIterator();
    while (itb.hasNext())
      this.lba[operandID].add(itb.next());

    for (final Bindings binding : bindings) {

      for (int i = 0; i < this.getNumberOfOperands(); i++) {
        if (this.lba[i].isEmpty()) {
          return null;
        }
      }
      qr.addAll(combineAndProcess(operandID, binding, 0, QueryResult
          .createInstance()));
    }
    if (qr.size() > 0)
      return qr;
    else
      return null;
  }
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);
          }
        }
      }
View Full Code Here

   *
   * @param Dataset
   */
  @Override
  public QueryResult process(final Dataset dataset) {
    final QueryResult queryResult = QueryResult.createInstance();
    if(this.rdfGraph!=null && this.rdfGraph.isVariable()){
      final Variable graphConstraint = (Variable) this.rdfGraph;
      if (this.root.namedGraphs != null && this.root.namedGraphs.size() > 0) {
        // Convert the named graphs' names into URILiterals
        // to be applicable later on
        for (final String name : this.root.namedGraphs) {
          final Bindings graphConstraintBindings = this.bindingsFactory.createInstance();
          try {
            graphConstraintBindings.add(graphConstraint, LiteralFactory.createURILiteralWithoutLazyLiteral(name));
          } catch (final URISyntaxException e) {
            System.err.println(e);
            e.printStackTrace();
          }
          queryResult.add(graphConstraintBindings);
        }
        } else {
          final Collection<Indices> dataSetIndices = dataset.getNamedGraphIndices();
          if (dataSetIndices != null) {
            for (final Indices indices : dataSetIndices) {
              final Bindings graphConstraintBindings = this.bindingsFactory.createInstance();
              graphConstraintBindings.add(graphConstraint, indices.getRdfName());
              queryResult.add(graphConstraintBindings);
            }
          }
        }
    } else {
      queryResult.add(this.bindingsFactory.createInstance());
    }

    return queryResult;
  }
View Full Code Here

  }

  private QueryResult combineAndProcess(final int pos,
      final Bindings binding, final int currentPos,
      final QueryResult bindings) {
    final QueryResult qr = QueryResult.createInstance();
    if (pos == currentPos) {
      bindings.add(binding);
      qr
          .addAll(combineAndProcess(pos, binding, currentPos + 1,
              bindings));
    } else if (currentPos < this.getNumberOfOperands()) {
      final Iterator<Bindings> it = this.lba[currentPos].iterator();
      while (it.hasNext()) {
        final Bindings b = it.next();
        final QueryResult bl = bindings.clone();
        bl.add(b);
        qr.addAll(combineAndProcess(pos, binding, currentPos + 1, bl));
      }
    }
    if (currentPos == this.getNumberOfOperands()) {
      qr.addAll(joinBindings(bindings));
View Full Code Here

  public abstract void init();

  @Override
  public synchronized QueryResult process(final QueryResult bindings, final int operandID) {
    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]) {
              joinBindings(result, binding.clone(), b2);
            }
 
            for (final QueryResult qr : this.lba[otherOperand].values()) {
              for (final Bindings b2 : qr) {
                joinBindings(result, binding.clone(), b2);
              }
            }
          }

          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);
      this.lba[operandID].put(keyJoin, lb);

      if(added || !isDuplicateEliminationEnabled()){
        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();

            joinBindings(result, binding.clone(), b2);
          }
View Full Code Here

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

    this.lba[operandID].clear();
  }

  @Override
  public QueryResult deleteQueryResult(final QueryResult queryResult, final int operandID) {
    final QueryResult result = this.createQueryResult();

    int otherOperand;
    if (operandID == 0)
      otherOperand = 1;
    else
      otherOperand = 0;

    final Iterator<Bindings> itbindings = queryResult.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 removed = this.cartesianProduct[operandID].remove(binding);
          if(removed || !isDuplicateEliminationEnabled()){
            // build the cartesian product
            for (final Bindings b2 : this.cartesianProduct[otherOperand]) {
              joinBindings(result, binding.clone(), b2);
            }
 
            for (final QueryResult qr : this.lba[otherOperand].values()) {
              for (final Bindings b2 : qr) {
                joinBindings(result, binding.clone(), b2);
              }
            }
          }

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

      if (keyJoin == null)
        continue;

      final QueryResult lb = this.lba[operandID].get(keyJoin);
      boolean removed = false;
      if (lb != null){
        removed = lb.remove(binding);
      }
      this.lba[operandID].put(keyJoin, lb);

      if(removed || !isDuplicateEliminationEnabled()){
        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();
 
            joinBindings(result, binding.clone(), b2);
          }
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.