@NotThreadSafe public class LocalPageStore extends Object implements PageStore
LocalPageStore
is an implementation of PageStore
which
stores all pages in a directory somewhere on the local disk.PageStore.Metrics
Constructor and Description |
---|
LocalPageStore(PageStoreOptions options)
Creates a new instance of
LocalPageStore . |
Modifier and Type | Method and Description |
---|---|
void |
abort(String fileId)
Abort a temporary file.
|
void |
close() |
void |
commit(String fileId,
String newFileId)
Commit a temporary file with a new file ID.
|
void |
delete(PageId pageId,
boolean isTemporary)
Deletes a temporary page from the store.
|
int |
get(PageId pageId,
int pageOffset,
int bytesToRead,
ReadTargetBuffer target,
boolean isTemporary)
Gets part of a page from the store to the destination buffer.
|
DataFileChannel |
getDataFileChannel(PageId pageId,
int pageOffset,
int bytesToRead,
boolean isTemporary)
Get a
DataFileChannel which wraps a FileRegion . |
Path |
getPagePath(PageId pageId,
boolean isTemporary) |
void |
put(PageId pageId,
ByteBuffer page,
boolean isTemporary)
Writes a new page from a source channel to the store.
|
public static final String TEMP_DIR
public LocalPageStore(PageStoreOptions options)
LocalPageStore
.options
- options for the local page storepublic void put(PageId pageId, ByteBuffer page, boolean isTemporary) throws ResourceExhaustedException, IOException
PageStore
put
in interface PageStore
pageId
- page identifierpage
- page dataisTemporary
- is page data temporaryResourceExhaustedException
- when there is not enough space found on diskIOException
- when the store fails to write this pagepublic int get(PageId pageId, int pageOffset, int bytesToRead, ReadTargetBuffer target, boolean isTemporary) throws IOException, PageNotFoundException
PageStore
get
in interface PageStore
pageId
- page identifierpageOffset
- offset within pagebytesToRead
- bytes to read in this pagetarget
- destination bufferisTemporary
- is page data temporaryIOException
- when the store fails to read this pagePageNotFoundException
- when the page isn't found in the storepublic void delete(PageId pageId, boolean isTemporary) throws IOException, PageNotFoundException
PageStore
delete
in interface PageStore
pageId
- page identifierisTemporary
- whether is to delete a temporary page or notIOException
PageNotFoundException
public void commit(String fileId, String newFileId) throws IOException
PageStore
commit
in interface PageStore
IOException
public void abort(String fileId) throws IOException
PageStore
abort
in interface PageStore
IOException
public Path getPagePath(PageId pageId, boolean isTemporary)
pageId
- page IdisTemporary
- public DataFileChannel getDataFileChannel(PageId pageId, int pageOffset, int bytesToRead, boolean isTemporary) throws PageNotFoundException
PageStore
DataFileChannel
which wraps a FileRegion
.getDataFileChannel
in interface PageStore
pageId
- the page idpageOffset
- the offset inside the pagebytesToRead
- the bytes to readisTemporary
- whether it is temporary or notDataFileChannel
PageNotFoundException
public void close()
close
in interface AutoCloseable
Copyright © 2023. All Rights Reserved.