Class Buffer_Namespace::Buffer

class Buffer : public Data_Namespace::AbstractBuffer

Note(s): Forbid Copying Idiom 4.1.

Subclassed by Buffer_Namespace::CpuBuffer, Buffer_Namespace::GpuCudaBuffer

Public Functions

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.

Parameters
  • mem: The beginning memory address of the buffer.

  • numPages: The number of pages into which the buffer’s memory space is divided.

  • pageSize: The size in bytes of each page that composes the buffer.

  • epoch: A temporal reference implying the buffer is up-to-date up to the epoch.

~Buffer()

Destructor.

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)

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

void reserve(const size_t num_bytes)
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)

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.

void append(int8_t *src, const size_t num_bytes, const MemoryLevel src_buffer_type = CPU_LEVEL, const int deviceId = -1)
int8_t *getMemoryPtr()

Returns a raw, constant (read-only) pointer to the underlying buffer.

Return

A constant memory pointer for read-only access.

void setMemoryPtr(int8_t *new_ptr)
size_t reservedSize() const

Returns the total number of bytes allocated for the buffer.

size_t pageCount() const

Returns the number of pages in the buffer.

size_t pageSize() const

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

int pin()
int unPin()
int getPinCount()
int32_t getSlabNum() const

Protected Attributes

int8_t *mem_

Private Functions

Buffer(const Buffer&)

pointer to beginning of buffer’s memory

Buffer &operator=(const Buffer&)
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
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

Private Members

BufferMgr *bm_
BufferList::iterator seg_it_
size_t page_size_
size_t num_pages_

the size of each page in the buffer

int epoch_
std::vector<bool> page_dirty_flags_

indicates when the buffer was last flushed

int pin_count_
std::mutex pin_mutex_

Friends

friend Buffer_Namespace::Buffer::BufferMgr
friend Buffer_Namespace::Buffer::FileMgr