Package lupos.datastructures.bindings

Examples of lupos.datastructures.bindings.Bindings


          }

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

          public Bindings computeNext() {
            while ((this.newTriples == null || !this.newTriples.hasNext()) && this.oldBindings.hasNext()) {
              this.retrieveNewTriples();
            }
            if (this.newTriples == null || !this.newTriples.hasNext()) {
              return null;
            }
            final Triple triple = this.newTriples.next();
            final Bindings cB = this.currentBindings.clone();
            for (int i = 0; i < 3; i++) {
              if (tp.getPos(i).isVariable()) {
                final Literal l = cB.get((Variable) tp.getPos(i));
                if (l != null) {
                  if (!triple.getPos(i).equals(l)) {
                    return this.computeNext();
                  }
                } else {
                  cB.add((Variable) tp.getPos(i), triple.getPos(i));
                }
              }
            }
            cB.addTriple(triple);
            return cB;
          }

          private void retrieveNewTriples() {
            this.currentBindings = this.oldBindings.next();
View Full Code Here


          }

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

          public Bindings computeNext() {
            while ((this.newTriples == null || !this.newTriples.hasNext()) && this.oldBindings.hasNext()) {
              this.retrieveNewTriples();
            }
            if (this.newTriples == null || !this.newTriples.hasNext()) {
              return null;
            }
            final Triple triple = this.newTriples.next();
            final Bindings cB = this.currentBindings.clone();
            for (int i = 0; i < 3; i++) {
              if (tp.getPos(i).isVariable()) {
                final Literal l = cB.get((Variable) tp.getPos(i));
                if (l != null) {
                  if (!triple.getPos(i).equals(l)) {
                    return this.computeNext();
                  }
                } else {
                  cB.add((Variable) tp.getPos(i), triple.getPos(i));
                }
              }
            }
            cB.addTriple(triple);
            return cB;
          }

          private void retrieveNewTriples() {
            this.currentBindings = this.oldBindings.next();
View Full Code Here

    if (bindings.size() == 1) {
      return bindings;
    } else if (bindings.size() == 2) {
      final QueryResult ret = getQR();
      final Iterator<Bindings> iter = bindings.iterator();
      final Bindings b1 = iter.next();
      final Bindings b2 = iter.next();
      if (this.comparator.compare(b1, b2) <= 0) {
        ret.add(b1);
        ret.add(b2);
        return ret;
      } else {
        ret.add(b2);
        ret.add(b1);
        return ret;
      }
    }

    QueryResult _LowEnd = getQR();
    QueryResult _HighEnd = getQR();
    final Bindings pivot = bindings.get(new Random().nextInt(bindings
        .size()));

    final Iterator<Bindings> it = bindings.iterator();
    while (it.hasNext()) {

      final Bindings nextB = it.next();

      if (this.comparator.compare(pivot, nextB) <= 0) {
        _HighEnd.add(nextB);
      } else {
        _LowEnd.add(nextB);
View Full Code Here

      public boolean hasNext() {
        return itb.hasNext();
      }

      public Bindings next() {
        final Bindings b = itb.next();
        if (b != null) {
          final Iterator<BitVector> ibv = bloomFilters.iterator();
          for (final Variable v : vars) {
            final BitVector bv = ibv.next();
            Literal literal = b.get(v);
            if(literal!=null){
              bv.set((Math.abs(literal.hashCode()) % NUMBEROFBITSFORBLOOMFILTER));
            }
          }
          if (!itb.hasNext()) {
View Full Code Here

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

      }

      @Override
      public Bindings next() {
        if(this.it.hasNext()){
          final Bindings b = this.it.next().clone();
          b.addAll(bindings);
          return b;
        } else {
          return null;
        }
      }
View Full Code Here

          return (this.next != null);
        }

        @Override
        public Bindings next() {
          final Bindings zNext = this.next;
          this.next = this.computeNext();
          return zNext;
        }

        private Bindings computeNext() {
          while (this.bindIt.hasNext()) {
            final Bindings bind = this.bindIt.next();
            try {
              if (bind != null) {
                final Object o = Filter.this.evalTree(bind, Filter.this.np
                    .jjtGetChild(0),
                    null);
View Full Code Here

              final Object znext = this.next;
              this.next = null;
              return znext;
            }
            while (this.iterator.hasNext()) {
              final Bindings b = this.iterator.next();
              try {
                return Filter.staticEvalTree(b, this.node,
                    resultsOfAggregationFunctions, evaluationVisitor);

              } catch (final Exception e) {
View Full Code Here

            return (this.next != null);
          }

          @Override
          public Bindings next() {
            final Bindings zNext = this.next;
            this.next = this.computeNext();
            return zNext;
          }

          private Bindings computeNext() {
            while (this.bindIt.hasNext()) {
              final Bindings bind = this.bindIt.next();
              try {
                if (bind != null) {
                  final Object o = Filter.staticEvalTree(bind, np
                      .jjtGetChild(0),
                      resultsOfAggregationFunctions, evaluationVisitor);
View Full Code Here

   */
  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 {
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.