OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResultSet.h File Reference

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

#include "CardinalityEstimator.h"
#include "DataMgr/Chunk/Chunk.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::QueryExecutionTimings
 
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 AppendedStorage = std::vector< std::unique_ptr< ResultSetStorage >>
 
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)
 
std::vector< int64_t > initialize_target_values_for_storage (const std::vector< TargetInfo > &targets)
 

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

using AppendedStorage = std::vector<std::unique_ptr<ResultSetStorage>>

Definition at line 302 of file ResultSet.h.

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

Definition at line 949 of file ResultSet.h.

Function Documentation

bool can_use_parallel_algorithms ( const ResultSet rows)

Definition at line 996 of file ResultSet.cpp.

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

996  {
997  return !rows.isTruncated();
998 }

+ Here is the caller graph for this function:

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

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

183  {
184  switch (key_width) {
185  case 4: {
186  auto key_ptr_i32 = reinterpret_cast<int32_t*>(key_ptr);
187  fill_empty_key_32(key_ptr_i32, key_count);
188  break;
189  }
190  case 8: {
191  auto key_ptr_i64 = reinterpret_cast<int64_t*>(key_ptr);
192  fill_empty_key_64(key_ptr_i64, key_count);
193  break;
194  }
195  default:
196  CHECK(false);
197  }
198 }
ALWAYS_INLINE void fill_empty_key_32(int32_t *key_ptr_i32, const size_t key_count)
CHECK(cgen_state)
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:

size_t get_byteoff_of_slot ( const size_t  slot_idx,
const QueryMemoryDescriptor query_mem_desc 
)

Definition at line 111 of file ResultSetIteration.cpp.

References QueryMemoryDescriptor::getPaddedColWidthForRange().

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

112  {
113  return query_mem_desc.getPaddedColWidthForRange(0, slot_idx);
114 }
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:

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 734 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().

743  {
744  uint32_t h = key_hash(key, key_count, key_width) % groups_buffer_entry_count;
746  h,
747  key,
748  key_count,
749  key_width,
750  query_mem_desc,
751  that_buff_i64,
752  that_entry_idx,
753  that_entry_count,
754  row_size_quad);
755  if (matching_gvi.first) {
756  return matching_gvi;
757  }
758  uint32_t h_probe = (h + 1) % groups_buffer_entry_count;
759  while (h_probe != h) {
761  h_probe,
762  key,
763  key_count,
764  key_width,
765  query_mem_desc,
766  that_buff_i64,
767  that_entry_idx,
768  that_entry_count,
769  row_size_quad);
770  if (matching_gvi.first) {
771  return matching_gvi;
772  }
773  h_probe = (h_probe + 1) % groups_buffer_entry_count;
774  }
775  return {nullptr, true};
776 }
const int32_t groups_buffer_size return groups_buffer
ALWAYS_INLINE DEVICE uint32_t key_hash(const int64_t *key, const uint32_t key_count, const uint32_t key_byte_width)
GroupValueInfo get_matching_group_value_reduction(int64_t *groups_buffer, const uint32_t h, const T *key, const uint32_t key_count, 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)
const int64_t const uint32_t groups_buffer_entry_count

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1346 of file ResultSetReduction.cpp.

References QueryMemoryDescriptor::getPaddedSlotWidthBytes().

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

1348  {
1349  if (float_argument_input) {
1350  return sizeof(float);
1351  }
1352  return query_mem_desc.getPaddedSlotWidthBytes(target_slot_idx);
1353 }
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:

std::vector<int64_t> initialize_target_values_for_storage ( const std::vector< TargetInfo > &  targets)

Definition at line 47 of file ResultSet.cpp.

References kAPPROX_COUNT_DISTINCT, kAVG, kCOUNT, kSAMPLE, null_val_bit_pattern(), and takes_float_argument().

Referenced by GpuSharedMemCodeBuilder::codegenReduction().

48  {
49  std::vector<int64_t> target_init_vals;
50  for (const auto& target_info : targets) {
51  if (target_info.agg_kind == kCOUNT ||
52  target_info.agg_kind == kAPPROX_COUNT_DISTINCT) {
53  target_init_vals.push_back(0);
54  continue;
55  }
56  if (target_info.sql_type.is_column()) {
57  int64_t init_val = null_val_bit_pattern(target_info.sql_type.get_subtype(),
58  takes_float_argument(target_info));
59  target_init_vals.push_back(target_info.is_agg ? init_val : 0);
60  } else if (!target_info.sql_type.get_notnull()) {
61  int64_t init_val =
62  null_val_bit_pattern(target_info.sql_type, takes_float_argument(target_info));
63  target_init_vals.push_back(target_info.is_agg ? init_val : 0);
64  } else {
65  target_init_vals.push_back(target_info.is_agg ? 0xdeadbeef : 0);
66  }
67  if (target_info.agg_kind == kAVG) {
68  target_init_vals.push_back(0);
69  } else if (target_info.agg_kind == kSAMPLE && target_info.sql_type.is_geometry()) {
70  for (int i = 1; i < 2 * target_info.sql_type.get_physical_coord_cols(); i++) {
71  target_init_vals.push_back(0);
72  }
73  } else if (target_info.agg_kind == kSAMPLE && target_info.sql_type.is_varlen()) {
74  target_init_vals.push_back(0);
75  }
76  }
77  return target_init_vals;
78 }
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:133
int64_t null_val_bit_pattern(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: sqldefs.h:76
Definition: sqldefs.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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(), SQLTypeInfo::get_elem_type(), inline_fixed_encoding_null_val(), inline_int_null_val(), SQLTypeInfo::is_column(), 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(), and ResultSet::makeTargetValue().

764  {
765  CHECK(col_lazy_fetch.is_lazily_fetched);
766  const auto& type_info =
767  (col_lazy_fetch.type.is_column() ? col_lazy_fetch.type.get_elem_type()
768  : col_lazy_fetch.type);
769  if (type_info.is_fp()) {
770  if (type_info.get_type() == kFLOAT) {
771  double fval = fixed_width_float_decode_noinline(byte_stream, pos);
772  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&fval));
773  } else {
774  double fval = fixed_width_double_decode_noinline(byte_stream, pos);
775  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&fval));
776  }
777  }
778  CHECK(type_info.is_integer() || type_info.is_decimal() || type_info.is_time() ||
779  type_info.is_timeinterval() || type_info.is_boolean() || type_info.is_string() ||
780  type_info.is_array());
781  size_t type_bitwidth = get_bit_width(type_info);
782  if (type_info.get_compression() == kENCODING_FIXED) {
783  type_bitwidth = type_info.get_comp_param();
784  } else if (type_info.get_compression() == kENCODING_DICT) {
785  type_bitwidth = 8 * type_info.get_size();
786  }
787  CHECK_EQ(size_t(0), type_bitwidth % 8);
788  int64_t val;
789  if (type_info.is_date_in_days()) {
790  val = type_info.get_comp_param() == 16
792  byte_stream, 2, NULL_SMALLINT, NULL_BIGINT, pos)
794  byte_stream, 4, NULL_INT, NULL_BIGINT, pos);
795  } else {
796  val = (type_info.get_compression() == kENCODING_DICT &&
797  type_info.get_size() < type_info.get_logical_size() &&
798  type_info.get_comp_param())
799  ? fixed_width_unsigned_decode_noinline(byte_stream, type_bitwidth / 8, pos)
800  : fixed_width_int_decode_noinline(byte_stream, type_bitwidth / 8, pos);
801  }
802  if (type_info.get_compression() != kENCODING_NONE &&
803  type_info.get_compression() != kENCODING_DATE_IN_DAYS) {
804  CHECK(type_info.get_compression() == kENCODING_FIXED ||
805  type_info.get_compression() == kENCODING_DICT);
806  auto encoding = type_info.get_compression();
807  if (encoding == kENCODING_FIXED) {
808  encoding = kENCODING_NONE;
809  }
810  SQLTypeInfo col_logical_ti(type_info.get_type(),
811  type_info.get_dimension(),
812  type_info.get_scale(),
813  false,
814  encoding,
815  0,
816  type_info.get_subtype());
817  if (val == inline_fixed_encoding_null_val(type_info)) {
818  return inline_int_null_val(col_logical_ti);
819  }
820  }
821  return val;
822 }
const SQLTypeInfo type
Definition: ResultSet.h:236
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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:183
size_t get_bit_width(const SQLTypeInfo &ti)
CHECK(cgen_state)
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:182
bool is_column() const
Definition: sqltypes.h:428
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:234
#define NULL_SMALLINT
Definition: sqltypes.h:181
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
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:622

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool use_parallel_algorithms ( const ResultSet rows)

Definition at line 1000 of file ResultSet.cpp.

References can_use_parallel_algorithms().

Referenced by ColumnarResults::materializeAllLazyColumns(), and synthesize_metadata().

1000  {
1001  return can_use_parallel_algorithms(rows) && rows.entryCount() >= 20000;
1002 }
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:996

+ Here is the call graph for this function:

+ Here is the caller graph for this function: