Query
classin packageklyn.data
public final class Query<T> extends QuerySourceBase 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 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 existsPlan
existsPlan(plan as QueryPlanBase) as Boolean
Tests whether an outer plan produces a row.
public first
first() as T throws NoResultException
Returns the first row using a one-row provider window.
public firstOrNull
firstOrNull() as Object
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 single Returns the sole result row.
public singleOrNull
singleOrNull() as Object 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 toSet
toSet() as Set<T>
Executes and materializes unique result rows.