33 using namespace Data_Namespace;
35 #define NUM_METADATA 10
36 #define METADATA_VERSION 0
38 namespace File_Namespace {
66 const size_t pageSize,
68 const size_t initialSize = 0);
71 const size_t pageSize,
74 const size_t initialSize = 0);
78 const std::vector<HeaderInfo>::const_iterator& headerStartIt,
79 const std::vector<HeaderInfo>::const_iterator& headerEndIt);
84 Page addNewMultiPage(
const int32_t epoch);
86 void reserve(
const size_t numBytes)
override;
88 size_t freeMetadataPages();
89 size_t freeChunkPages();
91 void freePagesBeforeEpoch(
const int32_t targetEpoch);
93 void read(int8_t*
const dst,
94 const size_t numBytes = 0,
95 const size_t offset = 0,
97 const int32_t deviceId = -1)
override;
107 void write(int8_t* src,
108 const size_t numBytes,
109 const size_t offset = 0,
111 const int32_t deviceId = -1)
override;
114 const size_t numBytes,
116 const int32_t deviceId = -1)
override;
117 void copyPage(
Page& srcPage,
119 const size_t numBytes,
120 const size_t offset = 0);
125 LOG(
FATAL) <<
"Operation not supported.";
130 inline size_t pageCount()
const override {
return multiPages_.size(); }
137 inline size_t pageSize()
const override {
return pageSize_; }
147 inline virtual std::vector<MultiPage>
getMultiPage()
const {
return multiPages_; }
151 inline size_t reservedSize()
const override {
return multiPages_.size() * pageSize_; }
158 bool isMissingPages()
const;
159 size_t numChunkPages()
const;
160 std::string dump()
const;
162 static size_t getMinPageSize();
165 void freePage(
const Page& page);
167 static constexpr
size_t kHeaderBufferOffset{32};
177 void writeHeader(
Page& page,
178 const int32_t pageId,
180 const bool writeMetadata =
false);
181 void writeMetadata(
const int32_t epoch);
182 void readMetadata(
const Page& page);
183 void setBufferHeaderSize();
185 void freePage(
const Page& page,
const bool isRolloff);
186 void freePagesBeforeEpochForMultiPage(
MultiPage& multiPage,
187 const int32_t targetEpoch,
188 const int32_t currentEpoch);
189 void initMetadataAndPageDataSize();
190 int32_t getFileMgrEpoch();
virtual std::vector< MultiPage > getMultiPage() const
Returns vector of MultiPages in the FileBuffer.
std::vector< int > ChunkKey
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.
size_t reservedHeaderSize_
size_t reservedSize() const override
Returns the total number of bytes allocated for the FileBuffer.
A logical page (Page) belongs to a file on disk.
Data_Namespace::MemoryLevel getType() const override
const size_t metadataPageSize_
std::vector< MultiPage > multiPages_
Represents/provides access to contiguous data stored in the file system.
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.
MultiPage getMetadataPage() const
size_t pageSize() const override
Returns the size in bytes of each page in the FileBuffer.
An AbstractBuffer is a unit of data management for a data manager.
size_t pageCount() const override
Returns the number of pages in the FileBuffer.
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.
size_t numMetadataPages() const
Returns the total number of used bytes in the FileBuffer.
virtual size_t reservedHeaderSize() const
bool hasDataPages() const
This file contains the declaration and definition of a Page type and a MultiPage type.
int8_t * getMemoryPtr() override
Not implemented for FileMgr – throws a runtime_error.
virtual size_t pageDataSize() const
Returns the size in bytes of the data portion of each page in the FileBuffer.
The MultiPage stores versions of the same logical page in a deque.
A FileMgr capable of limiting it's size and storing data from multiple tables in a shared directory...