OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 void setMemoryPtr (int8_t *new_ptr)
 
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 ( )

Definition at line 20 of file ForeignStorageBuffer.cpp.

Member Function Documentation

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 45 of file ForeignStorageBuffer.cpp.

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

48  {
49  if (size_ + num_bytes > reserved_byte_count_) {
50  reserve(size_ + num_bytes);
51  }
52  memcpy(buffer_.get() + size_, source, num_bytes);
53  size_ += num_bytes;
54 }
void reserve(size_t additional_num_bytes) override

+ Here is the call graph for this function:

int8_t * ForeignStorageBuffer::getMemoryPtr ( )
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 56 of file ForeignStorageBuffer.cpp.

References buffer_.

56  {
57  return buffer_.get();
58 }
MemoryLevel ForeignStorageBuffer::getType ( ) const
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 64 of file ForeignStorageBuffer.cpp.

References Data_Namespace::CPU_LEVEL.

64  {
65  return CPU_LEVEL;
66 }
size_t ForeignStorageBuffer::pageCount ( ) const
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 76 of file ForeignStorageBuffer.cpp.

References UNREACHABLE.

76  {
77  UNREACHABLE();
78  return 0; // Added to avoid "no return statement" compiler warning
79 }
#define UNREACHABLE()
Definition: Logger.h:338
size_t ForeignStorageBuffer::pageSize ( ) const
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 81 of file ForeignStorageBuffer.cpp.

References UNREACHABLE.

81  {
82  UNREACHABLE();
83  return 0; // Added to avoid "no return statement" compiler warning
84 }
#define UNREACHABLE()
Definition: Logger.h:338
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 }
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 (total_num_bytes > reserved_byte_count_) {
33  auto old_buffer = std::move(buffer_);
35  while (total_num_bytes > reserved_byte_count_) {
37  }
38  buffer_ = std::make_unique<int8_t[]>(reserved_byte_count_);
39  if (old_buffer) {
40  memcpy(buffer_.get(), old_buffer.get(), size_);
41  }
42  }
43 }

+ Here is the caller graph for this function:

size_t ForeignStorageBuffer::reservedSize ( ) const
overridevirtual

Implements Data_Namespace::AbstractBuffer.

Definition at line 60 of file ForeignStorageBuffer.cpp.

References reserved_byte_count_.

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 68 of file ForeignStorageBuffer.cpp.

References UNREACHABLE.

72  {
73  UNREACHABLE();
74 }
#define UNREACHABLE()
Definition: Logger.h:338

Member Data Documentation

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

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: