public class FileChannelStorageServiceImpl extends Object implements StorageService
Use Java NIO2.0 to read file, leverage page cache, data are read into JVM direct memory then copy to heap.
Note that to achieve GC-less load, we prefer to use DirectBuffer in ThreadLocal. We could create one
DirectByteBuffer pool to make the same result, but here we use HeapByteBuffer
because direct byte buffer cannot be released once page is load, the lifecycle has to be extended until decoding by
IndexService is done, so we cannot simply add
try-finally to clean the buffer after load and recycle them to the pool. The lifecycle of the direct byte buffer must be
managed by index service as well, this will be enhanced in the future.
| 构造器和说明 |
|---|
FileChannelStorageServiceImpl() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
InnerPage |
loadPage(long pageNumber)
load page
|
FilHeader |
loadPageHeader(long pageNumber)
only load page header
|
long |
numOfPages()
Number of pages in the tablespace
|
void |
open(String ibdFilePath)
open file
|
public void open(String ibdFilePath) throws IOException
StorageServiceopen 在接口中 StorageServiceibdFilePath - file pathIOException - throws IOException when open file failspublic InnerPage loadPage(long pageNumber) throws ReaderException
StorageServiceloadPage 在接口中 StorageServicepageNumber - page numberReaderException - throws ReaderException when internal errors occurspublic FilHeader loadPageHeader(long pageNumber) throws ReaderException
StorageServiceloadPageHeader 在接口中 StorageServicepageNumber - page numberReaderException - throws ReaderException when internal errors occurspublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableIOExceptionpublic long numOfPages()
StorageServicenumOfPages 在接口中 StorageServiceCopyright © 2019–2020 Alibaba Group Holding Limited. All rights reserved.