public class FilePageStore extends Object implements PageStore
| Modifier and Type | Field and Description |
|---|---|
protected DataStorageConfiguration |
dbCfg
Database configuration.
|
protected FileIO |
fileIO
I/O interface for read/write operations with file
|
static int |
HEADER_SIZE
Allocated field offset.
|
protected int |
pageSize |
static int |
VERSION
File version.
|
| Constructor and Description |
|---|
FilePageStore(byte type,
IgniteOutClosure<Path> pathProvider,
FileIOFactory factory,
DataStorageConfiguration cfg,
LongAdderMetric allocatedTracker) |
| Modifier and Type | Method and Description |
|---|---|
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() |
String |
getFileAbsolutePath() |
int |
getPageSize() |
long |
getSparseSize() |
ByteBuffer |
header(byte type,
int pageSize)
Creates header for current version file store.
|
int |
headerSize()
Size of page store header.
|
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.
|
void |
read(long pageId,
ByteBuffer pageBuf,
boolean keepCrc)
Reads a page.
|
void |
readHeader(ByteBuffer buf)
Reads a header.
|
long |
size() |
void |
stop(boolean delete) |
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()
Page store version.
|
void |
write(long pageId,
ByteBuffer pageBuf,
int tag,
boolean calculateCrc)
Writes a page.
|
public static final int VERSION
public static final int HEADER_SIZE
protected final DataStorageConfiguration dbCfg
protected volatile FileIO fileIO
protected final int pageSize
public FilePageStore(byte type,
IgniteOutClosure<Path> pathProvider,
FileIOFactory factory,
DataStorageConfiguration cfg,
LongAdderMetric allocatedTracker)
public int getPageSize()
getPageSize in interface PageStorepublic int getBlockSize()
getBlockSize in interface PageStorepublic long size()
size in interface PageStorePageStore.pages() * PageStore.getPageSize()
due to delayed writes or due to other implementation specific details.public long getSparseSize()
getSparseSize in interface PageStorePageStore.size().PageStore.punchHole(long, int)public void punchHole(long pageId,
int usefulBytes)
public boolean exists()
public int headerSize()
public int version()
public ByteBuffer header(byte type, int pageSize)
type - Type.pageSize - Page size.public void stop(boolean delete)
throws StorageException
stop in interface PageStoredelete - True to delete file.StorageException - If failed.public void truncate(int tag)
throws StorageException
truncate in interface PageStoretag - New partition tag.StorageException - If failed.public void beginRecover()
beginRecover in interface PageStorepublic void finishRecover()
throws StorageException
finishRecover in interface PageStoreStorageException - If failed.public void read(long pageId,
ByteBuffer pageBuf,
boolean keepCrc)
throws IgniteCheckedException
read in interface PageStorepageId - 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 keepCrcIgniteCheckedException - If reading failed (IO error occurred).public void readHeader(ByteBuffer buf) throws IgniteCheckedException
readHeader in interface PageStorebuf - Buffer to write to.IgniteCheckedException - If failed.public void write(long pageId,
ByteBuffer pageBuf,
int tag,
boolean calculateCrc)
throws IgniteCheckedException
write in interface PageStorepageId - 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.IgniteCheckedException - If page writing failed (IO error occurred).public long pageOffset(long pageId)
pageOffset in interface PageStorepageId - Page ID.public void sync()
throws StorageException
sync in interface PageStoreStorageExceptionpublic void ensure()
throws IgniteCheckedException
ensure in interface PageStoreIgniteCheckedException - If sync failed (IO error occurred).public long allocatePage()
throws IgniteCheckedException
allocatePage in interface PageStoreIgniteCheckedException - If failed to allocate.public String getFileAbsolutePath()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.8.0 Release Date : February 27 2020