Package lupos.datastructures.bindings

Examples of lupos.datastructures.bindings.Bindings


    }
  }

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

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

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

          if (compare == 0) {

            this.bindings1 = new CollectionImplementation<Bindings>(MergeJoin.MEMORYLIMIT);
            this.bindings2 = new CollectionImplementation<Bindings>(MergeJoin.MEMORYLIMIT);

            final Bindings bindings = this.b1;
            do {
              this.bindings1.add(this.b1);
              if (!ssb1it.hasNext()) {
                this.processFurther = false;
                break;
              }
              this.b1 = ssb1it.next();
            } while (comp.compare(this.b1, bindings) == 0);
            do {
              this.bindings2.add(this.b2);
              if (!ssb2it.hasNext()) {
                this.processFurther = false;
                break;
              }
              this.b2 = ssb2it.next();
            } while (comp.compare(this.b2, bindings) == 0);
            this.currentBinding = new Iterator<Bindings>() {
              final Iterator<Bindings> itb1 = bindings1.iterator();
              Iterator<Bindings> itb2 = bindings2.iterator();
              Bindings zb1 = this.itb1.next();

              @Override
              public boolean hasNext() {
                return this.itb1.hasNext() || this.itb2.hasNext();
              }

              @Override
              public Bindings next() {
                if (!this.hasNext()) {
                  return null;
                }
                if (!this.itb2.hasNext()) {
                  this.zb1 = this.itb1.next();
                  this.itb2 = bindings2.iterator();
                }
                final Bindings bnew = this.zb1.clone();
                final Bindings zb2 = this.itb2.next();
                bnew.addAll(zb2);
                bnew.addAllTriples(zb2);
                bnew.addAllPresortingNumbers(zb2);
                return bnew;
              }

              @Override
              public void remove() {
                throw new UnsupportedOperationException();
              }
            };
            return;
          } else if (compare < 0) {
            if (ssb1it.hasNext()) {
              if (ssb1it instanceof SIPParallelIterator) {
                final Bindings projected = bindingsFactory.createInstance();
                for (final Variable v : vars) {
                  projected.add(v, this.b2.get(v));
                }
                do {
                  this.b1 = ((SIPParallelIterator<Bindings, Bindings>) ssb1it).next(projected);
                } while (this.b1 != null && comp.compare(this.b1, projected) < 0);
                if (this.b1 == null) {
                  this.processFurther = false;
                }
              } else {
                this.b1 = ssb1it.next();
              }
            } else {
              this.processFurther = false;
            }
          } else if (compare > 0) {
            if (ssb2it.hasNext()) {
              if (ssb2it instanceof SIPParallelIterator) {
                final Bindings projected = bindingsFactory.createInstance();
                for (final Variable v : vars) {
                  projected.add(v, this.b1.get(v));
                }
                do {
                  this.b2 = ((SIPParallelIterator<Bindings, Bindings>) ssb2it).next(projected);
                } while (this.b2 != null && comp.compare(this.b2, projected) < 0);
                if (this.b2 == null) {
View Full Code Here

      }

      public void computeNextResults() {
        while (this.processFurther == true) {
          boolean equal = true;
          Bindings maximum = b[0];
          for (int i = 1; i < b.length; i++) {
            final int compare = comp.compare(maximum, b[i]);
            if (compare > 0) {
              equal = false;
            } else if (compare < 0) {
              equal = false;
              maximum = b[i];
            }
          }

          if (equal) {
            for (int i = 0; i < b.length; i++) {
              bindings[i] = new CollectionImplementation<Bindings>(MergeJoin.MEMORYLIMIT);
              final Bindings bindingsCurrent = b[i];
              while (comp.compare(b[i], bindingsCurrent) == 0) {
                bindings[i].add(b[i]);
                if (!ssbit[i].hasNext()) {
                  this.processFurther = false;
                  break;
                }
                b[i] = ssbit[i].next();
              }
            }

            final Iterator<Bindings>[] itb = new Iterator[b.length];
            final Bindings zb[] = new Bindings[b.length - 1];
            for (int i = 0; i < b.length; i++) {
              itb[i] = bindings[i].iterator();
            }
            for (int i = 0; i < zb.length; i++) {
              zb[i] = itb[i].next();
            }

            this.currentBinding = new Iterator<Bindings>() {

              @Override
              public boolean hasNext() {
                for (final Iterator<Bindings> it : itb) {
                  if (it.hasNext()) {
                    return true;
                  }
                }
                return false;
              }

              @Override
              public Bindings next() {
                if (!this.hasNext()) {
                  return null;
                }
                int i = b.length - 1;
                for (; i >= 0 && !itb[i].hasNext(); i--) {
                  itb[i] = bindings[i].iterator();
                }
                if (i < b.length - 1) {
                  zb[i] = itb[i].next();
                }
                final Bindings bnew = zb[0].clone();
                for (int j = 1; j < zb.length; j++) {
                  bnew.addAll(zb[j]);
                  bnew.addAllTriples(zb[j]);
                  bnew.addAllPresortingNumbers(zb[j]);
                }
                final Bindings zb2 = itb[b.length - 1].next();
                bnew.addAll(zb2);
                bnew.addAllTriples(zb2);
                bnew.addAllPresortingNumbers(zb2);
                return bnew;
              }

              @Override
              public void remove() {
                throw new UnsupportedOperationException();
              }
            };
            return;
          } else {
            for (int i = 0; i < b.length; i++) {
              if (comp.compare(maximum, b[i]) != 0) {
                if (ssbit[i].hasNext()) {
                  if (ssbit[i] instanceof SIPParallelIterator) {
                    final Bindings projected = bindingsFactory.createInstance();
                    for (final Variable v : vars) {
                      projected.add(v, maximum.get(v));
                    }
                    do {
                      b[i] = ((SIPParallelIterator<Bindings, Bindings>) ssbit[i]).next(projected);
                    } while (b[i] != null && comp.compare(b[i], projected) < 0);
                    if (b[i] == null) {
View Full Code Here

      }

      public void computeNextResults() {
        while (this.processFurther == true) {
          boolean equal = true;
          Bindings maximum = b[0];
          for (int i = 1; i < b.length; i++) {
            final int compare = comp.compare(maximum, b[i]);
            if (compare > 0) {
              equal = false;
            } else if (compare < 0) {
              equal = false;
              maximum = b[i];
            }
          }
          if (comp.compare(maximum, maximum2) > 0) {
            this.processFurther = false;
            break;
          }

          if (equal) {
            for (int i = 0; i < b.length; i++) {
              bindings[i] = new CollectionImplementation<Bindings>(MergeJoin.MEMORYLIMIT);
              final Bindings bindingsCurrent = b[i];
              do {
                bindings[i].add(b[i]);
                if (!ssbit[i].hasNext()) {
                  this.processFurther = false;
                  break;
                }
                b[i] = ssbit[i].next();
              } while (comp.compare(b[i], bindingsCurrent) == 0);
            }

            final Iterator<Bindings>[] itb = new Iterator[b.length];
            final Bindings zb[] = new Bindings[b.length - 1];
            for (int i = 0; i < b.length; i++) {
              itb[i] = bindings[i].iterator();
            }
            for (int i = 0; i < zb.length; i++) {
              zb[i] = itb[i].next();
            }

            this.currentBinding = new Iterator<Bindings>() {

              @Override
              public boolean hasNext() {
                for (final Iterator<Bindings> it : itb) {
                  if (it.hasNext()) {
                    return true;
                  }
                }
                return false;
              }

              @Override
              public Bindings next() {
                if (!this.hasNext()) {
                  return null;
                }
                int i = b.length - 1;
                for (; i >= 0 && !itb[i].hasNext(); i--) {
                  itb[i] = bindings[i].iterator();
                  if (i != b.length - 1) {
                    zb[i] = itb[i].next();
                  }
                }
                if (i < b.length - 1) {
                  zb[i] = itb[i].next();
                }
                final Bindings bnew = zb[0].clone();
                for (int j = 1; j < zb.length; j++) {
                  bnew.addAll(zb[j]);
                  bnew.addAllTriples(zb[j]);
                  bnew.addAllPresortingNumbers(zb[j]);
                }
                final Bindings zb2 = itb[b.length - 1].next();
                bnew.addAll(zb2);
                bnew.addAllTriples(zb2);
                bnew.addAllPresortingNumbers(zb2);
                return bnew;
              }

              @Override
              public void remove() {
                throw new UnsupportedOperationException();
              }
            };
            return;
          } else {
            final Bindings projected = bindingsFactory.createInstance();
            for (final Variable v : vars) {
              projected.add(v, maximum.get(v));
            }
            for (int i = 0; i < b.length; i++) {
              if (comp.compare(maximum, b[i]) != 0) {
                if (ssbit[i].hasNext()) {
                  if (ssbit[i] instanceof SIPParallelIterator) {
View Full Code Here

            this.bindings1 = new CollectionImplementation<Bindings>(MergeJoin.MEMORYLIMIT);
            this.bindings2 = new CollectionImplementation<Bindings>(MergeJoin.MEMORYLIMIT);
            Iterator<Bindings> currentBinding2 = null;

            final Bindings bindings = this.b1;
            do {
              this.bindings1.add(this.b1);
              if (!ssb1it.hasNext()) {
                this.b1 = null;
                this.processFurther = false;
                break;
              }
              this.b1 = ssb1it.next();
            } while(comp.compare(this.b1, bindings) == 0);
            do {
              this.bindings2.add(this.b2);
              if (!ssb2it.hasNext()) {
                this.processFurther = false;
                // rest from ssb1:
                currentBinding2 = new Iterator<Bindings>() {
                  Bindings zb1 = b1;

                  @Override
                  public boolean hasNext() {
                    return (this.zb1 != null || ssb1it.hasNext());
                  }

                  @Override
                  public Bindings next() {
                    if (this.zb1 != null) {
                      final Bindings zzb1 = this.zb1;
                      this.zb1 = null;
                      return zzb1;
                    }
                    return ssb1it.next();
                  }

                  @Override
                  public void remove() {
                    throw new UnsupportedOperationException();
                  }
                };
                break;
              }
              this.b2 = ssb2it.next();
            } while (comp.compare(this.b2, bindings) == 0);
            final Iterator<Bindings> currentBinding3 = currentBinding2;
            this.currentBinding = new Iterator<Bindings>() {
              final Iterator<Bindings> itb1 = bindings1.iterator();
              Iterator<Bindings> itb2 = bindings2.iterator();
              Bindings zb1 = this.itb1.next();
              Iterator<Bindings> restFrom1 = currentBinding3;

              @Override
              public boolean hasNext() {
                return this.itb1.hasNext()
                    || this.itb2.hasNext()
                    || (this.restFrom1 != null && this.restFrom1
                        .hasNext());
              }

              @Override
              public Bindings next() {
                if (!this.hasNext()) {
                  return null;
                }
                if (!(this.itb1.hasNext() || this.itb2.hasNext())) {
                  if (this.restFrom1 != null && this.restFrom1.hasNext()) {
                    return this.restFrom1.next();
                  }
                }
                if (!this.itb2.hasNext()) {
                  this.zb1 = this.itb1.next();
                  this.itb2 = bindings2.iterator();
                }
                final Bindings bnew = this.zb1.clone();
                final Bindings zb2 = this.itb2.next();
                bnew.addAll(zb2);
                bnew.addAllTriples(zb2);
                bnew.addAllPresortingNumbers(zb2);
                return bnew;
              }

              @Override
              public void remove() {
                throw new UnsupportedOperationException();
              }
            };
            return;
          } else if (compare < 0) {
            if (ssb1it.hasNext()) {
              this.currentBinding = new Iterator<Bindings>() {
                @Override
                public boolean hasNext() {
                  return (b1 != null && comp.compare(b1, b2) < 0);
                }

                @Override
                public Bindings next() {
                  if (comp.compare(b1, b2) >= 0) {
                    return null;
                  }
                  final Bindings zb1 = b1;
                  b1 = ssb1it.next();
                  if (b1 == null) {
                    processFurther = false;
                  }
                  return zb1;
                }

                @Override
                public void remove() {
                  throw new UnsupportedOperationException();
                }
              };
              return;
            } else {
              this.processFurther = false;
            }
          } else if (compare > 0) {
            if (ssb2it.hasNext()) {
              this.b2 = ssb2it.next();
            } else {
              this.currentBinding = new Iterator<Bindings>() {
                Bindings zb1 = b1;

                @Override
                public boolean hasNext() {
                  return (this.zb1 != null || ssb1it.hasNext());
                }

                @Override
                public Bindings next() {
                  if (this.zb1 != null) {
                    final Bindings zzb1 = this.zb1;
                    this.zb1 = null;
                    return zzb1;
                  }
                  return ssb1it.next();
                }
View Full Code Here

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

          }
        }
        if (this.currentOuterElement == null) {
          return null;
        }
        final Bindings innerElement = this.inner.next();
        final Bindings bnew = this.currentOuterElement.clone();
        bnew.addAll(innerElement);
        bnew.addAllTriples(innerElement);
        bnew.addAllPresortingNumbers(innerElement);

        return bnew;
      }

      @Override
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.