Class PageAware

java.lang.Object
org.apache.cassandra.io.util.PageAware

public final class PageAware extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    bytesLeftInPage(long dstPos)
    Calculate the number of bytes left in this page.
    static int
    numPages(int size)
    Calculate the number of pages that fit in the given size, rounded up to a page if the size is not an exact multiple.
    static void
    Pad the given output stream with zeroes until the next page boundary.
    static long
    padded(long dstPos)
    Calculate the earliest page boundary for the given position.
    static long
    pageLimit(long dstPos)
    Calculate the end of the page identified by the given position.
    static int
    pageNum(long dstPos)
    Given a position relative to the start of a number of pages, determine the exact page number this position falls into.
    static long
    pageStart(long dstPos)
    Calculate the start of the page that contains the given position.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PAGE_SIZE

      public static final int PAGE_SIZE
      See Also:
    • PAGE_SIZE_SHIFT

      public static final int PAGE_SIZE_SHIFT
  • Constructor Details

    • PageAware

      public PageAware()
  • Method Details

    • pageLimit

      public static long pageLimit(long dstPos)
      Calculate the end of the page identified by the given position. Equivalent to floor(dstPos / PAGE_SIZE + 1) * PAGE_SIZE.

      When the argument is equal to the page boundary, returns the next page boundary. E.g. pageLimit(0) == PAGE_SIZE.

    • pageStart

      public static long pageStart(long dstPos)
      Calculate the start of the page that contains the given position. Equivalent to floor(dstPos / PAGE_SIZE) * PAGE_SIZE.
    • padded

      public static long padded(long dstPos)
      Calculate the earliest page boundary for the given position. Equivalent to ceil(dstPos / PAGE_SIZE) * PAGE_SIZE.

      When the argument is equal to a page boundary, returns the argument.

    • bytesLeftInPage

      public static int bytesLeftInPage(long dstPos)
      Calculate the number of bytes left in this page. Equivalent to pageLimit(position) - position.

      When the argument is equal to a page boundary, returns PAGE_SIZE.

    • numPages

      public static int numPages(int size)
      Calculate the number of pages that fit in the given size, rounded up to a page if the size is not an exact multiple.
      Parameters:
      size - the size that needs to cover a number of pages
      Returns:
      the number of pages, rounded up
    • pageNum

      public static int pageNum(long dstPos)
      Given a position relative to the start of a number of pages, determine the exact page number this position falls into. For example, positions from 0 to PAGE_SIZE -1 will fall into page zero and so forth.
      Parameters:
      dstPos - the position
      Returns:
      the page number, indexed at zero
    • pad

      public static void pad(DataOutputPlus dest) throws IOException
      Pad the given output stream with zeroes until the next page boundary. If the destination position is already at a page boundary, do not do anything.
      Throws:
      IOException