Class File_Namespace::FileBuffer

class FileBuffer : public Data_Namespace::AbstractBuffer

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

Subclassed by File_Namespace::CachingFileBuffer

Public Functions

FileBuffer(FileMgr *fm, const size_t pageSize, const ChunkKey &chunkKey, const size_t initialSize = 0)

Constructs a FileBuffer object.

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()

Destructor.

Page addNewMultiPage(const int32_t epoch)
void reserve(const size_t numBytes)
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)
void write(int8_t *src, const size_t numBytes, const size_t offset = 0, const MemoryLevel srcMemoryLevel = CPU_LEVEL, const int32_t deviceId = -1)

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)

void append(int8_t *src, const size_t numBytes, const MemoryLevel srcMemoryLevel = CPU_LEVEL, const int32_t deviceId = -1)
void copyPage(Page &srcPage, Page &destPage, const size_t numBytes, const size_t offset = 0)
Data_Namespace::MemoryLevel getType() const
int8_t *getMemoryPtr()

Not implemented for FileMgr throws a runtime_error.

size_t pageCount() const

Returns the number of pages in the FileBuffer.

bool hasDataPages() const

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.

size_t pageSize() const

Returns the size in bytes of each page in the FileBuffer.

virtual size_t pageDataSize() const

Returns the size in bytes of the data portion of each page in the FileBuffer.

virtual size_t reservedHeaderSize() const

Returns the size in bytes of the reserved header portion of each page in the FileBuffer.

virtual std::vector<MultiPage> getMultiPage() const

Returns vector of MultiPages in the FileBuffer.

MultiPage getMetadataPage() const
size_t reservedSize() const

Returns the total number of bytes allocated for the FileBuffer.

size_t numMetadataPages() const

Returns the total number of used bytes in the FileBuffer.

bool isMissingPages() const
size_t numChunkPages() const
std::string dump() const
void freePage(const Page &page)

Public Static Attributes

constexpr size_t headerBufferOffset_ = 32

Private 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.

void writeMetadata(const int32_t epoch)
void readMetadata(const Page &page)
void calcHeaderBuffer()
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 Members

FileMgr *fm_
MultiPage metadataPages_
std::vector<MultiPage> multiPages_
size_t pageSize_
size_t pageDataSize_
size_t reservedHeaderSize_
ChunkKey chunkKey_

Friends

friend File_Namespace::FileBuffer::FileMgr
friend File_Namespace::FileBuffer::CachingFileMgr