38 throw std::runtime_error(
"Geo operation requires GEOS support.");
43 std::string func =
"Geos_Wkb"s;
45 throw std::runtime_error(
46 "GEOS runtime does not support transforms on geometry inputs.");
50 throw std::runtime_error(
51 "GEOS runtime does not support transforms on geometry outputs.");
55 argument_list.begin(),
58 argument_list.insert(argument_list.begin(),
62 argument_list.insert(argument_list.end(),
63 llvm::ConstantPointerNull::get(
82 throw std::runtime_error(
"Unsupported unary geo operation.");
94 throw std::runtime_error(
"Geo operation requires GEOS support.");
101 std::string func =
"Geos_Wkb"s;
103 throw std::runtime_error(
104 "GEOS runtime does not support transforms on geometry inputs.");
107 throw std::runtime_error(
108 "GEOS runtime does not support transforms on geometry outputs.");
111 argument_list.insert(
112 argument_list.begin(),
115 argument_list.insert(argument_list.begin(),
119 argument_list.insert(argument_list.end(),
120 llvm::ConstantPointerNull::get(
124 argument_list.insert(
129 argument_list.insert(
145 arg1_list.insert(arg1_list.end(),
146 llvm::ConstantPointerNull::get(
150 arg1_list.insert(arg1_list.end(),
154 arg1_list.insert(arg1_list.end(),
160 throw std::runtime_error(
"Unsupported binary geo operation.");
164 argument_list.insert(argument_list.end(), arg1_list.begin(), arg1_list.end());
170 const std::vector<std::shared_ptr<Analyzer::Expr>>& geo_args,
173 std::vector<llvm::Value*> argument_list;
174 bool coord_col =
true;
175 for (
const auto& geo_arg : geo_args) {
176 const auto arg = geo_arg.get();
177 const auto& arg_ti = arg->get_type_info();
178 const auto elem_ti = arg_ti.get_elem_type();
179 const auto arg_lvs =
codegen(arg,
true, co);
180 if (arg_ti.is_number()) {
181 argument_list.emplace_back(arg_lvs.front());
184 if (arg_ti.is_geometry()) {
185 argument_list.insert(argument_list.end(), arg_lvs.begin(), arg_lvs.end());
188 CHECK(arg_ti.is_array());
189 if (arg_lvs.size() > 1) {
190 CHECK_EQ(
size_t(2), arg_lvs.size());
191 auto ptr_lv = arg_lvs.front();
198 argument_list.emplace_back(ptr_lv);
201 argument_list.emplace_back(cast_len_lv);
203 CHECK_EQ(
size_t(1), arg_lvs.size());
204 if (arg_ti.get_size() > 0) {
206 auto ptr_lv = arg_lvs.front();
211 "fast_fixlen_array_buff",
213 {arg_lvs.front(), posArg(arg)});
221 argument_list.emplace_back(ptr_lv);
227 {arg_lvs.front(), posArg(arg)});
234 argument_list.emplace_back(ptr_lv);
240 cgen_state_->llInt(log2_bytes(elem_ti.get_logical_size()))});
243 argument_list.emplace_back(cast_len_lv);
247 return argument_list;
251 const std::string& func,
252 std::vector<llvm::Value*> argument_list,
257 argument_list.emplace_back(
result);
264 llvm::BasicBlock* geos_pred_ok_bb{
nullptr};
265 llvm::BasicBlock* geos_pred_fail_bb{
nullptr};
266 geos_pred_ok_bb = llvm::BasicBlock::Create(
268 geos_pred_fail_bb = llvm::BasicBlock::Create(
283 const std::string& func,
284 std::vector<llvm::Value*> argument_list,
291 auto pi8_type = llvm::PointerType::get(i8_type, 0);
292 auto pi32_type = llvm::PointerType::get(i32_type, 0);
298 auto result_coords_size =
300 auto result_ring_sizes =
302 auto result_ring_sizes_size =
304 auto result_poly_rings =
306 auto result_poly_rings_size =
309 argument_list.emplace_back(result_type);
310 argument_list.emplace_back(result_coords);
311 argument_list.emplace_back(result_coords_size);
312 argument_list.emplace_back(result_ring_sizes);
313 argument_list.emplace_back(result_ring_sizes_size);
314 argument_list.emplace_back(result_poly_rings);
315 argument_list.emplace_back(result_poly_rings_size);
322 llvm::BasicBlock* geos_ok_bb{
nullptr};
323 llvm::BasicBlock* geos_fail_bb{
nullptr};
324 geos_ok_bb = llvm::BasicBlock::Create(
326 geos_fail_bb = llvm::BasicBlock::Create(
352 "register_buffer_with_executor_rsm",
354 {cgen_state_->llInt(reinterpret_cast<int64_t>(executor())),
355 cgen_state_->ir_builder_.CreatePointerCast(buf1, pi8_type)});
357 "register_buffer_with_executor_rsm",
359 {cgen_state_->llInt(reinterpret_cast<int64_t>(executor())),
360 cgen_state_->ir_builder_.CreatePointerCast(buf2, pi8_type)});
362 "register_buffer_with_executor_rsm",
364 {cgen_state_->llInt(reinterpret_cast<int64_t>(executor())),
365 cgen_state_->ir_builder_.CreatePointerCast(buf3, pi8_type)});
Geospatial::GeoBase::GeoOp getOp() const
llvm::IRBuilder ir_builder_
Geospatial::GeoBase::GeoOp getOp() const
int32_t get_compression_scheme(const SQLTypeInfo &ti)
const SQLTypeInfo getTypeInfo1() const
static const int32_t ERR_GEOS
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs0() const
std::vector< llvm::Value * > codegenGeoBinOper(const Analyzer::GeoBinOper *, const CompilationOptions &)
llvm::ConstantInt * llBool(const bool v) const
llvm::LLVMContext & context_
llvm::Function * current_func_
HOST DEVICE int get_output_srid() const
std::vector< llvm::Value * > codegenGeoUOper(const Analyzer::GeoUOper *, const CompilationOptions &)
std::vector< llvm::Value * > codegenGeosPredicateCall(const std::string &, std::vector< llvm::Value *>, const CompilationOptions &)
const SQLTypeInfo getTypeInfo0() const
ExecutorDeviceType device_type
llvm::Value * emitExternalCall(const std::string &fname, llvm::Type *ret_type, const std::vector< llvm::Value *> args, const std::vector< llvm::Attribute::AttrKind > &fnattrs={}, const bool has_struct_return=false)
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs0() const
std::vector< llvm::Value * > codegen(const Analyzer::Expr *, const bool fetch_columns, const CompilationOptions &)
std::vector< llvm::Value * > codegenGeosConstructorCall(const std::string &, std::vector< llvm::Value *>, const CompilationOptions &)
const SQLTypeInfo getTypeInfo0() const
const SQLTypeInfo & get_type_info() const
std::vector< llvm::Value * > codegenGeoArgs(const std::vector< std::shared_ptr< Analyzer::Expr >> &, const CompilationOptions &)
int get_physical_coord_cols() const
HOST DEVICE SQLTypes get_type() const
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs1() const
llvm::ConstantInt * llInt(const T v) const