OmniSciDB  ba1bac9284
 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 573 of file ResultSet.h.

Constructor & Destructor Documentation

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

Definition at line 574 of file ResultSet.h.

References initializeOffsetsForStorage().

575  : result_set_(result_set)
576  , row_bytes_(get_row_bytes(result_set->query_mem_desc_))
577  , key_width_(result_set_->query_mem_desc_.getEffectiveKeyWidth())
579  align_to_int64(get_key_bytes_rowwise(result_set->query_mem_desc_))) {
581  }
const size_t key_bytes_with_padding_
Definition: ResultSet.h:603
const ResultSet * result_set_
Definition: ResultSet.h:598
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 591 of file ResultSet.h.

References row_bytes_.

592  {
593  return buff + entry_idx * row_bytes_;
594  }
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 425 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.

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

+ Here is the call graph for this function:

void ResultSet::RowWiseTargetAccessor::initializeOffsetsForStorage ( )

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

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

const size_t ResultSet::RowWiseTargetAccessor::key_width_

Definition at line 602 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

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

Definition at line 596 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

const ResultSet* ResultSet::RowWiseTargetAccessor::result_set_

Definition at line 598 of file ResultSet.h.

Referenced by initializeOffsetsForStorage().

const size_t ResultSet::RowWiseTargetAccessor::row_bytes_

Definition at line 601 of file ResultSet.h.

Referenced by get_rowwise_ptr().


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