Package lupos.datastructures.bindings

Examples of lupos.datastructures.bindings.Bindings


      private Iterator<Bindings> nextIteratorQueryResult(){
        try {
          if(!this.bindingsIterator.hasNext()){
            return null;
          }
          final Bindings bindingsTemp = this.bindingsIterator.next();
          final String fQuery = FederatedQueryFetchAsNeeded.this.toStringQuery(bindingsTemp);
          if (!FederatedQueryFetchAsNeeded.this.endpoint.isVariable()) {
            return new IteratorQueryResultAndOneBindings(Client.submitQuery(((URILiteral)FederatedQueryFetchAsNeeded.this.endpoint).getString(), fQuery, FederatedQueryFetchAsNeeded.this.bindingsFactory), bindingsTemp);
          } else {
            Literal endpointURI = bindingsTemp.get((Variable) FederatedQueryFetchAsNeeded.this.endpoint);
            if (endpointURI instanceof LazyLiteral) {
              endpointURI = ((LazyLiteral) endpointURI).getLiteral();
            }
            if (endpointURI instanceof URILiteral) {
              return new IteratorQueryResultAndOneBindings(Client.submitQuery(((URILiteral) endpointURI).getString(), fQuery, FederatedQueryFetchAsNeeded.this.bindingsFactory), bindingsTemp);
View Full Code Here


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

      private Iterator<Bindings> nextIteratorQueryResult(){
        try {
          if(!this.bindingsIterator.hasNext()){
            return null;
          }
          final Bindings bindingsTemp = this.bindingsIterator.next();

          final Bindings bindingsKey = bindingsTemp.clone();
          final Set<Variable> otherVars = bindingsKey.getVariableSet();
          otherVars.removeAll(FederatedQueryFetchAsNeededWithCache.this.variablesInServiceCall);
          otherVars.remove(FederatedQueryFetchAsNeededWithCache.this.endpoint);
          for(final Variable var: otherVars){
            bindingsKey.add(var, null);
          }

          final QueryResult cached = FederatedQueryFetchAsNeededWithCache.this.cache.get(bindingsKey);
          if(cached!=null){
            return cached.iterator();
View Full Code Here

          }
          result +="<http://www.ifis.uni-luebeck.de/functions/BitVectorFilter>("+variable;
          result +=",";
          BitVector bv = new BitVector(FederatedQueryBitVectorJoinNonStandardSPARQL.bitvectorSize);
          while (bindingsIterator.hasNext()) {
            Bindings b = bindingsIterator.next();
            Literal literal = variable.getLiteral(b);
            if(literal!=null){
              oneOrMoreResults=true;
              bv.set(Math.abs(literal.toString().hashCode() % FederatedQueryBitVectorJoinNonStandardSPARQL.bitvectorSize));
            }
View Full Code Here

    final HashSet<Triple> triples = new HashSet<Triple>();

    // collect all query-triples!
    final Iterator<Bindings> it = queryResult.oneTimeIterator();
    while(it.hasNext()){
      final Bindings bindings = it.next();
      for(final Triple triple: bindings.getTriples()){
        triples.add(triple);
      }
    }
    // now write out all triples without any duplicates
    for(final Triple triple: triples){
View Full Code Here

          this.writeFirstStartResult(os);
          firstTime = false;
        } else {
          this.writeStartResult(os);
        }
        final Bindings bindings = it.next();
        boolean firstTimeBinding = true;
        final Iterator<Variable> it_v2 = this.getVariablesToIterateOnForOneBindings(variables, bindings);
        while(it_v2.hasNext()){
          final Variable v = it_v2.next();
          if(firstTimeBinding){
            this.writeFirstStartBinding(os, v);
            firstTimeBinding = false;
          } else {
            this.writeStartBinding(os, v);
          }

          this.writeLiteral(os, bindings.get(v));

          this.writeEndBinding(os);
        }

        if(this.writeQueryTriples && bindings instanceof BindingsArrayReadTriples){
          this.writeQueryTriples(os, bindings.getTriples());
        }

        this.writeEndResult(os);
      }
      this.writeEpilogue(os);
View Full Code Here

  private QueryResult tripleResultAsQueryResult(TriplePattern triplePattern,
      List<Triple> foundTriples) {
    QueryResult result = QueryResult.createInstance();
    if (foundTriples != null)
      for (Triple t : foundTriples) {
        Bindings b = addVariablesToBindings(triplePattern.getItems(), t);
        if (b != null)
          result.add(b);
      }
    return result;
  }
View Full Code Here

    return result;
  }

  private Bindings addVariablesToBindings(Item[] items, Triple t) {
   
    Bindings b = bindingsFactory.createInstance();
    for (int i = 0; i < items.length; i++) {
      Item item = items[i];
      if (item.getClass() == Variable.class) {
        Variable v = (Variable) item;
        b.add(v, t.getPos(i));

      } else {
        if (t.getPos(i)
            .compareToNotNecessarilySPARQLSpecificationConform(
                (Literal) item) != 0) {
View Full Code Here

     * we will not execute this, if using subgraph-submission
     */
    final List<Triple> lst = new LinkedList<Triple>();
    final QueryResult qr = this.sendDirect(key, "SELECT * WHERE {?s ?p ?o}");
    for (final Iterator<Bindings> it = qr.oneTimeIterator(); it.hasNext();) {
      final Bindings bind = it.next();
      final List<Triple> t = bind.getTriples();
      if (t != null) {
        lst.addAll(t);
      }
    }
    return lst;
View Full Code Here

    // use oneTimeIterator() whenever the result need to
    // be iterated only once, otherwise iterator()...
    final Iterator<Bindings> it_query = qr.oneTimeIterator();
    while (it_query.hasNext()) {
      // get next solution of the query...
      final Bindings bindings = it_query.next();
      // print out the bound values of all bindings!
      StringBuilder result=new StringBuilder("{");
      boolean first=true;
      for (final Variable v : bindings.getVariableSet()) {
        if(first){
          first=false;
        } else {
          result.append(", ");
        }
        result.append(v);
        result.append('=');
        result.append(bindings.get(v));
      }
      result.append("}");
      System.out.println(result.toString());
    }
  }
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.