OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 811 of file ResultSet.h.

Constructor & Destructor Documentation

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

Definition at line 812 of file ResultSet.h.

References initializeOffsetsForStorage().

812  : result_set_(result_set) {
814  }

+ 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 555 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.

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

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

+ 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 824 of file ResultSet.h.

const ResultSet* ResultSet::ColumnWiseTargetAccessor::result_set_

Definition at line 826 of file ResultSet.h.


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