OmniSciDB
a5dc49c757
|
A FileMgr capable of limiting it's size and storing data from multiple tables in a shared directory. For any table that supports DiskCaching, the CachingFileMgr must contain either metadata for all table chunks, or for none (the cache is either has no knowledge of that table, or has complete knowledge of that table). Any data chunk within a table may or may not be contained within the cache. More...
#include <CachingFileMgr.h>
Public Member Functions | |
CachingFileMgr (const DiskCacheConfig &config) | |
~CachingFileMgr () override | |
MgrType | getMgrType () override |
std::string | getStringMgrType () override |
size_t | getPageSize () |
size_t | getMaxSize () override |
size_t | getMaxDataFiles () const |
size_t | getMaxMetaFiles () const |
size_t | getMaxWrapperSize () const |
size_t | getDataFileSize () const |
size_t | getMetadataFileSize () const |
size_t | getNumDataFiles () const |
size_t | getNumMetaFiles () const |
size_t | getAvailableSpace () |
size_t | getAvailableWrapperSpace () |
size_t | getAllocated () override |
size_t | getMaxDataFilesSize () const |
void | removeChunkKeepMetadata (const ChunkKey &key) |
Free pages for chunk and remove it from the chunk eviction algorithm. More... | |
void | clearForTable (int32_t db_id, int32_t tb_id) |
Removes all data related to the given table (pages and subdirectories). More... | |
bool | hasFileMgrKey () const override |
Query to determine if the contained pages will have their database and table ids overriden by the filemgr key (FileMgr does this). More... | |
void | closeRemovePhysical () override |
Closes files and removes the caching directory. More... | |
size_t | getChunkSpaceReservedByTable (int32_t db_id, int32_t tb_id) const |
size_t | getMetadataSpaceReservedByTable (int32_t db_id, int32_t tb_id) const |
size_t | getTableFileMgrSpaceReserved (int32_t db_id, int32_t tb_id) const |
size_t | getSpaceReservedByTable (int32_t db_id, int32_t tb_id) const |
std::string | describeSelf () const override |
describes this FileMgr for logging purposes. More... | |
void | checkpoint (const int32_t db_id, const int32_t tb_id) override |
writes buffers for the given table, synchronizes files to disk, updates file epoch, and commits free pages. More... | |
int32_t | epoch (int32_t db_id, int32_t tb_id) const override |
obtain the epoch version for the given table. More... | |
FileBuffer * | putBuffer (const ChunkKey &key, AbstractBuffer *srcBuffer, const size_t numBytes=0) override |
deletes any existing buffer for the given key then copies in a new one. More... | |
CachingFileBuffer * | allocateBuffer (const size_t page_size, const ChunkKey &key, const size_t num_bytes=0) override |
allocates a new CachingFileBuffer and tracks it's use in the eviction algorithms. More... | |
CachingFileBuffer * | allocateBuffer (const ChunkKey &key, const std::vector< HeaderInfo >::const_iterator &headerStartIt, const std::vector< HeaderInfo >::const_iterator &headerEndIt) override |
bool | updatePageIfDeleted (FileInfo *file_info, ChunkKey &chunk_key, int32_t contingent, int32_t page_epoch, int32_t page_num) override |
checks whether a page should be deleted. More... | |
bool | failOnReadError () const override |
True if a read error should cause a fatal error. More... | |
void | deleteBufferIfExists (const ChunkKey &key) |
deletes a buffer if it exists in the mgr. Otherwise do nothing. More... | |
size_t | getNumChunksWithMetadata () const |
Returns the number of buffers with metadata in the CFM. Any buffer with an encoder counts. More... | |
size_t | getNumDataChunks () const |
Returns the number of buffers with chunk data in the CFM. More... | |
std::vector< ChunkKey > | getChunkKeysForPrefix (const ChunkKey &prefix) const |
Returns the keys for chunks with chunk data that match the given prefix. More... | |
std::unique_ptr< CachingFileMgr > | reconstruct () const |
Initializes a new CFM using the initialization values in the current CFM. More... | |
void | deleteWrapperFile (int32_t db, int32_t tb) |
Deletes the wrapper file from a table subdir. More... | |
void | writeWrapperFile (const std::string &doc, int32_t db, int32_t tb) |
Writes a wrapper file to a table subdir. More... | |
bool | hasWrapperFile (int32_t db_id, int32_t table_id) const |
std::string | getTableFileMgrPath (int32_t db, int32_t tb) const |
size_t | getFilesSize () const |
Get the total size of page files (data and metadata files). This includes allocated, but unused space. More... | |
size_t | getTableFileMgrsSize () const |
Returns the total size of all subdirectory files. Each table represented in the CFM has a subdirectory for serialized data wrappers and epoch files. More... | |
std::optional< FileBuffer * > | getBufferIfExists (const ChunkKey &key) |
an optional version of get buffer if we are not sure a chunk exists. More... | |
void | free_page (std::pair< FileInfo *, int32_t > &&page) override |
Unlike the FileMgr, the CFM frees pages immediately instead of holding them until the next checkpoint. More... | |
void | getChunkMetadataVecForKeyPrefix (ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix) override |
std::string | dumpKeysWithMetadata () const |
std::string | dumpKeysWithChunkData () const |
std::string | dumpTableQueue () const |
std::string | dumpEvictionQueue () const |
std::string | dump () const |
void | setMaxNumDataFiles (size_t max) |
void | setMaxNumMetadataFiles (size_t max) |
void | setMaxWrapperSpace (size_t max) |
std::set< ChunkKey > | getKeysWithMetadata () const |
void | setDataSizeLimit (size_t max) |
Page | requestFreePage (size_t pagesize, const bool isMetadata) override |
requests a free page similar to FileMgr, but this override will also evict existing pages to make space if there are none available. More... | |
Public Member Functions inherited from File_Namespace::FileMgr | |
FileMgr (const int32_t device_id, GlobalFileMgr *gfm, const TablePair file_mgr_key, const int32_t max_rollback_epochs=-1, const size_t num_reader_threads=0, const int32_t epoch=-1) | |
Constructor. More... | |
FileMgr (const int32_t device_id, GlobalFileMgr *gfm, const TablePair file_mgr_key, const bool run_core_init) | |
FileMgr (GlobalFileMgr *gfm, std::string basePath) | |
~FileMgr () override | |
Destructor. More... | |
StorageStats | getStorageStats () const |
FileBuffer * | createBuffer (const ChunkKey &key, size_t pageSize=0, const size_t numBytes=0) override |
Creates a chunk with the specified key and page size. More... | |
bool | isBufferOnDevice (const ChunkKey &key) override |
void | deleteBuffer (const ChunkKey &key, const bool purge=true) override |
Deletes the chunk with the specified key. More... | |
void | deleteBuffersWithPrefix (const ChunkKey &keyPrefix, const bool purge=true) override |
FileBuffer * | getBuffer (const ChunkKey &key, const size_t numBytes=0) override |
Returns the a pointer to the chunk with the specified key. More... | |
void | fetchBuffer (const ChunkKey &key, AbstractBuffer *destBuffer, const size_t numBytes) override |
FileBuffer * | putBuffer (const ChunkKey &key, AbstractBuffer *d, const size_t numBytes=0) override |
Puts the contents of d into the Chunk with the given key. More... | |
AbstractBuffer * | alloc (const size_t numBytes) override |
void | free (AbstractBuffer *buffer) override |
MgrType | getMgrType () override |
std::string | getStringMgrType () override |
std::string | printSlabs () override |
size_t | getMaxSize () override |
size_t | getInUseSize () override |
size_t | getAllocated () override |
bool | isAllocationCapped () override |
FileInfo * | getFileInfoForFileId (const int32_t fileId) const |
FileMetadata | getMetadataForFile (const boost::filesystem::directory_iterator &fileIterator) const |
void | copyPage (Page &srcPage, FileMgr *destFileMgr, Page &destPage, const size_t reservedHeaderSize, const size_t numBytes, const size_t offset) |
void | requestFreePages (size_t npages, size_t pagesize, std::vector< Page > &pages, const bool isMetadata) |
Obtains free pages – creates new files if necessary – of the requested size. More... | |
void | getChunkMetadataVecForKeyPrefix (ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix) override |
bool | hasChunkMetadataForKeyPrefix (const ChunkKey &keyPrefix) |
void | checkpoint () override |
Fsyncs data files, writes out epoch and fsyncs that. More... | |
void | checkpoint (const int32_t db_id, const int32_t tb_id) override |
int32_t | epochFloor () const |
int32_t | incrementEpoch () |
int32_t | lastCheckpointedEpoch () const |
Returns value of epoch at last checkpoint. More... | |
void | resetEpochFloor () |
int32_t | maxRollbackEpochs () |
Returns value max_rollback_epochs. More... | |
size_t | getNumReaderThreads () |
Returns number of threads defined by parameter num-reader-threads which should be used during initial load and consequent read of data. More... | |
FILE * | getFileForFileId (const int32_t fileId) |
Returns FILE pointer associated with requested fileId. More... | |
size_t | getNumChunks () override |
size_t | getNumUsedMetadataPagesForChunkKey (const ChunkKey &chunkKey) const |
bool | getDBConvert () const |
Index for looking up chunks. More... | |
void | createOrMigrateTopLevelMetadata () |
std::string | getFileMgrBasePath () const |
void | removeTableRelatedDS (const int32_t db_id, const int32_t table_id) override |
const TablePair | get_fileMgrKey () const |
boost::filesystem::path | getFilePath (const std::string &file_name) const |
void | writePageMappingsToStatusFile (const std::vector< PageMapping > &page_mappings) |
void | renameCompactionStatusFile (const char *const from_status, const char *const to_status) |
void | compactFiles () |
size_t | getPageSize () const |
size_t | getMetadataPageSize () const |
FILE * | createFile (const std::string &full_path, const size_t requested_file_size) const |
std::pair< FILE *, std::string > | createFile (const std::string &base_path, const int file_id, const size_t page_size, const size_t num_pages) const |
size_t | writeFile (FILE *f, const size_t offset, const size_t size, const int8_t *buf) const |
Static Public Member Functions | |
static size_t | getMinimumSize () |
Static Public Member Functions inherited from File_Namespace::FileMgr | |
static void | setNumPagesPerDataFile (size_t num_pages) |
static void | setNumPagesPerMetadataFile (size_t num_pages) |
static void | renameAndSymlinkLegacyFiles (const std::string &table_data_dir) |
Static Public Attributes | |
static constexpr char | WRAPPER_FILE_NAME [] = "wrapper_metadata.json" |
static constexpr float | METADATA_SPACE_PERCENTAGE {0.1} |
static constexpr float | METADATA_FILE_SPACE_PERCENTAGE {0.01} |
Static Public Attributes inherited from File_Namespace::FileMgr | |
static constexpr size_t | DEFAULT_NUM_PAGES_PER_DATA_FILE {256} |
static constexpr size_t | DEFAULT_NUM_PAGES_PER_METADATA_FILE {4096} |
static constexpr char const * | COPY_PAGES_STATUS {"pending_data_compaction_0"} |
static constexpr char const * | UPDATE_PAGE_VISIBILITY_STATUS {"pending_data_compaction_1"} |
static constexpr char const * | DELETE_EMPTY_FILES_STATUS {"pending_data_compaction_2"} |
static constexpr char | LEGACY_EPOCH_FILENAME [] = "epoch" |
static constexpr char | EPOCH_FILENAME [] = "epoch_metadata" |
static constexpr char | DB_META_FILENAME [] = "dbmeta" |
static constexpr char | FILE_MGR_VERSION_FILENAME [] = "filemgr_version" |
static constexpr int32_t | INVALID_VERSION = -1 |
static constexpr int32_t | LATEST_FILE_MGR_VERSION = 2 |
Private Member Functions | |
void | incrementEpoch (int32_t db_id, int32_t tb_id) |
Increments epoch for the given table. More... | |
void | init (const size_t num_reader_threads) |
Initializes a CFM, parsing any existing files and initializing data structures appropriately (currently not thread-safe). More... | |
void | writeAndSyncEpochToDisk (int32_t db_id, int32_t tb_id) |
Flushes epoch value to disk for a table. More... | |
void | readTableFileMgrs () |
Checks for any sub-directories containing table-specific data and creates epochs from found files. More... | |
FileBuffer * | createBufferFromHeaders (const ChunkKey &key, const std::vector< HeaderInfo >::const_iterator &startIt, const std::vector< HeaderInfo >::const_iterator &endIt) override |
Creates a buffer and initializes it with info read from files on disk. More... | |
FileBuffer * | createBufferUnlocked (const ChunkKey &key, size_t pageSize=0, const size_t numBytes=0) override |
Creates a buffer. More... | |
void | createTableFileMgrIfNoneExists (const int32_t db_id, const int32_t tb_id) |
Create and initialize a subdirectory for a table if none exists. More... | |
void | incrementAllEpochs () |
Increment epochs for each table in the CFM. More... | |
void | removeTableFileMgr (int32_t db_id, int32_t tb_id) |
Removes the subdirectory content for a table. More... | |
void | removeTableBuffers (int32_t db_id, int32_t tb_id) |
Erases and cleans up all buffers for a table. More... | |
void | writeDirtyBuffers (int32_t db_id, int32_t tb_id) |
helper function to flush all dirty buffers to disk. More... | |
void | touchKey (const ChunkKey &key) const |
Used to track which tables/chunks were least recently used. More... | |
void | removeKey (const ChunkKey &key) const |
std::vector< ChunkKey > | getKeysForTable (int32_t db_id, int32_t tb_id) const |
returns set of keys contained in chunkIndex_ that match the given table prefix. More... | |
FileInfo * | evictMetadataPages () |
evicts all metadata pages for the least recently used table. Returns the first FileInfo that a page was evicted from (guaranteed to now have at least one free page in it). More... | |
FileInfo * | evictPages () |
evicts all data pages for the least recently used Chunk (metadata pages persist). Returns the first FileInfo that a page was evicted from (guaranteed to now have at least one free page in it). More... | |
void | deleteCacheIfTooLarge () |
When the cache is read from disk, we don't know which chunks were least recently used. Rather than try to evict random pages to get down to size we just reset the cache to make sure we have space. More... | |
void | setMaxSizes () |
Sets the maximum number of files/space for each type of storage based on the maximum size. More... | |
FileBuffer * | getBufferUnlocked (const ChunkKey &key, const size_t numBytes=0) const override |
ChunkKeyToChunkMap::iterator | deleteBufferUnlocked (const ChunkKeyToChunkMap::iterator chunk_it, const bool purge=true) override |
void | readOnlyCheck (const std::string &action, const std::optional< std::string > &file_name={}) const override |
Private Attributes | |
heavyai::shared_mutex | table_dirs_mutex_ |
std::map< TablePair, std::unique_ptr< TableFileMgr > > | table_dirs_ |
size_t | max_num_data_files_ |
size_t | max_num_meta_files_ |
size_t | max_wrapper_space_ |
size_t | max_size_ |
std::optional< size_t > | limit_data_size_ {} |
LRUEvictionAlgorithm | chunk_evict_alg_ |
LRUEvictionAlgorithm | table_evict_alg_ |
Additional Inherited Members | |
Public Attributes inherited from File_Namespace::FileMgr | |
ChunkKeyToChunkMap | chunkIndex_ |
Protected Member Functions inherited from File_Namespace::FileMgr | |
FileMgr (const size_t defaultPageSize, const size_t defaultMetadataPageSize) | |
FileInfo * | createFileInfo (const size_t pageSize, const size_t numPages) |
Adds a file to the file manager repository. More... | |
FileInfo * | openExistingFile (const std::string &path, const int32_t fileId, const size_t pageSize, const size_t numPages, std::vector< HeaderInfo > &headerVec) |
void | createEpochFile (const std::string &epochFileName) |
int32_t | openAndReadLegacyEpochFile (const std::string &epochFileName) |
void | openAndReadEpochFile (const std::string &epochFileName) |
void | writeAndSyncEpochToDisk () |
void | setEpoch (const int32_t newEpoch) |
int32_t | readVersionFromDisk (const std::string &versionFileName) const |
void | writeAndSyncVersionToDisk (const std::string &versionFileName, const int32_t version) |
void | processFileFutures (std::vector< std::future< std::vector< HeaderInfo >>> &file_futures, std::vector< HeaderInfo > &headerVec) |
void | migrateToLatestFileMgrVersion () |
void | migrateEpochFileV0 () |
void | migrateLegacyFilesV1 () |
OpenFilesResult | openFiles () |
void | clearFileInfos () |
void | copySourcePageForCompaction (const Page &source_page, FileInfo *destination_file_info, std::vector< PageMapping > &page_mappings, std::set< Page > &touched_pages) |
int32_t | copyPageWithoutHeaderSize (const Page &source_page, const Page &destination_page) |
void | sortAndCopyFilePagesForCompaction (size_t page_size, std::vector< PageMapping > &page_mappings, std::set< Page > &touched_pages) |
void | updateMappedPagesVisibility (const std::vector< PageMapping > &page_mappings) |
void | deleteEmptyFiles () |
void | resumeFileCompaction (const std::string &status_file_name) |
std::vector< PageMapping > | readPageMappingsFromStatusFile () |
FileMgr (const int epoch) | |
void | closePhysicalUnlocked () |
void | syncFilesToDisk () |
void | freePages () |
void | initializeNumThreads (size_t num_reader_threads=0) |
Protected Attributes inherited from File_Namespace::FileMgr | |
int32_t | maxRollbackEpochs_ |
std::string | fileMgrBasePath_ |
std::map< int32_t, std::unique_ptr< FileInfo > > | files_ |
PageSizeFileMMap | fileIndex_ |
size_t | num_reader_threads_ |
Maps page sizes to FileInfo objects. More... | |
unsigned | nextFileId_ |
number of threads used when loading data More... | |
int32_t | fileMgrVersion_ |
the index of the next file id More... | |
FILE * | DBMetaFile_ = nullptr |
std::mutex | getPageMutex_ |
pointer to DB level metadata More... | |
heavyai::shared_mutex | chunkIndexMutex_ |
heavyai::shared_mutex | files_rw_mutex_ |
heavyai::shared_mutex | mutex_free_page_ |
std::vector< std::pair < FileInfo *, int32_t > > | free_pages_ |
bool | isFullyInitted_ {false} |
const size_t | page_size_ |
const size_t | metadata_page_size_ |
Static Protected Attributes inherited from File_Namespace::FileMgr | |
static size_t | num_pages_per_data_file_ {DEFAULT_NUM_PAGES_PER_DATA_FILE} |
static size_t | num_pages_per_metadata_file_ {DEFAULT_NUM_PAGES_PER_METADATA_FILE} |
A FileMgr capable of limiting it's size and storing data from multiple tables in a shared directory. For any table that supports DiskCaching, the CachingFileMgr must contain either metadata for all table chunks, or for none (the cache is either has no knowledge of that table, or has complete knowledge of that table). Any data chunk within a table may or may not be contained within the cache.
Definition at line 178 of file CachingFileMgr.h.
File_Namespace::CachingFileMgr::CachingFileMgr | ( | const DiskCacheConfig & | config | ) |
Definition at line 71 of file CachingFileMgr.cpp.
References File_Namespace::FileMgr::fileMgrBasePath_, init(), max_size_, File_Namespace::FileMgr::maxRollbackEpochs_, File_Namespace::FileMgr::nextFileId_, File_Namespace::DiskCacheConfig::num_reader_threads, File_Namespace::DiskCacheConfig::path, setMaxSizes(), and File_Namespace::DiskCacheConfig::size_limit.
|
override |
Definition at line 81 of file CachingFileMgr.cpp.
|
overridevirtual |
allocates a new CachingFileBuffer and tracks it's use in the eviction algorithms.
Reimplemented from File_Namespace::FileMgr.
Definition at line 346 of file CachingFileMgr.cpp.
|
overridevirtual |
Reimplemented from File_Namespace::FileMgr.
Definition at line 352 of file CachingFileMgr.cpp.
|
override |
writes buffers for the given table, synchronizes files to disk, updates file epoch, and commits free pages.
Definition at line 246 of file CachingFileMgr.cpp.
References CHECK, table_dirs_, and table_dirs_mutex_.
void File_Namespace::CachingFileMgr::clearForTable | ( | int32_t | db_id, |
int32_t | tb_id | ||
) |
Removes all data related to the given table (pages and subdirectories).
Definition at line 173 of file CachingFileMgr.cpp.
References File_Namespace::FileMgr::freePages(), removeTableBuffers(), and removeTableFileMgr().
|
overridevirtual |
Closes files and removes the caching directory.
Reimplemented from File_Namespace::FileMgr.
Definition at line 183 of file CachingFileMgr.cpp.
References File_Namespace::FileMgr::closePhysicalUnlocked(), File_Namespace::FileMgr::files_rw_mutex_, File_Namespace::FileMgr::getFileMgrBasePath(), table_dirs_, and table_dirs_mutex_.
|
overrideprivatevirtual |
Creates a buffer and initializes it with info read from files on disk.
Reimplemented from File_Namespace::FileMgr.
Definition at line 279 of file CachingFileMgr.cpp.
References get_table_prefix().
Referenced by init().
|
overrideprivatevirtual |
Creates a buffer.
Reimplemented from File_Namespace::FileMgr.
Definition at line 270 of file CachingFileMgr.cpp.
References get_table_prefix().
|
private |
Create and initialize a subdirectory for a table if none exists.
Definition at line 260 of file CachingFileMgr.cpp.
void File_Namespace::CachingFileMgr::deleteBufferIfExists | ( | const ChunkKey & | key | ) |
deletes a buffer if it exists in the mgr. Otherwise do nothing.
Definition at line 396 of file CachingFileMgr.cpp.
|
overrideprivatevirtual |
Reimplemented from File_Namespace::FileMgr.
Definition at line 713 of file CachingFileMgr.cpp.
|
private |
When the cache is read from disk, we don't know which chunks were least recently used. Rather than try to evict random pages to get down to size we just reset the cache to make sure we have space.
Definition at line 415 of file CachingFileMgr.cpp.
References logger::INFO, LOG, and anonymous_namespace{CachingFileMgr.cpp}::size_of_dir().
Referenced by init().
void File_Namespace::CachingFileMgr::deleteWrapperFile | ( | int32_t | db, |
int32_t | tb | ||
) |
Deletes the wrapper file from a table subdir.
Definition at line 652 of file CachingFileMgr.cpp.
References CHECK.
|
overridevirtual |
describes this FileMgr for logging purposes.
Reimplemented from File_Namespace::FileMgr.
Definition at line 241 of file CachingFileMgr.cpp.
std::string File_Namespace::CachingFileMgr::dump | ( | ) | const |
Definition at line 58 of file CachingFileMgr.cpp.
References chunk_evict_alg_, File_Namespace::FileMgr::chunkIndex_, LRUEvictionAlgorithm::dumpEvictionQueue(), show_chunk(), and table_evict_alg_.
|
inline |
Definition at line 373 of file CachingFileMgr.h.
References chunk_evict_alg_, and LRUEvictionAlgorithm::dumpEvictionQueue().
std::string File_Namespace::CachingFileMgr::dumpKeysWithChunkData | ( | ) | const |
Definition at line 631 of file CachingFileMgr.cpp.
References show_chunk().
std::string File_Namespace::CachingFileMgr::dumpKeysWithMetadata | ( | ) | const |
Definition at line 620 of file CachingFileMgr.cpp.
References show_chunk().
|
inline |
Definition at line 372 of file CachingFileMgr.h.
References LRUEvictionAlgorithm::dumpEvictionQueue(), and table_evict_alg_.
|
overridevirtual |
obtain the epoch version for the given table.
Reimplemented from File_Namespace::FileMgr.
Definition at line 141 of file CachingFileMgr.cpp.
References Epoch::min_allowable_epoch(), table_dirs_, and table_dirs_mutex_.
|
private |
evicts all metadata pages for the least recently used table. Returns the first FileInfo that a page was evicted from (guaranteed to now have at least one free page in it).
Definition at line 475 of file CachingFileMgr.cpp.
References CHECK, anonymous_namespace{CachingFileMgr.cpp}::evict_chunk_or_fail(), and get_table_prefix().
|
private |
evicts all data pages for the least recently used Chunk (metadata pages persist). Returns the first FileInfo that a page was evicted from (guaranteed to now have at least one free page in it).
Definition at line 503 of file CachingFileMgr.cpp.
References CHECK, and anonymous_namespace{CachingFileMgr.cpp}::evict_chunk_or_fail().
|
inlineoverridevirtual |
True if a read error should cause a fatal error.
Reimplemented from File_Namespace::FileMgr.
Definition at line 298 of file CachingFileMgr.h.
|
overridevirtual |
Unlike the FileMgr, the CFM frees pages immediately instead of holding them until the next checkpoint.
Reimplemented from File_Namespace::FileMgr.
Definition at line 735 of file CachingFileMgr.cpp.
|
inlineoverride |
Definition at line 218 of file CachingFileMgr.h.
References getFilesSize(), and getTableFileMgrsSize().
Referenced by getAvailableSpace().
|
inline |
Definition at line 214 of file CachingFileMgr.h.
References getAllocated(), and max_size_.
|
inline |
Definition at line 215 of file CachingFileMgr.h.
References getTableFileMgrsSize(), and max_wrapper_space_.
std::optional< FileBuffer * > File_Namespace::CachingFileMgr::getBufferIfExists | ( | const ChunkKey & | key | ) |
an optional version of get buffer if we are not sure a chunk exists.
Definition at line 704 of file CachingFileMgr.cpp.
|
overrideprivatevirtual |
Reimplemented from File_Namespace::FileMgr.
Definition at line 729 of file CachingFileMgr.cpp.
std::vector< ChunkKey > File_Namespace::CachingFileMgr::getChunkKeysForPrefix | ( | const ChunkKey & | prefix | ) | const |
Returns the keys for chunks with chunk data that match the given prefix.
Definition at line 582 of file CachingFileMgr.cpp.
References in_same_table().
|
override |
Definition at line 720 of file CachingFileMgr.cpp.
size_t File_Namespace::CachingFileMgr::getChunkSpaceReservedByTable | ( | int32_t | db_id, |
int32_t | tb_id | ||
) | const |
Set of functions to determine how much space is reserved in a table by type.
Definition at line 195 of file CachingFileMgr.cpp.
References File_Namespace::FileMgr::chunkIndex_, File_Namespace::FileMgr::chunkIndexMutex_, and File_Namespace::FileMgr::page_size_.
Referenced by getSpaceReservedByTable().
|
inline |
Definition at line 207 of file CachingFileMgr.h.
References File_Namespace::FileMgr::num_pages_per_data_file_, and File_Namespace::FileMgr::page_size_.
size_t File_Namespace::CachingFileMgr::getFilesSize | ( | ) | const |
Get the total size of page files (data and metadata files). This includes allocated, but unused space.
Definition at line 554 of file CachingFileMgr.cpp.
Referenced by getAllocated().
|
private |
returns set of keys contained in chunkIndex_ that match the given table prefix.
Definition at line 462 of file CachingFileMgr.cpp.
std::set< ChunkKey > File_Namespace::CachingFileMgr::getKeysWithMetadata | ( | ) | const |
Definition at line 739 of file CachingFileMgr.cpp.
|
inline |
Definition at line 204 of file CachingFileMgr.h.
References max_num_data_files_.
size_t File_Namespace::CachingFileMgr::getMaxDataFilesSize | ( | ) | const |
Definition at line 750 of file CachingFileMgr.cpp.
|
inline |
Definition at line 205 of file CachingFileMgr.h.
References max_num_meta_files_.
|
inlineoverride |
|
inline |
Definition at line 206 of file CachingFileMgr.h.
References max_wrapper_space_.
|
inline |
Definition at line 208 of file CachingFileMgr.h.
References File_Namespace::FileMgr::metadata_page_size_, and File_Namespace::FileMgr::num_pages_per_metadata_file_.
size_t File_Namespace::CachingFileMgr::getMetadataSpaceReservedByTable | ( | int32_t | db_id, |
int32_t | tb_id | ||
) | const |
Definition at line 209 of file CachingFileMgr.cpp.
References File_Namespace::FileMgr::chunkIndex_, File_Namespace::FileMgr::chunkIndexMutex_, and File_Namespace::FileMgr::metadata_page_size_.
Referenced by getSpaceReservedByTable().
|
inlineoverride |
Definition at line 200 of file CachingFileMgr.h.
|
inlinestatic |
Definition at line 188 of file CachingFileMgr.h.
References DEFAULT_METADATA_PAGE_SIZE, File_Namespace::FileMgr::DEFAULT_NUM_PAGES_PER_METADATA_FILE, and METADATA_FILE_SPACE_PERCENTAGE.
Referenced by CommandLineOptions::validate().
size_t File_Namespace::CachingFileMgr::getNumChunksWithMetadata | ( | ) | const |
Returns the number of buffers with metadata in the CFM. Any buffer with an encoder counts.
Definition at line 609 of file CachingFileMgr.cpp.
size_t File_Namespace::CachingFileMgr::getNumDataChunks | ( | ) | const |
Returns the number of buffers with chunk data in the CFM.
Definition at line 404 of file CachingFileMgr.cpp.
size_t File_Namespace::CachingFileMgr::getNumDataFiles | ( | ) | const |
Definition at line 572 of file CachingFileMgr.cpp.
size_t File_Namespace::CachingFileMgr::getNumMetaFiles | ( | ) | const |
Definition at line 577 of file CachingFileMgr.cpp.
|
inline |
size_t File_Namespace::CachingFileMgr::getSpaceReservedByTable | ( | int32_t | db_id, |
int32_t | tb_id | ||
) | const |
Definition at line 234 of file CachingFileMgr.cpp.
References getChunkSpaceReservedByTable(), getMetadataSpaceReservedByTable(), and getTableFileMgrSpaceReserved().
|
inlineoverride |
Definition at line 201 of file CachingFileMgr.h.
std::string File_Namespace::CachingFileMgr::getTableFileMgrPath | ( | int32_t | db, |
int32_t | tb | ||
) | const |
Definition at line 179 of file CachingFileMgr.cpp.
References File_Namespace::get_dir_name_for_table(), and File_Namespace::FileMgr::getFileMgrBasePath().
size_t File_Namespace::CachingFileMgr::getTableFileMgrSpaceReserved | ( | int32_t | db_id, |
int32_t | tb_id | ||
) | const |
Definition at line 224 of file CachingFileMgr.cpp.
References table_dirs_, and table_dirs_mutex_.
Referenced by getSpaceReservedByTable().
size_t File_Namespace::CachingFileMgr::getTableFileMgrsSize | ( | ) | const |
Returns the total size of all subdirectory files. Each table represented in the CFM has a subdirectory for serialized data wrappers and epoch files.
Definition at line 563 of file CachingFileMgr.cpp.
Referenced by getAllocated(), and getAvailableWrapperSpace().
|
inlineoverridevirtual |
Query to determine if the contained pages will have their database and table ids overriden by the filemgr key (FileMgr does this).
Reimplemented from File_Namespace::FileMgr.
Definition at line 237 of file CachingFileMgr.h.
bool File_Namespace::CachingFileMgr::hasWrapperFile | ( | int32_t | db_id, |
int32_t | table_id | ||
) | const |
Checks if data wrapper file has been written to disk/cached.
Definition at line 671 of file CachingFileMgr.cpp.
|
private |
Increment epochs for each table in the CFM.
Definition at line 318 of file CachingFileMgr.cpp.
Referenced by init().
|
private |
Increments epoch for the given table.
Definition at line 158 of file CachingFileMgr.cpp.
References CHECK, table_dirs_, and table_dirs_mutex_.
|
private |
Initializes a CFM, parsing any existing files and initializing data structures appropriately (currently not thread-safe).
Definition at line 83 of file CachingFileMgr.cpp.
References createBufferFromHeaders(), deleteCacheIfTooLarge(), File_Namespace::FileMgr::freePages(), incrementAllEpochs(), File_Namespace::FileMgr::initializeNumThreads(), File_Namespace::FileMgr::isFullyInitted_, File_Namespace::FileMgr::nextFileId_, File_Namespace::FileMgr::openFiles(), readTableFileMgrs(), gpu_enabled::sort(), and VLOG.
Referenced by CachingFileMgr().
|
override |
deletes any existing buffer for the given key then copies in a new one.
putBuffer() needs to behave differently than it does in FileMgr. Specifically, it needs to delete the buffer beforehand and then append, rather than overwrite the existing buffer. This way we only store a single version of the buffer rather than accumulating versions that need to be rolled off.
Definition at line 306 of file CachingFileMgr.cpp.
References CHECK, Data_Namespace::AbstractBuffer::isDirty(), Data_Namespace::AbstractBuffer::setAppended(), Data_Namespace::AbstractBuffer::setDirty(), and Data_Namespace::AbstractBuffer::size().
|
inlineoverrideprivatevirtual |
Reimplemented from File_Namespace::FileMgr.
Definition at line 499 of file CachingFileMgr.h.
|
private |
Checks for any sub-directories containing table-specific data and creates epochs from found files.
Definition at line 117 of file CachingFileMgr.cpp.
References CHECK, File_Namespace::FileMgr::fileMgrBasePath_, table_dirs_, and table_dirs_mutex_.
Referenced by init().
std::unique_ptr< CachingFileMgr > File_Namespace::CachingFileMgr::reconstruct | ( | ) | const |
Initializes a new CFM using the initialization values in the current CFM.
Definition at line 642 of file CachingFileMgr.cpp.
void File_Namespace::CachingFileMgr::removeChunkKeepMetadata | ( | const ChunkKey & | key | ) |
Free pages for chunk and remove it from the chunk eviction algorithm.
Definition at line 597 of file CachingFileMgr.cpp.
References CHECK.
|
private |
Definition at line 535 of file CachingFileMgr.cpp.
References get_table_prefix().
|
private |
Erases and cleans up all buffers for a table.
Definition at line 335 of file CachingFileMgr.cpp.
Referenced by clearForTable().
|
private |
Removes the subdirectory content for a table.
Definition at line 325 of file CachingFileMgr.cpp.
Referenced by clearForTable().
|
overridevirtual |
requests a free page similar to FileMgr, but this override will also evict existing pages to make space if there are none available.
Reimplemented from File_Namespace::FileMgr.
Definition at line 423 of file CachingFileMgr.cpp.
References CHECK, File_Namespace::FileInfo::fileId, and File_Namespace::FileInfo::getFreePage().
|
inline |
Definition at line 381 of file CachingFileMgr.h.
References limit_data_size_.
|
inline |
Definition at line 377 of file CachingFileMgr.h.
References max_num_data_files_.
|
inline |
Definition at line 378 of file CachingFileMgr.h.
References max_num_meta_files_.
|
private |
Sets the maximum number of files/space for each type of storage based on the maximum size.
Definition at line 689 of file CachingFileMgr.cpp.
References CHECK_GT.
Referenced by CachingFileMgr().
|
inline |
Definition at line 379 of file CachingFileMgr.h.
References max_wrapper_space_.
|
private |
Used to track which tables/chunks were least recently used.
Definition at line 530 of file CachingFileMgr.cpp.
References get_table_key().
|
overridevirtual |
checks whether a page should be deleted.
Reimplemented from File_Namespace::FileMgr.
Definition at line 360 of file CachingFileMgr.cpp.
References File_Namespace::DELETE_CONTINGENT, File_Namespace::FileInfo::freePage(), and File_Namespace::ROLLOFF_CONTINGENT.
|
private |
Flushes epoch value to disk for a table.
Definition at line 166 of file CachingFileMgr.cpp.
References CHECK, table_dirs_, and table_dirs_mutex_.
|
private |
helper function to flush all dirty buffers to disk.
Definition at line 378 of file CachingFileMgr.cpp.
void File_Namespace::CachingFileMgr::writeWrapperFile | ( | const std::string & | doc, |
int32_t | db, | ||
int32_t | tb | ||
) |
Writes a wrapper file to a table subdir.
Definition at line 659 of file CachingFileMgr.cpp.
References CHECK_LE.
|
mutableprivate |
Definition at line 512 of file CachingFileMgr.h.
Referenced by dump(), and dumpEvictionQueue().
|
private |
Definition at line 510 of file CachingFileMgr.h.
Referenced by setDataSizeLimit().
|
private |
Definition at line 506 of file CachingFileMgr.h.
Referenced by getMaxDataFiles(), and setMaxNumDataFiles().
|
private |
Definition at line 507 of file CachingFileMgr.h.
Referenced by getMaxMetaFiles(), and setMaxNumMetadataFiles().
|
private |
Definition at line 509 of file CachingFileMgr.h.
Referenced by CachingFileMgr(), getAvailableSpace(), and getMaxSize().
|
private |
Definition at line 508 of file CachingFileMgr.h.
Referenced by getAvailableWrapperSpace(), getMaxWrapperSize(), and setMaxWrapperSpace().
|
static |
Definition at line 186 of file CachingFileMgr.h.
Referenced by getMinimumSize().
|
static |
Definition at line 184 of file CachingFileMgr.h.
|
private |
Definition at line 504 of file CachingFileMgr.h.
Referenced by checkpoint(), closeRemovePhysical(), epoch(), getTableFileMgrSpaceReserved(), incrementEpoch(), readTableFileMgrs(), and writeAndSyncEpochToDisk().
|
mutableprivate |
Definition at line 500 of file CachingFileMgr.h.
Referenced by checkpoint(), closeRemovePhysical(), epoch(), getTableFileMgrSpaceReserved(), incrementEpoch(), readTableFileMgrs(), and writeAndSyncEpochToDisk().
|
mutableprivate |
Definition at line 513 of file CachingFileMgr.h.
Referenced by dump(), and dumpTableQueue().
|
static |
Definition at line 180 of file CachingFileMgr.h.
Referenced by foreign_storage::ForeignStorageCache::getSerializedWrapperPath().