Interface Queryable<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Queryable.Order<T,U extends Comparable<? super U>>
Represents an order rule
-
Field Summary
Fields Modifier and Type Field Description static Queryable
EMPTY_QUERYABLE
Represents the empty Queryable instancestatic Object
NULL
Represents null of GINQ, it could be used as the default group field
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <U> U
agg(Function<? super Queryable<? extends T>,? extends U> mapper)
The most powerful aggregate function in GINQ, it will receive the grouped result(Queryable
instance) and apply any processingBigDecimal
avg(Function<? super T,? extends Number> mapper)
Aggregate functionavg
, similar to SQL'savg
Long
count()
Aggreate functioncount
, similar to SQL'scount
<U> Long
count(Function<? super T,? extends U> mapper)
Aggregate functioncount
, similar to SQL'scount
Note: if the chosen field isnull
, the field will not be counted<U> Queryable<Tuple2<T,U>>
crossJoin(Queryable<? extends U> queryable)
Cross join anotherQueryable
instance, similar to SQL'scross join
Queryable<T>
distinct()
Eliminate duplicated records, similar to SQL'sdistinct
static <T> Queryable<T>
emptyQueryable()
Returns the empty Queryable instancedefault boolean
exists()
Check if the result is empty, similar to SQL'sexists
static <T> Queryable<T>
from(Iterable<T> iterable)
Factory method to createQueryable
instancestatic <T> Queryable<T>
from(Stream<T> sourceStream)
Factory method to createQueryable
instancestatic <T> Queryable<T>
from(Queryable<T> queryable)
Returns the originalQueryable
instance directlystatic <T> Queryable<T>
from(T[] array)
Factory method to createQueryable
instance<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
<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
default Queryable<Tuple2<?,Queryable<T>>>
groupBy(Function<? super T,?> classifier)
Queryable<Tuple2<?,Queryable<T>>>
groupBy(Function<? super T,?> classifier, Predicate<? super Tuple2<?,Queryable<? extends T>>> having)
Group byQueryable
instance, similar to SQL'sgroup by
<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
.<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
Queryable<T>
intersect(Queryable<? extends T> queryable)
Intersect anotherQueryable
instance, similar to SQL'sintersect
<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
<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
default Queryable<T>
limit(long size)
PaginateQueryable
instance, similar to MySQL'slimit
Queryable<T>
limit(long offset, long size)
PaginateQueryable
instance, similar to MySQL'slimit
<U extends Comparable<? super U>>
Umax(Function<? super T,? extends U> mapper)
Aggregate functionmax
, similar to SQL'smax
BigDecimal
median(Function<? super T,? extends Number> mapper)
Aggregate functionmedian
, similar to SQL'smedian
<U extends Comparable<? super U>>
Umin(Function<? super T,? extends U> mapper)
Aggregate functionmin
, similar to SQL'smin
Queryable<T>
minus(Queryable<? extends T> queryable)
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>over(Tuple2<T,Long> currentRecord, WindowDefinition<T,U> windowDefinition)
Open window for current record<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
<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
<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
instanceBigDecimal
stdev(Function<? super T,? extends Number> mapper)
Aggregate functionstdev
, similar to SQL'sstdev
BigDecimal
stdevp(Function<? super T,? extends Number> mapper)
Aggregate functionstdevp
, similar to SQL'sstdevp
default Stream<T>
stream()
BigDecimal
sum(Function<? super T,? extends Number> mapper)
Aggregate functionsum
, similar to SQL'ssum
List<T>
toList()
default Queryable<T>
union(Queryable<? extends T> queryable)
Union anotherQueryable
instance, similar to SQL'sunion
Queryable<T>
unionAll(Queryable<? extends T> queryable)
Union all anotherQueryable
instance, similar to SQL'sunion all
BigDecimal
var(Function<? super T,? extends Number> mapper)
Aggregate functionvar
, similar to SQL'svar
BigDecimal
varp(Function<? super T,? extends Number> mapper)
Aggregate functionvarp
, similar to SQL'svarp
Queryable<T>
where(Predicate<? super T> filter)
FilterQueryable
instance via some condition, similar to SQL'swhere
-
-
-
Method Detail
-
emptyQueryable
static <T> Queryable<T> emptyQueryable()
Returns the empty Queryable instance- Type Parameters:
T
- the type of element- Returns:
- the empty Queryable instance
- Since:
- 4.0.0
-
from
static <T> Queryable<T> from(Iterable<T> iterable)
Factory method to createQueryable
instance
-
from
static <T> Queryable<T> from(T[] array)
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
static <T> Queryable<T> from(Stream<T> sourceStream)
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
static <T> Queryable<T> from(Queryable<T> queryable)
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
<U> Queryable<Tuple2<T,U>> crossJoin(Queryable<? extends U> queryable)
Cross join anotherQueryable
instance, similar to SQL'scross join
-
where
Queryable<T> where(Predicate<? super T> filter)
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
default Queryable<Tuple2<?,Queryable<T>>> groupBy(Function<? super T,?> classifier)
- 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
Queryable<T> limit(long offset, long size)
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
default Queryable<T> limit(long size)
PaginateQueryable
instance, similar to MySQL'slimit
- Parameters:
size
- the size to take- Returns:
- the result of paginating
- Since:
- 4.0.0
-
select
<U> Queryable<U> select(BiFunction<? super T,? super Queryable<? extends T>,? extends U> mapper)
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
Queryable<T> distinct()
Eliminate duplicated records, similar to SQL'sdistinct
- Returns:
- the distinct result
- Since:
- 4.0.0
-
union
default Queryable<T> union(Queryable<? extends T> queryable)
Union anotherQueryable
instance, similar to SQL'sunion
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the union result
- Since:
- 4.0.0
-
unionAll
Queryable<T> unionAll(Queryable<? extends T> queryable)
Union all anotherQueryable
instance, similar to SQL'sunion all
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the union all result
- Since:
- 4.0.0
-
intersect
Queryable<T> intersect(Queryable<? extends T> queryable)
Intersect anotherQueryable
instance, similar to SQL'sintersect
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the intersect result
- Since:
- 4.0.0
-
minus
Queryable<T> minus(Queryable<? extends T> queryable)
Minus anotherQueryable
instance, similar to SQL'sminus
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the minus result
- Since:
- 4.0.0
-
count
Long count()
Aggreate functioncount
, similar to SQL'scount
- Returns:
- count result
- Since:
- 4.0.0
-
count
<U> Long count(Function<? super T,? extends U> mapper)
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
BigDecimal sum(Function<? super T,? extends Number> mapper)
Aggregate functionsum
, similar to SQL'ssum
- Parameters:
mapper
- choose the field to sum- Returns:
- sum result
- Since:
- 4.0.0
-
avg
BigDecimal avg(Function<? super T,? extends Number> mapper)
Aggregate functionavg
, similar to SQL'savg
- Parameters:
mapper
- choose the field to calculate the average- Returns:
- avg result
- Since:
- 4.0.0
-
min
<U extends Comparable<? super U>> U min(Function<? super T,? extends U> mapper)
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
<U extends Comparable<? super U>> U max(Function<? super T,? extends U> mapper)
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
-
median
BigDecimal median(Function<? super T,? extends Number> mapper)
Aggregate functionmedian
, similar to SQL'smedian
- Parameters:
mapper
- choose the field to median- Returns:
- median result
- Since:
- 4.0.0
-
stdev
BigDecimal stdev(Function<? super T,? extends Number> mapper)
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
BigDecimal stdevp(Function<? super T,? extends Number> mapper)
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
BigDecimal var(Function<? super T,? extends Number> mapper)
Aggregate functionvar
, similar to SQL'svar
- Parameters:
mapper
- choose the field to calculate the statistical variance- Returns:
- statistical variance
- Since:
- 4.0.0
-
varp
BigDecimal varp(Function<? super T,? extends Number> mapper)
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
<U> U agg(Function<? super Queryable<? extends T>,? extends U> mapper)
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
-
size
long size()
Returns the count of elements of theQueryable
instance- Returns:
- the count of elements of the
Queryable
instance - 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
-
-