OmniSciDB
a5dc49c757
|
Namespaces | |
anonymous_namespace{FileBuffer.cpp} | |
anonymous_namespace{FileMgr.cpp} | |
Classes | |
struct | DiskCacheConfig |
class | TableFileMgr |
class | CachingFileBuffer |
class | CachingFileMgr |
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... | |
class | CachingGlobalFileMgr |
struct | readThreadDS |
class | FileBuffer |
Represents/provides access to contiguous data stored in the file system. More... | |
struct | FileInfo |
struct | FileMetadata |
struct | StorageStats |
struct | OpenFilesResult |
struct | PageMapping |
class | FileMgr |
struct | FileMgrParams |
class | GlobalFileMgr |
struct | Page |
A logical page (Page) belongs to a file on disk. More... | |
struct | EpochedPage |
struct | MultiPage |
The MultiPage stores versions of the same logical page in a deque. More... | |
struct | HeaderInfo |
Stores Pair of ChunkKey and Page id and version, in a pair with a Page struct itself (File id and Page num) More... | |
Typedefs | |
using | PageSizeFileMMap = std::multimap< size_t, int32_t > |
Maps logical page sizes to files. More... | |
using | Chunk = FileBuffer |
A Chunk is the fundamental unit of execution in Map-D. More... | |
using | ChunkKeyToChunkMap = std::map< ChunkKey, FileBuffer * > |
Maps ChunkKeys (unique ids for Chunks) to Chunk objects. More... | |
using | TablePair = std::pair< const int32_t, const int32_t > |
using | PageHeaderSizeType = int32_t |
Enumerations | |
enum | DiskCacheLevel { DiskCacheLevel::none, DiskCacheLevel::fsi, DiskCacheLevel::non_fsi, DiskCacheLevel::all } |
Functions | |
std::ostream & | operator<< (std::ostream &os, DiskCacheLevel disk_cache_level) |
std::string | get_dir_name_for_table (int db_id, int tb_id) |
static size_t | readForThread (FileBuffer *fileBuffer, const readThreadDS threadDS) |
bool | is_page_deleted_with_checkpoint (int32_t table_epoch, int32_t page_epoch, int32_t contingent) |
bool | is_page_deleted_without_checkpoint (int32_t table_epoch, int32_t page_epoch, int32_t contingent) |
std::string | get_data_file_path (const std::string &base_path, int file_id, size_t page_size) |
std::string | get_legacy_data_file_path (const std::string &new_data_file_path) |
std::pair< FILE *, std::string > | create (const std::string &basePath, const int fileId, const size_t pageSize, const size_t numPages) |
FILE * | create (const std::string &full_path, const size_t requested_file_size) |
Opens/creates a file with the given path and file size. Fatal crash if file can not be created to required size. More... | |
FILE * | open (int file_id) |
Opens the file with the given id; fatal crash on error. More... | |
FILE * | open (const std::string &path) |
void | close (FILE *f) |
Closes the file pointed to by the FILE pointer. More... | |
bool | removeFile (const std::string &basePath, const std::string &filename) |
Deletes the file pointed to by the FILE pointer. More... | |
size_t | read (FILE *f, const size_t offset, const size_t size, int8_t *buf, const std::string &file_path) |
Reads the specified number of bytes from the offset position in file f into buf. More... | |
size_t | write (FILE *f, const size_t offset, const size_t size, const int8_t *buf) |
Writes the specified number of bytes to the offset position in file f from buf. More... | |
size_t | append (FILE *f, const size_t size, const int8_t *buf) |
Appends the specified number of bytes to the end of the file f from buf. More... | |
size_t | readPage (FILE *f, const size_t pageSize, const size_t pageNum, int8_t *buf, const std::string &file_path) |
Reads the specified page from the file f into buf. More... | |
size_t | readPartialPage (FILE *f, const size_t pageSize, const size_t offset, const size_t readSize, const size_t pageNum, int8_t *buf, const std::string &file_path) |
size_t | writePage (FILE *f, const size_t pageSize, const size_t pageNum, int8_t *buf) |
Writes a page from buf to the file. More... | |
size_t | writePartialPage (FILE *f, const size_t pageSize, const size_t offset, const size_t writeSize, const size_t pageNum, int8_t *buf) |
size_t | appendPage (FILE *f, const size_t pageSize, int8_t *buf) |
Appends a page from buf to the file. More... | |
size_t | fileSize (FILE *f) |
Returns the size of the specified file. More... | |
void | renameForDelete (const std::string directoryName) |
Renames a directory to DELETE_ME_<EPOCH>_<oldname>. More... | |
Variables | |
constexpr int32_t | DELETE_CONTINGENT = -1 |
A FileInfo type has a file pointer and metadata about a file. More... | |
constexpr int32_t | ROLLOFF_CONTINGENT = -2 |
constexpr int32_t | kDbVersion {2} |
DB version for DataMgr DS and corresponding file buffer read/write code. More... | |
constexpr auto | kLegacyDataFileExtension {".mapd"} |
using File_Namespace::Chunk = typedef FileBuffer |
A Chunk is the fundamental unit of execution in Map-D.
Chunk A chunk is composed of logical pages. These pages can exist across multiple files managed by the file manager.
The collection of pages is implemented as a FileBuffer object, which is composed of a vector of MultiPage objects, one for each logical page of the file buffer.
using File_Namespace::ChunkKeyToChunkMap = typedef std::map<ChunkKey, FileBuffer*> |
Maps ChunkKeys (unique ids for Chunks) to Chunk objects.
ChunkKeyToChunkMap The file system can store multiple chunks across multiple files. With that in mind, the challenge is to be able to reconstruct the pages that compose a chunk upon request. A chunk key (ChunkKey) uniquely identifies a chunk, and so ChunkKeyToChunkMap maps chunk keys to Chunk types, which are vectors of MultiPage* pointers (logical pages).
using File_Namespace::PageHeaderSizeType = typedef int32_t |
using File_Namespace::PageSizeFileMMap = typedef std::multimap<size_t, int32_t> |
Maps logical page sizes to files.
PageSizeFileMMap The file manager uses this type in order to quickly find files of a certain page size. A multimap is used to associate the key (page size) with values (file identifiers of files having the matching page size).
using File_Namespace::TablePair = typedef std::pair<const int32_t, const int32_t> |
|
strong |
Enumerator | |
---|---|
none | |
fsi | |
non_fsi | |
all |
Definition at line 42 of file CachingFileMgr.h.
size_t File_Namespace::append | ( | FILE * | f, |
const size_t | size, | ||
const int8_t * | buf | ||
) |
Appends the specified number of bytes to the end of the file f from buf.
f | Pointer to the FILE. |
n | The number of bytes to append to the file. |
buf | The source buffer containing the data to be appended. |
err | If not NULL, will hold an error code should an error occur. |
Definition at line 158 of file File.cpp.
References fileSize(), and write().
Referenced by benchmarks.GoogleBenchmark::aggregateBenchmarks(), run_benchmark::benchmark(), concat(), concat_with(), com.mapd.utility.SQLImporter::createDBTable(), org.apache.calcite.rel.externalize.HeavyDBRelWriterImpl::explain_(), com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction::getExtendedSignature(), ai.heavy.jdbc.HeavyAIPreparedStatement::getQuery(), com.mapd.parser.server.ExtensionFunctionSignatureParser::join(), run_benchmark::read_query_files(), run_benchmark_arrow::run_query(), run_benchmark::run_query(), org.apache.calcite.rel.externalize.HeavyDBRelWriterImpl::simple(), ai.heavy.jdbc.HeavyAIEscapeFunctions::singleArgumentFunctionCall(), com.mapd.parser.server.ExtensionFunction::toJson(), ai.heavy.jdbc.HeavyAIArray::toString(), and TableFunctionsFactory_transformers.AmbiguousSignatureCheckTransformer::visit_udtf_node().
size_t File_Namespace::appendPage | ( | FILE * | f, |
const size_t | pageSize, | ||
int8_t * | buf | ||
) |
Appends a page from buf to the file.
f | Pointer to the FILE. |
pageSize | The logical page size of the file. |
buf | The source buffer from where data is being read. |
err | If not NULL, will hold an error code should an error occur. |
Definition at line 193 of file File.cpp.
References fileSize(), and write().
void File_Namespace::close | ( | FILE * | f | ) |
Closes the file pointed to by the FILE pointer.
f | Pointer to the FILE. |
Definition at line 114 of file File.cpp.
References CHECK, and CHECK_EQ.
Referenced by File_Namespace::FileMgr::closePhysicalUnlocked(), File_Namespace::FileMgr::openAndReadLegacyEpochFile(), File_Namespace::FileMgr::readVersionFromDisk(), File_Namespace::FileMgr::writeAndSyncVersionToDisk(), File_Namespace::FileInfo::~FileInfo(), File_Namespace::FileMgr::~FileMgr(), and File_Namespace::TableFileMgr::~TableFileMgr().
std::pair< FILE *, std::string > File_Namespace::create | ( | const std::string & | basePath, |
const int | fileId, | ||
const size_t | pageSize, | ||
const size_t | numPages | ||
) |
Definition at line 55 of file File.cpp.
References f(), logger::FATAL, nvtx_helpers::anonymous_namespace{nvtx_helpers.cpp}::filename(), fileSize(), heavyai::fopen(), get_data_file_path(), get_legacy_data_file_path(), and LOG.
Referenced by File_Namespace::FileMgr::createEpochFile(), File_Namespace::FileMgr::createFile(), File_Namespace::FileMgr::createFileInfo(), UdfCompiler::generateAST(), kafka_insert(), org.apache.calcite.sql2rel.SqlToRelConverter::SqlToRelConverter(), File_Namespace::TableFileMgr::TableFileMgr(), and File_Namespace::FileMgr::writeAndSyncVersionToDisk().
FILE * File_Namespace::create | ( | const std::string & | full_path, |
const size_t | requested_file_size | ||
) |
Opens/creates a file with the given path and file size. Fatal crash if file can not be created to required size.
full_path | Full path to file. ^ |
requested_file_size | File size file must be created with. |
Definition at line 83 of file File.cpp.
References f(), logger::FATAL, fileSize(), heavyai::fopen(), and LOG.
size_t File_Namespace::fileSize | ( | FILE * | f | ) |
Returns the size of the specified file.
f | A pointer to the file. |
Definition at line 198 of file File.cpp.
Referenced by append(), appendPage(), and create().
std::string File_Namespace::get_data_file_path | ( | const std::string & | base_path, |
int | file_id, | ||
size_t | page_size | ||
) |
Definition at line 42 of file File.cpp.
References DATA_FILE_EXT, and to_string().
Referenced by create(), File_Namespace::FileMgr::createFile(), File_Namespace::FileMgr::createFileInfo(), and File_Namespace::FileMgr::deleteEmptyFiles().
|
inline |
Definition at line 90 of file CachingFileMgr.h.
Referenced by File_Namespace::CachingFileMgr::getTableFileMgrPath().
std::string File_Namespace::get_legacy_data_file_path | ( | const std::string & | new_data_file_path | ) |
Definition at line 49 of file File.cpp.
References kLegacyDataFileExtension.
Referenced by create(), and File_Namespace::FileMgr::deleteEmptyFiles().
bool File_Namespace::is_page_deleted_with_checkpoint | ( | int32_t | table_epoch, |
int32_t | page_epoch, | ||
int32_t | contingent | ||
) |
Definition at line 259 of file FileInfo.cpp.
References DELETE_CONTINGENT, and ROLLOFF_CONTINGENT.
Referenced by anonymous_namespace{TableArchiver.cpp}::update_or_drop_column_ids_in_page_headers(), and File_Namespace::FileMgr::updatePageIfDeleted().
bool File_Namespace::is_page_deleted_without_checkpoint | ( | int32_t | table_epoch, |
int32_t | page_epoch, | ||
int32_t | contingent | ||
) |
Definition at line 271 of file FileInfo.cpp.
References DELETE_CONTINGENT, and ROLLOFF_CONTINGENT.
Referenced by File_Namespace::FileMgr::updatePageIfDeleted().
FILE * File_Namespace::open | ( | int | file_id | ) |
Opens the file with the given id; fatal crash on error.
file_id | The id of the file to open. |
Definition at line 100 of file File.cpp.
References DATA_FILE_EXT, and to_string().
Referenced by File_Namespace::FileMgr::openAndReadEpochFile(), File_Namespace::FileMgr::openAndReadLegacyEpochFile(), File_Namespace::FileMgr::openExistingFile(), File_Namespace::FileMgr::readVersionFromDisk(), File_Namespace::TableFileMgr::TableFileMgr(), and File_Namespace::FileMgr::writeAndSyncVersionToDisk().
FILE * File_Namespace::open | ( | const std::string & | path | ) |
Definition at line 105 of file File.cpp.
References f(), logger::FATAL, heavyai::fopen(), and LOG.
std::ostream & File_Namespace::operator<< | ( | std::ostream & | os, |
DiskCacheLevel | disk_cache_level | ||
) |
Definition at line 847 of file CachingFileMgr.cpp.
References all, fsi, non_fsi, none, and UNREACHABLE.
size_t File_Namespace::read | ( | FILE * | f, |
const size_t | offset, | ||
const size_t | size, | ||
int8_t * | buf, | ||
const std::string & | file_path | ||
) |
Reads the specified number of bytes from the offset position in file f into buf.
f | Pointer to the FILE. |
offset | The location within the file from which to read. |
size | The number of bytes to be read. |
buf | The destination buffer to where data is being read from the file. |
file_path | Path of file to read from. |
Definition at line 125 of file File.cpp.
References CHECK_EQ.
Referenced by File_Namespace::FileMgr::openAndReadEpochFile(), File_Namespace::FileMgr::openAndReadLegacyEpochFile(), File_Namespace::FileInfo::read(), readPage(), readPartialPage(), File_Namespace::FileMgr::readVersionFromDisk(), heavyai::safe_read(), and File_Namespace::TableFileMgr::TableFileMgr().
|
static |
Definition at line 256 of file FileBuffer.cpp.
References CHECK, File_Namespace::FileMgr::getFileInfoForFileId(), File_Namespace::readThreadDS::multiPages, File_Namespace::FileBuffer::pageDataSize(), File_Namespace::FileBuffer::pageSize(), File_Namespace::FileInfo::read(), File_Namespace::FileBuffer::reservedHeaderSize(), File_Namespace::readThreadDS::t_bytesLeft, File_Namespace::readThreadDS::t_curPtr, File_Namespace::readThreadDS::t_endPage, File_Namespace::readThreadDS::t_fm, File_Namespace::readThreadDS::t_isFirstPage, File_Namespace::readThreadDS::t_startPage, and File_Namespace::readThreadDS::t_startPageOffset.
Referenced by File_Namespace::FileBuffer::read().
size_t File_Namespace::readPage | ( | FILE * | f, |
const size_t | pageSize, | ||
const size_t | pageNum, | ||
int8_t * | buf, | ||
const std::string & | file_path | ||
) |
Reads the specified page from the file f into buf.
f | Pointer to the FILE. |
pageSize | The logical page size of the file. |
pageNum | The page number from where data is being read. |
buf | The destination buffer to where data is being written. |
file_path | Path of file to read from. |
Definition at line 162 of file File.cpp.
References read().
size_t File_Namespace::readPartialPage | ( | FILE * | f, |
const size_t | pageSize, | ||
const size_t | offset, | ||
const size_t | readSize, | ||
const size_t | pageNum, | ||
int8_t * | buf, | ||
const std::string & | file_path | ||
) |
Definition at line 170 of file File.cpp.
References read().
bool File_Namespace::removeFile | ( | const std::string & | basePath, |
const std::string & | filename | ||
) |
Deletes the file pointed to by the FILE pointer.
basePath | The base path (directory) of the file. |
f | Pointer to the FILE. |
Definition at line 120 of file File.cpp.
References nvtx_helpers::anonymous_namespace{nvtx_helpers.cpp}::filename().
void File_Namespace::renameForDelete | ( | const std::string | directoryName | ) |
Renames a directory to DELETE_ME_<EPOCH>_<oldname>.
directoryName | name of directory |
Definition at line 210 of file File.cpp.
References logger::ERROR, report::error_code(), logger::FATAL, LOG, and to_string().
Referenced by File_Namespace::FileMgr::closeRemovePhysical(), Catalog_Namespace::Catalog::delDictionaryNontransactional(), Catalog_Namespace::Catalog::doTruncateTable(), and Catalog_Namespace::Catalog::removeTableFromMap().
size_t File_Namespace::write | ( | FILE * | f, |
const size_t | offset, | ||
const size_t | size, | ||
const int8_t * | buf | ||
) |
Writes the specified number of bytes to the offset position in file f from buf.
f | Pointer to the FILE. |
offset | The location within the file where data is being written. |
size | The number of bytes to write to the file. |
buf | The source buffer containing the data to be written. |
err | If not NULL, will hold an error code should an error occur. |
Definition at line 143 of file File.cpp.
References logger::FATAL, and LOG.
Referenced by StringDictionary::addStorageCapacity(), append(), appendPage(), lockmgr::TableLockMgrImpl< T >::getClusterTableMutex(), import_export::DataStreamSink::import_compressed(), heavyai::safe_write(), File_Namespace::TableFileMgr::writeAndSyncEpochToDisk(), File_Namespace::FileMgr::writeAndSyncVersionToDisk(), File_Namespace::FileMgr::writeFile(), writePage(), and writePartialPage().
size_t File_Namespace::writePage | ( | FILE * | f, |
const size_t | pageSize, | ||
const size_t | pageNum, | ||
int8_t * | buf | ||
) |
Writes a page from buf to the file.
f | Pointer to the FILE. |
pageSize | The logical page size of the file. |
pageNum | The page number to where data is being written. |
buf | The source buffer from where data is being read. |
err | If not NULL, will hold an error code should an error occur. |
Definition at line 180 of file File.cpp.
References write().
size_t File_Namespace::writePartialPage | ( | FILE * | f, |
const size_t | pageSize, | ||
const size_t | offset, | ||
const size_t | writeSize, | ||
const size_t | pageNum, | ||
int8_t * | buf | ||
) |
Definition at line 184 of file File.cpp.
References write().
constexpr int32_t File_Namespace::DELETE_CONTINGENT = -1 |
A FileInfo type has a file pointer and metadata about a file.
FileInfo A file info structure wraps around a file pointer in order to contain additional information/metadata about the file that is pertinent to the file manager.
The free pages (freePages) within a file must be tracked, and this is implemented using a basic STL set. The set ensures that no duplicate pages are included, and that the pages are sorted, faciliating the obtaining of consecutive free pages by a constant time pop operation, which may reduce the cost of DBMS disk accesses.
Helper functions are provided: size(), available(), and used().
Definition at line 51 of file FileInfo.h.
Referenced by File_Namespace::FileInfo::freePage(), is_page_deleted_with_checkpoint(), is_page_deleted_without_checkpoint(), and File_Namespace::CachingFileMgr::updatePageIfDeleted().
constexpr int32_t File_Namespace::kDbVersion {2} |
constexpr auto File_Namespace::kLegacyDataFileExtension {".mapd"} |
Definition at line 36 of file File.h.
Referenced by anonymous_namespace{TableArchiver.cpp}::add_data_file_symlinks(), get_legacy_data_file_path(), and File_Namespace::FileMgr::renameAndSymlinkLegacyFiles().
constexpr int32_t File_Namespace::ROLLOFF_CONTINGENT = -2 |
Definition at line 52 of file FileInfo.h.
Referenced by File_Namespace::FileInfo::freePage(), is_page_deleted_with_checkpoint(), is_page_deleted_without_checkpoint(), and File_Namespace::CachingFileMgr::updatePageIfDeleted().