Package lupos.datastructures.bindings

Examples of lupos.datastructures.bindings.Bindings


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


    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);
          }
        }
        // build cartesian product
View Full Code Here

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

      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

                return currentResult.hasNext();
              }

              @Override
              public Bindings next() {
                final Bindings b = currentResult.next();
                if (!currentResult.hasNext()) {
                  MergeJoinWithoutSortingSeveralIterations.this.realCardinality = this.number;
                  this.close();
                }
                if (b != null) {
View Full Code Here

    }

    @Override
    public Bindings next() {
      if (this.next != null) {
        final Bindings znext = this.next;
        this.next = null;
        return znext;
      } else {
        return this.computeNext();
      }
View Full Code Here

    private Bindings computeNext() {
      while (true) {
        if (!this.it.hasNext()) {
          return null;
        }
        final Bindings next_local = this.it.next();
        if (next_local == null) {
          return null;
        }
        while (true) {
          if (this.currentMinus == null) {
View Full Code Here

   * return null; } } } if (altered){ bindings.addTriple(triple);
   * qresult.add(bindings); } return bindings; }
   */
  @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()) {
View Full Code Here

  }

  public Bindings process(final Triple triple, final boolean failOnBlank,
      final int id) {

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

    // process all items of this triple pattern
    for (int i = 0; i < 3; i++) {

      if (this.bloomFilters != null) {
        if (this.bloomFilters[i] != null) {
          if (!this.bloomFilters[i]
                            .get((Math.abs(triple.getPos(i).hashCode()) % SIPFilterOperator.NUMBEROFBITSFORBLOOMFILTER))) {
            return null;
          }
        }
      }

      // if the triple's node at the current position is a blank
      // one which is not allowed due to the current configuration
      // return null to indicate this problem
      if (failOnBlank && triple.getPos(i).isBlank()) {
        return null;
      }

      // if the item is a variable
      if (this.items[i].isVariable()) {

        // if the item is an unbound variable
        final Variable item = triple.getVariable((Variable) this.items[i]);
        if ((literal = bindings.get(item)) == null) {
          bindings.add(item, triple.getPos(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(triple.getPos(i))) {
          return null; // join within triple pattern!
        }
      }

      // if the item is no variable ...
      else {

        // its value has to be equal to the corresponding value of
        // the triple pattern
        try {
          if (!this.items[i].getLiteral(null)
              .valueEquals(triple.getPos(i))) {
            return null;
          }
        } catch (final Exception e) {
          System.out.println(e);
          e.printStackTrace();
          return null;
        }
      }
    }
    bindings.addTriple(triple);
    if (this.projectionPresortingNumbers != null) {
      if (this.order1 == null) {
        final int i = 0;
        for (final BasicOperator bo : this.projectionPresortingNumbers.keySet()) {
          final LinkedList<Variable> li = this.projectionPresortingNumbers.get(bo);

          // else if (triple instanceof SortedTripleElement) {
          // final Object o =
          // lupos.engine.operators.index.mergeJoin.MergeJoinIndex
          // .getSortPatterns4OptimizedJoin(this,
          // projectionPresortingNumbers);
          // bindings
          // .addPresortingNumber(
          // this,
          // o,
          // ((SortedTripleElement) triple)
          // .getPosition((SortedTripleElement.ORDER_PATTERN) o),
          // ((SortedTripleElement) triple).getMax());
          // }
        }
        // System.out.println(this);
        // System.out.println("order1, size " + order1.length + ":");
        // for (int j = 0; j < order1.length; j++) {
        // System.out.print(order1[j] + ", ");
        // }
        // System.out.println();
      }
    } else if (bindings instanceof BindingsArrayVarMinMax
        && this.minMaxPresortingNumbers != null) {
      // this can only be reached for --optimization
      // MergeJoinSortLazyLiteral --codemap LazyLiteral
      final Map<Variable, Integer> hmvi = this.bindingsFactory.getPosVariables();
      for (final Variable v : bindings.getVariableSet()) {
        final Container container = this.minMaxPresortingNumbers.get(hmvi
            .get(v));
        if (container != null) {
          ((BindingsArrayVarMinMax) bindings).addMinMax(v,
              container.min, container.max);
View Full Code Here

    return tk;
  }

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

TOP

Related Classes of lupos.datastructures.bindings.Bindings

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.