OmniSciDB  f17484ade4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{WindowFunctionIR.cpp} Namespace Reference

Functions

std::string get_window_agg_name (const SqlWindowFunctionKind kind, const SQLTypeInfo &window_func_ti)
 
SQLTypeInfo get_adjusted_window_type_info (const Analyzer::WindowFunction *window_func)
 
std::string get_col_type_name_by_size (const size_t size, const bool is_fp)
 
llvm::Value * get_null_value_by_size (CgenState *cgen_state, SQLTypeInfo col_ti)
 
llvm::Value * get_null_value_by_size_with_encoding (CgenState *cgen_state, SQLTypeInfo col_ti)
 

Function Documentation

SQLTypeInfo anonymous_namespace{WindowFunctionIR.cpp}::get_adjusted_window_type_info ( const Analyzer::WindowFunction window_func)

Definition at line 132 of file WindowFunctionIR.cpp.

References run_benchmark_import::args, AVG, COUNT, Analyzer::Expr::get_type_info(), Analyzer::WindowFunction::getArgs(), and Analyzer::WindowFunction::getKind().

Referenced by Executor::aggregateWindowStatePtr(), Executor::codegenAggregateWindowState(), Executor::codegenWindowAvgEpilogue(), Executor::codegenWindowFunctionAggregateCalls(), and Executor::codegenWindowFunctionStateInit().

132  {
133  const auto& args = window_func->getArgs();
134  return ((window_func->getKind() == SqlWindowFunctionKind::COUNT && !args.empty()) ||
135  window_func->getKind() == SqlWindowFunctionKind::AVG)
136  ? args.front()->get_type_info()
137  : window_func->get_type_info();
138 }
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:2709
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs() const
Definition: Analyzer.h:2711
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{WindowFunctionIR.cpp}::get_col_type_name_by_size ( const size_t  size,
const bool  is_fp 
)

Definition at line 140 of file WindowFunctionIR.cpp.

Referenced by Executor::codegenLoadOrderKeyBufPtr(), Executor::codegenWindowFunctionAggregateCalls(), Executor::codegenWindowNavigationFunctionOnFrame(), and Executor::getOrderKeyTypeName().

140  {
141  if (is_fp) {
142  if (size == 4) {
143  return "float";
144  }
145  return "double";
146  }
147  if (size == 1) {
148  return "int8_t";
149  } else if (size == 2) {
150  return "int16_t";
151  } else if (size == 4) {
152  return "int32_t";
153  }
154  return "int64_t";
155 }

+ Here is the caller graph for this function:

llvm::Value* anonymous_namespace{WindowFunctionIR.cpp}::get_null_value_by_size ( CgenState cgen_state,
SQLTypeInfo  col_ti 
)

Definition at line 157 of file WindowFunctionIR.cpp.

References CHECK_EQ, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_size(), SQLTypeInfo::get_type(), inline_fixed_encoding_null_val(), inline_fp_null_value< double >(), inline_fp_null_value< float >(), inline_int_null_val(), SQLTypeInfo::is_date(), SQLTypeInfo::is_dict_encoded_string(), SQLTypeInfo::is_fp(), kBIGINT, kBOOLEAN, kDECIMAL, kENCODING_FIXED, kFLOAT, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kNUMERIC, kSMALLINT, kTIME, kTIMESTAMP, kTINYINT, CgenState::llFp(), and CgenState::llInt().

Referenced by Executor::codegenWindowFunctionAggregateCalls(), and Executor::codegenWindowNavigationFunctionOnFrame().

157  {
158  if (col_ti.is_fp()) {
159  if (col_ti.get_type() == kFLOAT) {
160  return cgen_state->llFp(inline_fp_null_value<float>());
161  } else {
162  return cgen_state->llFp(inline_fp_null_value<double>());
163  }
164  } else if (col_ti.is_dict_encoded_string()) {
165  if (col_ti.get_size() == 2) {
166  return cgen_state->llInt((int16_t)inline_int_null_value<int16_t>());
167  } else {
168  CHECK_EQ(col_ti.get_size(), 4);
169  return cgen_state->llInt((int32_t)inline_int_null_value<int32_t>());
170  }
171  } else if (col_ti.is_date()) {
172  if (col_ti.get_comp_param() == 16) {
173  return cgen_state->llInt((int16_t)inline_int_null_value<int16_t>());
174  } else if (col_ti.get_comp_param() == 32) {
175  return cgen_state->llInt((int32_t)inline_int_null_value<int32_t>());
176  } else {
177  return cgen_state->llInt((int64_t)inline_int_null_value<int64_t>());
178  }
179  } else {
180  switch (col_ti.get_type()) {
181  case kBOOLEAN:
182  case kTINYINT:
183  return cgen_state->llInt((int8_t)inline_int_null_value<int8_t>());
184  case kSMALLINT:
185  return cgen_state->llInt((int16_t)inline_int_null_value<int16_t>());
186  case kINT:
187  return cgen_state->llInt((int32_t)inline_int_null_value<int32_t>());
188  case kTIME:
189  case kTIMESTAMP:
190  if (col_ti.get_compression() == kENCODING_FIXED) {
191  return cgen_state->llInt((int64_t)(inline_fixed_encoding_null_val(col_ti)));
192  }
193  case kBIGINT:
194  case kINTERVAL_DAY_TIME:
196  case kDECIMAL:
197  case kNUMERIC:
198  return cgen_state->llInt((int64_t)inline_int_null_value<int64_t>());
199  default:
200  abort();
201  }
202  return cgen_state->llInt(inline_int_null_val(col_ti));
203  }
204 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
Definition: sqltypes.h:76
bool is_fp() const
Definition: sqltypes.h:571
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
llvm::ConstantFP * llFp(const float v) const
Definition: CgenState.h:253
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
constexpr float inline_fp_null_value< float >()
constexpr double inline_fp_null_value< double >()
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:402
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:249
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
bool is_dict_encoded_string() const
Definition: sqltypes.h:641
Definition: sqltypes.h:72
bool is_date() const
Definition: sqltypes.h:1026

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Value* anonymous_namespace{WindowFunctionIR.cpp}::get_null_value_by_size_with_encoding ( CgenState cgen_state,
SQLTypeInfo  col_ti 
)

Definition at line 206 of file WindowFunctionIR.cpp.

References CgenState::castToTypeIn(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_logical_size(), SQLTypeInfo::get_type(), inline_fixed_encoding_null_val(), inline_fp_null_value< double >(), inline_fp_null_value< float >(), inline_int_null_val(), SQLTypeInfo::is_fp(), kENCODING_DATE_IN_DAYS, kENCODING_FIXED, kFLOAT, CgenState::llFp(), and CgenState::llInt().

Referenced by Executor::codegenWindowNavigationFunctionOnFrame().

207  {
208  if (col_ti.is_fp()) {
209  if (col_ti.get_type() == kFLOAT) {
210  return cgen_state->llFp(inline_fp_null_value<float>());
211  } else {
212  return cgen_state->llFp(inline_fp_null_value<double>());
213  }
214  } else {
215  llvm::Value* ret_val{nullptr};
216  if (col_ti.get_compression() == kENCODING_FIXED ||
218  ret_val = cgen_state->llInt(inline_fixed_encoding_null_val(col_ti));
219  } else {
220  ret_val = cgen_state->llInt(inline_int_null_val(col_ti));
221  }
222  size_t ret_val_col_size_in_bytes = col_ti.get_logical_size() * 8;
223  if (ret_val->getType()->getIntegerBitWidth() > ret_val_col_size_in_bytes) {
224  return cgen_state->castToTypeIn(ret_val, ret_val_col_size_in_bytes);
225  }
226  return ret_val;
227  }
228 }
llvm::Value * castToTypeIn(llvm::Value *val, const size_t bit_width)
Definition: CgenState.cpp:150
bool is_fp() const
Definition: sqltypes.h:571
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
int get_logical_size() const
Definition: sqltypes.h:419
llvm::ConstantFP * llFp(const float v) const
Definition: CgenState.h:253
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
constexpr float inline_fp_null_value< float >()
constexpr double inline_fp_null_value< double >()
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:249
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{WindowFunctionIR.cpp}::get_window_agg_name ( const SqlWindowFunctionKind  kind,
const SQLTypeInfo window_func_ti 
)

Definition at line 82 of file WindowFunctionIR.cpp.

References AVG, CONDITIONAL_CHANGE_EVENT, COUNT, COUNT_IF, logger::FATAL, SQLTypeInfo::get_type(), kDOUBLE, kFLOAT, LOG, MAX, MIN, SUM, and SUM_IF.

Referenced by Executor::codegenWindowFunctionAggregateCalls().

83  {
84  std::string agg_name;
85  switch (kind) {
87  agg_name = "agg_min";
88  break;
89  }
91  agg_name = "agg_max";
92  break;
93  }
97  agg_name = "agg_sum";
98  break;
99  }
101  agg_name = "agg_count";
102  break;
103  }
105  agg_name = "agg_count_if";
106  break;
107  }
109  agg_name = "agg_sum_if";
110  break;
111  }
112  default: {
113  LOG(FATAL) << "Invalid window function kind";
114  }
115  }
116  switch (window_func_ti.get_type()) {
117  case kFLOAT: {
118  agg_name += "_float";
119  break;
120  }
121  case kDOUBLE: {
122  agg_name += "_double";
123  break;
124  }
125  default: {
126  break;
127  }
128  }
129  return agg_name;
130 }
#define LOG(tag)
Definition: Logger.h:285
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391

+ Here is the call graph for this function:

+ Here is the caller graph for this function: