OmniSciDB  a5dc49c757
 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:2925
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs() const
Definition: Analyzer.h:2927
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  if (col_ti.get_compression() == kENCODING_FIXED) {
186  return cgen_state->llInt((int16_t)(inline_fixed_encoding_null_val(col_ti)));
187  }
188  return cgen_state->llInt((int16_t)inline_int_null_value<int16_t>());
189  case kINT:
190  if (col_ti.get_compression() == kENCODING_FIXED) {
191  return cgen_state->llInt((int32_t)(inline_fixed_encoding_null_val(col_ti)));
192  }
193  return cgen_state->llInt((int32_t)inline_int_null_value<int32_t>());
194  case kTIME:
195  case kTIMESTAMP:
196  if (col_ti.get_compression() == kENCODING_FIXED) {
197  return cgen_state->llInt((int64_t)(inline_fixed_encoding_null_val(col_ti)));
198  }
199  case kBIGINT:
200  if (col_ti.get_compression() == kENCODING_FIXED) {
201  return cgen_state->llInt((int64_t)(inline_fixed_encoding_null_val(col_ti)));
202  }
203  return cgen_state->llInt((int64_t)inline_int_null_value<int64_t>());
204  case kINTERVAL_DAY_TIME:
206  case kDECIMAL:
207  case kNUMERIC:
208  return cgen_state->llInt((int64_t)inline_int_null_value<int64_t>());
209  default:
210  abort();
211  }
212  return cgen_state->llInt(inline_int_null_val(col_ti));
213  }
214 }
#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:573
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:643
Definition: sqltypes.h:72
bool is_date() const
Definition: sqltypes.h:1028

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

217  {
218  if (col_ti.is_fp()) {
219  if (col_ti.get_type() == kFLOAT) {
220  return cgen_state->llFp(inline_fp_null_value<float>());
221  } else {
222  return cgen_state->llFp(inline_fp_null_value<double>());
223  }
224  } else {
225  llvm::Value* ret_val{nullptr};
226  if (col_ti.get_compression() == kENCODING_FIXED ||
228  ret_val = cgen_state->llInt(inline_fixed_encoding_null_val(col_ti));
229  } else {
230  ret_val = cgen_state->llInt(inline_int_null_val(col_ti));
231  }
232  size_t ret_val_col_size_in_bytes = col_ti.get_logical_size() * 8;
233  if (ret_val->getType()->getIntegerBitWidth() > ret_val_col_size_in_bytes) {
234  return cgen_state->castToTypeIn(ret_val, ret_val_col_size_in_bytes);
235  }
236  return ret_val;
237  }
238 }
llvm::Value * castToTypeIn(llvm::Value *val, const size_t bit_width)
Definition: CgenState.cpp:150
bool is_fp() const
Definition: sqltypes.h:573
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
int get_logical_size() const
Definition: sqltypes.h:421
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: