OmniSciDB  2e3a973ef4
foreign_storage::ForeignStorageBuffer Class Reference

#include <ForeignStorageBuffer.h>

+ Inheritance diagram for foreign_storage::ForeignStorageBuffer:
+ Collaboration diagram for foreign_storage::ForeignStorageBuffer:

Public Member Functions

 ForeignStorageBuffer ()
 
void read (int8_t *const destination, const size_t num_bytes, const size_t offset=0, const MemoryLevel destination_buffer_type=CPU_LEVEL, const int destination_device_id=-1) override
 
void write (int8_t *source, const size_t num_bytes, const size_t offset=0, const MemoryLevel source_buffer_type=CPU_LEVEL, const int source_device_id=-1) override
 
void reserve (size_t additional_num_bytes) override
 
void append (int8_t *source, const size_t num_bytes, const MemoryLevel source_buffer_type=CPU_LEVEL, const int device_id=-1) override
 
int8_t * getMemoryPtr () override
 
size_t pageCount () const override
 
size_t pageSize () const override
 
size_t reservedSize () const override
 
MemoryLevel getType () const override
 
- Public Member Functions inherited from Data_Namespace::AbstractBuffer
 AbstractBuffer (const int device_id)
 
 AbstractBuffer (const int device_id, const SQLTypeInfo sql_type)
 
virtual ~AbstractBuffer ()
 
virtual int pin ()
 
virtual int unPin ()
 
virtual int getPinCount ()
 
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)
 
EncodergetEncoder () 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 ()
 

Private Attributes

std::unique_ptr< int8_t[]> buffer_
 
size_t reserved_byte_count_
 

Additional Inherited Members

- Protected Attributes inherited from Data_Namespace::AbstractBuffer
std::unique_ptr< Encoderencoder_
 
SQLTypeInfo sql_type_
 
size_t size_
 
int device_id_
 

Detailed Description

Definition at line 24 of file ForeignStorageBuffer.h.

Constructor & Destructor Documentation

◆ ForeignStorageBuffer()

ForeignStorageBuffer::ForeignStorageBuffer ( )

Definition at line 20 of file ForeignStorageBuffer.cpp.

Member Function Documentation

◆ append()

void ForeignStorageBuffer::append ( int8_t *  source,
const size_t  num_bytes,
const MemoryLevel  source_buffer_type = CPU_LEVEL,
const int  device_id = -1 
)
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 42 of file ForeignStorageBuffer.cpp.

References buffer_, reserve(), reserved_byte_count_, and Data_Namespace::AbstractBuffer::size_.

45  {
46  if (size_ + num_bytes > reserved_byte_count_) {
47  reserve(num_bytes);
48  }
49  memcpy(buffer_.get() + size_, source, num_bytes);
50  size_ += num_bytes;
51 }
void reserve(size_t additional_num_bytes) override
+ Here is the call graph for this function:

◆ getMemoryPtr()

int8_t * ForeignStorageBuffer::getMemoryPtr ( )
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 53 of file ForeignStorageBuffer.cpp.

References buffer_.

53  {
54  return buffer_.get();
55 }

◆ getType()

MemoryLevel ForeignStorageBuffer::getType ( ) const
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 61 of file ForeignStorageBuffer.cpp.

References Data_Namespace::CPU_LEVEL.

61  {
62  return CPU_LEVEL;
63 }

◆ pageCount()

size_t ForeignStorageBuffer::pageCount ( ) const
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 73 of file ForeignStorageBuffer.cpp.

References UNREACHABLE.

73  {
74  UNREACHABLE();
75  return 0; // Added to avoid "no return statement" compiler warning
76 }
#define UNREACHABLE()
Definition: Logger.h:241

◆ pageSize()

size_t ForeignStorageBuffer::pageSize ( ) const
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 78 of file ForeignStorageBuffer.cpp.

References UNREACHABLE.

78  {
79  UNREACHABLE();
80  return 0; // Added to avoid "no return statement" compiler warning
81 }
#define UNREACHABLE()
Definition: Logger.h:241

◆ read()

void ForeignStorageBuffer::read ( int8_t *const  destination,
const size_t  num_bytes,
const size_t  offset = 0,
const MemoryLevel  destination_buffer_type = CPU_LEVEL,
const int  destination_device_id = -1 
)
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 23 of file ForeignStorageBuffer.cpp.

References buffer_.

27  {
28  memcpy(destination, buffer_.get() + offset, num_bytes);
29 }

◆ reserve()

void ForeignStorageBuffer::reserve ( size_t  additional_num_bytes)
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 31 of file ForeignStorageBuffer.cpp.

References buffer_, reserved_byte_count_, and Data_Namespace::AbstractBuffer::size_.

Referenced by append().

31  {
32  if (size_ + additional_num_bytes > reserved_byte_count_) {
33  auto old_buffer = std::move(buffer_);
34  reserved_byte_count_ += additional_num_bytes;
35  buffer_ = std::make_unique<int8_t[]>(reserved_byte_count_);
36  if (old_buffer) {
37  memcpy(buffer_.get(), old_buffer.get(), size_);
38  }
39  }
40 }
+ Here is the caller graph for this function:

◆ reservedSize()

size_t ForeignStorageBuffer::reservedSize ( ) const
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 57 of file ForeignStorageBuffer.cpp.

References reserved_byte_count_.

◆ write()

void ForeignStorageBuffer::write ( int8_t *  source,
const size_t  num_bytes,
const size_t  offset = 0,
const MemoryLevel  source_buffer_type = CPU_LEVEL,
const int  source_device_id = -1 
)
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 65 of file ForeignStorageBuffer.cpp.

References UNREACHABLE.

69  {
70  UNREACHABLE();
71 }
#define UNREACHABLE()
Definition: Logger.h:241

Member Data Documentation

◆ buffer_

std::unique_ptr<int8_t[]> foreign_storage::ForeignStorageBuffer::buffer_
private

Definition at line 54 of file ForeignStorageBuffer.h.

Referenced by append(), getMemoryPtr(), read(), and reserve().

◆ reserved_byte_count_

size_t foreign_storage::ForeignStorageBuffer::reserved_byte_count_
private

Definition at line 55 of file ForeignStorageBuffer.h.

Referenced by append(), reserve(), and reservedSize().


The documentation for this class was generated from the following files: