OmniSciDB  21ac014ffc
 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)
 
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 1124 of file ResultSet.cpp.

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

1124  {
1125  return !rows.isTruncated();
1126 }

+ 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 185 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().

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

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

Referenced by get_group_value_reduction_rt().

782  {
783  uint32_t h = key_hash(key, key_count, key_width) % groups_buffer_entry_count;
784  auto matching_gvi = get_matching_group_value_reduction(groups_buffer,
785  h,
786  key,
787  key_count,
788  key_width,
789  query_mem_desc,
790  that_buff_i64,
791  that_entry_idx,
792  that_entry_count,
793  row_size_quad);
794  if (matching_gvi.first) {
795  return matching_gvi;
796  }
797  uint32_t h_probe = (h + 1) % groups_buffer_entry_count;
798  while (h_probe != h) {
799  matching_gvi = get_matching_group_value_reduction(groups_buffer,
800  h_probe,
801  key,
802  key_count,
803  key_width,
804  query_mem_desc,
805  that_buff_i64,
806  that_entry_idx,
807  that_entry_count,
808  row_size_quad);
809  if (matching_gvi.first) {
810  return matching_gvi;
811  }
812  h_probe = (h_probe + 1) % groups_buffer_entry_count;
813  }
814  return {nullptr, true};
815 }
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 1388 of file ResultSetReduction.cpp.

References QueryMemoryDescriptor::getPaddedSlotWidthBytes().

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

1390  {
1391  if (float_argument_input) {
1392  return sizeof(float);
1393  }
1394  return query_mem_desc.getPaddedSlotWidthBytes(target_slot_idx);
1395 }
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 87 of file ResultSetStorage.cpp.

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

Referenced by GpuSharedMemCodeBuilder::codegenReduction().

88  {
89  std::vector<int64_t> target_init_vals;
90  for (const auto& target_info : targets) {
91  if (target_info.agg_kind == kCOUNT ||
92  target_info.agg_kind == kAPPROX_COUNT_DISTINCT) {
93  target_init_vals.push_back(0);
94  continue;
95  }
96  if (!target_info.sql_type.get_notnull()) {
97  int64_t init_val =
98  null_val_bit_pattern(target_info.sql_type, takes_float_argument(target_info));
99  target_init_vals.push_back(target_info.is_agg ? init_val : 0);
100  } else {
101  target_init_vals.push_back(target_info.is_agg ? 0xdeadbeef : 0);
102  }
103  if (target_info.agg_kind == kAVG) {
104  target_init_vals.push_back(0);
105  } else if (target_info.agg_kind == kSAMPLE && target_info.sql_type.is_geometry()) {
106  for (int i = 1; i < 2 * target_info.sql_type.get_physical_coord_cols(); i++) {
107  target_init_vals.push_back(0);
108  }
109  } else if (target_info.agg_kind == kSAMPLE && target_info.sql_type.is_varlen()) {
110  target_init_vals.push_back(0);
111  }
112  }
113  return target_init_vals;
114 }
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:157
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 result_set::lazy_decode ( const ColumnLazyFetchInfo col_lazy_fetch,
const int8_t *  byte_stream,
const int64_t  pos 
)

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

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

References can_use_parallel_algorithms().

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

1128  {
1129  return result_set::can_use_parallel_algorithms(rows) && rows.entryCount() >= 20000;
1130 }
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:1124

+ Here is the call graph for this function:

+ Here is the caller graph for this function: