@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(LocalPageStoreOptions options)
Creates a new instance of
LocalPageStore . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
delete(PageId pageId)
Deletes a page from the store.
|
int |
get(PageId pageId,
int pageOffset,
int bytesToRead,
byte[] buffer,
int bufferOffset,
boolean isTemporary)
Gets part of a page from the store to the destination buffer.
|
Path |
getFilePath(PageId pageId,
boolean isTemporary) |
void |
put(PageId pageId,
byte[] page,
boolean isTemporary)
Writes a new page from a source channel to the store.
|
public static final String TEMP_DIR
public LocalPageStore(LocalPageStoreOptions options)
LocalPageStore
.options
- options for the local page storepublic void put(PageId pageId, byte[] 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, byte[] buffer, int bufferOffset, boolean isTemporary) throws IOException, PageNotFoundException
PageStore
get
in interface PageStore
pageId
- page identifierpageOffset
- offset within pagebytesToRead
- bytes to read in this pagebuffer
- destination bufferbufferOffset
- offset in 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) throws IOException, PageNotFoundException
PageStore
delete
in interface PageStore
pageId
- page identifierIOException
- when the store fails to delete this pagePageNotFoundException
- when the page isn't found in the storepublic Path getFilePath(PageId pageId, boolean isTemporary)
pageId
- page IdisTemporary
- public void close()
close
in interface AutoCloseable
Copyright © 2023. All Rights Reserved.