OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
result_set Namespace Reference

Functions

bool can_use_parallel_algorithms (const ResultSet &rows)
 
std::optional< size_t > first_dict_encoded_idx (std::vector< TargetInfo > const &)
 
bool use_parallel_algorithms (const ResultSet &rows)
 
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)
 
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)
 

Function Documentation

bool result_set::can_use_parallel_algorithms ( const ResultSet rows)

Definition at line 1561 of file ResultSet.cpp.

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

1561  {
1562  return !rows.isTruncated();
1563 }

+ Here is the caller graph for this function:

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

Definition at line 182 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::initRowGroups().

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

std::optional< size_t > result_set::first_dict_encoded_idx ( std::vector< TargetInfo > const &  targets)

Definition at line 1573 of file ResultSet.cpp.

Referenced by anonymous_namespace{Execute.cpp}::get_merged_result().

1574  {
1575  auto const itr = std::find_if(targets.begin(), targets.end(), IsDictEncodedStr{});
1576  return itr == targets.end() ? std::nullopt
1577  : std::make_optional<size_t>(itr - targets.begin());
1578 }

+ Here is the caller graph for this function:

size_t result_set::get_byteoff_of_slot ( const size_t  slot_idx,
const QueryMemoryDescriptor query_mem_desc 
)

Definition at line 114 of file ResultSetIteration.cpp.

References QueryMemoryDescriptor::getPaddedColWidthForRange().

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

115  {
116  return query_mem_desc.getPaddedColWidthForRange(0, slot_idx);
117 }
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 result_set::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 783 of file ResultSetReduction.cpp.

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

Referenced by get_group_value_reduction_rt().

793  {
794  uint32_t h = key_hash(key, key_count, key_width) % groups_buffer_entry_count;
795  auto matching_gvi = get_matching_group_value_reduction(groups_buffer,
796  h,
797  key,
798  key_count,
799  key_width,
800  query_mem_desc,
801  that_buff_i64,
802  that_entry_idx,
803  that_entry_count,
804  row_size_quad);
805  if (matching_gvi.first) {
806  return matching_gvi;
807  }
808  uint32_t h_probe = (h + 1) % groups_buffer_entry_count;
809  while (h_probe != h) {
810  matching_gvi = get_matching_group_value_reduction(groups_buffer,
811  h_probe,
812  key,
813  key_count,
814  key_width,
815  query_mem_desc,
816  that_buff_i64,
817  that_entry_idx,
818  that_entry_count,
819  row_size_quad);
820  if (matching_gvi.first) {
821  return matching_gvi;
822  }
823  h_probe = (h_probe + 1) % groups_buffer_entry_count;
824  }
825  return {nullptr, true};
826 }
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)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE uint32_t key_hash(const int64_t *key, const uint32_t key_count, const uint32_t key_byte_width)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1403 of file ResultSetReduction.cpp.

References QueryMemoryDescriptor::getPaddedSlotWidthBytes().

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

1405  {
1406  if (float_argument_input) {
1407  return sizeof(float);
1408  }
1409  return query_mem_desc.getPaddedSlotWidthBytes(target_slot_idx);
1410 }
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 > result_set::initialize_target_values_for_storage ( const std::vector< TargetInfo > &  targets)

Definition at line 83 of file ResultSetStorage.cpp.

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

Referenced by GpuSharedMemCodeBuilder::codegenReduction().

84  {
85  std::vector<int64_t> target_init_vals;
86  for (const auto& target_info : targets) {
87  if (shared::is_any<kCOUNT, kCOUNT_IF, kAPPROX_COUNT_DISTINCT>(target_info.agg_kind)) {
88  target_init_vals.push_back(0);
89  continue;
90  }
91  if (!target_info.sql_type.get_notnull()) {
92  int64_t init_val =
93  null_val_bit_pattern(target_info.sql_type, takes_float_argument(target_info));
94  target_init_vals.push_back(target_info.is_agg ? init_val : 0);
95  } else {
96  target_init_vals.push_back(target_info.is_agg ? 0xdeadbeef : 0);
97  }
98  if (target_info.agg_kind == kAVG) {
99  target_init_vals.push_back(0);
100  } else if (target_info.agg_kind == kSAMPLE && target_info.sql_type.is_geometry()) {
101  for (int i = 1; i < 2 * target_info.sql_type.get_physical_coord_cols(); i++) {
102  target_init_vals.push_back(0);
103  }
104  } else if (target_info.agg_kind == kSAMPLE && target_info.sql_type.is_varlen()) {
105  target_init_vals.push_back(0);
106  }
107  }
108  return target_init_vals;
109 }
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:102
int64_t null_val_bit_pattern(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: sqldefs.h:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 111 of file ResultSetStorage.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(), and ResultSet::makeTargetValue().

113  {
114  CHECK(col_lazy_fetch.is_lazily_fetched);
115  const auto& type_info = col_lazy_fetch.type;
116  if (type_info.is_fp()) {
117  if (type_info.get_type() == kFLOAT) {
118  double fval = fixed_width_float_decode_noinline(byte_stream, pos);
119  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&fval));
120  } else {
121  double fval = fixed_width_double_decode_noinline(byte_stream, pos);
122  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&fval));
123  }
124  }
125  CHECK(type_info.is_integer() || type_info.is_decimal() || type_info.is_time() ||
126  type_info.is_timeinterval() || type_info.is_boolean() || type_info.is_string() ||
127  type_info.is_array());
128  size_t type_bitwidth = get_bit_width(type_info);
129  if (type_info.get_compression() == kENCODING_FIXED) {
130  type_bitwidth = type_info.get_comp_param();
131  } else if (type_info.get_compression() == kENCODING_DICT) {
132  type_bitwidth = 8 * type_info.get_size();
133  }
134  CHECK_EQ(size_t(0), type_bitwidth % 8);
135  int64_t val;
136  if (type_info.is_date_in_days()) {
137  val = type_info.get_comp_param() == 16
139  byte_stream, 2, NULL_SMALLINT, NULL_BIGINT, pos)
141  byte_stream, 4, NULL_INT, NULL_BIGINT, pos);
142  } else {
143  val = (type_info.get_compression() == kENCODING_DICT &&
144  type_info.get_size() < type_info.get_logical_size() &&
145  type_info.get_comp_param())
146  ? fixed_width_unsigned_decode_noinline(byte_stream, type_bitwidth / 8, pos)
147  : fixed_width_int_decode_noinline(byte_stream, type_bitwidth / 8, pos);
148  }
149  if (type_info.get_compression() != kENCODING_NONE &&
150  type_info.get_compression() != kENCODING_DATE_IN_DAYS) {
151  CHECK(type_info.get_compression() == kENCODING_FIXED ||
152  type_info.get_compression() == kENCODING_DICT);
153  auto encoding = type_info.get_compression();
154  if (encoding == kENCODING_FIXED) {
155  encoding = kENCODING_NONE;
156  }
157  SQLTypeInfo col_logical_ti(type_info.get_type(),
158  type_info.get_dimension(),
159  type_info.get_scale(),
160  false,
161  encoding,
162  0,
163  type_info.get_subtype());
164  if (val == inline_fixed_encoding_null_val(type_info)) {
165  return inline_int_null_val(col_logical_ti);
166  }
167  }
168  return val;
169 }
const SQLTypeInfo type
#define CHECK_EQ(x, y)
Definition: Logger.h:297
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:91
#define NULL_BIGINT
#define NULL_INT
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:98
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:149
const bool is_lazily_fetched
#define CHECK(condition)
Definition: Logger.h:289
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
#define NULL_SMALLINT
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:121
DEVICE NEVER_INLINE double SUFFIX() fixed_width_double_decode_noinline(const int8_t *byte_stream, const int64_t pos)
Definition: DecodersImpl.h:134

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool result_set::use_parallel_algorithms ( const ResultSet rows)

Definition at line 1580 of file ResultSet.cpp.

References can_use_parallel_algorithms().

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

1580  {
1581  return result_set::can_use_parallel_algorithms(rows) && rows.entryCount() >= 20000;
1582 }
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:1561

+ Here is the call graph for this function:

+ Here is the caller graph for this function: