public interface PageStore extends AutoCloseable
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Modifier and Type | Method and Description |
---|---|
static PageStore |
create(PageStoreOptions options,
boolean init)
Creates a
PageStore . |
void |
delete(PageId pageId,
long pageSize)
Deletes a page from the store.
|
default ReadableByteChannel |
get(PageId pageId)
Wraps a page from the store as a channel to read.
|
ReadableByteChannel |
get(PageId pageId,
int pageOffset)
Gets part of a page from the store to the destination channel.
|
long |
getCacheSize() |
java.util.stream.Stream<PageInfo> |
getPages()
Gets a stream of all pages from the page store.
|
static Path |
getStorePath(PageStoreType storeType,
String rootDir)
Gets store path given root directory and store type.
|
static void |
initialize(PageStoreOptions options)
Initializes a page store at the configured location.
|
void |
put(PageId pageId,
byte[] page)
Writes a new page from a source channel to the store.
|
close
static PageStore create(PageStoreOptions options, boolean init) throws IOException
PageStore
. When init is false, restore from previous state; clean up the
cache dir otherwise.options
- the options to instantiate the page storeinit
- whether to init the cache dirIOException
- if I/O error happensstatic Path getStorePath(PageStoreType storeType, String rootDir)
storeType
- the type of the page storerootDir
- the root directory pathstatic void initialize(PageStoreOptions options) throws IOException
options
- initialize a new page store based on the optionsIOException
- when failed to clean up the specific locationvoid put(PageId pageId, byte[] page) throws IOException
pageId
- page identifierpage
- page dataIOException
default ReadableByteChannel get(PageId pageId) throws IOException, PageNotFoundException
pageId
- page identifierIOException
- when the store fails to read this pagePageNotFoundException
- when the page isn't found in the storeReadableByteChannel get(PageId pageId, int pageOffset) throws IOException, PageNotFoundException
pageId
- page identifierpageOffset
- offset within pageIOException
- when the store fails to read this pagePageNotFoundException
- when the page isn't found in the storeIllegalArgumentException
- when the page offset exceeds the page sizevoid delete(PageId pageId, long pageSize) throws IOException, PageNotFoundException
pageId
- page identifierpageSize
- page size in bytesIOException
- when the store fails to delete this pagePageNotFoundException
- when the page isn't found in the storejava.util.stream.Stream<PageInfo> getPages() throws IOException
IOException
- if any error occurslong getCacheSize()
Copyright © 2023. All Rights Reserved.