30 using namespace Data_Namespace;
32 namespace Buffer_Namespace {
66 BufferList::iterator seg_it,
68 const size_t page_size = 512,
69 const size_t num_bytes = 0);
83 void read(int8_t*
const dst,
84 const size_t num_bytes,
85 const size_t offset = 0,
87 const int device_id = -1)
override;
89 void reserve(
const size_t num_bytes)
override;
99 void write(int8_t* src,
100 const size_t num_bytes,
101 const size_t offset = 0,
103 const int device_id = -1)
override;
106 const size_t num_bytes,
108 const int deviceId = -1)
override;
114 int8_t* getMemoryPtr()
override;
116 void setMemoryPtr(int8_t* new_ptr)
override;
118 inline size_t reservedSize()
const override {
return page_size_ * num_pages_; }
121 inline size_t pageCount()
const override {
return num_pages_; }
124 inline size_t pageSize()
const override {
return page_size_; }
126 inline int pin()
override {
127 std::lock_guard<std::mutex> pin_lock(pin_mutex_);
128 return (++pin_count_);
132 std::lock_guard<std::mutex> pin_lock(pin_mutex_);
133 CHECK(pin_count_ > 0);
134 return (--pin_count_);
138 std::lock_guard<std::mutex> pin_lock(pin_mutex_);
151 virtual void readData(int8_t*
const dst,
152 const size_t num_bytes,
153 const size_t offset = 0,
155 const int dst_device_id = -1) = 0;
156 virtual void writeData(int8_t*
const src,
157 const size_t num_bytes,
158 const size_t offset = 0,
160 const int src_device_id = -1) = 0;
size_t num_pages_
the size of each page in the buffer
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.
BufferList::iterator seg_it_
int getPinCount() override
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.
Note(s): Forbid Copying Idiom 4.1.
std::vector< bool > page_dirty_flags_
indicates when the buffer was last flushed
An AbstractBuffer is a unit of data management for a data manager.
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 pageCount() const override
Returns the number of pages in the buffer.
int32_t getSlabNum() const
size_t pageSize() const override
Returns the size in bytes of each page in the buffer.
size_t reservedSize() const override
Returns the total number of bytes allocated for the buffer.
Note(s): Forbid Copying Idiom 4.1.