Package org.apache.cassandra.io.util
Class PageAware
java.lang.Object
org.apache.cassandra.io.util.PageAware
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intbytesLeftInPage(long dstPos) Calculate the number of bytes left in this page.static intnumPages(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 voidpad(DataOutputPlus dest) Pad the given output stream with zeroes until the next page boundary.static longpadded(long dstPos) Calculate the earliest page boundary for the given position.static longpageLimit(long dstPos) Calculate the end of the page identified by the given position.static intpageNum(long dstPos) Given a position relative to the start of a number of pages, determine the exact page number this position falls into.static longpageStart(long dstPos) Calculate the start of the page that contains the given position.
-
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 toPAGE_SIZE-1 will fall into page zero and so forth.- Parameters:
dstPos- the position- Returns:
- the page number, indexed at zero
-
pad
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
-