Interface PageStore
-
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
FilePageStore,FilePageStoreV2
public interface PageStore extends Closeable
Persistent store of pages.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddWriteListener(PageWriteListener lsnr)longallocatePage()Allocates next page index.voidbeginRecover()Starts recover process.voidensure()booleanexists()Checks if page exists.voidfinishRecover()Ends recover process.intgetBlockSize()intgetPageSize()longgetSparseSize()longpageOffset(long pageId)Gets page offset within the store file.intpages()Gets number of allocated pages.voidpunchHole(long pageId, int usefulBytes)Should free all the extra storage space after the given number of useful bytes in the given page.booleanread(long pageId, ByteBuffer pageBuf, boolean keepCrc)Reads a page.voidreadHeader(ByteBuffer buf)Reads a header.voidremoveWriteListener(PageWriteListener lsnr)longsize()voidstop(boolean cleanFile)voidsync()Sync method used to ensure that the given pages are guaranteed to be written to the store.voidtruncate(int tag)Truncates and deletes partition file.intversion()voidwrite(long pageId, ByteBuffer pageBuf, int tag, boolean calculateCrc)Writes a page.
-
-
-
Field Detail
-
TYPE_DATA
static final byte TYPE_DATA
Type for regular affinity partitions.- See Also:
- Constant Field Values
-
TYPE_IDX
static final byte TYPE_IDX
Type for index partition.- See Also:
- Constant Field Values
-
-
Method Detail
-
addWriteListener
void addWriteListener(PageWriteListener lsnr)
- Parameters:
lsnr- Page write listener to set.
-
removeWriteListener
void removeWriteListener(PageWriteListener lsnr)
- Parameters:
lsnr- Page write listener to remove.
-
exists
boolean exists()
Checks if page exists.- Returns:
Trueif page exists.
-
allocatePage
long allocatePage() throws IgniteCheckedExceptionAllocates next page index.- Returns:
- Next page index.
- Throws:
IgniteCheckedException- If failed to allocate.
-
pages
int pages()
Gets number of allocated pages.- Returns:
- Number of allocated pages.
-
read
boolean read(long pageId, ByteBuffer pageBuf, boolean keepCrc) throws IgniteCheckedExceptionReads a page.- Parameters:
pageId- Page ID.pageBuf- Page buffer to read into.keepCrc- by default reading zeroes CRC which was on file, but you can keep it in pageBuf if set keepCrc- Returns:
trueif page has been read successfully,falseif page hasn't been written yet.- Throws:
IgniteCheckedException- If reading failed (IO error occurred).
-
readHeader
void readHeader(ByteBuffer buf) throws IgniteCheckedException
Reads a header.- Parameters:
buf- Buffer to write to.- Throws:
IgniteCheckedException- If failed.
-
write
void write(long pageId, ByteBuffer pageBuf, int tag, boolean calculateCrc) throws IgniteCheckedExceptionWrites a page.- Parameters:
pageId- Page ID.pageBuf- Page buffer to write.tag- Partition file version, 1-based incrementing counter. For outdated pagestaghas lower value, and write does nothing.calculateCrc- ifFalsecrc calculation will be forcibly skipped.- Throws:
IgniteCheckedException- If page writing failed (IO error occurred).
-
pageOffset
long pageOffset(long pageId)
Gets page offset within the store file.- Parameters:
pageId- Page ID.- Returns:
- Page offset.
-
sync
void sync() throws IgniteCheckedException
Sync method used to ensure that the given pages are guaranteed to be written to the store.- Throws:
IgniteCheckedException- If sync failed (IO error occurred).
-
ensure
void ensure() throws IgniteCheckedException- Throws:
IgniteCheckedException- If sync failed (IO error occurred).
-
version
int version()
- Returns:
- Page store version.
-
stop
void stop(boolean cleanFile) throws StorageException
- Parameters:
cleanFile-Trueto delete file.- Throws:
StorageException- If failed.
-
beginRecover
void beginRecover()
Starts recover process.
-
finishRecover
void finishRecover() throws StorageExceptionEnds recover process.- Throws:
StorageException- If failed.
-
truncate
void truncate(int tag) throws StorageExceptionTruncates and deletes partition file.- Parameters:
tag- New partition tag.- Throws:
StorageException- If failed.
-
getPageSize
int getPageSize()
- Returns:
- Page size in bytes.
-
getBlockSize
int getBlockSize()
- Returns:
- Storage block size or negative value if unknown or not supported.
-
size
long size()
- Returns:
- Size of the storage in bytes. May differ from
pages()*getPageSize()due to delayed writes or due to other implementation specific details.
-
getSparseSize
long getSparseSize()
- Returns:
- Size of the storage adjusted for sparsity in bytes or negative
value if not supported. Should be less than or equal to
size(). - See Also:
punchHole(long, int)
-
punchHole
void punchHole(long pageId, int usefulBytes)Should free all the extra storage space after the given number of useful bytes in the given page.- Parameters:
pageId- Page id.usefulBytes- Number of meaningful bytes from the beginning of the page.
-
-