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

Constructor & Destructor Documentation

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

Definition at line 779 of file ResultSet.h.

References initializeOffsetsForStorage().

780  : result_set_(result_set)
781  , row_bytes_(get_row_bytes(result_set->query_mem_desc_))
782  , key_width_(result_set_->query_mem_desc_.getEffectiveKeyWidth())
784  align_to_int64(get_key_bytes_rowwise(result_set->query_mem_desc_))) {
786  }
const size_t key_bytes_with_padding_
Definition: ResultSet.h:808
const ResultSet * result_set_
Definition: ResultSet.h:803
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 796 of file ResultSet.h.

References row_bytes_.

797  {
798  return buff + entry_idx * row_bytes_;
799  }
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 424 of file ResultSetIteration.cpp.

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

428  {
429  CHECK(buff);
430  const int8_t* rowwise_target_ptr{nullptr};
431  const int8_t* keys_ptr{nullptr};
432 
433  const size_t storage_idx = storage_lookup_result.storage_idx;
434 
435  CHECK_LT(storage_idx, offsets_for_storage_.size());
436  CHECK_LT(target_logical_idx, offsets_for_storage_[storage_idx].size());
437 
438  const auto& offsets_for_target = offsets_for_storage_[storage_idx][target_logical_idx];
439  const auto& agg_info = result_set_->storage_->targets_[target_logical_idx];
440  const auto& type_info = 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  } else if (agg_info.is_agg && agg_info.agg_kind == kMODE) {
491  return InternalTargetValue(i1); // AggMode*
492  }
493  return InternalTargetValue(
494  type_info.is_fp() ? i1 : int_resize_cast(i1, type_info.get_logical_size()));
495  }
496 }
#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)
const size_t key_bytes_with_padding_
Definition: ResultSet.h:808
const ResultSet * result_set_
Definition: ResultSet.h:803
#define CHECK_LT(x, y)
Definition: Logger.h:303
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:796
#define CHECK(condition)
Definition: Logger.h:291
std::vector< std::vector< TargetOffsets > > offsets_for_storage_
Definition: ResultSet.h:801
Definition: sqldefs.h:77
Definition: sqldefs.h:86

+ Here is the call graph for this function:

void ResultSet::RowWiseTargetAccessor::initializeOffsetsForStorage ( )

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

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

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

const size_t ResultSet::RowWiseTargetAccessor::key_width_

Definition at line 807 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

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

Definition at line 801 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

const ResultSet* ResultSet::RowWiseTargetAccessor::result_set_

Definition at line 803 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

const size_t ResultSet::RowWiseTargetAccessor::row_bytes_

Definition at line 806 of file ResultSet.h.

Referenced by get_rowwise_ptr().


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