Package lupos.datastructures.bindings

Examples of lupos.datastructures.bindings.Bindings


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


      @Override
      public Bindings next() {
        if (!this.hasNext()) {
          return null;
        }
        final Bindings oldBinding = this.oldIt.next();
        if (oldBindings == null) {
          return null;
        }
        final Bindings newBinding = ReplaceVar.this.bindingsFactory.createInstance();
        for (int i = 0; i < ReplaceVar.this.substitutionsVariableLeft.size(); i++) {

          final Variable itemName = ReplaceVar.this.substitutionsVariableLeft.get(i);
          // always do like this!
          newBinding.add(itemName, oldBinding
              .get(ReplaceVar.this.substitutionsVariableRight.get(i)));
        }
        return newBinding;
      }
View Full Code Here

  // bindings should contain exactly one element!
  @Override
  public QueryResult process(final QueryResult bindings, final int operandID) {
    final Iterator<Bindings> pib = bindings.oneTimeIterator();
    while (pib.hasNext()) {
      final Bindings bind1 = pib.next();
      // TODO Prevent duplicates
      // bind1.getTriples();

      final Triple triple = new Triple();

      for (int i = 0; i < 3; i++) {
        if (valueOrVariable[i].isVariable())
          triple.setPos(i, bind1.get((Variable) valueOrVariable[i]));
        else
          triple.setPos(i, (Literal) valueOrVariable[i]);
      }

      if (triple.getSubject() == null || triple.getPredicate()==null || triple.getObject()==null || !(triple.getPredicate().isURI() && (triple.getSubject().isBlank() || triple.getSubject().isURI()))) {
View Full Code Here

      @Override
      public Bindings next() {
        if (!this.itb.hasNext()) {
          return null;
        }
        final Bindings oldBinding = this.itb.next();
        final Literal literal = oldBinding.get(AddBindingFromOtherVar.this.var);
        if (literal == null) {
          oldBinding.add(AddBindingFromOtherVar.this.var, oldBinding.get(AddBindingFromOtherVar.this.valueFromVar));
        }
        // 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(AddBindingFromOtherVar.this.valueFromVar))) {
          System.out
              .println("AddBindingFromOtherVar: Error: Variable "
                  + AddBindingFromOtherVar.this.var + " was already bound!");
          return null;
        }
View Full Code Here

  public QueryResult processDebugStep(final QueryResult bindings,
      final DebugStep debugStep) {
    final Iterator<Bindings> pib = bindings.oneTimeIterator();
    while (pib.hasNext()) {
      final Bindings bind1 = pib.next();
      // TODO Prevent duplicates
      // bind1.getTriples();

      final Triple triple = new Triple();

      for (int i = 0; i < 3; i++) {
        if (valueOrVariable[i].isVariable())
          triple.setPos(i, bind1.get((Variable) valueOrVariable[i]));
        else
          triple.setPos(i, (Literal) valueOrVariable[i]);
      }

      if (triple.getSubject() instanceof TypedLiteral) {
View Full Code Here

    if(this.zeroPairs==null){
      this.zeroPairs = new HashSet<Bindings>()
    }
   
    while (itb.hasNext()){
      Bindings bind = itb.next();
      Bindings newBind = new BindingsCollection();
      if((this.allowedSubjects==null || this.allowedSubjects.contains(bind.get(this.subject))) && (this.allowedObjects==null || this.allowedObjects.contains(bind.get(this.subject)))){
        newBind.add(this.subject, bind.get(this.subject));
        newBind.add(this.object, bind.get(this.subject));
        this.zeroPairs.add(newBind);
      }
     
      if((this.allowedSubjects==null || this.allowedSubjects.contains(bind.get(this.object))) && (this.allowedObjects==null || this.allowedObjects.contains(bind.get(this.object)))){
        newBind = new BindingsCollection();
        newBind.add(this.subject, bind.get(this.object));
        newBind.add(this.object, bind.get(this.object));
        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

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

                return currentResult.hasNext();
              }

              @Override
              public Bindings next() {
                final Bindings b = currentResult.next();
                if (b != null) {
                  this.number++;
                }
                if (!currentResult.hasNext()) {
                  MergeJoinWithoutSorting.this.realCardinality = this.number;
                  this.close();
                }
                return b;
              }

              public Bindings getNext(final Bindings k) {
                @SuppressWarnings("unchecked")
                final Bindings b = ((SIPParallelIterator<Bindings, Bindings>) currentResult)
                    .next(k);
                if (b != null) {
                  this.number++;
                }
View Full Code Here

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

        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) {
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.