Package lupos.datastructures.queryresult

Examples of lupos.datastructures.queryresult.QueryResult


  }

  @Override
  public QueryResult process(final QueryResult oldBindings,
      final int operandID) {
    final QueryResult qr = QueryResult.createInstance();

    for (final Bindings oldBinding : oldBindings) {
      // Triple triple = getTriple();

      final Bindings bindings = this.bindingsFactory.createInstance();
      Literal literal = null;

      for (int i = 0; i < this.filterLeft.size(); i++) {
        // its value has to be equal to the corresponding value of
        // the triple pattern
        if (!this.filterLeft.get(i).getLiteral(null).valueEquals(
            oldBinding.get(this.filterRight.get(i)))) {
          return null;
        }
      }

      // process all items
      // for(int i = 0; i < 3; i++){
      for (int i = 0; i < this.substitutionsLiteralLeft.size(); i++) {
        // if the item is an unbound variable
        final Variable item = this.substitutionsLiteralLeft.get(i);
        if ((literal = bindings.get(item)) == null) {
          bindings.add(item, this.substitutionsLiteralRight.get(i));
        }
        // if the item is a variable which is already bound
        // and the value differs from the value of the triple
        // which would be used as binding, a conflict was
        // detected
        else if (!literal.valueEquals(this.substitutionsLiteralRight.get(i))) {
          return null; // join within triple pattern!
        }
      }

      for (int i = 0; i < this.substitutionsVariableLeft.size(); i++) {
        // if the item is an unbound variable
        final Variable item = this.substitutionsVariableLeft.get(i);
        if ((literal = bindings.get(item)) == null) {
          bindings.add(item, oldBinding
              .get(this.substitutionsVariableRight.get(i)));
        }
        // if the item is a variable which is already bound
        // and the value differs from the value of the triple
        // which would be used as binding, a conflict was
        // detected
        else if (!literal.valueEquals(oldBinding
            .get(this.substitutionsVariableRight.get(i)))) {
          return null; // join within triple pattern!
        }
      }

      qr.add(bindings);
    }
    // bindings.addTriple(triple);
    return qr;
  }
View Full Code Here


    // just do dirty trick to determine the number of results of a triple pattern...
    final LinkedList<TriplePattern> tpc = new LinkedList<TriplePattern>();
    tpc.add(triplePattern);
    final Collection<TriplePattern> zTP = indexScan.getTriplePattern();
    indexScan.setTriplePatterns(tpc);
    final QueryResult queryResult = indexScan.join(indexScan.getRoot().dataset);
    indexScan.setTriplePatterns(zTP);
    final int entries = (queryResult==null)? 0 : queryResult.oneTimeSize();
    return entries;
  }
View Full Code Here

    return super.preProcessMessage(msg);
  }

  @Override
  public Message preProcessMessage(final EndOfEvaluationMessage msg) {
    final QueryResult qr = getQueryResultForAggregatedFilter(this.np, this.queryResult, this.aggregationFunctions, this.evaluationVisitor);
    if (qr != null) {
      if (this.succeedingOperators.size() > 1) {
        qr.materialize();
      }
      for (final OperatorIDTuple opId : this.succeedingOperators) {
        opId.processAll(qr);
      }
    }
View Full Code Here

  }

  @Override
  public Message preProcessMessageDebug(final EndOfEvaluationMessage msg,
      final DebugStep debugstep) {
    final QueryResult qr = getQueryResultForAggregatedFilter(this.np, this.queryResult, this.aggregationFunctions, this.evaluationVisitor);
    if (qr != null) {
      if (this.succeedingOperators.size() > 1) {
        qr.materialize();
      }
      for (final OperatorIDTuple opId : this.succeedingOperators) {
        final QueryResultDebug qrDebug = new QueryResultDebug(qr,
            debugstep, this, opId.getOperator(), true);
        ((Operator) opId.getOperator()).processAllDebug(qrDebug, opId
View Full Code Here

   * Bindings are compared and split in separate QueryResults
   *
   */
  private void computeResult(){
    if (!this.queryResults.isEmpty()) {
      QueryResult newQueryResult = QueryResult.createInstance();
      final Iterator<Bindings> it = this.queryResults.getQueryResult().oneTimeIterator();
      Bindings oldBinding = null;
      boolean firstRun = true;
      while (it.hasNext()) {
        final Bindings b = it.next();
        if (!firstRun) {
          final int compareValue = this.comp.compare(oldBinding, b);
          if (compareValue == 0) {
            newQueryResult.add(b);
          } else {
            // Send queryResult
            for (final OperatorIDTuple opId: this.succeedingOperators) {
              opId.processAll(newQueryResult);
            }
            newQueryResult = QueryResult.createInstance();
            newQueryResult.add(b);
          }
        } else {
          firstRun = false;
          newQueryResult.add(b);
        }
        oldBinding = b;
      }
      // Send queryResult
      for (final OperatorIDTuple opId: this.succeedingOperators) {
View Full Code Here

    return msg;
  }

  private void computeResultDebug(final DebugStep debugstep){
    if (!this.queryResults.isEmpty()) {
      QueryResult newQueryResult = QueryResult.createInstance();
      final Iterator<Bindings> it = this.queryResults.getQueryResult().oneTimeIterator();
      Bindings oldBinding = null;
      boolean firstRun = true;
      while (it.hasNext()) {
        final Bindings b = it.next();
        if (!firstRun) {
          final int compareValue = this.comp.compare(oldBinding, b);
          if (compareValue == 0) {
            newQueryResult.add(b);
          } else {
            // Send queryResult
            for (final OperatorIDTuple opId: this.succeedingOperators) {
              final QueryResultDebug qrDebug = new QueryResultDebug(newQueryResult, debugstep, this, opId.getOperator(), true);
              ((Operator) opId.getOperator()).processAllDebug(qrDebug, opId.getId(), debugstep);
            }
            newQueryResult = QueryResult.createInstance();
            newQueryResult.add(b);
          }
        } else {
          firstRun = false;
          newQueryResult.add(b);
        }
        oldBinding = b;
      }
      // Send queryResult
      for (final OperatorIDTuple opId: this.succeedingOperators) {
View Full Code Here

        this.zeroPairs.add(newBind);
      }
    }
   
    final Iterator<Bindings> itz = this.zeroPairs.iterator();
    QueryResult result = new QueryResult();

    while(itz.hasNext()){
      Bindings zeroPath = itz.next();
      result.add(zeroPath);
    }
   
    return result;
  }
View Full Code Here

  }

  // bindings should contain exactly one element!
  @Override
  public QueryResult process(final QueryResult bindings, final int operandID) {
    final QueryResult result = QueryResult.createInstance();

    final Iterator<Bindings> itb = bindings.iterator();
    Bindings bind1;
    if (itb.hasNext())
      bind1 = itb.next();
    else
      return null;

    boolean conditionFulfilled = true;

    // check conditions...
    Iterator<Variable> it = conditions.keySet().iterator();

    while (it.hasNext()) {
      final Variable elem = it.next();
      if (!conditions.get(elem).valueEquals(bind1.get(elem))) {
        conditionFulfilled = false;
      }
    }

    if (conditionFulfilled) {
      final Bindings bnew = bind1.clone();

      it = constants.keySet().iterator();
      while (it.hasNext()) {
        final Variable elem = it.next();
        bind1.add(elem, constants.get(elem));
      }
      result.add(bnew);
    }

    result.add(bind1);
    return result;
  }
View Full Code Here

  }

  @Override
  public QueryResult process(final QueryResult oldBindings,
      final int operandID) {
    final QueryResult qr = QueryResult.createInstance();

    for (final Bindings oldBinding : oldBindings) {
      // Triple triple = getTriple();

      // final Bindings bindings = Bindings.createNewInstance();
      Literal literal = null;

      for (int i = 0; i < filterLeft.size(); i++) {
        // its value has to be equal to the corresponding value of
        // the triple pattern
        if (!filterLeft.get(i).getLiteral(null).valueEquals(
            oldBinding.get(filterRight.get(i)))) {
          return null;
        }
      }

      for (int i = 0; i < substitutionsVariableLeft.size(); i++) {
        // if the item is an unbound variable
        final Variable itemName = substitutionsVariableLeft.get(i);
        if ((literal = oldBinding.get(itemName)) == null) {
          oldBinding.add(itemName, oldBinding
              .get(substitutionsVariableRight.get(i)));
        }
        // if the item is a variable which is already bound
        // and the value differs from the value of the triple
        // which would be used as binding, a conflict was
        // detected
        else if (!literal.valueEquals(oldBinding
            .get(substitutionsVariableRight.get(i)))) {
          return null; // join within triple pattern!
        }
      }

      qr.add(oldBinding);
    }
    // bindings.addTriple(triple);
    return qr;
  }
View Full Code Here

    this.operands[1] = new ParallelIteratorMultipleQueryResults();
    return msg;
  }

  public QueryResult join(final QueryResult left, final QueryResult right) {
    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 QueryResult result = new QueryResult(0);
    this.probe(rootSmaller, rootLarger, result);
    // System.out.println("HashJoin: Result sizes: Left:"+left.size()+
    // " Right:"+right.size()+" Result:"+result.size());
    if (result.size() > 0) {
      return result;
    } else {
      return null;
    }
  }
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.