org.apache.ignite.internal.pagemem.store

## Interface PageStore

All Superinterfaces:
  AutoCloseable, Closeable

All Known Implementing Classes:
  FilePageStore, FilePageStoreV2

    public interface PageStore
    extends Closeable

Persistent store of pages.

### Field Summary

Fields
`static byte` `TYPE_DATA` Type for regular affinity partitions.
`static byte` `TYPE_IDX` Type for index partition.

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `addWriteListener(PageWriteListener lsnr)`
`long` `allocatePage()` Allocates next page index.
`void` `beginRecover()` Starts recover process.
`void` `ensure()`
`boolean` `exists()` Checks if page exists.
`void` `finishRecover()` Ends recover process.
`int` `getBlockSize()`
`int` `getPageSize()`
`long` `getSparseSize()`
`long` `pageOffset(long pageId)` Gets page offset within the store file.
`int` `pages()` Gets number of allocated pages.
`void` `punchHole(long pageId, int usefulBytes)` Should free all the extra storage space after the given number of useful bytes in the given page.
`boolean` `read(long pageId, ByteBuffer pageBuf, boolean keepCrc)` Reads a page.
`void` `readHeader(ByteBuffer buf)` Reads a header.
`void` `removeWriteListener(PageWriteListener lsnr)`
`long` `size()`
`void` `stop(boolean cleanFile)`
`void` `sync()` Sync method used to ensure that the given pages are guaranteed to be written to the store.
`void` `truncate(int tag)` Truncates and deletes partition file.
`int` `version()`
`void` `write(long pageId, ByteBuffer pageBuf, int tag, boolean calculateCrc)` Writes a page.

### Methods inherited from interface java.io.Closeable

`close`

### 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:
  `True` if page exists.

#### allocatePage

    long allocatePage()
               throws IgniteCheckedException

Allocates 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 IgniteCheckedException

Reads 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:
  `true` if page has been read successfully, `false` if 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 IgniteCheckedException

Writes a page.

Parameters:
  `pageId` - Page ID.
  `pageBuf` - Page buffer to write.
  `tag` - Partition file version, 1-based incrementing counter. For outdated pages `tag` has lower value, and write does nothing.
  `calculateCrc` - if `False` crc 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` - `True` to delete file.
Throws:
  `StorageException` - If failed.

#### beginRecover

    void beginRecover()

Starts recover process.

#### finishRecover

    void finishRecover()
                throws StorageException

Ends recover process.

Throws:
  `StorageException` - If failed.

#### truncate

    void truncate(int tag)
           throws StorageException

Truncates 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.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.14.0
Release Date | : September 29 2022