/** * Creates a QueryExecution by selecting the most appropriate {@link QueryEngineType} that can answer the given query. * * @see QueryEngineType * @param query the query * @param dataset the target of the query * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution create(final Query query, final Dataset dataset) { return create(query, dataset, null); }
/** * Creates a QueryExecution by selecting the most appropriate {@link QueryEngineType} that can answer the given query. * * @see QueryEngineType * @param query the query * @param dataset the target of the query * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution create(final Query query, final Dataset dataset) { return create(query, dataset, null); }
/** * Creates a QueryExecution by selecting the most appropriate {@link QueryEngineType} that can answer the given query. * * @see QueryEngineType * @param query the query * @param dataset the target of the query * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution create(final Query query, final Dataset dataset) { return create(query, dataset, null); }
/** * Creates a QueryExecution with the given {@link QueryEngineType}. If the query engine cannot handle the given query a QueryException may be thrown during * query execution. Users are recommended to use {@link #create(Query, Dataset, QuerySolution)} * * @param query the query * @param dataset the target of the query * @param initialBinding used for parametrized queries * @param queryEngineType type of the query engine that will be used to answer the query * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution create(final Query query, final Dataset dataset, final QuerySolution initialBinding, final QueryEngineType queryEngineType) { return create(query, dataset, initialBinding, queryEngineType, true); }
/** * Creates a QueryExecution object where the Basic Graph Patterns (BGPs) will be answered by native Pellet query engine whenever possible. The unsupported * BGPs, i.e. the ones that are not in the SPARQL-DL fragment, will be answered by the Jena query engine. With this fall-back model all types of SPARQL * queries are supported. * * @param query the query * @param model the target of the query * @return a <code>QueryExecution</code> that will answer the query with the given model * @throws QueryException if the given model is not associated with Pellet reasoner */ public static QueryExecution create(final Query query, final Model model) { return create(query, model, null); }
/** * Creates a QueryExecution with the given {@link QueryEngineType}. If the query engine cannot handle the given query a QueryException may be thrown during * query execution. Users are recommended to use {@link #create(Query, Dataset, QuerySolution)} * * @param query the query * @param dataset the target of the query * @param initialBinding used for parametrized queries * @param queryEngineType type of the query engine that will be used to answer the query * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution create(final Query query, final Dataset dataset, final QuerySolution initialBinding, final QueryEngineType queryEngineType) { return create(query, dataset, initialBinding, queryEngineType, true); }
/** * Creates a QueryExecution object where the Basic Graph Patterns (BGPs) will be answered by native Pellet query engine whenever possible. The unsupported * BGPs, i.e. the ones that are not in the SPARQL-DL fragment, will be answered by the Jena query engine. With this fall-back model all types of SPARQL * queries are supported. * * @param query the query * @param model the target of the query * @return a <code>QueryExecution</code> that will answer the query with the given model * @throws QueryException if the given model is not associated with Pellet reasoner */ public static QueryExecution create(final Query query, final Model model) { return create(query, model, null); }
/** * Creates a Pellet query engine that will answer the given query. This function should be used only if it is known that Pellet query engine can handle the * given query. Otherwise query execution will result in an exception. for arbitrary queries it is safer to use the <code>create</code> functions. * * @see QueryEngineType * @param query the query * @param dataset the target of the query * @param initialBinding initial binding that will be applied before query execution or <code>null</code> if there is no initial binding * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution createPelletExecution(final Query query, final Dataset dataset, final QuerySolution initialBinding) { return create(query, dataset, initialBinding, QueryEngineType.PELLET); }
/** * Creates a Pellet query engine that will answer the given query. This function should be used only if it is known that Pellet query engine can handle the * given query. Otherwise query execution will result in an exception. for arbitrary queries it is safer to use the <code>create</code> functions. * * @see QueryEngineType * @param query the query * @param model the target of the query * @return a <code>QueryExecution</code> that will answer the query with the given model */ public static QueryExecution createPelletExecution(final Query query, final Model model) { return create(query, DatasetFactory.create(model), null, QueryEngineType.PELLET); }
/** * Creates a QueryExecution by selecting the most appropriate {@link QueryEngineType} that can answer the given query. * * @see QueryEngineType * @param query the query * @param model the target of the query * @param initialBinding initial binding that will be applied before query execution or <code>null</code> if there is no initial binding * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution create(final Query query, final Model model, final QuerySolution initialBinding) { return create(query, DatasetFactory.create(model), initialBinding); }
/** * Creates a QueryExecution by selecting the most appropriate {@link QueryEngineType} that can answer the given query. * * @see QueryEngineType * @param query the query * @param model the target of the query * @param initialBinding initial binding that will be applied before query execution or <code>null</code> if there is no initial binding * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution create(final Query query, final Model model, final QuerySolution initialBinding) { return create(query, DatasetFactory.create(model), initialBinding); }
/** * Creates a Pellet query engine that will answer the given query. This function should be used only if it is known that Pellet query engine can handle the * given query. Otherwise query execution will result in an exception. for arbitrary queries it is safer to use the <code>create</code> functions. * * @see QueryEngineType * @param query the query * @param model the target of the query * @param initialBinding initial binding that will be applied before query execution or <code>null</code> if there is no initial binding * @return a <code>QueryExecution</code> that will answer the query with the given model */ public static QueryExecution createPelletExecution(final Query query, final Model model, final QuerySolution initialBinding) { return create(query, DatasetFactory.create(model), initialBinding, QueryEngineType.PELLET); }
/** * Creates a QueryExecution by selecting the most appropriate {@link QueryEngineType} that can answer the given query. * * @see QueryEngineType * @param query the query * @param model the target of the query * @param initialBinding initial binding that will be applied before query execution or <code>null</code> if there is no initial binding * @return a <code>QueryExecution</code> that will answer the query with the given dataset */ public static QueryExecution create(final Query query, final Model model, final QuerySolution initialBinding) { return create(query, DatasetFactory.create(model), initialBinding); }
/** * Creates a Pellet query engine that will answer the given query. This function should be used only if it is known that Pellet query engine can handle the * given query. Otherwise query execution will result in an exception. for arbitrary queries it is safer to use the <code>create</code> functions. * * @see QueryEngineType * @param query the query * @param model the target of the query * @return a <code>QueryExecution</code> that will answer the query with the given model */ public static QueryExecution createPelletExecution(final Query query, final Model model) { return create(query, DatasetFactory.create(model), null, QueryEngineType.PELLET); }
/** * Creates a Pellet query engine that will answer the given query. This function should be used only if it is known that Pellet query engine can handle the * given query. Otherwise query execution will result in an exception. for arbitrary queries it is safer to use the <code>create</code> functions. * * @see QueryEngineType * @param query the query * @param model the target of the query * @return a <code>QueryExecution</code> that will answer the query with the given model */ public static QueryExecution createPelletExecution(final Query query, final Model model) { return create(query, DatasetFactory.create(model), null, QueryEngineType.PELLET); }
/** * Creates a Pellet query engine that will answer the given query. This function should be used only if it is known that Pellet query engine can handle the * given query. Otherwise query execution will result in an exception. for arbitrary queries it is safer to use the <code>create</code> functions. * * @see QueryEngineType * @param query the query * @param model the target of the query * @param initialBinding initial binding that will be applied before query execution or <code>null</code> if there is no initial binding * @return a <code>QueryExecution</code> that will answer the query with the given model */ public static QueryExecution createPelletExecution(final Query query, final Model model, final QuerySolution initialBinding) { return create(query, DatasetFactory.create(model), initialBinding, QueryEngineType.PELLET); }
@Override protected QueryExecution createQueryExecution() { return SparqlDLExecutionFactory.create(_query, createDataset(), null, _queryEngineType, _handleVariableSPO); }
@Test public void test() { final Query query = QueryFactory.read(_queryURL); final Dataset dataset = DatasetFactory.create(_model); final QueryExecution qe = SparqlDLExecutionFactory.create(query, dataset, null, _queryEngineType); assertEquals("Failed query engine: " + _queryEngineType + " query: " + _queryURL, _expectedResult, qe.execAsk()); } }
@Test public void testDAWG4() { final Model model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); model.read("file:test/data/sparql-dawg-tests/data-r2/optional-filter/data-1.ttl", "N3"); final Query query = QueryFactory.read("file:test/data/sparql-dawg-tests/data-r2/optional-filter/expr-5.rq"); final QueryExecution qe = SparqlDLExecutionFactory.create(query, model); final ResultSet rs = qe.execSelect(); ResultSetFormatter.consume(rs); assertEquals(3, rs.getRowNumber()); }
@Test public void testDAWG1() { final OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); model.read("file:test/data/sparql-dawg-tests/data-r2/basic/data-1.ttl", "N3"); final Query query = QueryFactory.read("file:test/data/sparql-dawg-tests/data-r2/basic/base-prefix-1.rq"); final QueryExecution qe = SparqlDLExecutionFactory.create(query, model); final ResultSet rs = qe.execSelect(); //ResultSetFormatter.out( rs ); ResultSetFormatter.consume(rs); // Type, sameAs, one entry for each property assertion assertEquals(1 + 1 + 2, rs.getRowNumber()); }