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

Constructor & Destructor Documentation

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

Definition at line 695 of file ResultSet.h.

References initializeOffsetsForStorage().

696  : result_set_(result_set)
697  , row_bytes_(get_row_bytes(result_set->query_mem_desc_))
698  , key_width_(result_set_->query_mem_desc_.getEffectiveKeyWidth())
700  align_to_int64(get_key_bytes_rowwise(result_set->query_mem_desc_))) {
702  }
const size_t key_bytes_with_padding_
Definition: ResultSet.h:724
const ResultSet * result_set_
Definition: ResultSet.h:719
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)

+ Here is the call graph for this function:

Member Function Documentation

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

Definition at line 712 of file ResultSet.h.

References row_bytes_.

713  {
714  return buff + entry_idx * row_bytes_;
715  }
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 422 of file ResultSetIteration.cpp.

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

426  {
427  CHECK(buff);
428  const int8_t* rowwise_target_ptr{nullptr};
429  const int8_t* keys_ptr{nullptr};
430 
431  const size_t storage_idx = storage_lookup_result.storage_idx;
432 
433  CHECK_LT(storage_idx, offsets_for_storage_.size());
434  CHECK_LT(target_logical_idx, offsets_for_storage_[storage_idx].size());
435 
436  const auto& offsets_for_target = offsets_for_storage_[storage_idx][target_logical_idx];
437  const auto& agg_info = result_set_->storage_->targets_[target_logical_idx];
438  const auto& type_info =
439  (agg_info.sql_type.is_column() ? agg_info.sql_type.get_elem_type()
440  : agg_info.sql_type);
441 
442  keys_ptr = get_rowwise_ptr(buff, entry_idx);
443  rowwise_target_ptr = keys_ptr + key_bytes_with_padding_;
444  auto ptr1 = rowwise_target_ptr + reinterpret_cast<size_t>(offsets_for_target.ptr1);
445  if (result_set_->query_mem_desc_.targetGroupbyIndicesSize() > 0) {
446  if (result_set_->query_mem_desc_.getTargetGroupbyIndex(target_logical_idx) >= 0) {
447  ptr1 = keys_ptr +
448  result_set_->query_mem_desc_.getTargetGroupbyIndex(target_logical_idx) *
449  key_width_;
450  }
451  }
452  const auto i1 =
453  result_set_->lazyReadInt(read_int_from_buff(ptr1, offsets_for_target.compact_sz1),
454  target_logical_idx,
455  storage_lookup_result);
456  if (agg_info.is_agg && agg_info.agg_kind == kAVG) {
457  CHECK(offsets_for_target.ptr2);
458  const auto ptr2 =
459  rowwise_target_ptr + reinterpret_cast<size_t>(offsets_for_target.ptr2);
460  const auto i2 = read_int_from_buff(ptr2, offsets_for_target.compact_sz2);
461  return InternalTargetValue(i1, i2);
462  } else {
463  if (type_info.is_string() && type_info.get_compression() == kENCODING_NONE) {
464  CHECK(!agg_info.is_agg);
465  if (!result_set_->lazy_fetch_info_.empty()) {
466  CHECK_LT(target_logical_idx, result_set_->lazy_fetch_info_.size());
467  const auto& col_lazy_fetch = result_set_->lazy_fetch_info_[target_logical_idx];
468  if (col_lazy_fetch.is_lazily_fetched) {
469  return InternalTargetValue(reinterpret_cast<const std::string*>(i1));
470  }
471  }
472  if (result_set_->separate_varlen_storage_valid_) {
473  if (i1 < 0) {
474  CHECK_EQ(-1, i1);
475  return InternalTargetValue(static_cast<const std::string*>(nullptr));
476  }
477  CHECK_LT(storage_lookup_result.storage_idx,
478  result_set_->serialized_varlen_buffer_.size());
479  const auto& varlen_buffer_for_fragment =
480  result_set_->serialized_varlen_buffer_[storage_lookup_result.storage_idx];
481  CHECK_LT(static_cast<size_t>(i1), varlen_buffer_for_fragment.size());
482  return InternalTargetValue(&varlen_buffer_for_fragment[i1]);
483  }
484  CHECK(offsets_for_target.ptr2);
485  const auto ptr2 =
486  rowwise_target_ptr + reinterpret_cast<size_t>(offsets_for_target.ptr2);
487  const auto str_len = read_int_from_buff(ptr2, offsets_for_target.compact_sz2);
488  CHECK_GE(str_len, 0);
489  return result_set_->getVarlenOrderEntry(i1, str_len);
490  }
491  return InternalTargetValue(
492  type_info.is_fp() ? i1 : int_resize_cast(i1, type_info.get_logical_size()));
493  }
494 }
#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)
const size_t key_bytes_with_padding_
Definition: ResultSet.h:724
const ResultSet * result_set_
Definition: ResultSet.h:719
CHECK(cgen_state)
#define CHECK_LT(x, y)
Definition: Logger.h:207
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:712
std::vector< std::vector< TargetOffsets > > offsets_for_storage_
Definition: ResultSet.h:717
Definition: sqldefs.h:72

+ Here is the call graph for this function:

void ResultSet::RowWiseTargetAccessor::initializeOffsetsForStorage ( )

Definition at line 368 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_.

Referenced by RowWiseTargetAccessor().

368  {
369  // Compute offsets for base storage and all appended storage
370  for (size_t storage_idx = 0; storage_idx < result_set_->appended_storage_.size() + 1;
371  ++storage_idx) {
372  offsets_for_storage_.emplace_back();
373 
374  const int8_t* rowwise_target_ptr{0};
375 
376  size_t agg_col_idx = 0;
377  for (size_t target_idx = 0; target_idx < result_set_->storage_->targets_.size();
378  ++target_idx) {
379  const auto& agg_info = result_set_->storage_->targets_[target_idx];
380 
381  auto ptr1 = rowwise_target_ptr;
382  const auto compact_sz1 =
383  result_set_->query_mem_desc_.getPaddedSlotWidthBytes(agg_col_idx)
384  ? result_set_->query_mem_desc_.getPaddedSlotWidthBytes(agg_col_idx)
385  : key_width_;
386 
387  const int8_t* ptr2{nullptr};
388  int8_t compact_sz2{0};
389  if ((agg_info.is_agg && agg_info.agg_kind == kAVG)) {
390  ptr2 = ptr1 + compact_sz1;
391  compact_sz2 =
392  result_set_->query_mem_desc_.getPaddedSlotWidthBytes(agg_col_idx + 1);
393  } else if (is_real_str_or_array(agg_info)) {
394  ptr2 = ptr1 + compact_sz1;
395  if (!result_set_->separate_varlen_storage_valid_) {
396  // None encoded strings explicitly attached to ResultSetStorage do not have a
397  // second slot in the QueryMemoryDescriptor col width vector
398  compact_sz2 =
399  result_set_->query_mem_desc_.getPaddedSlotWidthBytes(agg_col_idx + 1);
400  }
401  }
402  offsets_for_storage_[storage_idx].push_back(
403  TargetOffsets{ptr1,
404  static_cast<size_t>(compact_sz1),
405  ptr2,
406  static_cast<size_t>(compact_sz2)});
407  rowwise_target_ptr =
408  advance_target_ptr_row_wise(rowwise_target_ptr,
409  agg_info,
410  agg_col_idx,
411  result_set_->query_mem_desc_,
412  result_set_->separate_varlen_storage_valid_);
413 
414  agg_col_idx = advance_slot(
415  agg_col_idx, agg_info, result_set_->separate_varlen_storage_valid_);
416  }
417  CHECK_EQ(offsets_for_storage_[storage_idx].size(),
418  result_set_->storage_->targets_.size());
419  }
420 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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:719
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:717
Definition: sqldefs.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

const size_t ResultSet::RowWiseTargetAccessor::key_bytes_with_padding_

Definition at line 724 of file ResultSet.h.

const size_t ResultSet::RowWiseTargetAccessor::key_width_

Definition at line 723 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

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

Definition at line 717 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

const ResultSet* ResultSet::RowWiseTargetAccessor::result_set_

Definition at line 719 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

const size_t ResultSet::RowWiseTargetAccessor::row_bytes_

Definition at line 722 of file ResultSet.h.

Referenced by get_rowwise_ptr().


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