Beispiel #1
0
  public CoolResponse execute() throws CoolQueryException {
    try {
      Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
      System.gc();
      long time_model = System.currentTimeMillis();
      long memory_model = StatsUtil.getMemoryUsed(Runtime.getRuntime());
      Model model = pairing.getCorrespondingModel();
      memory_model = StatsUtil.getMemoryUsed(Runtime.getRuntime()) - memory_model;
      time_model = System.currentTimeMillis() - time_model;

      System.gc();
      long time_query = System.currentTimeMillis();
      long memory_query = StatsUtil.getMemoryUsed(Runtime.getRuntime());

      QueryExecution exec = QueryExecutionFactory.create(query, model);

      ResultSet rs;

      try {
        rs = exec.execSelect();
      } catch (Exception e) {
        exec.close();
        throw new CoolQueryException("Error while sparql exec (" + e.getMessage() + ").");
      }

      memory_query = StatsUtil.getMemoryUsed(Runtime.getRuntime()) - memory_query;
      time_query = System.currentTimeMillis() - time_query;

      return new CoolResponse(this, rs, time_model, memory_model, time_query, memory_query);

    } catch (PairingException e) {
      throw new CoolQueryException("Oops something goes wrong...");
    } catch (ModelException e) {
      throw new CoolQueryException("Oops something goes wrong...");
    } catch (IOException e) {
      throw new CoolQueryException("Problem occured while getting properties files.");
    }
  }
Beispiel #2
0
 public CoolQuery(String q, PairingDescription p) throws CoolQueryException {
   queryString = q;
   pairing = p;
   if (!pairing.complete())
     throw new CoolQueryException("Pairing have to be complete to construct a CoolQuery");
 }