Class DefaultLimitSpec
- java.lang.Object
-
- org.apache.druid.query.groupby.orderby.DefaultLimitSpec
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultLimitSpec.Builderstatic classDefaultLimitSpec.LimitJsonIncludeFilterJsonIncludefilter forgetLimit().
-
Constructor Summary
Constructors Constructor Description DefaultLimitSpec(List<OrderByColumnSpec> columns, Integer limit)Constructor that does not accept "offset".DefaultLimitSpec(List<OrderByColumnSpec> columns, Integer offset, Integer limit)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.base.Function<Sequence<ResultRow>,Sequence<ResultRow>>build(GroupByQuery query)Returns a function that applies a limit to an input sequence that is assumed to be sorted on dimensions.static DefaultLimitSpec.Builderbuilder()booleanequals(Object o)LimitSpecfilterColumns(Set<String> names)Discard sorting columns not contained in given set.byte[]getCacheKey()Get a byte array used as a cache key.List<OrderByColumnSpec>getColumns()static StringComparatorgetComparatorForDimName(DefaultLimitSpec limitSpec, String dimName)intgetLimit()Limit for this query; behaves like SQL "LIMIT".intgetOffset()Offset for this query; behaves like SQL "OFFSET".inthashCode()booleanisLimited()booleanisOffset()static booleansortingOrderHasNonGroupingFields(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`.StringtoString()DefaultLimitSpecwithOffsetToLimit()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.
-
-
-
Constructor Detail
-
DefaultLimitSpec
public DefaultLimitSpec(List<OrderByColumnSpec> columns, Integer offset, Integer limit)
-
DefaultLimitSpec
public DefaultLimitSpec(List<OrderByColumnSpec> columns, Integer limit)
Constructor that does not accept "offset". Useful for tests that only want to provide "columns" and "limit".
-
-
Method Detail
-
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-nulldimensions- 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_VALUEis 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:LimitSpecReturns a function that applies a limit to an input sequence that is assumed to be sorted on dimensions.
-
filterColumns
public LimitSpec filterColumns(Set<String> names)
Description copied from interface:LimitSpecDiscard 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:
filterColumnsin interfaceLimitSpec- 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.
-
getCacheKey
public byte[] getCacheKey()
Description copied from interface:CacheableGet a byte array used as a cache key.- Specified by:
getCacheKeyin interfaceCacheable- Returns:
- a cache key
-
-