Class DefaultLimitSpec

java.lang.Object
org.apache.druid.query.groupby.orderby.DefaultLimitSpec
All Implemented Interfaces:
Cacheable, LimitSpec

public class DefaultLimitSpec extends Object implements LimitSpec
  • Constructor Details

  • Method Details

    • builder

      public static DefaultLimitSpec.Builder builder()
    • sortingOrderHasNonGroupingFields

      public static boolean sortingOrderHasNonGroupingFields(DefaultLimitSpec limitSpec, List<DimensionSpec> dimensions)
      Check if a limitSpec has columns in the sorting order that are not part of the grouping fields represented by `dimensions`.
      Parameters:
      limitSpec - LimitSpec, assumed to be non-null
      dimensions - Grouping fields for a groupBy query
      Returns:
      True if limitSpec has sorting columns not contained in dimensions
    • getComparatorForDimName

      public static StringComparator getComparatorForDimName(DefaultLimitSpec limitSpec, String dimName)
    • getColumns

      public List<OrderByColumnSpec> getColumns()
    • getOffset

      public int getOffset()
      Offset for this query; behaves like SQL "OFFSET". Zero means no offset. Negative values are invalid.
    • getLimit

      public int getLimit()
      Limit for this query; behaves like SQL "LIMIT". Will always be positive. Integer.MAX_VALUE is used in situations where the user wants an effectively unlimited result set.
    • isOffset

      public boolean isOffset()
    • isLimited

      public boolean isLimited()
    • build

      public com.google.common.base.Function<Sequence<ResultRow>,Sequence<ResultRow>> build(GroupByQuery query)
      Description copied from interface: LimitSpec
      Returns a function that applies a limit to an input sequence that is assumed to be sorted on dimensions.
      Specified by:
      build in interface LimitSpec
      Parameters:
      query - the query that this limit spec belongs to
      Returns:
      limit function
    • filterColumns

      public LimitSpec filterColumns(Set<String> names)
      Description copied from interface: LimitSpec
      Discard sorting columns not contained in given set. This is used when generating new queries, e.g. to process subtotal spec in GroupBy query.
      Specified by:
      filterColumns in interface LimitSpec
      Parameters:
      names - columns names to keep
      Returns:
      new LimitSpec that works with fitlered set of columns
    • withOffsetToLimit

      public DefaultLimitSpec withOffsetToLimit()
      Returns a new DefaultLimitSpec identical to this one except for one difference: an offset parameter, if any, will be removed and added to the limit. This is designed for passing down queries to lower levels of the stack. Only the highest level should apply the offset parameter, and any pushed-down limits must be increased to accommodate the offset.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getCacheKey

      public byte[] getCacheKey()
      Description copied from interface: Cacheable
      Get a byte array used as a cache key.
      Specified by:
      getCacheKey in interface Cacheable
      Returns:
      bytes to be used as cache key - or null if this object should not be cached.