|
| Buffer (BufferMgr *bm, BufferList::iterator seg_it, const int device_id, const size_t page_size=512, const size_t num_bytes=0) |
| Constructs a Buffer object. The constructor requires a memory address (provided by BufferMgr), number of pages, and the size in bytes of each page. Additionally, the Buffer can be initialized with an epoch. More...
|
|
| ~Buffer () override |
| Destructor. More...
|
|
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 device_id=-1) override |
| Reads (copies) data from the buffer to the destination (dst) memory location. Reads (copies) nbytes of data from the buffer, beginning at the specified byte offset, into the destination (dst) memory location. More...
|
|
void | reserve (const size_t num_bytes) override |
|
void | write (int8_t *src, const size_t num_bytes, const size_t offset=0, const MemoryLevel src_buffer_type=CPU_LEVEL, const int device_id=-1) override |
| Writes (copies) data from src into the buffer. Writes (copies) nbytes of data into the buffer at the specified byte offset, from the source (src) memory location. More...
|
|
void | append (int8_t *src, const size_t num_bytes, const MemoryLevel src_buffer_type=CPU_LEVEL, const int deviceId=-1) override |
|
int8_t * | getMemoryPtr () override |
| Returns a raw, constant (read-only) pointer to the underlying buffer. More...
|
|
void | setMemoryPtr (int8_t *new_ptr) override |
|
size_t | reservedSize () const override |
| Returns the total number of bytes allocated for the buffer. More...
|
|
size_t | pageCount () const override |
| Returns the number of pages in the buffer. More...
|
|
size_t | pageSize () const override |
| Returns the size in bytes of each page in the buffer. More...
|
|
int | pin () override |
|
int | unPin () override |
|
int | getPinCount () override |
|
int32_t | getSlabNum () const |
|
| AbstractBuffer (const int device_id) |
|
| AbstractBuffer (const int device_id, const SQLTypeInfo sql_type) |
|
virtual | ~AbstractBuffer () |
|
virtual MemoryLevel | getType () const =0 |
|
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 () |
|
Note(s): Forbid Copying Idiom 4.1.
Definition at line 42 of file Buffer.h.
void Buffer_Namespace::Buffer::read |
( |
int8_t *const |
dst, |
|
|
const size_t |
num_bytes, |
|
|
const size_t |
offset = 0 , |
|
|
const MemoryLevel |
dst_buffer_type = CPU_LEVEL , |
|
|
const int |
device_id = -1 |
|
) |
| |
|
overridevirtual |
Reads (copies) data from the buffer to the destination (dst) memory location. Reads (copies) nbytes of data from the buffer, beginning at the specified byte offset, into the destination (dst) memory location.
- Parameters
-
dst | The destination address to where the buffer's data is being copied. |
offset | The byte offset into the buffer from where reading (copying) begins. |
nbytes | The number of bytes being read (copied) into the destination (dst). |
Implements Data_Namespace::AbstractBuffer.
Definition at line 67 of file Buffer.cpp.
References CHECK, logger::FATAL, LOG, mem_, readData(), and Data_Namespace::AbstractBuffer::size_.
77 boost::shared_lock<boost::shared_mutex> read_lock(read_write_mutex_);
80 if (num_bytes + offset >
size_) {
81 LOG(
FATAL) <<
"Buffer: Out of bounds read error";
83 readData(dst, num_bytes, offset, dst_buffer_type, dst_device_id);
virtual void readData(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
void Buffer_Namespace::Buffer::write |
( |
int8_t * |
src, |
|
|
const size_t |
num_bytes, |
|
|
const size_t |
offset = 0 , |
|
|
const MemoryLevel |
src_buffer_type = CPU_LEVEL , |
|
|
const int |
device_id = -1 |
|
) |
| |
|
overridevirtual |
Writes (copies) data from src into the buffer. Writes (copies) nbytes of data into the buffer at the specified byte offset, from the source (src) memory location.
- Parameters
-
src | The source address from where data is being copied to the buffer. |
num_bytes | The number of bytes being written (copied) into the buffer. |
offset | The byte offset into the buffer to where writing begins. |
Implements Data_Namespace::AbstractBuffer.
Definition at line 86 of file Buffer.cpp.
References CHECK_GT, page_dirty_flags_, page_size_, reserve(), reservedSize(), Data_Namespace::AbstractBuffer::setAppended(), Data_Namespace::AbstractBuffer::setDirty(), Data_Namespace::AbstractBuffer::setUpdated(), Data_Namespace::AbstractBuffer::size_, and writeData().
93 boost::unique_lock<boost::shared_mutex> write_lock(read_write_mutex_);
99 writeData(src, num_bytes, offset, src_buffer_type, src_device_id);
103 if (offset <
size_) {
106 if (offset + num_bytes >
size_) {
108 size_ = offset + num_bytes;
113 size_t first_dirty_page = offset /
page_size_;
114 size_t last_dirty_page = (offset + num_bytes - 1) /
page_size_;
115 for (
size_t i = first_dirty_page; i <= last_dirty_page; ++i) {
virtual void writeData(int8_t *const 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
std::vector< bool > page_dirty_flags_
indicates when the buffer was last flushed
size_t reservedSize() const override
Returns the total number of bytes allocated for the buffer.
void reserve(const size_t num_bytes) override