OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Chunk_NS::Chunk Class Reference

#include <Chunk.h>

+ Collaboration diagram for Chunk_NS::Chunk:

Public Member Functions

 Chunk (bool pinnable=true)
 
 Chunk (const ColumnDescriptor *td)
 
 Chunk (const ColumnDescriptor *td, bool pinnable)
 
 Chunk (AbstractBuffer *b, AbstractBuffer *ib, const ColumnDescriptor *td, bool pinnable=true)
 
 ~Chunk ()
 
void setPinnable (bool pinnable)
 
const ColumnDescriptorgetColumnDesc () const
 
void setColumnDesc (const ColumnDescriptor *cd)
 
ChunkIter begin_iterator (const std::shared_ptr< ChunkMetadata > &, int start_idx=0, int skip=1) const
 
size_t getNumElemsForBytesEncodedDataAtIndices (const int8_t *index_data, const std::vector< size_t > &selected_idx, const size_t byte_limit)
 
size_t getNumElemsForBytesInsertData (const DataBlockPtr &src_data, const size_t num_elems, const size_t start_idx, const size_t byte_limit, const bool replicating=false)
 
std::shared_ptr< ChunkMetadataappendData (DataBlockPtr &srcData, const size_t numAppendElems, const size_t startIdx, const bool replicating=false)
 
std::shared_ptr< ChunkMetadataappendEncodedDataAtIndices (const Chunk &src_chunk, const std::vector< size_t > &selected_idx)
 
std::shared_ptr< ChunkMetadataappendEncodedData (const Chunk &src_chunk, const size_t num_elements, const size_t start_idx)
 
void createChunkBuffer (DataMgr *data_mgr, const ChunkKey &key, const MemoryLevel mem_level, const int deviceId=0, const size_t page_size=0)
 
void getChunkBuffer (DataMgr *data_mgr, const ChunkKey &key, const MemoryLevel mem_level, const int deviceId=0, const size_t num_bytes=0, const size_t num_elems=0)
 
bool isChunkOnDevice (DataMgr *data_mgr, const ChunkKey &key, const MemoryLevel mem_level, const int device_id)
 
AbstractBuffergetBuffer () const
 
AbstractBuffergetIndexBuf () const
 
void setBuffer (AbstractBuffer *b)
 
void setIndexBuffer (AbstractBuffer *ib)
 
void initEncoder ()
 
void decompress (int8_t *compressed, VarlenDatum *result, Datum *datum) const
 
std::string toString () const
 

Static Public Member Functions

static void translateColumnDescriptorsToChunkVec (const std::list< const ColumnDescriptor * > &colDescs, std::vector< Chunk > &chunkVec)
 
static std::shared_ptr< ChunkgetChunk (const ColumnDescriptor *cd, DataMgr *data_mgr, const ChunkKey &key, const MemoryLevel mem_level, const int deviceId, const size_t num_bytes, const size_t num_elems, const bool pinnable=true)
 
static std::shared_ptr< ChunkgetChunk (const ColumnDescriptor *cd, AbstractBuffer *data_buffer, AbstractBuffer *index_buffer, const bool pinnable=true)
 Compose a chunk from components and return it. More...
 

Private Member Functions

void setChunkBuffer (AbstractBuffer *buffer, AbstractBuffer *index_buffer)
 
void unpinBuffer ()
 

Private Attributes

AbstractBufferbuffer_
 
AbstractBufferindex_buf_
 
const ColumnDescriptorcolumn_desc_
 
bool pinnable_
 

Detailed Description

Definition at line 41 of file Chunk.h.

Constructor & Destructor Documentation

Chunk_NS::Chunk::Chunk ( bool  pinnable = true)
inline

Definition at line 43 of file Chunk.h.

Referenced by getChunk().

44  : buffer_(nullptr)
45  , index_buf_(nullptr)
46  , column_desc_(nullptr)
47  , pinnable_(pinnable) {}
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
AbstractBuffer * buffer_
Definition: Chunk.h:163
AbstractBuffer * index_buf_
Definition: Chunk.h:164
bool pinnable_
Definition: Chunk.h:168

+ Here is the caller graph for this function:

Chunk_NS::Chunk::Chunk ( const ColumnDescriptor td)
inlineexplicit

Definition at line 49 of file Chunk.h.

50  : buffer_(nullptr), index_buf_(nullptr), column_desc_(td), pinnable_(true) {}
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
AbstractBuffer * buffer_
Definition: Chunk.h:163
AbstractBuffer * index_buf_
Definition: Chunk.h:164
bool pinnable_
Definition: Chunk.h:168
Chunk_NS::Chunk::Chunk ( const ColumnDescriptor td,
bool  pinnable 
)
inline

Definition at line 52 of file Chunk.h.

53  : buffer_(nullptr), index_buf_(nullptr), column_desc_(td), pinnable_(pinnable) {}
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
AbstractBuffer * buffer_
Definition: Chunk.h:163
AbstractBuffer * index_buf_
Definition: Chunk.h:164
bool pinnable_
Definition: Chunk.h:168
Chunk_NS::Chunk::Chunk ( AbstractBuffer b,
AbstractBuffer ib,
const ColumnDescriptor td,
bool  pinnable = true 
)
inline

Definition at line 55 of file Chunk.h.

59  : buffer_(b), index_buf_(ib), column_desc_(td), pinnable_(pinnable) {}
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
AbstractBuffer * buffer_
Definition: Chunk.h:163
AbstractBuffer * index_buf_
Definition: Chunk.h:164
bool pinnable_
Definition: Chunk.h:168
Chunk_NS::Chunk::~Chunk ( )
inline

Definition at line 61 of file Chunk.h.

References unpinBuffer().

61 { unpinBuffer(); }
void unpinBuffer()
Definition: Chunk.cpp:279

+ Here is the call graph for this function:

Member Function Documentation

std::shared_ptr< ChunkMetadata > Chunk_NS::Chunk::appendData ( DataBlockPtr srcData,
const size_t  numAppendElems,
const size_t  startIdx,
const bool  replicating = false 
)

Definition at line 232 of file Chunk.cpp.

References StringNoneEncoder::appendData(), ArrayNoneEncoder::appendData(), FixedLengthArrayNoneEncoder::appendData(), Encoder::appendData(), DataBlockPtr::arraysPtr, buffer_, CHECK, CHECK_EQ, column_desc_, ColumnDescriptor::columnType, Data_Namespace::AbstractBuffer::getEncoder(), kARRAY, kCHAR, kENCODING_NONE, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, kPOLYGON, kTEXT, kVARCHAR, DataBlockPtr::numbersPtr, and DataBlockPtr::stringsPtr.

235  {
236  const auto& ti = column_desc_->columnType;
237  if (ti.is_varlen()) {
238  switch (ti.get_type()) {
239  case kARRAY: {
240  if (ti.get_size() > 0) {
241  FixedLengthArrayNoneEncoder* array_encoder =
243  return array_encoder->appendData(
244  src_data.arraysPtr, start_idx, num_elems, replicating);
245  }
246  ArrayNoneEncoder* array_encoder =
247  dynamic_cast<ArrayNoneEncoder*>(buffer_->getEncoder());
248  return array_encoder->appendData(
249  src_data.arraysPtr, start_idx, num_elems, replicating);
250  }
251  case kTEXT:
252  case kVARCHAR:
253  case kCHAR: {
254  CHECK_EQ(kENCODING_NONE, ti.get_compression());
255  StringNoneEncoder* str_encoder =
256  dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
257  return str_encoder->appendData(
258  src_data.stringsPtr, start_idx, num_elems, replicating);
259  }
260  case kPOINT:
261  case kMULTIPOINT:
262  case kLINESTRING:
263  case kMULTILINESTRING:
264  case kPOLYGON:
265  case kMULTIPOLYGON: {
266  StringNoneEncoder* str_encoder =
267  dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
268  return str_encoder->appendData(
269  src_data.stringsPtr, start_idx, num_elems, replicating);
270  }
271  default:
272  CHECK(false);
273  }
274  }
275  return buffer_->getEncoder()->appendData(
276  src_data.numbersPtr, num_elems, ti, replicating);
277 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1) override
AbstractBuffer * buffer_
Definition: Chunk.h:163
std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1) override
Definition: sqltypes.h:67
std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1) override
Definition: sqltypes.h:56
#define CHECK(condition)
Definition: Logger.h:222
SQLTypeInfo columnType
virtual std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1)=0

+ Here is the call graph for this function:

std::shared_ptr< ChunkMetadata > Chunk_NS::Chunk::appendEncodedData ( const Chunk src_chunk,
const size_t  num_elements,
const size_t  start_idx 
)

Definition at line 220 of file Chunk.cpp.

References Encoder::appendEncodedData(), buffer_, CHECK, column_desc_, ColumnDescriptor::columnType, getBuffer(), Data_Namespace::AbstractBuffer::getEncoder(), getIndexBuf(), and Data_Namespace::AbstractBuffer::getMemoryPtr().

222  {
223  const auto& ti = column_desc_->columnType;
224  int8_t* data_buffer_ptr = src_chunk.getBuffer()->getMemoryPtr();
225  const int8_t* index_buffer_ptr =
226  ti.is_varlen_indeed() ? src_chunk.getIndexBuf()->getMemoryPtr() : nullptr;
229  index_buffer_ptr, data_buffer_ptr, start_idx, num_elements);
230 }
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
AbstractBuffer * buffer_
Definition: Chunk.h:163
#define CHECK(condition)
Definition: Logger.h:222
SQLTypeInfo columnType
bool is_varlen_indeed() const
Definition: sqltypes.h:621
virtual std::shared_ptr< ChunkMetadata > appendEncodedData(const int8_t *index_data, int8_t *data, const size_t start_idx, const size_t num_elements)=0

+ Here is the call graph for this function:

std::shared_ptr< ChunkMetadata > Chunk_NS::Chunk::appendEncodedDataAtIndices ( const Chunk src_chunk,
const std::vector< size_t > &  selected_idx 
)

Definition at line 208 of file Chunk.cpp.

References Encoder::appendEncodedDataAtIndices(), buffer_, CHECK, column_desc_, ColumnDescriptor::columnType, getBuffer(), Data_Namespace::AbstractBuffer::getEncoder(), getIndexBuf(), and Data_Namespace::AbstractBuffer::getMemoryPtr().

210  {
211  const auto& ti = column_desc_->columnType;
212  int8_t* data_buffer_ptr = src_chunk.getBuffer()->getMemoryPtr();
213  const int8_t* index_buffer_ptr =
214  ti.is_varlen_indeed() ? src_chunk.getIndexBuf()->getMemoryPtr() : nullptr;
217  index_buffer_ptr, data_buffer_ptr, selected_idx);
218 }
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
AbstractBuffer * buffer_
Definition: Chunk.h:163
#define CHECK(condition)
Definition: Logger.h:222
SQLTypeInfo columnType
bool is_varlen_indeed() const
Definition: sqltypes.h:621
virtual std::shared_ptr< ChunkMetadata > appendEncodedDataAtIndices(const int8_t *index_data, int8_t *data, const std::vector< size_t > &selected_idx)=0

+ Here is the call graph for this function:

ChunkIter Chunk_NS::Chunk::begin_iterator ( const std::shared_ptr< ChunkMetadata > &  chunk_metadata,
int  start_idx = 0,
int  skip = 1 
) const

Definition at line 327 of file Chunk.cpp.

References buffer_, column_desc_, ColumnDescriptor::columnType, ChunkIter::current_pos, ChunkIter::end_pos, SQLTypeInfo::get_size(), Data_Namespace::AbstractBuffer::getMemoryPtr(), index_buf_, ChunkIter::num_elems, ChunkIter::second_buf, Data_Namespace::AbstractBuffer::size(), ChunkIter::skip, ChunkIter::skip_size, ChunkIter::start_pos, and ChunkIter::type_info.

329  {
330  ChunkIter it;
332  it.skip = skip;
334  if (it.skip_size < 0) { // if it's variable length
335  it.current_pos = it.start_pos =
336  index_buf_->getMemoryPtr() + start_idx * sizeof(StringOffsetT);
339  } else {
340  it.current_pos = it.start_pos = buffer_->getMemoryPtr() + start_idx * it.skip_size;
341  it.end_pos = buffer_->getMemoryPtr() + buffer_->size();
342  it.second_buf = nullptr;
343  }
344  it.num_elems = chunk_metadata->numElements;
345  return it;
346 }
int8_t * start_pos
Definition: ChunkIter.h:34
HOST DEVICE int get_size() const
Definition: sqltypes.h:389
int8_t * current_pos
Definition: ChunkIter.h:33
SQLTypeInfo type_info
Definition: ChunkIter.h:31
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
virtual int8_t * getMemoryPtr()=0
int32_t StringOffsetT
Definition: sqltypes.h:1224
int8_t * end_pos
Definition: ChunkIter.h:35
size_t num_elems
Definition: ChunkIter.h:38
AbstractBuffer * buffer_
Definition: Chunk.h:163
int skip_size
Definition: ChunkIter.h:37
int8_t * second_buf
Definition: ChunkIter.h:32
int skip
Definition: ChunkIter.h:36
SQLTypeInfo columnType
AbstractBuffer * index_buf_
Definition: Chunk.h:164

+ Here is the call graph for this function:

void Chunk_NS::Chunk::createChunkBuffer ( DataMgr data_mgr,
const ChunkKey key,
const MemoryLevel  mem_level,
const int  deviceId = 0,
const size_t  page_size = 0 
)

Definition at line 135 of file Chunk.cpp.

References buffer_, column_desc_, ColumnDescriptor::columnType, Data_Namespace::DataMgr::createChunkBuffer(), index_buf_, SQLTypeInfo::is_fixlen_array(), and SQLTypeInfo::is_varlen().

139  {
142  ChunkKey subKey = key;
143  subKey.push_back(1); // 1 for the main buffer_
144  buffer_ = data_mgr->createChunkBuffer(subKey, mem_level, device_id, page_size);
145  subKey.pop_back();
146  subKey.push_back(2); // 2 for the index buffer_
147  index_buf_ = data_mgr->createChunkBuffer(subKey, mem_level, device_id, page_size);
148  } else {
149  buffer_ = data_mgr->createChunkBuffer(key, mem_level, device_id, page_size);
150  }
151 }
std::vector< int > ChunkKey
Definition: types.h:36
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
bool is_varlen() const
Definition: sqltypes.h:615
bool is_fixlen_array() const
Definition: sqltypes.h:585
AbstractBuffer * buffer_
Definition: Chunk.h:163
AbstractBuffer * createChunkBuffer(const ChunkKey &key, const MemoryLevel memoryLevel, const int deviceId=0, const size_t page_size=0)
Definition: DataMgr.cpp:472
SQLTypeInfo columnType
AbstractBuffer * index_buf_
Definition: Chunk.h:164

+ Here is the call graph for this function:

void Chunk_NS::Chunk::decompress ( int8_t *  compressed,
VarlenDatum result,
Datum datum 
) const
std::shared_ptr< Chunk > Chunk_NS::Chunk::getChunk ( const ColumnDescriptor cd,
DataMgr data_mgr,
const ChunkKey key,
const MemoryLevel  mem_level,
const int  deviceId,
const size_t  num_bytes,
const size_t  num_elems,
const bool  pinnable = true 
)
static

Definition at line 31 of file Chunk.cpp.

References Chunk().

Referenced by Fragmenter_Namespace::get_chunks(), getChunkAccessorTable(), Fragmenter_Namespace::InsertOrderFragmenter::getChunksForAllColumns(), ColumnFetcher::getOneColumnFragment(), ColumnFetcher::getOneTableColumnFragment(), DBHandler::insert_chunks(), ColumnFetcher::linearizeColumnFragments(), anonymous_namespace{ForeignDataImporter.cpp}::load_foreign_data_buffers(), foreign_storage::populate_string_dictionary(), anonymous_namespace{RelAlgExecutor.cpp}::prepare_for_system_table_execution(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), Fragmenter_Namespace::InsertOrderFragmenter::updateColumn(), TableOptimizer::vacuumFragments(), StorageIOFacility::yieldDeleteCallback(), and StorageIOFacility::yieldUpdateCallback().

38  {
39  std::shared_ptr<Chunk> chunkp = std::make_shared<Chunk>(Chunk(cd, pinnable));
40  chunkp->getChunkBuffer(data_mgr, key, memoryLevel, deviceId, numBytes, numElems);
41  return chunkp;
42 }
Chunk(bool pinnable=true)
Definition: Chunk.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr< Chunk > Chunk_NS::Chunk::getChunk ( const ColumnDescriptor cd,
AbstractBuffer data_buffer,
AbstractBuffer index_buffer,
const bool  pinnable = true 
)
static

Compose a chunk from components and return it.

Parameters
cd- the column descriptor for the chunk
data_buffer- the data buffer for the chunk
index_buffer- the (optional) index buffer for the chunk
pinnable- sets the chunk as pinnable (or not)
Returns
a chunk composed of supplied components

Note, the index_buffer is only applicable if the column is a variable length column. If the column type is not variable length, this parameter is ignored.

Definition at line 44 of file Chunk.cpp.

References Chunk().

47  {
48  std::shared_ptr<Chunk> chunkp = std::make_shared<Chunk>(Chunk(cd, pinnable));
49  chunkp->setChunkBuffer(data_buffer, index_buffer);
50  return chunkp;
51 }
Chunk(bool pinnable=true)
Definition: Chunk.h:43

+ Here is the call graph for this function:

void Chunk_NS::Chunk::getChunkBuffer ( DataMgr data_mgr,
const ChunkKey key,
const MemoryLevel  mem_level,
const int  deviceId = 0,
const size_t  num_bytes = 0,
const size_t  num_elems = 0 
)

Definition at line 112 of file Chunk.cpp.

References column_desc_, ColumnDescriptor::columnType, Data_Namespace::DataMgr::getChunkBuffer(), SQLTypeInfo::is_fixlen_array(), SQLTypeInfo::is_varlen(), and setChunkBuffer().

117  {
120  ChunkKey data_key = key;
121  data_key.push_back(1);
122  ChunkKey index_key = key;
123  index_key.push_back(2);
125  data_mgr->getChunkBuffer(data_key, mem_level, device_id, num_bytes),
126  data_mgr->getChunkBuffer(
127  index_key, mem_level, device_id, (num_elems + 1) * sizeof(StringOffsetT)));
128 
129  } else {
130  setChunkBuffer(data_mgr->getChunkBuffer(key, mem_level, device_id, num_bytes),
131  nullptr);
132  }
133 }
std::vector< int > ChunkKey
Definition: types.h:36
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
bool is_varlen() const
Definition: sqltypes.h:615
void setChunkBuffer(AbstractBuffer *buffer, AbstractBuffer *index_buffer)
Definition: Chunk.cpp:71
int32_t StringOffsetT
Definition: sqltypes.h:1224
bool is_fixlen_array() const
Definition: sqltypes.h:585
AbstractBuffer * getChunkBuffer(const ChunkKey &key, const MemoryLevel memoryLevel, const int deviceId=0, const size_t numBytes=0)
Definition: DataMgr.cpp:481
SQLTypeInfo columnType

+ Here is the call graph for this function:

const ColumnDescriptor* Chunk_NS::Chunk::getColumnDesc ( ) const
inline

Definition at line 65 of file Chunk.h.

References column_desc_.

Referenced by Fragmenter_Namespace::FixedLenArrayChunkConverter::FixedLenArrayChunkConverter(), and anonymous_namespace{ExecutionKernel.cpp}::need_to_hold_chunk().

65 { return column_desc_; }
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165

+ Here is the caller graph for this function:

AbstractBuffer* Chunk_NS::Chunk::getIndexBuf ( ) const
inline

Definition at line 148 of file Chunk.h.

References index_buf_.

Referenced by appendEncodedData(), appendEncodedDataAtIndices(), Fragmenter_Namespace::ArrayChunkConverter::ArrayChunkConverter(), foreign_storage::anonymous_namespace{LazyParquetChunkLoader.cpp}::create_parquet_string_encoder(), and Fragmenter_Namespace::StringChunkConverter::StringChunkConverter().

148 { return index_buf_; }
AbstractBuffer * index_buf_
Definition: Chunk.h:164

+ Here is the caller graph for this function:

size_t Chunk_NS::Chunk::getNumElemsForBytesEncodedDataAtIndices ( const int8_t *  index_data,
const std::vector< size_t > &  selected_idx,
const size_t  byte_limit 
)

Definition at line 153 of file Chunk.cpp.

References buffer_, CHECK, column_desc_, ColumnDescriptor::columnType, Data_Namespace::AbstractBuffer::getEncoder(), Encoder::getNumElemsForBytesEncodedDataAtIndices(), and SQLTypeInfo::is_varlen().

156  {
160  index_data, selected_idx, byte_limit);
161 }
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
bool is_varlen() const
Definition: sqltypes.h:615
virtual size_t getNumElemsForBytesEncodedDataAtIndices(const int8_t *index_data, const std::vector< size_t > &selected_idx, const size_t byte_limit)=0
AbstractBuffer * buffer_
Definition: Chunk.h:163
#define CHECK(condition)
Definition: Logger.h:222
SQLTypeInfo columnType

+ Here is the call graph for this function:

size_t Chunk_NS::Chunk::getNumElemsForBytesInsertData ( const DataBlockPtr src_data,
const size_t  num_elems,
const size_t  start_idx,
const size_t  byte_limit,
const bool  replicating = false 
)

Definition at line 163 of file Chunk.cpp.

References DataBlockPtr::arraysPtr, buffer_, CHECK, CHECK_EQ, column_desc_, ColumnDescriptor::columnType, SQLTypeInfo::get_compression(), SQLTypeInfo::get_size(), SQLTypeInfo::get_type(), Data_Namespace::AbstractBuffer::getEncoder(), StringNoneEncoder::getNumElemsForBytesInsertData(), ArrayNoneEncoder::getNumElemsForBytesInsertData(), FixedLengthArrayNoneEncoder::getNumElemsForBytesInsertData(), SQLTypeInfo::is_varlen(), kARRAY, kCHAR, kENCODING_NONE, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, kPOLYGON, kTEXT, kVARCHAR, and DataBlockPtr::stringsPtr.

167  {
169  switch (column_desc_->columnType.get_type()) {
170  case kARRAY: {
171  if (column_desc_->columnType.get_size() > 0) {
172  FixedLengthArrayNoneEncoder* array_encoder =
174  return array_encoder->getNumElemsForBytesInsertData(
175  src_data.arraysPtr, start_idx, num_elems, byte_limit, replicating);
176  }
177  ArrayNoneEncoder* array_encoder =
178  dynamic_cast<ArrayNoneEncoder*>(buffer_->getEncoder());
179  return array_encoder->getNumElemsForBytesInsertData(
180  src_data.arraysPtr, start_idx, num_elems, byte_limit, replicating);
181  }
182  case kTEXT:
183  case kVARCHAR:
184  case kCHAR: {
186  StringNoneEncoder* str_encoder =
187  dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
188  return str_encoder->getNumElemsForBytesInsertData(
189  src_data.stringsPtr, start_idx, num_elems, byte_limit, replicating);
190  }
191  case kPOINT:
192  case kMULTIPOINT:
193  case kLINESTRING:
194  case kMULTILINESTRING:
195  case kPOLYGON:
196  case kMULTIPOLYGON: {
197  StringNoneEncoder* str_encoder =
198  dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
199  return str_encoder->getNumElemsForBytesInsertData(
200  src_data.stringsPtr, start_idx, num_elems, byte_limit, replicating);
201  }
202  default:
203  CHECK(false);
204  return 0;
205  }
206 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
size_t getNumElemsForBytesInsertData(const std::vector< ArrayDatum > *srcData, const int start_idx, const size_t numAppendElems, const size_t byteLimit, const bool replicating=false)
HOST DEVICE int get_size() const
Definition: sqltypes.h:389
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:222
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:223
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
bool is_varlen() const
Definition: sqltypes.h:615
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
size_t getNumElemsForBytesInsertData(const std::vector< std::string > *srcData, const int start_idx, const size_t numAppendElems, const size_t byteLimit, const bool replicating=false)
AbstractBuffer * buffer_
Definition: Chunk.h:163
Definition: sqltypes.h:67
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:387
Definition: sqltypes.h:56
#define CHECK(condition)
Definition: Logger.h:222
SQLTypeInfo columnType
size_t getNumElemsForBytesInsertData(const std::vector< ArrayDatum > *srcData, const int start_idx, const size_t numAppendElems, const size_t byteLimit, const bool replicating=false)

+ Here is the call graph for this function:

void Chunk_NS::Chunk::initEncoder ( )

Definition at line 290 of file Chunk.cpp.

References buffer_, CHECK, CHECK_EQ, column_desc_, ColumnDescriptor::columnType, SQLTypeInfo::get_compression(), SQLTypeInfo::get_type(), Data_Namespace::AbstractBuffer::getEncoder(), index_buf_, Data_Namespace::AbstractBuffer::initEncoder(), SQLTypeInfo::is_fixlen_array(), SQLTypeInfo::is_varlen(), kARRAY, kCHAR, kENCODING_NONE, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, kPOLYGON, kTEXT, kVARCHAR, StringNoneEncoder::setIndexBuffer(), and ArrayNoneEncoder::setIndexBuffer().

Referenced by foreign_storage::init_chunk_for_column(), and foreign_storage::Csv::init_chunk_for_column().

290  {
294  switch (column_desc_->columnType.get_type()) {
295  case kARRAY: {
296  ArrayNoneEncoder* array_encoder =
297  dynamic_cast<ArrayNoneEncoder*>(buffer_->getEncoder());
298  array_encoder->setIndexBuffer(index_buf_);
299  break;
300  }
301  case kTEXT:
302  case kVARCHAR:
303  case kCHAR: {
305  StringNoneEncoder* str_encoder =
306  dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
307  str_encoder->setIndexBuffer(index_buf_);
308  break;
309  }
310  case kPOINT:
311  case kMULTIPOINT:
312  case kLINESTRING:
313  case kMULTILINESTRING:
314  case kPOLYGON:
315  case kMULTIPOLYGON: {
316  StringNoneEncoder* str_encoder =
317  dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
318  str_encoder->setIndexBuffer(index_buf_);
319  break;
320  }
321  default:
322  CHECK(false);
323  }
324  }
325 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
bool is_varlen() const
Definition: sqltypes.h:615
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
void initEncoder(const SQLTypeInfo &tmp_sql_type)
bool is_fixlen_array() const
Definition: sqltypes.h:585
AbstractBuffer * buffer_
Definition: Chunk.h:163
void setIndexBuffer(AbstractBuffer *buf)
Definition: sqltypes.h:67
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:387
Definition: sqltypes.h:56
#define CHECK(condition)
Definition: Logger.h:222
void setIndexBuffer(AbstractBuffer *buf)
SQLTypeInfo columnType
AbstractBuffer * index_buf_
Definition: Chunk.h:164

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Chunk_NS::Chunk::isChunkOnDevice ( DataMgr data_mgr,
const ChunkKey key,
const MemoryLevel  mem_level,
const int  device_id 
)

Definition at line 53 of file Chunk.cpp.

References column_desc_, ColumnDescriptor::columnType, SQLTypeInfo::is_fixlen_array(), SQLTypeInfo::is_varlen(), and Data_Namespace::DataMgr::isBufferOnDevice().

56  {
59  ChunkKey subKey = key;
60  ChunkKey indexKey(subKey);
61  indexKey.push_back(1);
62  ChunkKey dataKey(subKey);
63  dataKey.push_back(2);
64  return data_mgr->isBufferOnDevice(indexKey, mem_level, device_id) &&
65  data_mgr->isBufferOnDevice(dataKey, mem_level, device_id);
66  } else {
67  return data_mgr->isBufferOnDevice(key, mem_level, device_id);
68  }
69 }
std::vector< int > ChunkKey
Definition: types.h:36
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
bool is_varlen() const
Definition: sqltypes.h:615
bool is_fixlen_array() const
Definition: sqltypes.h:585
bool isBufferOnDevice(const ChunkKey &key, const MemoryLevel memLevel, const int deviceId)
Definition: DataMgr.cpp:459
SQLTypeInfo columnType

+ Here is the call graph for this function:

void Chunk_NS::Chunk::setBuffer ( AbstractBuffer b)
inline

Definition at line 150 of file Chunk.h.

References buffer_.

Referenced by foreign_storage::ParquetImportBatchResult::getChunksAndDictionaries(), foreign_storage::init_chunk_for_column(), and foreign_storage::Csv::init_chunk_for_column().

150 { buffer_ = b; }
AbstractBuffer * buffer_
Definition: Chunk.h:163

+ Here is the caller graph for this function:

void Chunk_NS::Chunk::setChunkBuffer ( AbstractBuffer buffer,
AbstractBuffer index_buffer 
)
private

Definition at line 71 of file Chunk.cpp.

References buffer_, CHECK, CHECK_EQ, column_desc_, ColumnDescriptor::columnType, SQLTypeInfo::get_compression(), SQLTypeInfo::get_type(), Data_Namespace::AbstractBuffer::getEncoder(), index_buf_, SQLTypeInfo::is_fixlen_array(), SQLTypeInfo::is_varlen(), kARRAY, kCHAR, kENCODING_NONE, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, kPOLYGON, kTEXT, kVARCHAR, and UNREACHABLE.

Referenced by getChunkBuffer().

71  {
74  CHECK(index_buffer);
75  buffer_ = buffer;
76  index_buf_ = index_buffer;
77  switch (column_desc_->columnType.get_type()) {
78  case kARRAY: {
79  auto array_encoder = dynamic_cast<ArrayNoneEncoder*>(buffer_->getEncoder());
80  CHECK(array_encoder);
81  array_encoder->setIndexBuffer(index_buf_);
82  break;
83  }
84  case kTEXT:
85  case kVARCHAR:
86  case kCHAR: {
88  auto str_encoder = dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
89  CHECK(str_encoder);
90  str_encoder->setIndexBuffer(index_buf_);
91  break;
92  }
93  case kPOINT:
94  case kMULTIPOINT:
95  case kLINESTRING:
96  case kMULTILINESTRING:
97  case kPOLYGON:
98  case kMULTIPOLYGON: {
99  auto str_encoder = dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
100  CHECK(str_encoder);
101  str_encoder->setIndexBuffer(index_buf_);
102  break;
103  }
104  default:
105  UNREACHABLE();
106  }
107  } else {
108  buffer_ = buffer;
109  }
110 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
bool is_varlen() const
Definition: sqltypes.h:615
#define UNREACHABLE()
Definition: Logger.h:266
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
bool is_fixlen_array() const
Definition: sqltypes.h:585
AbstractBuffer * buffer_
Definition: Chunk.h:163
Definition: sqltypes.h:67
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:387
Definition: sqltypes.h:56
#define CHECK(condition)
Definition: Logger.h:222
SQLTypeInfo columnType
AbstractBuffer * index_buf_
Definition: Chunk.h:164

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Chunk_NS::Chunk::setColumnDesc ( const ColumnDescriptor cd)
inline

Definition at line 67 of file Chunk.h.

References column_desc_.

Referenced by foreign_storage::init_chunk_for_column(), and foreign_storage::Csv::init_chunk_for_column().

67 { column_desc_ = cd; }
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165

+ Here is the caller graph for this function:

void Chunk_NS::Chunk::setIndexBuffer ( AbstractBuffer ib)
inline

Definition at line 152 of file Chunk.h.

References index_buf_.

Referenced by foreign_storage::init_chunk_for_column(), and foreign_storage::Csv::init_chunk_for_column().

152 { index_buf_ = ib; }
AbstractBuffer * index_buf_
Definition: Chunk.h:164

+ Here is the caller graph for this function:

void Chunk_NS::Chunk::setPinnable ( bool  pinnable)
inline

Definition at line 63 of file Chunk.h.

References pinnable_.

Referenced by foreign_storage::init_chunk_for_column().

63 { pinnable_ = pinnable; }
bool pinnable_
Definition: Chunk.h:168

+ Here is the caller graph for this function:

std::string Chunk_NS::Chunk::toString ( ) const

Definition at line 356 of file Chunk.cpp.

References buffer_, column_desc_, index_buf_, and typeName().

356  {
357  return ::typeName(this) + "(buffer=" + ::toString(buffer_) +
358  ", index_buf=" + ::toString(index_buf_) +
359  ", column_desc=" + ::toString(column_desc_) + ")";
360 }
const ColumnDescriptor * column_desc_
Definition: Chunk.h:165
AbstractBuffer * buffer_
Definition: Chunk.h:163
std::string typeName(const T *v)
Definition: toString.h:103
std::string toString() const
Definition: Chunk.cpp:356
AbstractBuffer * index_buf_
Definition: Chunk.h:164

+ Here is the call graph for this function:

void Chunk_NS::Chunk::translateColumnDescriptorsToChunkVec ( const std::list< const ColumnDescriptor * > &  colDescs,
std::vector< Chunk > &  chunkVec 
)
static

Definition at line 348 of file Chunk.cpp.

350  {
351  for (auto cd : colDescs) {
352  chunkVec.emplace_back(cd);
353  }
354 }
void Chunk_NS::Chunk::unpinBuffer ( )
private

Definition at line 279 of file Chunk.cpp.

References buffer_, index_buf_, pinnable_, and Data_Namespace::AbstractBuffer::unPin().

Referenced by ~Chunk().

279  {
280  if (pinnable_) {
281  if (buffer_) {
282  buffer_->unPin();
283  }
284  if (index_buf_) {
285  index_buf_->unPin();
286  }
287  }
288 }
AbstractBuffer * buffer_
Definition: Chunk.h:163
AbstractBuffer * index_buf_
Definition: Chunk.h:164
bool pinnable_
Definition: Chunk.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

AbstractBuffer* Chunk_NS::Chunk::index_buf_
private
bool Chunk_NS::Chunk::pinnable_
private

Definition at line 168 of file Chunk.h.

Referenced by setPinnable(), and unpinBuffer().


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