public class QueryPlan extends Object
A single QueryPlan
can be used to create multiple QueryStatement
objects. If you are intending to
execute the same query multiple times then, for performance reasons, it is recommended to use a QueryPlan
rather than create multiple QueryStatement
directly. When using a QueryPlan
the Prolog syntax will
only be parsed once and the plan for executing the query will be optimised for performance.
Modifier and Type | Method and Description |
---|---|
QueryStatement |
createStatement()
Return a newly created
QueryStatement for the query represented by this plan. |
void |
executeOnce()
Evaluate once the query represented by this statement.
|
QueryResult |
executeQuery()
Return a newly created
QueryResult for the query represented by this plan. |
List<String> |
findAllAsAtomName() |
List<Double> |
findAllAsDouble() |
List<Long> |
findAllAsLong() |
List<Term> |
findAllAsTerm() |
String |
findFirstAsAtomName() |
double |
findFirstAsDouble() |
long |
findFirstAsLong() |
Optional<String> |
findFirstAsOptionalAtomName() |
Optional<Double> |
findFirstAsOptionalDouble() |
Optional<Long> |
findFirstAsOptionalLong() |
Optional<Term> |
findFirstAsOptionalTerm() |
Term |
findFirstAsTerm() |
public QueryStatement createStatement()
QueryStatement
for the query represented by this plan.
Before the query is executed, values can be assigned to variables in the query by using
QueryStatement.setTerm(String, Term)
. The query can be executed by calling
QueryStatement.executeQuery()
.
Note: If you do not intend to assign terms to variables then executeQuery()
can be called instead.
executeQuery()
,
executeOnce()
public QueryResult executeQuery()
QueryResult
for the query represented by this plan.
The QueryResult.next()
and QueryResult.getTerm(String)
methods can be used to evaluate the query
and access values unified to the variables of the query.
createStatement()
,
executeOnce()
public void executeOnce()
The query will only be evaluated once, even if further solutions could of been found on backtracking.
ProjogException
- if no solution can be foundcreateStatement()
,
executeQuery()
public String findFirstAsAtomName()
public double findFirstAsDouble()
public long findFirstAsLong()
public Term findFirstAsTerm()
Copyright © 2024. All rights reserved.