OmniSciDB  0b528656ed
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 727 of file ResultSet.h.

Constructor & Destructor Documentation

◆ ColumnWiseTargetAccessor()

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

Definition at line 728 of file ResultSet.h.

728  : result_set_(result_set) {
730  }

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 554 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.

558  {
559  const size_t storage_idx = storage_lookup_result.storage_idx;
560 
561  CHECK_LT(storage_idx, offsets_for_storage_.size());
562  CHECK_LT(target_logical_idx, offsets_for_storage_[storage_idx].size());
563 
564  const auto& offsets_for_target = offsets_for_storage_[storage_idx][target_logical_idx];
565  const auto& agg_info = result_set_->storage_->targets_[target_logical_idx];
566  auto ptr1 = offsets_for_target.ptr1;
567  if (result_set_->query_mem_desc_.targetGroupbyIndicesSize() > 0) {
568  if (result_set_->query_mem_desc_.getTargetGroupbyIndex(target_logical_idx) >= 0) {
569  ptr1 =
570  buff + result_set_->query_mem_desc_.getTargetGroupbyIndex(target_logical_idx) *
571  result_set_->query_mem_desc_.getEffectiveKeyWidth() *
572  result_set_->query_mem_desc_.entry_count_;
573  }
574  }
575 
576  const auto i1 = result_set_->lazyReadInt(
578  columnar_elem_ptr(entry_idx, ptr1, offsets_for_target.compact_sz1),
579  offsets_for_target.compact_sz1),
580  target_logical_idx,
581  storage_lookup_result);
582  if (agg_info.is_agg && agg_info.agg_kind == kAVG) {
583  CHECK(offsets_for_target.ptr2);
584  const auto i2 = read_int_from_buff(
586  entry_idx, offsets_for_target.ptr2, offsets_for_target.compact_sz2),
587  offsets_for_target.compact_sz2);
588  return InternalTargetValue(i1, i2);
589  } else {
590  // for TEXT ENCODING NONE:
591  if (agg_info.sql_type.is_string() &&
592  agg_info.sql_type.get_compression() == kENCODING_NONE) {
593  CHECK(!agg_info.is_agg);
594  if (!result_set_->lazy_fetch_info_.empty()) {
595  CHECK_LT(target_logical_idx, result_set_->lazy_fetch_info_.size());
596  const auto& col_lazy_fetch = result_set_->lazy_fetch_info_[target_logical_idx];
597  if (col_lazy_fetch.is_lazily_fetched) {
598  return InternalTargetValue(reinterpret_cast<const std::string*>(i1));
599  }
600  }
601  if (result_set_->separate_varlen_storage_valid_) {
602  if (i1 < 0) {
603  CHECK_EQ(-1, i1);
604  return InternalTargetValue(static_cast<const std::string*>(nullptr));
605  }
606  CHECK_LT(storage_lookup_result.storage_idx,
607  result_set_->serialized_varlen_buffer_.size());
608  const auto& varlen_buffer_for_fragment =
609  result_set_->serialized_varlen_buffer_[storage_lookup_result.storage_idx];
610  CHECK_LT(static_cast<size_t>(i1), varlen_buffer_for_fragment.size());
611  return InternalTargetValue(&varlen_buffer_for_fragment[i1]);
612  }
613  CHECK(offsets_for_target.ptr2);
614  const auto i2 = read_int_from_buff(
616  entry_idx, offsets_for_target.ptr2, offsets_for_target.compact_sz2),
617  offsets_for_target.compact_sz2);
618  CHECK_GE(i2, 0);
619  return result_set_->getVarlenOrderEntry(i1, i2);
620  }
621  return InternalTargetValue(
622  agg_info.sql_type.is_fp()
623  ? i1
624  : int_resize_cast(i1, agg_info.sql_type.get_logical_size()));
625  }
626 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
#define CHECK_GE(x, y)
Definition: Logger.h:210
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:740
#define CHECK_LT(x, y)
Definition: Logger.h:207
int64_t int_resize_cast(const int64_t ival, const size_t sz)
#define CHECK(condition)
Definition: Logger.h:197
Definition: sqldefs.h:72
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 497 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_.

497  {
498  // Compute offsets for base storage and all appended storage
499  const auto key_width = result_set_->query_mem_desc_.getEffectiveKeyWidth();
500  for (size_t storage_idx = 0; storage_idx < result_set_->appended_storage_.size() + 1;
501  ++storage_idx) {
502  offsets_for_storage_.emplace_back();
503 
504  const int8_t* buff = storage_idx == 0
505  ? result_set_->storage_->buff_
506  : result_set_->appended_storage_[storage_idx - 1]->buff_;
507  CHECK(buff);
508 
509  const auto& crt_query_mem_desc =
510  storage_idx == 0
511  ? result_set_->storage_->query_mem_desc_
512  : result_set_->appended_storage_[storage_idx - 1]->query_mem_desc_;
513  const int8_t* crt_col_ptr = get_cols_ptr(buff, crt_query_mem_desc);
514 
515  size_t agg_col_idx = 0;
516  for (size_t target_idx = 0; target_idx < result_set_->storage_->targets_.size();
517  ++target_idx) {
518  const auto& agg_info = result_set_->storage_->targets_[target_idx];
519 
520  const auto compact_sz1 =
521  crt_query_mem_desc.getPaddedSlotWidthBytes(agg_col_idx)
522  ? crt_query_mem_desc.getPaddedSlotWidthBytes(agg_col_idx)
523  : key_width;
524 
525  const auto next_col_ptr = advance_to_next_columnar_target_buff(
526  crt_col_ptr, crt_query_mem_desc, agg_col_idx);
527  const bool uses_two_slots = (agg_info.is_agg && agg_info.agg_kind == kAVG) ||
528  is_real_str_or_array(agg_info);
529  const auto col2_ptr = uses_two_slots ? next_col_ptr : nullptr;
530  const auto compact_sz2 =
531  (agg_info.is_agg && agg_info.agg_kind == kAVG) || is_real_str_or_array(agg_info)
532  ? crt_query_mem_desc.getPaddedSlotWidthBytes(agg_col_idx + 1)
533  : 0;
534 
535  offsets_for_storage_[storage_idx].push_back(
536  TargetOffsets{crt_col_ptr,
537  static_cast<size_t>(compact_sz1),
538  col2_ptr,
539  static_cast<size_t>(compact_sz2)});
540 
541  crt_col_ptr = next_col_ptr;
542  if (uses_two_slots) {
544  crt_col_ptr, crt_query_mem_desc, agg_col_idx + 1);
545  }
546  agg_col_idx = advance_slot(
547  agg_col_idx, agg_info, result_set_->separate_varlen_storage_valid_);
548  }
549  CHECK_EQ(offsets_for_storage_[storage_idx].size(),
550  result_set_->storage_->targets_.size());
551  }
552 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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:740
bool is_real_str_or_array(const TargetInfo &target_info)
#define CHECK(condition)
Definition: Logger.h:197
T get_cols_ptr(T buff, const QueryMemoryDescriptor &query_mem_desc)
Definition: sqldefs.h:72
+ 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 740 of file ResultSet.h.

◆ result_set_

const ResultSet* ResultSet::ColumnWiseTargetAccessor::result_set_

Definition at line 742 of file ResultSet.h.


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