OmniSciDB  04ee39c94c
ResultSet::RowWiseTargetAccessor Struct Reference
+ Collaboration diagram for ResultSet::RowWiseTargetAccessor:

Public Member Functions

 RowWiseTargetAccessor (const ResultSet *result_set)
 
InternalTargetValue getColumnInternal (const int8_t *buff, const size_t entry_idx, const size_t target_logical_idx, const StorageLookupResult &storage_lookup_result) const
 
void initializeOffsetsForStorage ()
 
const int8_t * get_rowwise_ptr (const int8_t *buff, const size_t entry_idx) const
 

Public Attributes

std::vector< std::vector< TargetOffsets > > offsets_for_storage_
 
const ResultSetresult_set_
 
const size_t row_bytes_
 
const size_t key_width_
 
const size_t key_bytes_with_padding_
 

Detailed Description

Definition at line 661 of file ResultSet.h.

Constructor & Destructor Documentation

◆ RowWiseTargetAccessor()

ResultSet::RowWiseTargetAccessor::RowWiseTargetAccessor ( const ResultSet result_set)
inline

Definition at line 662 of file ResultSet.h.

663  : result_set_(result_set)
664  , row_bytes_(get_row_bytes(result_set->query_mem_desc_))
665  , key_width_(result_set_->query_mem_desc_.getEffectiveKeyWidth())
667  align_to_int64(get_key_bytes_rowwise(result_set->query_mem_desc_))) {
669  }
const size_t key_bytes_with_padding_
Definition: ResultSet.h:691
const ResultSet * result_set_
Definition: ResultSet.h:686
size_t get_row_bytes(const QueryMemoryDescriptor &query_mem_desc)
size_t get_key_bytes_rowwise(const QueryMemoryDescriptor &query_mem_desc)
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

Member Function Documentation

◆ get_rowwise_ptr()

const int8_t* ResultSet::RowWiseTargetAccessor::get_rowwise_ptr ( const int8_t *  buff,
const size_t  entry_idx 
) const
inline

Definition at line 679 of file ResultSet.h.

Referenced by getColumnInternal().

680  {
681  return buff + entry_idx * row_bytes_;
682  }
+ Here is the caller graph for this function:

◆ getColumnInternal()

InternalTargetValue ResultSet::RowWiseTargetAccessor::getColumnInternal ( const int8_t *  buff,
const size_t  entry_idx,
const size_t  target_logical_idx,
const StorageLookupResult storage_lookup_result 
) const

Definition at line 407 of file ResultSetIteration.cpp.

References CHECK, CHECK_EQ, CHECK_GE, CHECK_LT, get_rowwise_ptr(), anonymous_namespace{ResultSetIteration.cpp}::int_resize_cast(), kAVG, kENCODING_NONE, key_bytes_with_padding_, key_width_, offsets_for_storage_, read_int_from_buff(), result_set_, and ResultSet::StorageLookupResult::storage_idx.

411  {
412  CHECK(buff);
413  const int8_t* rowwise_target_ptr{nullptr};
414  const int8_t* keys_ptr{nullptr};
415 
416  const size_t storage_idx = storage_lookup_result.storage_idx;
417 
418  CHECK_LT(storage_idx, offsets_for_storage_.size());
419  CHECK_LT(target_logical_idx, offsets_for_storage_[storage_idx].size());
420 
421  const auto& offsets_for_target = offsets_for_storage_[storage_idx][target_logical_idx];
422  const auto& agg_info = result_set_->storage_->targets_[target_logical_idx];
423 
424  keys_ptr = get_rowwise_ptr(buff, entry_idx);
425  rowwise_target_ptr = keys_ptr + key_bytes_with_padding_;
426  auto ptr1 = rowwise_target_ptr + reinterpret_cast<size_t>(offsets_for_target.ptr1);
427  if (result_set_->query_mem_desc_.targetGroupbyIndicesSize() > 0) {
428  if (result_set_->query_mem_desc_.getTargetGroupbyIndex(target_logical_idx) >= 0) {
429  ptr1 = keys_ptr +
430  result_set_->query_mem_desc_.getTargetGroupbyIndex(target_logical_idx) *
431  key_width_;
432  }
433  }
434  const auto i1 =
435  result_set_->lazyReadInt(read_int_from_buff(ptr1, offsets_for_target.compact_sz1),
436  target_logical_idx,
437  storage_lookup_result);
438 
439  if (agg_info.is_agg && agg_info.agg_kind == kAVG) {
440  CHECK(offsets_for_target.ptr2);
441  const auto ptr2 =
442  rowwise_target_ptr + reinterpret_cast<size_t>(offsets_for_target.ptr2);
443  const auto i2 = read_int_from_buff(ptr2, offsets_for_target.compact_sz2);
444  return InternalTargetValue(i1, i2);
445  } else {
446  if (agg_info.sql_type.is_string() &&
447  agg_info.sql_type.get_compression() == kENCODING_NONE) {
448  CHECK(!agg_info.is_agg);
449  if (!result_set_->lazy_fetch_info_.empty()) {
450  CHECK_LT(target_logical_idx, result_set_->lazy_fetch_info_.size());
451  const auto& col_lazy_fetch = result_set_->lazy_fetch_info_[target_logical_idx];
452  if (col_lazy_fetch.is_lazily_fetched) {
453  return InternalTargetValue(reinterpret_cast<const std::string*>(i1));
454  }
455  }
456  if (result_set_->separate_varlen_storage_valid_) {
457  if (i1 < 0) {
458  CHECK_EQ(-1, i1);
459  return InternalTargetValue(static_cast<const std::string*>(nullptr));
460  }
461  CHECK_LT(storage_lookup_result.storage_idx,
462  result_set_->serialized_varlen_buffer_.size());
463  const auto& varlen_buffer_for_fragment =
464  result_set_->serialized_varlen_buffer_[storage_lookup_result.storage_idx];
465  CHECK_LT(static_cast<size_t>(i1), varlen_buffer_for_fragment.size());
466  return InternalTargetValue(&varlen_buffer_for_fragment[i1]);
467  }
468  CHECK(offsets_for_target.ptr2);
469  const auto ptr2 =
470  rowwise_target_ptr + reinterpret_cast<size_t>(offsets_for_target.ptr2);
471  const auto str_len = read_int_from_buff(ptr2, offsets_for_target.compact_sz2);
472  CHECK_GE(str_len, 0);
473  return result_set_->getVarlenOrderEntry(i1, str_len);
474  }
475  return InternalTargetValue(
476  agg_info.sql_type.is_fp()
477  ? i1
478  : int_resize_cast(i1, agg_info.sql_type.get_logical_size()));
479  }
480 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define CHECK_GE(x, y)
Definition: Logger.h:200
int64_t read_int_from_buff(const int8_t *ptr, const int8_t compact_sz)
const size_t key_bytes_with_padding_
Definition: ResultSet.h:691
const ResultSet * result_set_
Definition: ResultSet.h:686
#define CHECK_LT(x, y)
Definition: Logger.h:197
int64_t int_resize_cast(const int64_t ival, const size_t sz)
const int8_t * get_rowwise_ptr(const int8_t *buff, const size_t entry_idx) const
Definition: ResultSet.h:679
#define CHECK(condition)
Definition: Logger.h:187
std::vector< std::vector< TargetOffsets > > offsets_for_storage_
Definition: ResultSet.h:684
Definition: sqldefs.h:71
+ Here is the call graph for this function:

◆ initializeOffsetsForStorage()

void ResultSet::RowWiseTargetAccessor::initializeOffsetsForStorage ( )

Definition at line 353 of file ResultSetIteration.cpp.

References advance_slot(), advance_target_ptr_row_wise(), CHECK_EQ, is_real_str_or_array(), kAVG, key_width_, offsets_for_storage_, and result_set_.

353  {
354  // Compute offsets for base storage and all appended storage
355  for (size_t storage_idx = 0; storage_idx < result_set_->appended_storage_.size() + 1;
356  ++storage_idx) {
357  offsets_for_storage_.emplace_back();
358 
359  const int8_t* rowwise_target_ptr{0};
360 
361  size_t agg_col_idx = 0;
362  for (size_t target_idx = 0; target_idx < result_set_->storage_->targets_.size();
363  ++target_idx) {
364  const auto& agg_info = result_set_->storage_->targets_[target_idx];
365 
366  auto ptr1 = rowwise_target_ptr;
367  const auto compact_sz1 =
368  result_set_->query_mem_desc_.getPaddedSlotWidthBytes(agg_col_idx)
369  ? result_set_->query_mem_desc_.getPaddedSlotWidthBytes(agg_col_idx)
370  : key_width_;
371 
372  const int8_t* ptr2{nullptr};
373  int8_t compact_sz2{0};
374  if ((agg_info.is_agg && agg_info.agg_kind == kAVG)) {
375  ptr2 = ptr1 + compact_sz1;
376  compact_sz2 =
377  result_set_->query_mem_desc_.getPaddedSlotWidthBytes(agg_col_idx + 1);
378  } else if (is_real_str_or_array(agg_info)) {
379  ptr2 = ptr1 + compact_sz1;
380  if (!result_set_->separate_varlen_storage_valid_) {
381  // None encoded strings explicitly attached to ResultSetStorage do not have a
382  // second slot in the QueryMemoryDescriptor col width vector
383  compact_sz2 =
384  result_set_->query_mem_desc_.getPaddedSlotWidthBytes(agg_col_idx + 1);
385  }
386  }
387  offsets_for_storage_[storage_idx].push_back(
388  TargetOffsets{ptr1,
389  static_cast<size_t>(compact_sz1),
390  ptr2,
391  static_cast<size_t>(compact_sz2)});
392  rowwise_target_ptr =
393  advance_target_ptr_row_wise(rowwise_target_ptr,
394  agg_info,
395  agg_col_idx,
396  result_set_->query_mem_desc_,
397  result_set_->separate_varlen_storage_valid_);
398 
399  agg_col_idx = advance_slot(
400  agg_col_idx, agg_info, result_set_->separate_varlen_storage_valid_);
401  }
402  CHECK_EQ(offsets_for_storage_[storage_idx].size(),
403  result_set_->storage_->targets_.size());
404  }
405 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
T advance_target_ptr_row_wise(T target_ptr, const TargetInfo &target_info, const size_t slot_idx, const QueryMemoryDescriptor &query_mem_desc, const bool separate_varlen_storage)
const ResultSet * result_set_
Definition: ResultSet.h:686
size_t advance_slot(const size_t j, const TargetInfo &target_info, const bool separate_varlen_storage)
bool is_real_str_or_array(const TargetInfo &target_info)
std::vector< std::vector< TargetOffsets > > offsets_for_storage_
Definition: ResultSet.h:684
Definition: sqldefs.h:71
+ Here is the call graph for this function:

Member Data Documentation

◆ key_bytes_with_padding_

const size_t ResultSet::RowWiseTargetAccessor::key_bytes_with_padding_

Definition at line 691 of file ResultSet.h.

Referenced by getColumnInternal().

◆ key_width_

const size_t ResultSet::RowWiseTargetAccessor::key_width_

Definition at line 690 of file ResultSet.h.

Referenced by getColumnInternal(), and initializeOffsetsForStorage().

◆ offsets_for_storage_

std::vector<std::vector<TargetOffsets> > ResultSet::RowWiseTargetAccessor::offsets_for_storage_

◆ result_set_

◆ row_bytes_

const size_t ResultSet::RowWiseTargetAccessor::row_bytes_

Definition at line 689 of file ResultSet.h.


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