Interface NarrowedPageable

  • All Superinterfaces:
    org.springframework.data.domain.Pageable, UnnumberedPageable
    All Known Implementing Classes:
    DefaultNarrowedPageable

    public interface NarrowedPageable
    extends UnnumberedPageable
    Pageable that is suitable for denoting page boundaries for a narrowed fetch. Narrowed fetch results generally go through a NarrowExecutor, and as a result, can provide a narrowed result set from what is physically represented in the database. For this reason, it is important to keep track of a silent getUnderlyingPageSize() when determining next page offset values. For example, next page offset is generally calculated as the current offset plus the underlyingPageSize.

    An example API request containing a Pageable param could start off with these params for the first page:

    • forward : true
    • offset : 0
    • size : 2
    This should result in a page of records with at most 2 members. However, the response contains some additional parameters (e.g. in a JSON payload)
    • underlyingSize : 3
    • numberOfElements : 2
    • first : true
    This response would indicate that the Page of records returned was actually narrowed to 2 records from 3 physical records in the database. As a result, the next page of records would be:
    • forward : true
    • offset : 3
    • size : 2

    A backward NarrowedPageable request should always pivot off the current offset. This means that to go backward for the current page, you would keep the current offset, but reverse the direction:

    • forward : false
    • offset : 3
    • size : 2
    The resulting Page of records should yield at most two records in the reverse direction from offset 3. In fact, this should result in the same response for the first page of records (Note again that we've traversed 3 physical records to result in a reverse page result size of 2).
    • underlyingSize : 3
    • numberOfElements : 2
    • first : true
    Author:
    Jeff Fischer
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getUnderlyingPageSize()
      The number of physical database records processed.
      boolean isForward()
      Whether or not the current NarrowedPageable request represents a forward progression, or a backwards progression.
      void setUnderlyingPageSize​(int underlyingPageSize)
      The number of physical database records processed.
      • Methods inherited from interface org.springframework.data.domain.Pageable

        first, getOffset, getPageSize, getSort, getSortOr, hasPrevious, isPaged, isUnpaged, next, previousOrFirst, toOptional
    • Method Detail

      • getUnderlyingPageSize

        int getUnderlyingPageSize()
        The number of physical database records processed. This can be different than the narrowed records returned in a page.
        Returns:
        The number of physical database records processed
      • setUnderlyingPageSize

        void setUnderlyingPageSize​(int underlyingPageSize)
        The number of physical database records processed. This can be different than the narrowed records returned in a page in the case of a query against items that need to be narrowed. In the case of a query that is not being narrowed, this will always be equal to Pageable.getPageSize()
        Parameters:
        underlyingPageSize - The number of physical database records processed
      • isForward

        boolean isForward()
        Whether or not the current NarrowedPageable request represents a forward progression, or a backwards progression.
        Returns:
        Whether or not the response page records should be in advance of the offset, or behind the offset.