Class DefaultLimitSpec

    • Constructor Detail

      • 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

      • 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
      • 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.
      • 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:
        a cache key