OmniSciDB  c1a53651b2
 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 133 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().

133  {
134  const auto& args = window_func->getArgs();
135  return ((window_func->getKind() == SqlWindowFunctionKind::COUNT && !args.empty()) ||
136  window_func->getKind() == SqlWindowFunctionKind::AVG)
137  ? args.front()->get_type_info()
138  : window_func->get_type_info();
139 }
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:2576
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs() const
Definition: Analyzer.h:2578
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 141 of file WindowFunctionIR.cpp.

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

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

+ 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 158 of file WindowFunctionIR.cpp.

References CHECK_EQ, 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_dict_encoded_string(), SQLTypeInfo::is_fp(), kBIGINT, kBOOLEAN, kDATE, kDECIMAL, kENCODING_FIXED, kFLOAT, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kNUMERIC, kSMALLINT, kTIME, kTIMESTAMP, kTINYINT, CgenState::llFp(), and CgenState::llInt().

Referenced by Executor::codegenWindowNavigationFunctionOnFrame().

158  {
159  if (col_ti.is_fp()) {
160  if (col_ti.get_type() == kFLOAT) {
161  return cgen_state->llFp(inline_fp_null_value<float>());
162  } else {
163  return cgen_state->llFp(inline_fp_null_value<double>());
164  }
165  } else if (col_ti.is_dict_encoded_string()) {
166  if (col_ti.get_size() == 2) {
167  return cgen_state->llInt((int16_t)inline_int_null_value<int16_t>());
168  } else {
169  CHECK_EQ(col_ti.get_size(), 4);
170  return cgen_state->llInt((int32_t)inline_int_null_value<int32_t>());
171  }
172  } else {
173  switch (col_ti.get_type()) {
174  case kBOOLEAN:
175  case kTINYINT:
176  return cgen_state->llInt((int8_t)inline_int_null_value<int8_t>());
177  case kSMALLINT:
178  return cgen_state->llInt((int16_t)inline_int_null_value<int16_t>());
179  case kINT:
180  return cgen_state->llInt((int32_t)inline_int_null_value<int32_t>());
181  case kTIME:
182  case kTIMESTAMP:
183  if (col_ti.get_compression() == kENCODING_FIXED) {
184  return cgen_state->llInt((int64_t)(inline_fixed_encoding_null_val(col_ti)));
185  }
186  case kBIGINT:
187  case kDATE:
188  case kINTERVAL_DAY_TIME:
190  case kDECIMAL:
191  case kNUMERIC:
192  return cgen_state->llInt((int64_t)inline_int_null_value<int64_t>());
193  default:
194  abort();
195  }
196  return cgen_state->llInt(inline_int_null_val(col_ti));
197  }
198 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
HOST DEVICE int get_size() const
Definition: sqltypes.h:393
Definition: sqltypes.h:66
bool is_fp() const
Definition: sqltypes.h:584
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
llvm::ConstantFP * llFp(const float v) const
Definition: CgenState.h:246
Definition: sqltypes.h:70
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389
constexpr float inline_fp_null_value< float >()
constexpr double inline_fp_null_value< double >()
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:242
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:632
Definition: sqltypes.h:62

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

201  {
202  if (col_ti.is_fp()) {
203  if (col_ti.get_type() == kFLOAT) {
204  return cgen_state->llFp(inline_fp_null_value<float>());
205  } else {
206  return cgen_state->llFp(inline_fp_null_value<double>());
207  }
208  } else {
209  llvm::Value* ret_val{nullptr};
210  if (col_ti.get_compression() == kENCODING_FIXED ||
212  ret_val = cgen_state->llInt(inline_fixed_encoding_null_val(col_ti));
213  } else {
214  ret_val = cgen_state->llInt(inline_int_null_val(col_ti));
215  }
216  size_t ret_val_col_size_in_bytes = col_ti.get_logical_size() * 8;
217  if (ret_val->getType()->getIntegerBitWidth() > ret_val_col_size_in_bytes) {
218  return cgen_state->castToTypeIn(ret_val, ret_val_col_size_in_bytes);
219  }
220  return ret_val;
221  }
222 }
llvm::Value * castToTypeIn(llvm::Value *val, const size_t bit_width)
Definition: CgenState.cpp:149
bool is_fp() const
Definition: sqltypes.h:584
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
int get_logical_size() const
Definition: sqltypes.h:403
llvm::ConstantFP * llFp(const float v) const
Definition: CgenState.h:246
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389
constexpr float inline_fp_null_value< float >()
constexpr double inline_fp_null_value< double >()
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:242
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 84 of file WindowFunctionIR.cpp.

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

Referenced by Executor::codegenWindowFunctionAggregateCalls().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: