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
Nested ClassesModifier and TypeInterfaceDescriptionstatic classQueryable.Order<T,U extends Comparable<? super U>> Represents an order rule -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<U> UThe most powerful aggregate function in GINQ, it will receive the grouped result(Queryableinstance) and apply any processingAggregate functionavg, similar to SQL'savgcount()Aggreate functioncount, similar to SQL'scount<U> LongAggregate functioncount, similar to SQL'scountNote: if the chosen field isnull, the field will not be countedCross join anotherQueryableinstance, similar to SQL'scross joindistinct()Eliminate duplicated records, similar to SQL'sdistinctstatic <T> Queryable<T>Returns the empty Queryable instancedefault booleanexists()Check if the result is empty, similar to SQL'sexistsstatic <T> Queryable<T>Factory method to createQueryableinstancestatic <T> Queryable<T>Factory method to createQueryableinstancestatic <T> Queryable<T>Returns the originalQueryableinstance directlystatic <T> Queryable<T>from(T[] array) Factory method to createQueryableinstancefullHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Full hash join anotherQueryableinstance, similar to SQL'sfull joinfullJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Full join anotherQueryableinstance, similar to SQL'sfull joingroupBy(Function<? super T, ?> classifier, Predicate<? super Tuple2<?, Queryable<? extends T>>> having) Group byQueryableinstance, similar to SQL'sgroup byinnerHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Inner hash join anotherQueryableinstance, similar to SQL'sinner hash join.innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Inner join anotherQueryableinstance, similar to SQL'sinner joinIntersect anotherQueryableinstance, similar to SQL'sintersectleftHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2) Left hash join anotherQueryableinstance, similar to SQL'sleft hash joinleftJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Left join anotherQueryableinstance, similar to SQL'sleft joinlimit(long size) PaginateQueryableinstance, similar to MySQL'slimitlimit(long offset, long size) PaginateQueryableinstance, similar to MySQL'slimit<U extends Comparable<? super U>>
UAggregate functionmax, similar to SQL'smaxAggregate functionmedian, similar to SQL'smedian<U extends Comparable<? super U>>
UAggregate functionmin, similar to SQL'sminMinus anotherQueryableinstance, similar to SQL'sminusdefault <U extends Comparable<? super U>>
Queryable<T>orderBy(List<? extends Queryable.Order<? super T, ? extends U>> orders) SortQueryableinstance, similar to SQL'sorder by<U extends Comparable<? super U>>
Queryable<T>orderBy(Queryable.Order<? super T, ? extends U>... orders) SortQueryableinstance, 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 anotherQueryableinstance, similar to SQL'sright joinrightJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Right join anotherQueryableinstance, similar to SQL'sright join<U> Queryable<U>select(BiFunction<? super T, ? super Queryable<? extends T>, ? extends U> mapper) ProjectQueryableinstance, similar to SQL'sselectlongsize()Returns the count of elements of theQueryableinstanceAggregate functionstdev, similar to SQL'sstdevAggregate functionstdevp, similar to SQL'sstdevpstream()Aggregate functionsum, similar to SQL'ssumtoList()Union anotherQueryableinstance, similar to SQL'sunionUnion all anotherQueryableinstance, similar to SQL'sunion allAggregate functionvar, similar to SQL'svarAggregate functionvarp, similar to SQL'svarpFilterQueryableinstance 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 createQueryableinstance -
from
Factory method to createQueryableinstance- Type Parameters:
T- the type of element- Parameters:
array- array object- Returns:
- the
Queryableinstance - Since:
- 4.0.0
-
from
Factory method to createQueryableinstance- Type Parameters:
T- the type of element- Parameters:
sourceStream- stream object- Returns:
- the
Queryableinstance - Since:
- 4.0.0
-
from
Returns the originalQueryableinstance directly- Type Parameters:
T- the type of element- Parameters:
queryable- queryable object- Returns:
- the
Queryableinstance - Since:
- 4.0.0
-
innerJoin
<U> Queryable<Tuple2<T,U>> innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Inner join anotherQueryableinstance, 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 anotherQueryableinstance, 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 anotherQueryableinstance, 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 anotherQueryableinstance, 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 anotherQueryableinstance, 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 anotherQueryableinstance, similar to SQL'sright join -
fullJoin
<U> Queryable<Tuple2<T,U>> fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner) Full join anotherQueryableinstance, 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 anotherQueryableinstance, similar to SQL'sfull join -
crossJoin
Cross join anotherQueryableinstance, similar to SQL'scross join -
where
FilterQueryableinstance 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 byQueryableinstance, 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) SortQueryableinstance, 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) SortQueryableinstance, 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
PaginateQueryableinstance, similar to MySQL'slimit- Parameters:
offset- the start positionsize- the size to take- Returns:
- the result of paginating
- Since:
- 4.0.0
-
limit
PaginateQueryableinstance, similar to MySQL'slimit- Parameters:
size- the size to take- Returns:
- the result of paginating
- Since:
- 4.0.0
-
select
ProjectQueryableinstance, 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,
trueif result is not empty, otherwisefalse
-
distinct
Eliminate duplicated records, similar to SQL'sdistinct- Returns:
- the distinct result
- Since:
- 4.0.0
-
union
Union anotherQueryableinstance, similar to SQL'sunion- Parameters:
queryable- the otherQueryableinstance- Returns:
- the union result
- Since:
- 4.0.0
-
unionAll
Union all anotherQueryableinstance, similar to SQL'sunion all- Parameters:
queryable- the otherQueryableinstance- Returns:
- the union all result
- Since:
- 4.0.0
-
intersect
Intersect anotherQueryableinstance, similar to SQL'sintersect- Parameters:
queryable- the otherQueryableinstance- Returns:
- the intersect result
- Since:
- 4.0.0
-
minus
Minus anotherQueryableinstance, similar to SQL'sminus- Parameters:
queryable- the otherQueryableinstance- 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
Aggregate functioncount, similar to SQL'scountNote: 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
-
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(Queryableinstance) and apply any processing- Type Parameters:
U- the type aggregate result- Parameters:
mapper- map the grouped result(Queryableinstance) 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 theQueryableinstance- Returns:
- the count of elements of the
Queryableinstance - 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
-