OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 700 of file ResultSet.h.

Constructor & Destructor Documentation

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

Definition at line 701 of file ResultSet.h.

References initializeOffsetsForStorage().

701  : result_set_(result_set) {
703  }

+ Here is the call graph for this function:

Member Function Documentation

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 553 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, read_int_from_buff(), and ResultSet::StorageLookupResult::storage_idx.

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

void ResultSet::ColumnWiseTargetAccessor::initializeOffsetsForStorage ( )

Definition at line 496 of file ResultSetIteration.cpp.

References advance_slot(), advance_to_next_columnar_target_buff(), CHECK(), CHECK_EQ, get_cols_ptr(), is_real_str_or_array(), and kAVG.

Referenced by ColumnWiseTargetAccessor().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 713 of file ResultSet.h.

const ResultSet* ResultSet::ColumnWiseTargetAccessor::result_set_

Definition at line 715 of file ResultSet.h.


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