OmniSciDB
a5dc49c757
|
Represents/provides access to contiguous data stored in the file system. More...
#include <FileBuffer.h>
Public Member Functions | |
FileBuffer (FileMgr *fm, const size_t pageSize, const ChunkKey &chunkKey, const size_t initialSize=0) | |
Constructs a FileBuffer object. More... | |
FileBuffer (FileMgr *fm, const size_t pageSize, const ChunkKey &chunkKey, const SQLTypeInfo sqlType, const size_t initialSize=0) | |
FileBuffer (FileMgr *fm, const ChunkKey &chunkKey, const std::vector< HeaderInfo >::const_iterator &headerStartIt, const std::vector< HeaderInfo >::const_iterator &headerEndIt) | |
~FileBuffer () override | |
Destructor. More... | |
Page | addNewMultiPage (const int32_t epoch) |
void | reserve (const size_t numBytes) override |
size_t | freeMetadataPages () |
size_t | freeChunkPages () |
size_t | freePages () |
void | freePagesBeforeEpoch (const int32_t targetEpoch) |
void | read (int8_t *const dst, const size_t numBytes=0, const size_t offset=0, const MemoryLevel dstMemoryLevel=CPU_LEVEL, const int32_t deviceId=-1) override |
void | write (int8_t *src, const size_t numBytes, const size_t offset=0, const MemoryLevel srcMemoryLevel=CPU_LEVEL, const int32_t deviceId=-1) override |
Writes the contents of source (src) into new versions of the affected logical pages. More... | |
void | append (int8_t *src, const size_t numBytes, const MemoryLevel srcMemoryLevel=CPU_LEVEL, const int32_t deviceId=-1) override |
void | copyPage (Page &srcPage, Page &destPage, const size_t numBytes, const size_t offset=0) |
Data_Namespace::MemoryLevel | getType () const override |
int8_t * | getMemoryPtr () override |
Not implemented for FileMgr – throws a runtime_error. More... | |
size_t | pageCount () const override |
Returns the number of pages in the FileBuffer. More... | |
bool | hasDataPages () const |
size_t | pageSize () const override |
Returns the size in bytes of each page in the FileBuffer. More... | |
virtual size_t | pageDataSize () const |
Returns the size in bytes of the data portion of each page in the FileBuffer. More... | |
virtual size_t | reservedHeaderSize () const |
virtual std::vector< MultiPage > | getMultiPage () const |
Returns vector of MultiPages in the FileBuffer. More... | |
MultiPage | getMetadataPage () const |
size_t | reservedSize () const override |
Returns the total number of bytes allocated for the FileBuffer. More... | |
size_t | numMetadataPages () const |
Returns the total number of used bytes in the FileBuffer. More... | |
bool | isMissingPages () const |
size_t | numChunkPages () const |
std::string | dump () const |
void | freePage (const Page &page) |
Public Member Functions inherited from Data_Namespace::AbstractBuffer | |
AbstractBuffer (const int device_id) | |
AbstractBuffer (const int device_id, const SQLTypeInfo sql_type) | |
virtual | ~AbstractBuffer () |
virtual void | read (int8_t *const dst, const size_t num_bytes, const size_t offset=0, const MemoryLevel dst_buffer_type=CPU_LEVEL, const int dst_device_id=-1)=0 |
virtual void | write (int8_t *src, const size_t num_bytes, const size_t offset=0, const MemoryLevel src_buffer_type=CPU_LEVEL, const int src_device_id=-1)=0 |
virtual void | append (int8_t *src, const size_t num_bytes, const MemoryLevel src_buffer_type=CPU_LEVEL, const int device_id=-1)=0 |
virtual void | setMemoryPtr (int8_t *new_ptr) |
virtual int | pin () |
virtual int | unPin () |
virtual int | getPinCount () |
size_t | size () const |
int | getDeviceId () const |
bool | isDirty () const |
bool | isAppended () const |
bool | isUpdated () const |
bool | hasEncoder () const |
SQLTypeInfo | getSqlType () const |
void | setSqlType (const SQLTypeInfo &sql_type) |
Encoder * | getEncoder () const |
void | setDirty () |
void | setUpdated () |
void | setAppended () |
void | setSize (const size_t size) |
void | clearDirtyBits () |
void | initEncoder (const SQLTypeInfo &tmp_sql_type) |
void | syncEncoder (const AbstractBuffer *src_buffer) |
void | copyTo (AbstractBuffer *destination_buffer, const size_t num_bytes=0) |
void | resetToEmpty () |
Static Public Member Functions | |
static size_t | getMinPageSize () |
Static Public Attributes | |
static constexpr size_t | kHeaderBufferOffset {32} |
Private Member Functions | |
void | writeHeader (Page &page, const int32_t pageId, const int32_t epoch, const bool writeMetadata=false) |
Write header writes header at top of page in format. More... | |
void | writeMetadata (const int32_t epoch) |
void | readMetadata (const Page &page) |
void | setBufferHeaderSize () |
void | freePage (const Page &page, const bool isRolloff) |
void | freePagesBeforeEpochForMultiPage (MultiPage &multiPage, const int32_t targetEpoch, const int32_t currentEpoch) |
void | initMetadataAndPageDataSize () |
int32_t | getFileMgrEpoch () |
Private Attributes | |
FileMgr * | fm_ |
const size_t | metadataPageSize_ |
MultiPage | metadataPages_ |
std::vector< MultiPage > | multiPages_ |
size_t | pageSize_ |
size_t | pageDataSize_ |
size_t | reservedHeaderSize_ |
ChunkKey | chunkKey_ |
Friends | |
class | FileMgr |
class | CachingFileMgr |
Additional Inherited Members | |
Protected Attributes inherited from Data_Namespace::AbstractBuffer | |
std::unique_ptr< Encoder > | encoder_ |
SQLTypeInfo | sql_type_ |
size_t | size_ |
int | device_id_ |
Represents/provides access to contiguous data stored in the file system.
The FileBuffer consists of logical pages, which can map to any identically-sized page in any file of the underlying file system. A page's metadata (file and page number) are stored in MultiPage objects, and each MultiPage includes page metadata for multiple versions of the same page.
Note that a "Chunk" is brought into a FileBuffer by the FileMgr.
Note(s): Forbid Copying Idiom 4.1
Definition at line 57 of file FileBuffer.h.
File_Namespace::FileBuffer::FileBuffer | ( | FileMgr * | fm, |
const size_t | pageSize, | ||
const ChunkKey & | chunkKey, | ||
const size_t | initialSize = 0 |
||
) |
Constructs a FileBuffer object.
Definition at line 37 of file FileBuffer.cpp.
References CHECK, CHECK_GT, fm_, pageDataSize_, pageSize_, reservedHeaderSize_, and setBufferHeaderSize().
File_Namespace::FileBuffer::FileBuffer | ( | FileMgr * | fm, |
const size_t | pageSize, | ||
const ChunkKey & | chunkKey, | ||
const SQLTypeInfo | sqlType, | ||
const size_t | initialSize = 0 |
||
) |
Definition at line 67 of file FileBuffer.cpp.
References CHECK, fm_, pageDataSize_, pageSize_, reservedHeaderSize_, and setBufferHeaderSize().
File_Namespace::FileBuffer::FileBuffer | ( | FileMgr * | fm, |
const ChunkKey & | chunkKey, | ||
const std::vector< HeaderInfo >::const_iterator & | headerStartIt, | ||
const std::vector< HeaderInfo >::const_iterator & | headerEndIt | ||
) |
Definition at line 83 of file FileBuffer.cpp.
References CHECK, File_Namespace::FileMgr::failOnReadError(), logger::FATAL, fm_, initMetadataAndPageDataSize(), LOG, metadataPages_, multiPages_, pageSize_, File_Namespace::MultiPage::push(), setBufferHeaderSize(), and show_chunk().
|
override |
Destructor.
Definition at line 130 of file FileBuffer.cpp.
Page File_Namespace::FileBuffer::addNewMultiPage | ( | const int32_t | epoch | ) |
Definition at line 419 of file FileBuffer.cpp.
References fm_, multiPages_, pageSize_, File_Namespace::MultiPage::push(), and File_Namespace::FileMgr::requestFreePage().
Referenced by append(), reserve(), and write().
|
override |
Definition at line 503 of file FileBuffer.cpp.
References addNewMultiPage(), CHECK, File_Namespace::Page::fileId, fm_, File_Namespace::FileMgr::getFileInfoForFileId(), getFileMgrEpoch(), multiPages_, pageDataSize_, File_Namespace::Page::pageNum, pageSize_, reservedHeaderSize_, Data_Namespace::AbstractBuffer::setAppended(), Data_Namespace::AbstractBuffer::size_, File_Namespace::FileInfo::write(), and writeHeader().
void File_Namespace::FileBuffer::copyPage | ( | Page & | srcPage, |
Page & | destPage, | ||
const size_t | numBytes, | ||
const size_t | offset = 0 |
||
) |
Definition at line 401 of file FileBuffer.cpp.
References CHECK, CHECK_LE, checked_malloc(), File_Namespace::Page::fileId, fm_, File_Namespace::FileMgr::getFileInfoForFileId(), pageDataSize_, File_Namespace::Page::pageNum, pageSize_, File_Namespace::FileInfo::read(), reservedHeaderSize_, and File_Namespace::FileInfo::write().
Referenced by write().
std::string File_Namespace::FileBuffer::dump | ( | ) | const |
Definition at line 642 of file FileBuffer.cpp.
References chunkKey_, Data_Namespace::AbstractBuffer::hasEncoder(), show_chunk(), and Data_Namespace::AbstractBuffer::size_.
size_t File_Namespace::FileBuffer::freeChunkPages | ( | ) |
Definition at line 189 of file FileBuffer.cpp.
References freePage(), and multiPages_.
Referenced by freePages(), and freePagesBeforeEpoch().
size_t File_Namespace::FileBuffer::freeMetadataPages | ( | ) |
Definition at line 176 of file FileBuffer.cpp.
References freePage(), metadataPages_, File_Namespace::MultiPage::pageVersions, and File_Namespace::MultiPage::pop().
Referenced by freePages().
void File_Namespace::FileBuffer::freePage | ( | const Page & | page | ) |
Definition at line 166 of file FileBuffer.cpp.
Referenced by freeChunkPages(), freeMetadataPages(), and freePagesBeforeEpochForMultiPage().
|
private |
Definition at line 170 of file FileBuffer.cpp.
References CHECK, File_Namespace::Page::fileId, fm_, File_Namespace::FileInfo::freePage(), File_Namespace::FileMgr::getFileInfoForFileId(), getFileMgrEpoch(), and File_Namespace::Page::pageNum.
size_t File_Namespace::FileBuffer::freePages | ( | ) |
Definition at line 203 of file FileBuffer.cpp.
References freeChunkPages(), and freeMetadataPages().
void File_Namespace::FileBuffer::freePagesBeforeEpoch | ( | const int32_t | targetEpoch | ) |
Definition at line 217 of file FileBuffer.cpp.
References CHECK_LE, chunkKey_, fm_, freeChunkPages(), freePagesBeforeEpochForMultiPage(), getFileMgrEpoch(), metadataPages_, multiPages_, pageSize_, File_Namespace::MultiPage::pageVersions, and Data_Namespace::AbstractBuffer::size_.
|
private |
Definition at line 207 of file FileBuffer.cpp.
References freePage(), and File_Namespace::MultiPage::freePagesBeforeEpoch().
Referenced by freePagesBeforeEpoch().
|
private |
Definition at line 637 of file FileBuffer.cpp.
References chunkKey_, File_Namespace::FileMgr::epoch(), fm_, and get_table_prefix().
Referenced by append(), freePage(), freePagesBeforeEpoch(), reserve(), and write().
|
inlineoverridevirtual |
Not implemented for FileMgr – throws a runtime_error.
Implements Data_Namespace::AbstractBuffer.
Definition at line 124 of file FileBuffer.h.
References logger::FATAL, and LOG.
|
inline |
Definition at line 148 of file FileBuffer.h.
|
static |
Definition at line 161 of file FileBuffer.cpp.
References File_Namespace::anonymous_namespace{FileBuffer.cpp}::calculate_buffer_header_size().
Referenced by Parser::anonymous_namespace{ParserNode.cpp}::get_page_size_def().
|
inlinevirtual |
Returns vector of MultiPages in the FileBuffer.
Definition at line 147 of file FileBuffer.h.
Referenced by read().
|
inlineoverridevirtual |
Implements Data_Namespace::AbstractBuffer.
Definition at line 121 of file FileBuffer.h.
References Data_Namespace::DISK_LEVEL.
|
inline |
Returns whether or not a buffer has data pages. It is possible for a buffer to represent metadata (have a size and encode) but not contain actual data.
Definition at line 134 of file FileBuffer.h.
|
private |
Definition at line 650 of file FileBuffer.cpp.
References CHECK, File_Namespace::MultiPage::current(), File_Namespace::Page::fileId, metadataPages_, File_Namespace::EpochedPage::page, pageDataSize_, pageSize_, readMetadata(), and reservedHeaderSize_.
Referenced by FileBuffer().
bool File_Namespace::FileBuffer::isMissingPages | ( | ) | const |
Definition at line 656 of file FileBuffer.cpp.
References multiPages_, pageDataSize_, and Data_Namespace::AbstractBuffer::size().
size_t File_Namespace::FileBuffer::numChunkPages | ( | ) | const |
Definition at line 662 of file FileBuffer.cpp.
References multiPages_.
|
inline |
Returns the total number of used bytes in the FileBuffer.
Definition at line 156 of file FileBuffer.h.
|
inlineoverridevirtual |
Returns the number of pages in the FileBuffer.
Implements Data_Namespace::AbstractBuffer.
Definition at line 130 of file FileBuffer.h.
|
inlinevirtual |
Returns the size in bytes of the data portion of each page in the FileBuffer.
Definition at line 140 of file FileBuffer.h.
Referenced by File_Namespace::readForThread().
|
inlineoverridevirtual |
Returns the size in bytes of each page in the FileBuffer.
Implements Data_Namespace::AbstractBuffer.
Definition at line 137 of file FileBuffer.h.
Referenced by File_Namespace::readForThread(), and writeHeader().
|
override |
Definition at line 297 of file FileBuffer.cpp.
References threading_serial::async(), CHECK, Data_Namespace::CPU_LEVEL, logger::FATAL, fm_, getMultiPage(), File_Namespace::FileMgr::getNumReaderThreads(), LOG, File_Namespace::readThreadDS::multiPages, multiPages_, pageDataSize_, File_Namespace::readForThread(), 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.
|
private |
Definition at line 446 of file FileBuffer.cpp.
References CHECK, Data_Namespace::AbstractBuffer::encoder_, f(), File_Namespace::Page::fileId, fm_, File_Namespace::FileMgr::getFileForFileId(), Data_Namespace::AbstractBuffer::initEncoder(), METADATA_VERSION, metadataPageSize_, NUM_METADATA, File_Namespace::Page::pageNum, pageSize_, reservedHeaderSize_, SQLTypeInfo::set_comp_param(), SQLTypeInfo::set_compression(), SQLTypeInfo::set_dimension(), SQLTypeInfo::set_notnull(), SQLTypeInfo::set_scale(), SQLTypeInfo::set_size(), SQLTypeInfo::set_subtype(), SQLTypeInfo::set_type(), Data_Namespace::AbstractBuffer::size_, Data_Namespace::AbstractBuffer::sql_type_, and setup::version.
Referenced by initMetadataAndPageDataSize().
|
overridevirtual |
Implements Data_Namespace::AbstractBuffer.
Definition at line 135 of file FileBuffer.cpp.
References addNewMultiPage(), getFileMgrEpoch(), multiPages_, pageSize_, and writeHeader().
|
inlinevirtual |
Returns the size in bytes of the reserved header portion of each page in the FileBuffer.
Definition at line 144 of file FileBuffer.h.
Referenced by File_Namespace::readForThread().
|
inlineoverridevirtual |
Returns the total number of bytes allocated for the FileBuffer.
Implements Data_Namespace::AbstractBuffer.
Definition at line 151 of file FileBuffer.h.
|
private |
Definition at line 157 of file FileBuffer.cpp.
References File_Namespace::anonymous_namespace{FileBuffer.cpp}::calculate_buffer_header_size(), chunkKey_, and reservedHeaderSize_.
Referenced by FileBuffer().
|
override |
Writes the contents of source (src) into new versions of the affected logical pages.
This method will write the contents of source (src) into new version of the affected logical pages. New pages are only appended if the value of epoch (in FileMgr)
Definition at line 547 of file FileBuffer.cpp.
References addNewMultiPage(), CHECK, copyPage(), Data_Namespace::CPU_LEVEL, File_Namespace::Page::fileId, fm_, File_Namespace::FileMgr::getFileInfoForFileId(), getFileMgrEpoch(), multiPages_, pageDataSize_, File_Namespace::Page::pageNum, pageSize_, File_Namespace::FileMgr::requestFreePage(), reservedHeaderSize_, Data_Namespace::AbstractBuffer::setAppended(), Data_Namespace::AbstractBuffer::setDirty(), Data_Namespace::AbstractBuffer::setUpdated(), Data_Namespace::AbstractBuffer::size_, File_Namespace::FileInfo::write(), and writeHeader().
|
private |
Write header writes header at top of page in format.
Definition at line 427 of file FileBuffer.cpp.
References chunkKey_, gpu_enabled::copy(), File_Namespace::Page::fileId, fm_, File_Namespace::FileMgr::getFileInfoForFileId(), report::header, metadataPageSize_, File_Namespace::Page::pageNum, pageSize(), pageSize_, and File_Namespace::FileInfo::write().
Referenced by append(), reserve(), write(), and writeMetadata().
|
private |
Definition at line 472 of file FileBuffer.cpp.
References Data_Namespace::AbstractBuffer::encoder_, f(), File_Namespace::Page::fileId, fm_, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_dimension(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_size(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), File_Namespace::FileMgr::getFileForFileId(), Data_Namespace::AbstractBuffer::hasEncoder(), METADATA_VERSION, metadataPages_, metadataPageSize_, NUM_METADATA, File_Namespace::Page::pageNum, pageSize_, File_Namespace::MultiPage::push(), File_Namespace::FileMgr::requestFreePage(), reservedHeaderSize_, Data_Namespace::AbstractBuffer::size_, Data_Namespace::AbstractBuffer::sql_type_, and writeHeader().
|
friend |
Definition at line 59 of file FileBuffer.h.
|
friend |
Definition at line 58 of file FileBuffer.h.
|
private |
Definition at line 204 of file FileBuffer.h.
Referenced by dump(), freePagesBeforeEpoch(), getFileMgrEpoch(), setBufferHeaderSize(), and writeHeader().
|
private |
Definition at line 192 of file FileBuffer.h.
Referenced by addNewMultiPage(), append(), copyPage(), FileBuffer(), freePage(), freePagesBeforeEpoch(), getFileMgrEpoch(), read(), readMetadata(), write(), writeHeader(), and writeMetadata().
|
static |
Definition at line 167 of file FileBuffer.h.
Referenced by File_Namespace::anonymous_namespace{FileBuffer.cpp}::calculate_buffer_header_size().
|
private |
Definition at line 199 of file FileBuffer.h.
Referenced by FileBuffer(), freeMetadataPages(), freePagesBeforeEpoch(), initMetadataAndPageDataSize(), and writeMetadata().
|
private |
Definition at line 198 of file FileBuffer.h.
Referenced by readMetadata(), writeHeader(), and writeMetadata().
|
private |
Definition at line 200 of file FileBuffer.h.
Referenced by addNewMultiPage(), append(), FileBuffer(), freeChunkPages(), freePagesBeforeEpoch(), isMissingPages(), numChunkPages(), read(), reserve(), and write().
|
private |
Definition at line 202 of file FileBuffer.h.
Referenced by append(), copyPage(), FileBuffer(), initMetadataAndPageDataSize(), isMissingPages(), read(), and write().
|
private |
Definition at line 201 of file FileBuffer.h.
Referenced by addNewMultiPage(), append(), copyPage(), FileBuffer(), freePagesBeforeEpoch(), initMetadataAndPageDataSize(), readMetadata(), reserve(), write(), writeHeader(), and writeMetadata().
|
private |
Definition at line 203 of file FileBuffer.h.
Referenced by append(), copyPage(), FileBuffer(), initMetadataAndPageDataSize(), readMetadata(), setBufferHeaderSize(), write(), and writeMetadata().