OmniSciDB  b28c0d5765
 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 126 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().

126  {
127  const auto& args = window_func->getArgs();
128  return ((window_func->getKind() == SqlWindowFunctionKind::COUNT && !args.empty()) ||
129  window_func->getKind() == SqlWindowFunctionKind::AVG)
130  ? args.front()->get_type_info()
131  : window_func->get_type_info();
132 }
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:2562
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs() const
Definition: Analyzer.h:2564
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:82

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

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

134  {
135  if (is_fp) {
136  if (size == 4) {
137  return "float";
138  }
139  return "double";
140  }
141  if (size == 1) {
142  return "int8_t";
143  } else if (size == 2) {
144  return "int16_t";
145  } else if (size == 4) {
146  return "int32_t";
147  }
148  return "int64_t";
149 }

+ 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 151 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::codegenWindowFunctionOnFrame().

151  {
152  if (col_ti.is_fp()) {
153  if (col_ti.get_type() == kFLOAT) {
154  return cgen_state->llFp(inline_fp_null_value<float>());
155  } else {
156  return cgen_state->llFp(inline_fp_null_value<double>());
157  }
158  } else if (col_ti.is_dict_encoded_string()) {
159  if (col_ti.get_size() == 2) {
160  return cgen_state->llInt((int16_t)inline_int_null_value<int16_t>());
161  } else {
162  CHECK_EQ(col_ti.get_size(), 4);
163  return cgen_state->llInt((int32_t)inline_int_null_value<int32_t>());
164  }
165  } else {
166  switch (col_ti.get_type()) {
167  case kBOOLEAN:
168  case kTINYINT:
169  return cgen_state->llInt((int8_t)inline_int_null_value<int8_t>());
170  case kSMALLINT:
171  return cgen_state->llInt((int16_t)inline_int_null_value<int16_t>());
172  case kINT:
173  return cgen_state->llInt((int32_t)inline_int_null_value<int32_t>());
174  case kTIME:
175  case kTIMESTAMP:
176  if (col_ti.get_compression() == kENCODING_FIXED) {
177  return cgen_state->llInt((int64_t)(inline_fixed_encoding_null_val(col_ti)));
178  }
179  case kBIGINT:
180  case kDATE:
181  case kINTERVAL_DAY_TIME:
183  case kDECIMAL:
184  case kNUMERIC:
185  return cgen_state->llInt((int64_t)inline_int_null_value<int64_t>());
186  default:
187  abort();
188  }
189  return cgen_state->llInt(inline_int_null_val(col_ti));
190  }
191 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
HOST DEVICE int get_size() const
Definition: sqltypes.h:390
Definition: sqltypes.h:64
bool is_fp() const
Definition: sqltypes.h:580
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
llvm::ConstantFP * llFp(const float v) const
Definition: CgenState.h:244
Definition: sqltypes.h:68
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
constexpr float inline_fp_null_value< float >()
constexpr double inline_fp_null_value< double >()
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:240
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:628
Definition: sqltypes.h:60

+ 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 193 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::codegenWindowFunctionOnFrame().

194  {
195  if (col_ti.is_fp()) {
196  if (col_ti.get_type() == kFLOAT) {
197  return cgen_state->llFp(inline_fp_null_value<float>());
198  } else {
199  return cgen_state->llFp(inline_fp_null_value<double>());
200  }
201  } else {
202  llvm::Value* ret_val{nullptr};
203  if (col_ti.get_compression() == kENCODING_FIXED ||
205  ret_val = cgen_state->llInt(inline_fixed_encoding_null_val(col_ti));
206  } else {
207  ret_val = cgen_state->llInt(inline_int_null_val(col_ti));
208  }
209  size_t ret_val_col_size_in_bytes = col_ti.get_logical_size() * 8;
210  if (ret_val->getType()->getIntegerBitWidth() > ret_val_col_size_in_bytes) {
211  return cgen_state->castToTypeIn(ret_val, ret_val_col_size_in_bytes);
212  }
213  return ret_val;
214  }
215 }
llvm::Value * castToTypeIn(llvm::Value *val, const size_t bit_width)
Definition: CgenState.cpp:149
bool is_fp() const
Definition: sqltypes.h:580
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
int get_logical_size() const
Definition: sqltypes.h:400
llvm::ConstantFP * llFp(const float v) const
Definition: CgenState.h:244
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
constexpr float inline_fp_null_value< float >()
constexpr double inline_fp_null_value< double >()
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:240
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 81 of file WindowFunctionIR.cpp.

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

Referenced by Executor::codegenWindowFunctionAggregateCalls().

82  {
83  std::string agg_name;
84  switch (kind) {
86  agg_name = "agg_min";
87  break;
88  }
90  agg_name = "agg_max";
91  break;
92  }
95  agg_name = "agg_sum";
96  break;
97  }
99  agg_name = "agg_count";
100  break;
101  }
103  agg_name = "agg_count_if";
104  break;
105  }
106  default: {
107  LOG(FATAL) << "Invalid window function kind";
108  }
109  }
110  switch (window_func_ti.get_type()) {
111  case kFLOAT: {
112  agg_name += "_float";
113  break;
114  }
115  case kDOUBLE: {
116  agg_name += "_double";
117  break;
118  }
119  default: {
120  break;
121  }
122  }
123  return agg_name;
124 }
#define LOG(tag)
Definition: Logger.h:216
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380

+ Here is the call graph for this function:

+ Here is the caller graph for this function: