Package lupos.datastructures.queryresult

Examples of lupos.datastructures.queryresult.QueryResult


            Bindings.instanceClass = BindingsArrayReadTriples.class;
          } else {
            Bindings.instanceClass = Endpoint.getDefaultBindingsClass();
          }

          final QueryResult queryResult = (this.evaluator instanceof CommonCoreQueryEvaluator)?((CommonCoreQueryEvaluator)this.evaluator).getResult(queryParameter, false):this.evaluator.getResult(queryParameter);

          writer.write("\nResult (of size "+queryResult.size()+"):\n"+queryResult.toString());

          final String mimeType = formatter.getMIMEType(queryResult);
          System.out.println("Done, sending response using MIME type "+mimeType+"\n");
          writer.write("\nSending response using MIME type "+mimeType+"\n");
          t.getResponseHeaders().add("Content-type", mimeType);
View Full Code Here


  }

  @Override
  public void call(final QueryResult res) {
    if (res != null) {
      final QueryResult resQueryResult = (res instanceof QueryResultDebug) ? ((QueryResultDebug) res)
          .getOriginalQueryResult() : res;
      if (resQueryResult instanceof RuleResult) {
        if (this.rr == null) {
          this.rr = new RuleResult();
        }
View Full Code Here

      DelayedResult<QueryResult> waitingResult;
      waitingResults.put(id,
          waitingResult = new DelayedResult<QueryResult>());
      network.sendMessage(p2pKey, messageToSend.toString());

      QueryResult queryResult = new QueryResult();
      try {
        queryResult = waitingResult.get(SLEEP, TimeUnit.SECONDS);
        l.debug(String.format("Waiting for answer of message-id: %s: finished", id));
      } catch (ExecutionException e) {
        l.error(String.format(
            "Error waiting for result of message-id %s", id), e);
        RuntimeException re = new RuntimeException(String.format(
            "Error waiting for result of message-id %s", id));
        re.addSuppressed(e);
        throw re;
      } catch (TimeoutException e) {
        l.error(String.format(
            "Error waiting for result of message-id %s, timeout!",
            id), e);
        RuntimeException re = new RuntimeException(String.format(
            "Error waiting for result of message-id %s, timout!",
            id));
        re.addSuppressed(e);
        throw re;
      }
      return queryResult;
    } catch (InterruptedException e) {
      l.error(String
          .format("Error waiting of result for subgraph from node %s",
              p2pKey), e);
    }
    // Wait for answer of message id
    l.warn(String
        .format("Error waiting of result for subgraph from node %s. So return empty query-result.",
            p2pKey));
    return new QueryResult();
  }
View Full Code Here

    MIMEFormatReader reader = new JSONFormatReader();
    // read in the message (JSON message result)
    Bindings.instanceClass = lupos.datastructures.bindings.BindingsMap.class;

    QueryResult qr = null;
    try {
      qr = reader.getQueryResult(
          new ByteArrayInputStream(message.getBytes("UTF-8")),
          message,bindingsFactory);
    } catch (UnsupportedEncodingException e) {
View Full Code Here

      LiteralFactory.setType(MapType.NOCODEMAP);
     
     
      XMLFormatReader fr = new XMLFormatReader();
      //read in the query result
      QueryResult qr = fr.getQueryResult(in,this.bindingsFactory);
     
     
      long time = new Date().getTime();
      int tripelSize = 0;
      long difference = new Date().getTime() - time;
View Full Code Here

        final SubgraphContainerFormatter serializer = new SubgraphContainerFormatter();
        try {
          final JSONObject serializedGraph = serializer
              .serialize(AsynchronSubgraphContainer.this
                  .getRootOfSubgraph(), 0);
          final QueryResult result = AsynchronSubgraphContainer.this.subgraphExecutor
              .evaluate(AsynchronSubgraphContainer.this.getKey(),
                  serializedGraph.toString(),bindingsFactory);
          result.materialize();
          result.materialize(); // just for now read all from the
                      // stream sent by the endpoint,
                      // otherwise it may be blocked! (may
                      // be removed if each endpoint can
                      // work completely in parallel!)
         
View Full Code Here

      }
    }
    /*
     * now we want to wait for the result of the subgraph
     */
    QueryResult result;
    try {
      result = waitForResult.get();
    } catch (InterruptedException e) {
      result = null;
      e.printStackTrace();
    } catch (ExecutionException e) {
      result = null;
      e.printStackTrace();
    }
    // for now, forward the result to all succeeding's ....
    if (result != null) result.materialize();
    for (final OperatorIDTuple opId : this.succeedingOperators) {
      if (result != null)
        opId.processAll(result);
    }
    if (executor != null) executor.shutdown();
View Full Code Here

  @Override
  public QueryResult process(final Dataset dataset) {
    final SubgraphContainerFormatter serializer = new SubgraphContainerFormatter();
    try {
      final JSONObject serializedGraph = serializer.serialize(this.rootNodeOfSubGraph, 0);
      final QueryResult result = this.subgraphExecutor.evaluate(this.key,  serializedGraph.toString(),this.bindingsFactory);
      result.materialize(); // just for now read all from the stream sent by the endpoint, otherwise it may be blocked! (may be removed if each endpoint can work completely in parallel!)
      return result;
    } catch (final JSONException e) {
      System.err.println(e);
      e.printStackTrace();
      return null;
View Full Code Here

  }

  @Override
  public QueryResult process(final QueryResult oldBindings,
      final int operandID) {
    final QueryResult qr = QueryResult.createInstance();

    for (final Bindings oldBinding : oldBindings) {
      Literal literal = null;

      // process all items
      for (int i = 0; i < substitutionsLiteralLeft.size(); i++) {
        final Variable itemName = substitutionsLiteralLeft.get(i);
        // oldBinding.add(itemName, substitutionsLiteralRight.get(i));

        // if the item is an unbound variable
        if ((literal = oldBinding.get(itemName)) == null) {
          oldBinding.add(itemName, 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 is
        // detected
        else if (!literal.valueEquals(substitutionsLiteralRight.get(i))) {
          System.out.println("Error " + this.toString() + ": "
              + itemName + ":" + substitutionsLiteralRight.get(i)
              + "<->" + literal);
          System.out.println(oldBinding);
          return null; // join within triple pattern!
        }
      }
      qr.add(oldBinding);
    }
    return qr;
  }
View Full Code Here

  @Override
  public Message preProcessMessage(final EndOfEvaluationMessage msg) {
    if(!this.operands[0].isEmpty() && ! this.operands[1].isEmpty()){
      final Map<String, QueryResult> leftOperandsData = this.createDatastructure();
      final QueryResult cartesianProduct = QueryResult.createInstance();

      IndexOnLeftOperandJoin.indexQueryResult(this.operands[0].getQueryResult(), this.intersectionVariables, leftOperandsData, cartesianProduct);

      final QueryResult result = QueryResult.createInstance(new JoinIterator(this.intersectionVariables, this.operands[1].getQueryResult(), leftOperandsData, cartesianProduct));

      if(this.succeedingOperators.size()>1){
        result.materialize();
      }

      for (final OperatorIDTuple opId : this.succeedingOperators) {
        opId.processAll(result);
      }
View Full Code Here

TOP

Related Classes of lupos.datastructures.queryresult.QueryResult

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.