Package lupos.datastructures.bindings

Examples of lupos.datastructures.bindings.Bindings


    List<Triple> foundTriples = this.getTriple(newKey);
    return tripleResultAsQueryResult(triplePattern, foundTriples);
  }

  private Bindings addVariablesToBindings(Item[] items, Triple t) {
    Bindings b = this.bindings.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


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

            Arrays.toString(foundTriples.toArray())));
    return tripleResultAsQueryResult(triplePattern, foundTriples);
  }

  private Bindings addVariablesToBindings(Item[] items, Triple t) {
    Bindings b = this.bindings.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

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

        }
      }
      for(int i=0; i<root.jjtGetNumChildren(); i++){
        final Node child = root.jjtGetChild(i);
        if(child instanceof ASTOneResult){
          final Bindings bindings = bindingsFactory.createInstance();
          final Iterator<Variable> varIt = vars.iterator();
          for(int j=0; j<child.jjtGetNumChildren() && varIt.hasNext(); j++){
            final Variable var = varIt.next();
            final Node childchild = child.jjtGetChild(j);
            if(childchild instanceof ASTValue && childchild.jjtGetNumChildren()>0){
              bindings.add(var, TSVParser.getLiteral(childchild.jjtGetChild(0)));
            }
          }
          result.add(bindings);
        }
      }
View Full Code Here

        }
      }
      for(int i=0; i<root.jjtGetNumChildren(); i++){
        final Node child = root.jjtGetChild(i);
        if(child instanceof ASTOneResult){
          final Bindings bindings = bindingsFactory.createInstance();
          final Iterator<Variable> varIt = vars.iterator();
          for(int j=0; j<child.jjtGetNumChildren() && varIt.hasNext(); j++){
            final Variable var = varIt.next();
            final Node childchild = child.jjtGetChild(j);
            if(childchild instanceof ASTValue && childchild.jjtGetNumChildren()>0){
              bindings.add(var, CSVParser.getLiteral(childchild.jjtGetChild(0)));
            }
          }
          result.add(bindings);
        }
      }
View Full Code Here

          @Override
          public Bindings next() {
            if(this.hasNext()){
              try {
                final Bindings result = getBindings(this.bindings.getJSONObject(this.index), bindingsFactory);
                this.index++;
                return result;
              } catch (final JSONException e) {
                System.err.println(e);
                e.printStackTrace();
View Full Code Here

    }
    return null;
  }

  public static Bindings getBindings(final JSONObject oneResult, final BindingsFactory bindingsFactory) throws JSONException{
    final Bindings luposResult = bindingsFactory.createInstance();
    final Iterator<String> keysIt = oneResult.keys();
    while(keysIt.hasNext()){
      final String var = keysIt.next();
      if(var.compareTo("<Query-Triples>")!=0){
        luposResult.add(new Variable(var), getLiteral(oneResult.getJSONObject(var)));
      } else {
        // This JSONObject contains the query-triples!
        // This is no standard and a proprietary feature of LUPOSDATE!
        final JSONArray triples = oneResult.getJSONArray(var);
        for(int i=0; i<triples.length(); i++){
          final JSONObject jsonTriple = triples.getJSONObject(i);
          luposResult.addTriple(new Triple(getLiteral(jsonTriple.getJSONObject("subject")), getLiteral(jsonTriple.getJSONObject("predicate")), getLiteral(jsonTriple.getJSONObject("object"))));
        }
      }
    }
    return luposResult;
  }
View Full Code Here

      BigInteger usedVars = InputHelper.readLuposBigInteger(hm.size(), in);
      if (usedVars == null) {
        return null;
      }
      BigInteger differentFromPreviousBindings = InputHelper.readLuposBigInteger(hm.size(), in);
      final Bindings b = bindingsFactory.createInstance();
      final BigInteger TWO = BigInteger.valueOf(2);
      for (final Variable v : hm.keySet()) {
        if (usedVars.mod(TWO).compareTo(BigInteger.ONE)==0) {
          if (previousBindings == null || differentFromPreviousBindings.mod(TWO).compareTo(BigInteger.ONE)==0) {
            Literal lit;
            lit = InputHelper.readLuposLiteral(in);
            b.add(v, lit);
          } else {
            b.add(v, previousBindings.get(v));
          }
        }
        usedVars = usedVars.shiftRight(1);
        differentFromPreviousBindings = differentFromPreviousBindings.shiftRight(1);
      }
View Full Code Here

      final Map<Variable, Integer> hm = bindingsFactory.getPosVariables();
      BigInteger usedVars = InputHelper.readLuposBigInteger(hm.size(), in);
      if (usedVars == null) {
        return null;
      }
      final Bindings b = bindingsFactory.createInstance();
      final BigInteger TWO = BigInteger.valueOf(2);
      for (final Variable v : hm.keySet()) {
        if (usedVars.mod(TWO).compareTo(BigInteger.ONE)==0) {
          final Literal lit = InputHelper.readLuposLiteral(in);
          b.add(v, lit);
        }
        usedVars = usedVars.shiftRight(1);
      }
      InputHelper.addSpecialInformationToBindings(b, in);
      return b;
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.