OmniSciDB  1dac507f6e
 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 667 of file ResultSet.h.

Constructor & Destructor Documentation

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

Definition at line 668 of file ResultSet.h.

References initializeOffsetsForStorage().

669  : result_set_(result_set)
670  , row_bytes_(get_row_bytes(result_set->query_mem_desc_))
671  , key_width_(result_set_->query_mem_desc_.getEffectiveKeyWidth())
673  align_to_int64(get_key_bytes_rowwise(result_set->query_mem_desc_))) {
675  }
const size_t key_bytes_with_padding_
Definition: ResultSet.h:697
const ResultSet * result_set_
Definition: ResultSet.h:692
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 685 of file ResultSet.h.

References row_bytes_.

686  {
687  return buff + entry_idx * row_bytes_;
688  }
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 421 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.

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

+ Here is the call graph for this function:

void ResultSet::RowWiseTargetAccessor::initializeOffsetsForStorage ( )

Definition at line 367 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().

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

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

const size_t ResultSet::RowWiseTargetAccessor::key_width_

Definition at line 696 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

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

Definition at line 690 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

const ResultSet* ResultSet::RowWiseTargetAccessor::result_set_

Definition at line 692 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

const size_t ResultSet::RowWiseTargetAccessor::row_bytes_

Definition at line 695 of file ResultSet.h.

Referenced by get_rowwise_ptr().


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