Interface Queryable<T>

Type Parameters:
T - the type of Queryable element
All Known Subinterfaces:
Group<T>, Partition<T>, Window<T>

public interface Queryable<T>
Represents the queryable objects, e.g. Java collections
Since:
4.0.0
  • Field Details

    • NULL

      static final Object NULL
      Represents null of GINQ, e.g. it could be used as the default group field
      Since:
      4.0.0
    • EMPTY_QUERYABLE

      static final Queryable EMPTY_QUERYABLE
      Represents the empty Queryable instance
      Since:
      4.0.0
  • Method Details

    • 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 create Queryable instance
      Type Parameters:
      T - the type of element
      Parameters:
      iterable - iterable object, e.g. List
      Returns:
      the Queryable instance
      Since:
      4.0.0
    • from

      static <T> Queryable<T> from(T[] array)
      Factory method to create Queryable 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 create Queryable 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 original Queryable 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 another Queryable instance, similar to SQL's inner join
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      joiner - join condition
      Returns:
      the join result
      Since:
      4.0.0
    • innerHashJoin

      <U> Queryable<Tuple2<T,U>> innerHashJoin(Queryable<? extends U> queryable, Function<? super T,?> fieldsExtractor1, Function<? super U,?> fieldsExtractor2)
      Inner hash join another Queryable instance, similar to SQL's inner hash join. Note: Inner hash join requires equijoin predicate, e.g. on a == b
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      fieldsExtractor1 - extract fields of one data source
      fieldsExtractor2 - extract fields of the other data source
      Returns:
      the join result
      Since:
      4.0.0
    • leftJoin

      <U> Queryable<Tuple2<T,U>> leftJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
      Left join another Queryable instance, similar to SQL's left join
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      joiner - join condition
      Returns:
      the join result
      Since:
      4.0.0
    • leftHashJoin

      <U> Queryable<Tuple2<T,U>> leftHashJoin(Queryable<? extends U> queryable, Function<? super T,?> fieldsExtractor1, Function<? super U,?> fieldsExtractor2)
      Left hash join another Queryable instance, similar to SQL's left hash join
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      fieldsExtractor1 - extract fields of one data source
      fieldsExtractor2 - extract fields of the other data source
      Returns:
      the join result
      Since:
      4.0.0
    • rightJoin

      <U> Queryable<Tuple2<T,U>> rightJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
      Right join another Queryable instance, similar to SQL's right join
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      joiner - join condition
      Returns:
      the join result
      Since:
      4.0.0
    • rightHashJoin

      <U> Queryable<Tuple2<T,U>> rightHashJoin(Queryable<? extends U> queryable, Function<? super T,?> fieldsExtractor1, Function<? super U,?> fieldsExtractor2)
      Right hash join another Queryable instance, similar to SQL's right join
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      fieldsExtractor1 - extract fields of one data source
      fieldsExtractor2 - extract fields of the other data source
      Returns:
      the join result
      Since:
      4.0.0
    • fullJoin

      <U> Queryable<Tuple2<T,U>> fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
      Full join another Queryable instance, similar to SQL's full join
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      joiner - join condition
      Returns:
      the join result
      Since:
      4.0.0
    • fullHashJoin

      <U> Queryable<Tuple2<T,U>> fullHashJoin(Queryable<? extends U> queryable, Function<? super T,?> fieldsExtractor1, Function<? super U,?> fieldsExtractor2)
      Full hash join another Queryable instance, similar to SQL's full join
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      fieldsExtractor1 - extract fields of one data source
      fieldsExtractor2 - extract fields of the other data source
      Returns:
      the join result
      Since:
      4.0.0
    • crossJoin

      <U> Queryable<Tuple2<T,U>> crossJoin(Queryable<? extends U> queryable)
      Cross join another Queryable instance, similar to SQL's cross join
      Type Parameters:
      U - the type of element from another Queryable instance
      Parameters:
      queryable - another Queryable instance
      Returns:
      the join result
      Since:
      4.0.0
    • where

      Queryable<T> where(Predicate<? super T> filter)
      Filter Queryable instance via some condition, similar to SQL's where
      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 by Queryable instance, similar to SQL's group by
      Parameters:
      classifier - the classifier for group by
      having - the filter condition
      Returns:
      the result of group by
      Since:
      4.0.0
    • groupBy

      default Queryable<Tuple2<?,Queryable<T>>> groupBy(Function<? super T,?> classifier)
      Group by Queryable instance without having clause, similar to SQL's group by
      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)
      Sort Queryable instance, similar to SQL's order 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)
      Sort Queryable instance, similar to SQL's order 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)
      Paginate Queryable instance, similar to MySQL's limit
      Parameters:
      offset - the start position
      size - the size to take
      Returns:
      the result of paginating
      Since:
      4.0.0
    • limit

      default Queryable<T> limit(long size)
      Paginate Queryable instance, similar to MySQL's limit
      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)
      Project Queryable instance, similar to SQL's select
      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's exists
      Returns:
      the result of checking, true if result is not empty, otherwise false
    • distinct

      Queryable<T> distinct()
      Eliminate duplicated records, similar to SQL's distinct
      Returns:
      the distinct result
      Since:
      4.0.0
    • union

      default Queryable<T> union(Queryable<? extends T> queryable)
      Union another Queryable instance, similar to SQL's union
      Parameters:
      queryable - the other Queryable instance
      Returns:
      the union result
      Since:
      4.0.0
    • unionAll

      Queryable<T> unionAll(Queryable<? extends T> queryable)
      Union all another Queryable instance, similar to SQL's union all
      Parameters:
      queryable - the other Queryable instance
      Returns:
      the union all result
      Since:
      4.0.0
    • intersect

      Queryable<T> intersect(Queryable<? extends T> queryable)
      Intersect another Queryable instance, similar to SQL's intersect
      Parameters:
      queryable - the other Queryable instance
      Returns:
      the intersect result
      Since:
      4.0.0
    • minus

      Queryable<T> minus(Queryable<? extends T> queryable)
      Minus another Queryable instance, similar to SQL's minus
      Parameters:
      queryable - the other Queryable instance
      Returns:
      the minus result
      Since:
      4.0.0
    • count

      Long count()
      Aggregate function count, similar to SQL's count
      Returns:
      count result
      Since:
      4.0.0
    • count

      <U> Long count(Function<? super T,? extends U> mapper)
      Aggregate function count, similar to SQL's count Note: if the chosen field is null, 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 function sum, similar to SQL's sum
      Parameters:
      mapper - choose the field to sum
      Returns:
      sum result
      Since:
      4.0.0
    • avg

      BigDecimal avg(Function<? super T,? extends Number> mapper)
      Aggregate function avg, similar to SQL's avg
      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 function min, similar to SQL's min
      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 function max, similar to SQL's max
      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 function median, similar to SQL's median
      Parameters:
      mapper - choose the field to median
      Returns:
      median result
      Since:
      4.0.0
    • stdev

      BigDecimal stdev(Function<? super T,? extends Number> mapper)
      Aggregate function stdev, similar to SQL's stdev
      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 function stdevp, similar to SQL's stdevp
      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 function var, similar to SQL's var
      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 function varp, similar to SQL's varp
      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
    • toList

      List<T> toList()
      Convert the Queryable instance to List<T> instance
      Returns:
      the result list
      Since:
      4.0.0
    • size

      long size()
      Returns the count of elements of the Queryable instance
      Returns:
      the count of elements of the Queryable instance
      Since:
      4.0.0
    • stream

      default Stream<T> stream()
      Create Stream<T> object for the Queryable instance
      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 record
      windowDefinition - window definition
      Returns:
      the window