Query
classin packageklyn.data
public final class Query<T> implements Queryable<T>:
Query
All Implemented Interfaces: Queryable

Immutable, lazy and re-executable typed KQL query.

A query is not a collection. Execution occurs only through an explicit terminal operation such as toList(), count(), or stream().

Example
active = query:
from users user
where user.active
rows = active.toList()
Constructors
Modifier and Type Member Description
public Query
Query(source as QuerySource, plan as QueryPlanBase, description as String = "query"):
Creates a lazy query from a provider source and immutable typed plan.
Methods
Modifier and Type Member Description
public asQuery
asQuery() as Query<T>:
Returns this immutable query.
public count
count() as Long:
Counts result rows through the provider count operation.
public countPlan
countPlan(plan as QueryPlanBase) as Long:
Counts rows produced by an outer plan.
public executePlan
executePlan(plan as QueryPlanBase) as Object:
Applies an outer typed plan to this query.
public exists
exists() as Boolean:
Tests whether at least one row exists.
public existsPlan
existsPlan(plan as QueryPlanBase) as Boolean:
Tests whether an outer plan produces a row.
public explain
explain() as QueryExplanation:
Returns a typed, redacted query explanation.
public first
first() as T throws NoResultException:
Returns the first row using a one-row provider window.
public firstOrNull
firstOrNull() as T:
Returns the first row or null.
public openStream
openStream(plan as QueryPlanBase) as Object:
Opens an outer plan as an independent sequential stream.
public page
page(request as PageRequest) as Page<T>:
Materializes one page and obtains an exact total count.
public providerName
providerName() as String:
Returns the underlying provider identifier.
public providerText
providerText(plan as QueryPlanBase) as String:
Returns provider text and explicitly identifies composed memory work.
public single Returns the sole result row.
public singleOrNull
singleOrNull() as T throws NonUniqueResultException:
Returns the sole row or null.
public slice
slice(request as PageRequest) as Slice<T>:
Materializes one page window without executing an exact count.
public stream
stream() as QueryStream<T>:
Opens one independent forward-only result stream.
public toList
toList() as List<T>:
Executes and materializes the query into the standard list type.
public toProviderText
toProviderText() as String:
Returns the privileged provider representation for diagnostics.
public toSet
toSet() as Set<T>:
Executes and materializes unique result rows.
Inherited Methods
methodInherited Methods from Queryable: asQuery
methodInherited Methods from QuerySource: countPlan, executePlan, existsPlan, openStream, providerName, providerText