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

Public Member Functions

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

Public Attributes

std::vector< std::vector< TargetOffsets > > offsets_for_storage_
 
const ResultSetresult_set_
 

Detailed Description

Definition at line 694 of file ResultSet.h.

Constructor & Destructor Documentation

◆ ColumnWiseTargetAccessor()

ResultSet::ColumnWiseTargetAccessor::ColumnWiseTargetAccessor ( const ResultSet result_set)
inline

Definition at line 695 of file ResultSet.h.

695  : result_set_(result_set) {
697  }

Member Function Documentation

◆ getColumnInternal()

InternalTargetValue ResultSet::ColumnWiseTargetAccessor::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 539 of file ResultSetIteration.cpp.

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

543  {
544  const size_t storage_idx = storage_lookup_result.storage_idx;
545 
546  CHECK_LT(storage_idx, offsets_for_storage_.size());
547  CHECK_LT(target_logical_idx, offsets_for_storage_[storage_idx].size());
548 
549  const auto& offsets_for_target = offsets_for_storage_[storage_idx][target_logical_idx];
550  const auto& agg_info = result_set_->storage_->targets_[target_logical_idx];
551  auto ptr1 = offsets_for_target.ptr1;
552  if (result_set_->query_mem_desc_.targetGroupbyIndicesSize() > 0) {
553  if (result_set_->query_mem_desc_.getTargetGroupbyIndex(target_logical_idx) >= 0) {
554  ptr1 =
555  buff + result_set_->query_mem_desc_.getTargetGroupbyIndex(target_logical_idx) *
556  result_set_->query_mem_desc_.getEffectiveKeyWidth() *
557  result_set_->query_mem_desc_.entry_count_;
558  }
559  }
560 
561  const auto i1 = result_set_->lazyReadInt(
563  columnar_elem_ptr(entry_idx, ptr1, offsets_for_target.compact_sz1),
564  offsets_for_target.compact_sz1),
565  target_logical_idx,
566  storage_lookup_result);
567  if (agg_info.is_agg && agg_info.agg_kind == kAVG) {
568  CHECK(offsets_for_target.ptr2);
569  const auto i2 = read_int_from_buff(
571  entry_idx, offsets_for_target.ptr2, offsets_for_target.compact_sz2),
572  offsets_for_target.compact_sz2);
573  return InternalTargetValue(i1, i2);
574  } else {
575  // for TEXT ENCODING NONE:
576  if (agg_info.sql_type.is_string() &&
577  agg_info.sql_type.get_compression() == kENCODING_NONE) {
578  CHECK(!agg_info.is_agg);
579  if (!result_set_->lazy_fetch_info_.empty()) {
580  CHECK_LT(target_logical_idx, result_set_->lazy_fetch_info_.size());
581  const auto& col_lazy_fetch = result_set_->lazy_fetch_info_[target_logical_idx];
582  if (col_lazy_fetch.is_lazily_fetched) {
583  return InternalTargetValue(reinterpret_cast<const std::string*>(i1));
584  }
585  }
586  if (result_set_->separate_varlen_storage_valid_) {
587  if (i1 < 0) {
588  CHECK_EQ(-1, i1);
589  return InternalTargetValue(static_cast<const std::string*>(nullptr));
590  }
591  CHECK_LT(storage_lookup_result.storage_idx,
592  result_set_->serialized_varlen_buffer_.size());
593  const auto& varlen_buffer_for_fragment =
594  result_set_->serialized_varlen_buffer_[storage_lookup_result.storage_idx];
595  CHECK_LT(static_cast<size_t>(i1), varlen_buffer_for_fragment.size());
596  return InternalTargetValue(&varlen_buffer_for_fragment[i1]);
597  }
598  CHECK(offsets_for_target.ptr2);
599  const auto i2 = read_int_from_buff(
601  entry_idx, offsets_for_target.ptr2, offsets_for_target.compact_sz2),
602  offsets_for_target.compact_sz2);
603  CHECK_GE(i2, 0);
604  return result_set_->getVarlenOrderEntry(i1, i2);
605  }
606  return InternalTargetValue(
607  agg_info.sql_type.is_fp()
608  ? i1
609  : int_resize_cast(i1, agg_info.sql_type.get_logical_size()));
610  }
611 }
#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)
std::vector< std::vector< TargetOffsets > > offsets_for_storage_
Definition: ResultSet.h:707
#define CHECK_LT(x, y)
Definition: Logger.h:197
int64_t int_resize_cast(const int64_t ival, const size_t sz)
#define CHECK(condition)
Definition: Logger.h:187
Definition: sqldefs.h:71
const int8_t * columnar_elem_ptr(const size_t entry_idx, const int8_t *col1_ptr, const int8_t compact_sz1)
+ Here is the call graph for this function:

◆ initializeOffsetsForStorage()

void ResultSet::ColumnWiseTargetAccessor::initializeOffsetsForStorage ( )

Definition at line 482 of file ResultSetIteration.cpp.

References advance_slot(), advance_to_next_columnar_target_buff(), CHECK, CHECK_EQ, get_cols_ptr(), is_real_str_or_array(), kAVG, ResultSet::RowWiseTargetAccessor::offsets_for_storage_, and ResultSet::RowWiseTargetAccessor::result_set_.

482  {
483  // Compute offsets for base storage and all appended storage
484  const auto key_width = result_set_->query_mem_desc_.getEffectiveKeyWidth();
485  for (size_t storage_idx = 0; storage_idx < result_set_->appended_storage_.size() + 1;
486  ++storage_idx) {
487  offsets_for_storage_.emplace_back();
488 
489  const int8_t* buff = storage_idx == 0
490  ? result_set_->storage_->buff_
491  : result_set_->appended_storage_[storage_idx - 1]->buff_;
492  CHECK(buff);
493 
494  const auto& crt_query_mem_desc =
495  storage_idx == 0
496  ? result_set_->storage_->query_mem_desc_
497  : result_set_->appended_storage_[storage_idx - 1]->query_mem_desc_;
498  const int8_t* crt_col_ptr = get_cols_ptr(buff, crt_query_mem_desc);
499 
500  size_t agg_col_idx = 0;
501  for (size_t target_idx = 0; target_idx < result_set_->storage_->targets_.size();
502  ++target_idx) {
503  const auto& agg_info = result_set_->storage_->targets_[target_idx];
504 
505  const auto compact_sz1 =
506  crt_query_mem_desc.getPaddedSlotWidthBytes(agg_col_idx)
507  ? crt_query_mem_desc.getPaddedSlotWidthBytes(agg_col_idx)
508  : key_width;
509 
510  const auto next_col_ptr = advance_to_next_columnar_target_buff(
511  crt_col_ptr, crt_query_mem_desc, agg_col_idx);
512  const bool uses_two_slots = (agg_info.is_agg && agg_info.agg_kind == kAVG) ||
513  is_real_str_or_array(agg_info);
514  const auto col2_ptr = uses_two_slots ? next_col_ptr : nullptr;
515  const auto compact_sz2 =
516  (agg_info.is_agg && agg_info.agg_kind == kAVG) || is_real_str_or_array(agg_info)
517  ? crt_query_mem_desc.getPaddedSlotWidthBytes(agg_col_idx + 1)
518  : 0;
519 
520  offsets_for_storage_[storage_idx].push_back(
521  TargetOffsets{crt_col_ptr,
522  static_cast<size_t>(compact_sz1),
523  col2_ptr,
524  static_cast<size_t>(compact_sz2)});
525 
526  crt_col_ptr = next_col_ptr;
527  if (uses_two_slots) {
529  crt_col_ptr, crt_query_mem_desc, agg_col_idx + 1);
530  }
531  agg_col_idx = advance_slot(
532  agg_col_idx, agg_info, result_set_->separate_varlen_storage_valid_);
533  }
534  CHECK_EQ(offsets_for_storage_[storage_idx].size(),
535  result_set_->storage_->targets_.size());
536  }
537 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
T advance_to_next_columnar_target_buff(T target_ptr, const QueryMemoryDescriptor &query_mem_desc, const size_t target_slot_idx)
size_t advance_slot(const size_t j, const TargetInfo &target_info, const bool separate_varlen_storage)
std::vector< std::vector< TargetOffsets > > offsets_for_storage_
Definition: ResultSet.h:707
bool is_real_str_or_array(const TargetInfo &target_info)
#define CHECK(condition)
Definition: Logger.h:187
T get_cols_ptr(T buff, const QueryMemoryDescriptor &query_mem_desc)
Definition: sqldefs.h:71
+ Here is the call graph for this function:

Member Data Documentation

◆ offsets_for_storage_

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

Definition at line 707 of file ResultSet.h.

◆ result_set_

const ResultSet* ResultSet::ColumnWiseTargetAccessor::result_set_

Definition at line 709 of file ResultSet.h.


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