@Override public void close() throws OntopConnectionException { tupleResultSet.close(); } }
@Override public boolean hasNext() throws OntopConnectionException, OntopResultConversionException { if (results.size() > 0) return true; //in case of describe, we return the collected results list information if (storeResults) return false; // construct while(tupleResultSet.hasNext()) { List<Assertion> newTriples = processResults(tupleResultSet.next()); if (!newTriples.isEmpty()) { results.addAll(newTriples); return true; } } return false; }
@Override public int getFetchSize() throws OntopConnectionException { return tupleResultSet.getFetchSize(); }
@Override public boolean hasNext() throws QueryEvaluationException { try { return res.hasNext(); } catch (Exception e) { throw new QueryEvaluationException(e); } }
@Override public OWLBindingSet next() throws OWLException { try { return new OntopOWLBindingSet(res.next()); } catch (OntopConnectionException | OntopResultConversionException | NoSuchElementException e) { throw new OntopOWLException(e); } } }
@Override public List<String> getSignature() throws OWLException { try { return res.getSignature(); } catch (Exception e) { throw new OntopOWLException(e); } }
@Override public int getColumnCount() throws OWLException { try { return res.getColumnCount(); } catch (Exception e) { throw new OntopOWLException(e); } }
@Override public boolean hasNext() throws OWLException { try { return res.hasNext(); } catch (Exception e) { throw new OntopOWLException(e); } }
@Override public BindingSet next() throws QueryEvaluationException { try { return new OntopRDF4JBindingSet(res.next()); } catch (OntopConnectionException | OntopResultConversionException e) { throw new QueryEvaluationException(e); } // // MapBindingSet set = new MapBindingSet(this.signature.size() * 2); // for (String name : this.signature) { // Binding binding = createBinding(name, ontopBindingSet, this.bindingNames); // if (binding != null) { // set.addBinding(binding); // } // } }
@Override public TupleQueryResult evaluate() throws QueryEvaluationException { TupleResultSet res; OntopStatement stm; long start = System.currentTimeMillis(); try { stm = conn.createStatement(); if(this.queryTimeout > 0) stm.setQueryTimeout(this.queryTimeout); try { SelectQuery inputQuery = factory.createSelectQuery(getQueryString(), getParsedQuery()); res = stm.execute(inputQuery); } catch (OntopQueryAnsweringException e) { long end = System.currentTimeMillis(); if (this.queryTimeout > 0 && (end - start) >= this.queryTimeout * 1000){ throw new QueryEvaluationException("OntopTupleQuery timed out. More than " + this.queryTimeout + " seconds passed", e); } else throw e; } List<String> signature = res.getSignature(); return new OntopTupleQueryResult(res, signature); } catch (QueryEvaluationException e) { throw e; } catch (Exception e) { throw new QueryEvaluationException(e); } }
public DefaultSimpleGraphResultSet(TupleResultSet tupleResultSet, ConstructTemplate constructTemplate, boolean storeResults, TermFactory termFactory, org.apache.commons.rdf.api.RDF rdfFactory) throws OntopResultConversionException, OntopConnectionException { this.tupleResultSet = tupleResultSet; this.constructTemplate = constructTemplate; this.termFactory = termFactory; this.rdfFactory = rdfFactory; Extension ex = constructTemplate.getExtension(); if (ex != null) { extMap = ex.getElements().stream() .collect(ImmutableCollectors.toMap(e -> e.getName(), e -> e.getExpr())); } else extMap = null; this.storeResults = storeResults; if (storeResults) { //process current result set into local buffer, //since additional results will be collected while (tupleResultSet.hasNext()) { results.addAll(processResults(tupleResultSet.next())); } } }
@Override public void close() throws QueryEvaluationException { try { res.close(); } catch (Exception e) { throw new QueryEvaluationException(e); } }
@Override public boolean hasNext() throws QueryEvaluationException { try { return res.hasNext(); } catch (Exception e) { throw new QueryEvaluationException(e); } }
@Override public BindingSet next() throws QueryEvaluationException { try { return new OntopRDF4JBindingSet(res.next()); } catch (OntopConnectionException | OntopResultConversionException e) { throw new QueryEvaluationException(e); } // // MapBindingSet set = new MapBindingSet(this.signature.size() * 2); // for (String name : this.signature) { // Binding binding = createBinding(name, ontopBindingSet, this.bindingNames); // if (binding != null) { // set.addBinding(binding); // } // } }
@Override public TupleQueryResult evaluate() throws QueryEvaluationException { TupleResultSet res; OntopStatement stm; long start = System.currentTimeMillis(); try { stm = conn.createStatement(); if(this.queryTimeout > 0) stm.setQueryTimeout(this.queryTimeout); try { SelectQuery inputQuery = factory.createSelectQuery(getQueryString(), getParsedQuery()); res = stm.execute(inputQuery); } catch (OntopQueryAnsweringException e) { long end = System.currentTimeMillis(); if (this.queryTimeout > 0 && (end - start) >= this.queryTimeout * 1000){ throw new QueryEvaluationException("OntopTupleQuery timed out. More than " + this.queryTimeout + " seconds passed", e); } else throw e; } List<String> signature = res.getSignature(); return new OntopTupleQueryResult(res, signature); } catch (QueryEvaluationException e) { throw e; } catch (Exception e) { throw new QueryEvaluationException(e); } }
@Override public int getFetchSize() throws OWLException { try { return res.getFetchSize(); } catch (Exception e) { throw new OntopOWLException(e); } }
@Override public void close() throws OWLException { try { res.close(); } catch (Exception e) { throw new OntopOWLException(e); } }
@Override public void close() throws QueryEvaluationException { try { res.close(); } catch (Exception e) { throw new QueryEvaluationException(e); } }