public interface CacheManager extends AutoCloseable, CacheStatus
Modifier and Type | Interface and Description |
---|---|
static class |
CacheManager.Factory
Factory class to get or create a CacheManager.
|
static class |
CacheManager.State
State of a cache.
|
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Modifier and Type | Method and Description |
---|---|
boolean |
append(PageId pageId,
int appendAt,
byte[] page,
CacheContext cacheContext) |
void |
commitFile(String fileId)
Commit the File.
|
boolean |
delete(PageId pageId)
Deletes a page from the cache.
|
void |
deleteFile(String fileId)
Deletes all pages of the given file.
|
void |
deleteTempFile(String fileId)
Deletes all temporary pages of the given file.
|
default int |
get(PageId pageId,
int bytesToRead,
byte[] buffer,
int offsetInBuffer)
Reads the entire page if the queried page is found in the cache, stores the result in buffer.
|
default int |
get(PageId pageId,
int pageOffset,
int bytesToRead,
byte[] buffer,
int offsetInBuffer)
Reads a part of a page if the queried page is found in the cache, stores the result in buffer.
|
default int |
get(PageId pageId,
int pageOffset,
int bytesToRead,
byte[] buffer,
int offsetInBuffer,
CacheContext cacheContext)
Reads a part of a page if the queried page is found in the cache, stores the result in buffer.
|
int |
get(PageId pageId,
int pageOffset,
int bytesToRead,
ReadTargetBuffer buffer,
CacheContext cacheContext)
Reads a part of a page if the queried page is found in the cache, stores the result in buffer.
|
default int |
get(PageId pageId,
int pageOffset,
ReadTargetBuffer buffer,
CacheContext cacheContext)
Reads a part of a page if the queried page is found in the cache, stores the result in buffer.
|
int |
getAndLoad(PageId pageId,
int pageOffset,
int bytesToRead,
ReadTargetBuffer buffer,
CacheContext cacheContext,
java.util.function.Supplier<byte[]> externalDataSupplier)
Reads a part of a page if the queried page is found in the cache, stores the result in buffer.
|
default List<PageId> |
getCachedPageIdsByFileId(String fileId,
long fileLength)
Get page ids by the given file id.
|
Optional<DataFileChannel> |
getDataFileChannel(PageId pageId,
int pageOffset,
int bytesToRead,
CacheContext cacheContext)
Get a
DataFileChannel which wraps a FileRegion . |
Optional<CacheUsage> |
getUsage()
Gets cache usage.
|
default void |
invalidate(java.util.function.Predicate<PageInfo> predicate)
Invalidate the pages that match the given predicate.
|
default boolean |
put(PageId pageId,
byte[] page)
Puts a page into the cache manager.
|
default boolean |
put(PageId pageId,
byte[] page,
CacheContext cacheContext)
Puts a page into the cache manager with scope and quota respected.
|
default boolean |
put(PageId pageId,
ByteBuffer page)
Puts a page into the cache manager.
|
boolean |
put(PageId pageId,
ByteBuffer page,
CacheContext cacheContext)
Puts a page into the cache manager with scope and quota respected.
|
CacheManager.State |
state() |
close
default boolean put(PageId pageId, byte[] page)
pageId
- page identifierpage
- page datadefault boolean put(PageId pageId, ByteBuffer page)
pageId
- page identifierpage
- page datadefault boolean put(PageId pageId, byte[] page, CacheContext cacheContext)
pageId
- page identifierpage
- page datacacheContext
- cache related contextboolean put(PageId pageId, ByteBuffer page, CacheContext cacheContext)
pageId
- page identifierpage
- page datacacheContext
- cache related contextdefault int get(PageId pageId, int bytesToRead, byte[] buffer, int offsetInBuffer)
pageId
- page identifierbytesToRead
- number of bytes to read in this pagebuffer
- destination buffer to writeoffsetInBuffer
- offset in the destination buffer to writedefault int get(PageId pageId, int pageOffset, int bytesToRead, byte[] buffer, int offsetInBuffer)
pageId
- page identifierpageOffset
- offset into the pagebytesToRead
- number of bytes to read in this pagebuffer
- destination buffer to writeoffsetInBuffer
- offset in the destination buffer to writedefault int get(PageId pageId, int pageOffset, ReadTargetBuffer buffer, CacheContext cacheContext)
pageId
- page identifierpageOffset
- offset into the pagebuffer
- destination buffer to writecacheContext
- cache related contextdefault int get(PageId pageId, int pageOffset, int bytesToRead, byte[] buffer, int offsetInBuffer, CacheContext cacheContext)
pageId
- page identifierpageOffset
- offset into the pagebytesToRead
- number of bytes to read in this pagebuffer
- destination buffer to writeoffsetInBuffer
- offset in the destination buffer to writecacheContext
- cache related contextint get(PageId pageId, int pageOffset, int bytesToRead, ReadTargetBuffer buffer, CacheContext cacheContext)
pageId
- page identifierpageOffset
- offset into the pagebytesToRead
- number of bytes to read in this pagebuffer
- destination buffer to writecacheContext
- cache related contextint getAndLoad(PageId pageId, int pageOffset, int bytesToRead, ReadTargetBuffer buffer, CacheContext cacheContext, java.util.function.Supplier<byte[]> externalDataSupplier)
pageId
- page identifierpageOffset
- offset into the pagebytesToRead
- number of bytes to read in this pagebuffer
- destination buffer to writecacheContext
- cache related contextexternalDataSupplier
- the external data supplier to read a pagedefault List<PageId> getCachedPageIdsByFileId(String fileId, long fileLength)
fileId
- file identifierfileLength
- file length (this will not be needed after we have per-file metadata)void deleteFile(String fileId)
fileId
- the file id of the target filevoid deleteTempFile(String fileId)
fileId
- the file id of the target fileboolean delete(PageId pageId)
pageId
- page identifierCacheManager.State state()
boolean append(PageId pageId, int appendAt, byte[] page, CacheContext cacheContext)
pageId
- appendAt
- page
- cacheContext
- default void invalidate(java.util.function.Predicate<PageInfo> predicate)
predicate
- Optional<CacheUsage> getUsage()
CacheStatus
getUsage
in interface CacheStatus
void commitFile(String fileId)
fileId
- the file IDOptional<DataFileChannel> getDataFileChannel(PageId pageId, int pageOffset, int bytesToRead, CacheContext cacheContext) throws PageNotFoundException
DataFileChannel
which wraps a FileRegion
.pageId
- the page idpageOffset
- the offset inside the pagebytesToRead
- the bytes to readcacheContext
- the cache contextDataFileChannel
PageNotFoundException
Copyright © 2023. All Rights Reserved.