Interface Queryable<T>
- Type Parameters:
T
- the type of Queryable element
public interface Queryable<T>
Represents the queryable objects, e.g. Java collections
- Since:
- 4.0.0
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Queryable.Order<T,
U extends Comparable<? super U>> Represents an order rule -
Field Summary
-
Method Summary
Modifier and TypeMethodDescription<U> U
The most powerful aggregate function in GINQ, it will receive the grouped result(Queryable
instance) and apply any processingAggregate functionavg
, similar to SQL'savg
count()
Aggregate functioncount
, similar to SQL'scount
<U> Long
Aggregate functioncount
, similar to SQL'scount
Note: if the chosen field isnull
, the field will not be countedCross join anotherQueryable
instance, similar to SQL'scross join
distinct()
Eliminate duplicated records, similar to SQL'sdistinct
static <T> Queryable<T>
Returns the empty Queryable instancedefault boolean
exists()
Check if the result is empty, similar to SQL'sexists
static <T> Queryable<T>
Factory method to createQueryable
instancestatic <T> Queryable<T>
Factory method to createQueryable
instancestatic <T> Queryable<T>
Returns the originalQueryable
instance directlystatic <T> Queryable<T>
from
(T[] array) Factory method to createQueryable
instancefullHashJoin
(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Full hash join anotherQueryable
instance, similar to SQL'sfull join
fullJoin
(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Full join anotherQueryable
instance, similar to SQL'sfull join
groupBy
(Function<? super T, ?> classifier, Predicate<? super Tuple2<?, Queryable<? extends T>>> having) Group byQueryable
instance, similar to SQL'sgroup by
innerHashJoin
(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Inner hash join anotherQueryable
instance, similar to SQL'sinner hash join
.innerJoin
(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Inner join anotherQueryable
instance, similar to SQL'sinner join
Intersect anotherQueryable
instance, similar to SQL'sintersect
leftHashJoin
(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Left hash join anotherQueryable
instance, similar to SQL'sleft hash join
leftJoin
(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Left join anotherQueryable
instance, similar to SQL'sleft join
limit
(long size) PaginateQueryable
instance, similar to MySQL'slimit
limit
(long offset, long size) PaginateQueryable
instance, similar to MySQL'slimit
<U> List<U>
Aggregate functionlist
.<U extends Comparable<? super U>>
UAggregate functionmax
, similar to SQL'smax
Aggregate functionmedian
, similar to SQL'smedian
<U extends Comparable<? super U>>
UAggregate functionmin
, similar to SQL'smin
Minus anotherQueryable
instance, similar to SQL'sminus
default <U extends Comparable<? super U>>
Queryable<T>orderBy
(List<? extends Queryable.Order<? super T, ? extends U>> orders) SortQueryable
instance, similar to SQL'sorder by
<U extends Comparable<? super U>>
Queryable<T>orderBy
(Queryable.Order<? super T, ? extends U>... orders) SortQueryable
instance, similar to SQL'sorder by
<U extends Comparable<? super U>>
Window<T>Open window for current recordrightHashJoin
(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Right hash join anotherQueryable
instance, similar to SQL'sright join
rightJoin
(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Right join anotherQueryable
instance, similar to SQL'sright join
<U> Queryable<U>
select
(BiFunction<? super T, ? super Queryable<? extends T>, ? extends U> mapper) ProjectQueryable
instance, similar to SQL'sselect
long
size()
Returns the count of elements of theQueryable
instanceAggregate functionstdev
, similar to SQL'sstdev
Aggregate functionstdevp
, similar to SQL'sstdevp
stream()
Aggregate functionsum
, similar to SQL'ssum
toList()
Union anotherQueryable
instance, similar to SQL'sunion
Union all anotherQueryable
instance, similar to SQL'sunion all
Aggregate functionvar
, similar to SQL'svar
Aggregate functionvarp
, similar to SQL'svarp
FilterQueryable
instance via some condition, similar to SQL'swhere
-
Field Details
-
NULL
Represents null of GINQ, e.g. it could be used as the default group field- Since:
- 4.0.0
-
EMPTY_QUERYABLE
Represents the empty Queryable instance- Since:
- 4.0.0
-
-
Method Details
-
emptyQueryable
Returns the empty Queryable instance- Type Parameters:
T
- the type of element- Returns:
- the empty Queryable instance
- Since:
- 4.0.0
-
from
Factory method to createQueryable
instance -
from
Factory method to createQueryable
instance- Type Parameters:
T
- the type of element- Parameters:
array
- array object- Returns:
- the
Queryable
instance - Since:
- 4.0.0
-
from
Factory method to createQueryable
instance- Type Parameters:
T
- the type of element- Parameters:
sourceStream
- stream object- Returns:
- the
Queryable
instance - Since:
- 4.0.0
-
from
Returns the originalQueryable
instance directly- Type Parameters:
T
- the type of element- Parameters:
queryable
- queryable object- Returns:
- the
Queryable
instance - Since:
- 4.0.0
-
innerJoin
<U> Queryable<Tuple2<T,U>> innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Inner join anotherQueryable
instance, similar to SQL'sinner join
-
innerHashJoin
<U> Queryable<Tuple2<T,U>> innerHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Inner hash join anotherQueryable
instance, similar to SQL'sinner hash join
. Note: Inner hash join requires equijoin predicate, e.g.on a == b
-
leftJoin
<U> Queryable<Tuple2<T,U>> leftJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Left join anotherQueryable
instance, similar to SQL'sleft join
-
leftHashJoin
<U> Queryable<Tuple2<T,U>> leftHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Left hash join anotherQueryable
instance, similar to SQL'sleft hash join
-
rightJoin
<U> Queryable<Tuple2<T,U>> rightJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Right join anotherQueryable
instance, similar to SQL'sright join
-
rightHashJoin
<U> Queryable<Tuple2<T,U>> rightHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Right hash join anotherQueryable
instance, similar to SQL'sright join
-
fullJoin
<U> Queryable<Tuple2<T,U>> fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Full join anotherQueryable
instance, similar to SQL'sfull join
-
fullHashJoin
<U> Queryable<Tuple2<T,U>> fullHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Full hash join anotherQueryable
instance, similar to SQL'sfull join
-
crossJoin
Cross join anotherQueryable
instance, similar to SQL'scross join
-
where
FilterQueryable
instance via some condition, similar to SQL'swhere
- Parameters:
filter
- the filter condition- Returns:
- filter result
- Since:
- 4.0.0
-
groupBy
Queryable<Tuple2<?,Queryable<T>>> groupBy(Function<? super T, ?> classifier, Predicate<? super Tuple2<?, Queryable<? extends T>>> having) Group byQueryable
instance, similar to SQL'sgroup by
- Parameters:
classifier
- the classifier for group byhaving
- the filter condition- Returns:
- the result of group by
- Since:
- 4.0.0
-
groupBy
- Parameters:
classifier
- the classifier for group by- Returns:
- the result of group by
- Since:
- 4.0.0
-
orderBy
<U extends Comparable<? super U>> Queryable<T> orderBy(Queryable.Order<? super T, ? extends U>... orders) SortQueryable
instance, similar to SQL'sorder by
- Type Parameters:
U
- the type of field to sort- Parameters:
orders
- the order rules for sorting- Returns:
- the result of order by
- Since:
- 4.0.0
-
orderBy
default <U extends Comparable<? super U>> Queryable<T> orderBy(List<? extends Queryable.Order<? super T, ? extends U>> orders) SortQueryable
instance, similar to SQL'sorder by
- Type Parameters:
U
- the type of field to sort- Parameters:
orders
- the order rules for sorting- Returns:
- the result of order by
- Since:
- 4.0.0
-
limit
PaginateQueryable
instance, similar to MySQL'slimit
- Parameters:
offset
- the start positionsize
- the size to take- Returns:
- the result of paginating
- Since:
- 4.0.0
-
limit
PaginateQueryable
instance, similar to MySQL'slimit
- Parameters:
size
- the size to take- Returns:
- the result of paginating
- Since:
- 4.0.0
-
select
ProjectQueryable
instance, similar to SQL'sselect
- Type Parameters:
U
- the type of project record- Parameters:
mapper
- project fields- Returns:
- the result of projecting
- Since:
- 4.0.0
-
exists
default boolean exists()Check if the result is empty, similar to SQL'sexists
- Returns:
- the result of checking,
true
if result is not empty, otherwisefalse
-
distinct
Eliminate duplicated records, similar to SQL'sdistinct
- Returns:
- the distinct result
- Since:
- 4.0.0
-
union
Union anotherQueryable
instance, similar to SQL'sunion
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the union result
- Since:
- 4.0.0
-
unionAll
Union all anotherQueryable
instance, similar to SQL'sunion all
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the union all result
- Since:
- 4.0.0
-
intersect
Intersect anotherQueryable
instance, similar to SQL'sintersect
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the intersect result
- Since:
- 4.0.0
-
minus
Minus anotherQueryable
instance, similar to SQL'sminus
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the minus result
- Since:
- 4.0.0
-
count
Long count()Aggregate functioncount
, similar to SQL'scount
- Returns:
- count result
- Since:
- 4.0.0
-
count
Aggregate functioncount
, similar to SQL'scount
Note: if the chosen field isnull
, the field will not be counted- Parameters:
mapper
- choose the field to count- Returns:
- count result
- Since:
- 4.0.0
-
sum
Aggregate functionsum
, similar to SQL'ssum
- Parameters:
mapper
- choose the field to sum- Returns:
- sum result
- Since:
- 4.0.0
-
avg
Aggregate functionavg
, similar to SQL'savg
- Parameters:
mapper
- choose the field to calculate the average- Returns:
- avg result
- Since:
- 4.0.0
-
min
Aggregate functionmin
, similar to SQL'smin
- Type Parameters:
U
- the field type- Parameters:
mapper
- choose the field to find the minimum- Returns:
- min result
- Since:
- 4.0.0
-
max
Aggregate functionmax
, similar to SQL'smax
- Type Parameters:
U
- the field type- Parameters:
mapper
- choose the field to find the maximum- Returns:
- min result
- Since:
- 4.0.0
-
list
Aggregate functionlist
. There is no equivalent in standard SQL but various databases support a similar concept named:list
,listagg
, orarray_agg
.- Type Parameters:
U
- the field type- Parameters:
mapper
- choose the field to include in the list- Returns:
- aggregate list result
- Since:
- 4.0.14
-
median
Aggregate functionmedian
, similar to SQL'smedian
- Parameters:
mapper
- choose the field to median- Returns:
- median result
- Since:
- 4.0.0
-
stdev
Aggregate functionstdev
, similar to SQL'sstdev
- Parameters:
mapper
- choose the field to calculate the statistical standard deviation- Returns:
- statistical standard deviation
- Since:
- 4.0.0
-
stdevp
Aggregate functionstdevp
, similar to SQL'sstdevp
- Parameters:
mapper
- choose the field to calculate the statistical standard deviation for the population- Returns:
- statistical standard deviation for the population
- Since:
- 4.0.0
-
var
Aggregate functionvar
, similar to SQL'svar
- Parameters:
mapper
- choose the field to calculate the statistical variance- Returns:
- statistical variance
- Since:
- 4.0.0
-
varp
Aggregate functionvarp
, similar to SQL'svarp
- Parameters:
mapper
- choose the field to calculate the statistical variance for the population- Returns:
- statistical variance for the population
- Since:
- 4.0.0
-
agg
The most powerful aggregate function in GINQ, it will receive the grouped result(Queryable
instance) and apply any processing- Type Parameters:
U
- the type aggregate result- Parameters:
mapper
- map the grouped result(Queryable
instance) to aggregate result- Returns:
- aggregate result
- Since:
- 4.0.0
-
toList
- Returns:
- the result list
- Since:
- 4.0.0
-
size
long size()Returns the count of elements of theQueryable
instance- Returns:
- the count of elements of the
Queryable
instance - Since:
- 4.0.0
-
stream
- Returns:
- the result stream
- Since:
- 4.0.0
-
over
<U extends Comparable<? super U>> Window<T> over(Tuple2<T, Long> currentRecord, WindowDefinition<T, U> windowDefinition) Open window for current record- Type Parameters:
U
- the type of window value- Parameters:
currentRecord
- current recordwindowDefinition
- window definition- Returns:
- the window
-