OmniSciDB  29e35f4d58
ResultSet.h File Reference

Basic constructors and methods of the row set interface. More...

#include "../Chunk/Chunk.h"
#include "CardinalityEstimator.h"
#include "ResultSetBufferAccessors.h"
#include "TargetValue.h"
#include <atomic>
#include <functional>
#include <list>
+ Include dependency graph for ResultSet.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ResultSetStorage
 
struct  ColumnLazyFetchInfo
 
struct  OneIntegerColumnRow
 
class  ResultSetRowIterator
 
class  ResultSet
 
struct  ResultSet::VarlenTargetPtrPair
 
struct  ResultSet::StorageLookupResult
 
struct  ResultSet::TargetOffsets
 
struct  ResultSet::RowWiseTargetAccessor
 
struct  ResultSet::ColumnWiseTargetAccessor
 
struct  ResultSet::ResultSetComparator< BUFFER_ITERATOR_TYPE >
 
class  ResultSetManager
 
class  RowSortException
 

Namespaces

 Analyzer
 

Typedefs

using GroupValueInfo = std::pair< int64_t *, bool >
 

Functions

int64_t lazy_decode (const ColumnLazyFetchInfo &col_lazy_fetch, const int8_t *byte_stream, const int64_t pos)
 
void fill_empty_key (void *key_ptr, const size_t key_count, const size_t key_width)
 
bool can_use_parallel_algorithms (const ResultSet &rows)
 
bool use_parallel_algorithms (const ResultSet &rows)
 
int8_t get_width_for_slot (const size_t target_slot_idx, const bool float_argument_input, const QueryMemoryDescriptor &query_mem_desc)
 
size_t get_byteoff_of_slot (const size_t slot_idx, const QueryMemoryDescriptor &query_mem_desc)
 
GroupValueInfo get_group_value_reduction (int64_t *groups_buffer, const uint32_t groups_buffer_entry_count, const int64_t *key, const uint32_t key_count, const size_t key_width, const QueryMemoryDescriptor &query_mem_desc, const int64_t *that_buff_i64, const size_t that_entry_idx, const size_t that_entry_count, const uint32_t row_size_quad)
 

Detailed Description

Basic constructors and methods of the row set interface.

Author
Alex Suhan alex@.nosp@m.mapd.nosp@m..com Copyright (c) 2014 MapD Technologies, Inc. All rights reserved.

Definition in file ResultSet.h.

Typedef Documentation

◆ GroupValueInfo

using GroupValueInfo = std::pair<int64_t*, bool>

Definition at line 920 of file ResultSet.h.

Function Documentation

◆ can_use_parallel_algorithms()

bool can_use_parallel_algorithms ( const ResultSet rows)

Definition at line 869 of file ResultSet.cpp.

Referenced by anonymous_namespace{RelAlgTranslator.cpp}::get_in_values_expr(), RelAlgTranslator::getInIntegerSetExpr(), RowSortException::RowSortException(), and use_parallel_algorithms().

869  {
870  return !rows.isTruncated();
871 }
+ Here is the caller graph for this function:

◆ fill_empty_key()

void fill_empty_key ( void *  key_ptr,
const size_t  key_count,
const size_t  key_width 
)

Definition at line 180 of file ResultSetReduction.cpp.

References CHECK, anonymous_namespace{ResultSetReduction.cpp}::fill_empty_key_32(), and anonymous_namespace{ResultSetReduction.cpp}::fill_empty_key_64().

Referenced by QueryMemoryInitializer::initGroups(), and RowSortException::RowSortException().

180  {
181  switch (key_width) {
182  case 4: {
183  auto key_ptr_i32 = reinterpret_cast<int32_t*>(key_ptr);
184  fill_empty_key_32(key_ptr_i32, key_count);
185  break;
186  }
187  case 8: {
188  auto key_ptr_i64 = reinterpret_cast<int64_t*>(key_ptr);
189  fill_empty_key_64(key_ptr_i64, key_count);
190  break;
191  }
192  default:
193  CHECK(false);
194  }
195 }
ALWAYS_INLINE void fill_empty_key_32(int32_t *key_ptr_i32, const size_t key_count)
#define CHECK(condition)
Definition: Logger.h:193
ALWAYS_INLINE void fill_empty_key_64(int64_t *key_ptr_i64, const size_t key_count)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_byteoff_of_slot()

size_t get_byteoff_of_slot ( const size_t  slot_idx,
const QueryMemoryDescriptor query_mem_desc 
)

Definition at line 110 of file ResultSetIteration.cpp.

References advance_slot(), advance_target_ptr_col_wise(), advance_target_ptr_row_wise(), align_to_int64(), CHECK, anonymous_namespace{TypedDataAccessors.h}::decimal_to_double(), get_cols_ptr(), get_key_bytes_rowwise(), QueryMemoryDescriptor::getPaddedColWidthForRange(), ResultSet::getRowAt(), row_ptr_rowwise(), and UNLIKELY.

Referenced by ResultSetReductionJIT::isEmpty(), ResultSetStorage::isEmptyEntry(), and RowSortException::RowSortException().

111  {
112  return query_mem_desc.getPaddedColWidthForRange(0, slot_idx);
113 }
size_t getPaddedColWidthForRange(const size_t offset, const size_t range) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_group_value_reduction()

GroupValueInfo get_group_value_reduction ( int64_t *  groups_buffer,
const uint32_t  groups_buffer_entry_count,
const int64_t *  key,
const uint32_t  key_count,
const size_t  key_width,
const QueryMemoryDescriptor query_mem_desc,
const int64_t *  that_buff_i64,
const size_t  that_entry_idx,
const size_t  that_entry_count,
const uint32_t  row_size_quad 
)

Definition at line 731 of file ResultSetReduction.cpp.

References anonymous_namespace{ResultSetReduction.cpp}::get_matching_group_value_reduction(), groups_buffer_entry_count, and key_hash().

Referenced by get_group_value_reduction_rt().

740  {
741  uint32_t h = key_hash(key, key_count, key_width) % groups_buffer_entry_count;
742  auto matching_gvi = get_matching_group_value_reduction(groups_buffer,
743  h,
744  key,
745  key_count,
746  key_width,
747  query_mem_desc,
748  that_buff_i64,
749  that_entry_idx,
750  that_entry_count,
751  row_size_quad);
752  if (matching_gvi.first) {
753  return matching_gvi;
754  }
755  uint32_t h_probe = (h + 1) % groups_buffer_entry_count;
756  while (h_probe != h) {
757  matching_gvi = get_matching_group_value_reduction(groups_buffer,
758  h_probe,
759  key,
760  key_count,
761  key_width,
762  query_mem_desc,
763  that_buff_i64,
764  that_entry_idx,
765  that_entry_count,
766  row_size_quad);
767  if (matching_gvi.first) {
768  return matching_gvi;
769  }
770  h_probe = (h_probe + 1) % groups_buffer_entry_count;
771  }
772  return {nullptr, true};
773 }
ALWAYS_INLINE DEVICE uint32_t key_hash(const int64_t *key, const uint32_t key_count, const uint32_t key_byte_width)
const int64_t const uint32_t groups_buffer_entry_count
GroupValueInfo get_matching_group_value_reduction(int64_t *groups_buffer, const uint32_t h, const int64_t *key, const uint32_t key_count, const size_t key_width, const QueryMemoryDescriptor &query_mem_desc, const int64_t *that_buff_i64, const size_t that_entry_idx, const size_t that_entry_count, const uint32_t row_size_quad)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_width_for_slot()

int8_t get_width_for_slot ( const size_t  target_slot_idx,
const bool  float_argument_input,
const QueryMemoryDescriptor query_mem_desc 
)

Definition at line 1345 of file ResultSetReduction.cpp.

References QueryMemoryDescriptor::getPaddedSlotWidthBytes().

Referenced by ResultSetReductionJIT::reduceOneSlot(), ResultSetStorage::reduceOneSlot(), ResultSetStorage::reduceOneSlotSingleValue(), and RowSortException::RowSortException().

1347  {
1348  if (float_argument_input) {
1349  return sizeof(float);
1350  }
1351  return query_mem_desc.getPaddedSlotWidthBytes(target_slot_idx);
1352 }
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lazy_decode()

int64_t lazy_decode ( const ColumnLazyFetchInfo col_lazy_fetch,
const int8_t *  byte_stream,
const int64_t  pos 
)

Definition at line 762 of file ResultSetIteration.cpp.

References CHECK, CHECK_EQ, fixed_width_double_decode_noinline(), fixed_width_float_decode_noinline(), fixed_width_int_decode_noinline(), fixed_width_small_date_decode_noinline(), fixed_width_unsigned_decode_noinline(), get_bit_width(), inline_fixed_encoding_null_val(), inline_int_null_val(), ColumnLazyFetchInfo::is_lazily_fetched, kENCODING_DATE_IN_DAYS, kENCODING_DICT, kENCODING_FIXED, kENCODING_NONE, kFLOAT, NULL_BIGINT, NULL_INT, NULL_SMALLINT, and ColumnLazyFetchInfo::type.

Referenced by ResultSet::lazyReadInt(), ResultSet::makeTargetValue(), and RowSortException::RowSortException().

764  {
765  CHECK(col_lazy_fetch.is_lazily_fetched);
766  const auto& type_info = col_lazy_fetch.type;
767  if (type_info.is_fp()) {
768  if (type_info.get_type() == kFLOAT) {
769  double fval = fixed_width_float_decode_noinline(byte_stream, pos);
770  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&fval));
771  } else {
772  double fval = fixed_width_double_decode_noinline(byte_stream, pos);
773  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&fval));
774  }
775  }
776  CHECK(type_info.is_integer() || type_info.is_decimal() || type_info.is_time() ||
777  type_info.is_timeinterval() || type_info.is_boolean() || type_info.is_string() ||
778  type_info.is_array());
779  size_t type_bitwidth = get_bit_width(type_info);
780  if (type_info.get_compression() == kENCODING_FIXED) {
781  type_bitwidth = type_info.get_comp_param();
782  } else if (type_info.get_compression() == kENCODING_DICT) {
783  type_bitwidth = 8 * type_info.get_size();
784  }
785  CHECK_EQ(size_t(0), type_bitwidth % 8);
786  int64_t val;
787  if (type_info.is_date_in_days()) {
788  val = type_info.get_comp_param() == 16
790  byte_stream, 2, NULL_SMALLINT, NULL_BIGINT, pos)
792  byte_stream, 4, NULL_INT, NULL_BIGINT, pos);
793  } else {
794  val = (type_info.get_compression() == kENCODING_DICT &&
795  type_info.get_size() < type_info.get_logical_size() &&
796  type_info.get_comp_param())
797  ? fixed_width_unsigned_decode_noinline(byte_stream, type_bitwidth / 8, pos)
798  : fixed_width_int_decode_noinline(byte_stream, type_bitwidth / 8, pos);
799  }
800  if (type_info.get_compression() != kENCODING_NONE &&
801  type_info.get_compression() != kENCODING_DATE_IN_DAYS) {
802  CHECK(type_info.get_compression() == kENCODING_FIXED ||
803  type_info.get_compression() == kENCODING_DICT);
804  auto encoding = type_info.get_compression();
805  if (encoding == kENCODING_FIXED) {
806  encoding = kENCODING_NONE;
807  }
808  SQLTypeInfo col_logical_ti(type_info.get_type(),
809  type_info.get_dimension(),
810  type_info.get_scale(),
811  false,
812  encoding,
813  0,
814  type_info.get_subtype());
815  if (val == inline_fixed_encoding_null_val(type_info)) {
816  return inline_int_null_val(col_logical_ti);
817  }
818  }
819  return val;
820 }
const SQLTypeInfo type
Definition: ResultSet.h:232
#define CHECK_EQ(x, y)
Definition: Logger.h:201
DEVICE NEVER_INLINE int64_t SUFFIX() fixed_width_int_decode_noinline(const int8_t *byte_stream, const int32_t byte_width, const int64_t pos)
Definition: DecodersImpl.h:83
#define NULL_BIGINT
Definition: sqltypes.h:177
size_t get_bit_width(const SQLTypeInfo &ti)
DEVICE NEVER_INLINE int64_t SUFFIX() fixed_width_unsigned_decode_noinline(const int8_t *byte_stream, const int32_t byte_width, const int64_t pos)
Definition: DecodersImpl.h:90
#define NULL_INT
Definition: sqltypes.h:176
DEVICE NEVER_INLINE int64_t SUFFIX() fixed_width_small_date_decode_noinline(const int8_t *byte_stream, const int32_t byte_width, const int32_t null_val, const int64_t ret_null_val, const int64_t pos)
Definition: DecodersImpl.h:141
const bool is_lazily_fetched
Definition: ResultSet.h:230
#define NULL_SMALLINT
Definition: sqltypes.h:175
#define CHECK(condition)
Definition: Logger.h:193
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
DEVICE NEVER_INLINE float SUFFIX() fixed_width_float_decode_noinline(const int8_t *byte_stream, const int64_t pos)
Definition: DecodersImpl.h:113
DEVICE NEVER_INLINE double SUFFIX() fixed_width_double_decode_noinline(const int8_t *byte_stream, const int64_t pos)
Definition: DecodersImpl.h:126
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ use_parallel_algorithms()

bool use_parallel_algorithms ( const ResultSet rows)

Definition at line 873 of file ResultSet.cpp.

References can_use_parallel_algorithms().

Referenced by ColumnarResults::materializeAllLazyColumns(), RowSortException::RowSortException(), and anonymous_namespace{InputMetadata.cpp}::synthesize_metadata().

873  {
874  return can_use_parallel_algorithms(rows) && rows.entryCount() >= 20000;
875 }
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:869
+ Here is the call graph for this function:
+ Here is the caller graph for this function: