OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
spatial_type::StartEndPoint Class Reference

#include <StartEndPoint.h>

+ Inheritance diagram for spatial_type::StartEndPoint:
+ Collaboration diagram for spatial_type::StartEndPoint:

Public Member Functions

 StartEndPoint (const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
 
size_t size () const final
 
SQLTypeInfo getNullType () const final
 
std::tuple< std::vector
< llvm::Value * >, llvm::Value * > 
codegenLoads (const std::vector< llvm::Value * > &arg_lvs, const std::vector< llvm::Value * > &pos_lvs, CgenState *cgen_state) final
 
std::vector< llvm::Value * > codegen (const std::vector< llvm::Value * > &args, CodeGenerator::NullCheckCodegen *nullcheck_codegen, CgenState *cgen_state, const CompilationOptions &co) final
 
- Public Member Functions inherited from spatial_type::Codegen
 Codegen (const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
 
auto isNullable () const
 
auto getTypeInfo () const
 
std::string getName () const
 
virtual std::unique_ptr
< CodeGenerator::NullCheckCodegen
getNullCheckCodegen (llvm::Value *null_lv, CgenState *cgen_state, Executor *executor)
 
virtual const Analyzer::ExprgetOperand (const size_t index)
 
virtual ~Codegen ()
 

Additional Inherited Members

- Static Public Member Functions inherited from spatial_type::Codegen
static std::unique_ptr< Codegeninit (const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
 
- Protected Attributes inherited from spatial_type::Codegen
const Analyzer::GeoOperatoroperator_
 
const Catalog_Namespace::Catalogcat_
 
bool is_nullable_ {true}
 

Detailed Description

Definition at line 23 of file StartEndPoint.h.

Constructor & Destructor Documentation

spatial_type::StartEndPoint::StartEndPoint ( const Analyzer::GeoOperator geo_operator,
const Catalog_Namespace::Catalog catalog 
)
inline

Definition at line 25 of file StartEndPoint.h.

References CHECK_EQ, spatial_type::Codegen::is_nullable_, spatial_type::Codegen::operator_, and Analyzer::GeoOperator::size().

27  : Codegen(geo_operator, catalog) {
28  CHECK_EQ(operator_->size(), size_t(1));
29  // nulls not supported yet
30  this->is_nullable_ = false;
31  }
Codegen(const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
Definition: Codegen.h:28
#define CHECK_EQ(x, y)
Definition: Logger.h:219
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:70
size_t size() const
Definition: Analyzer.cpp:3644

+ Here is the call graph for this function:

Member Function Documentation

std::vector<llvm::Value*> spatial_type::StartEndPoint::codegen ( const std::vector< llvm::Value * > &  args,
CodeGenerator::NullCheckCodegen nullcheck_codegen,
CgenState cgen_state,
const CompilationOptions co 
)
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 76 of file StartEndPoint.h.

References run_benchmark_import::args, CHECK, CHECK_EQ, CHECK_GT, and kENCODING_GEOINT.

79  {
80  CHECK_EQ(args.size(), size_t(2)); // ptr, size
81  const auto& geo_ti = getOperand(0)->get_type_info();
82  CHECK(geo_ti.is_geometry());
83 
84  auto& builder = cgen_state->ir_builder_;
85  llvm::Value* array_buff_cast{nullptr};
86  int32_t elem_size_bytes = 0;
87  if (geo_ti.get_compression() == kENCODING_GEOINT) {
88  array_buff_cast = builder.CreateBitCast(
89  args.front(), llvm::Type::getInt32PtrTy(cgen_state->context_));
90  elem_size_bytes = 4; // 4-byte ints
91  } else {
92  array_buff_cast = builder.CreateBitCast(
93  args.front(), llvm::Type::getDoublePtrTy(cgen_state->context_));
94  elem_size_bytes = 8; // doubles
95  }
96  CHECK_GT(elem_size_bytes, 0);
97  const bool is_end_point = getName() == "ST_EndPoint";
98  const auto num_elements_lv =
99  builder.CreateSDiv(args.back(), cgen_state->llInt(elem_size_bytes));
100  const auto index_lv =
101  is_end_point ? builder.CreateSub(num_elements_lv, cgen_state->llInt(int32_t(2)))
102  : cgen_state->llInt(int32_t(0));
103  auto array_offset_lv =
104  builder.CreateGEP(array_buff_cast, index_lv, operator_->getName() + "_Offset");
105  return {array_offset_lv, args.back()};
106  }
#define CHECK_EQ(x, y)
Definition: Logger.h:219
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
#define CHECK_GT(x, y)
Definition: Logger.h:223
llvm::LLVMContext & context_
Definition: CgenState.h:338
const std::string & getName() const
Definition: Analyzer.h:1925
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:70
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:307
#define CHECK(condition)
Definition: Logger.h:211
virtual const Analyzer::Expr * getOperand(const size_t index)
Definition: Codegen.cpp:63
std::string getName() const
Definition: Codegen.h:39
std::tuple<std::vector<llvm::Value*>, llvm::Value*> spatial_type::StartEndPoint::codegenLoads ( const std::vector< llvm::Value * > &  arg_lvs,
const std::vector< llvm::Value * > &  pos_lvs,
CgenState cgen_state 
)
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 38 of file StartEndPoint.h.

References CHECK, CHECK_EQ, get_int_type(), spatial_type::Codegen::getOperand(), kLINESTRING, log2_bytes(), and size().

41  {
42  CHECK_EQ(pos_lvs.size(), size());
43  // TODO: add null handling
44  if (arg_lvs.size() == size_t(1)) {
45  // col byte stream from column on disk
46  auto operand = getOperand(0);
47  CHECK(operand);
48  const auto& geo_ti = operand->get_type_info();
49  CHECK(geo_ti.get_type() == kLINESTRING);
50 
51  std::vector<llvm::Value*> array_operand_lvs;
52  array_operand_lvs.push_back(
53  cgen_state->emitExternalCall("array_buff",
54  llvm::Type::getInt8PtrTy(cgen_state->context_),
55  {arg_lvs.front(), pos_lvs.front()}));
56  const bool is_nullable = !geo_ti.get_notnull();
57  std::string size_fn_name = "array_size";
58  if (is_nullable) {
59  size_fn_name += "_nullable";
60  }
61  uint32_t elem_sz = 1; // TINYINT coords array
62  std::vector<llvm::Value*> array_sz_args{
63  arg_lvs.front(), pos_lvs.front(), cgen_state->llInt(log2_bytes(elem_sz))};
64  if (is_nullable) {
65  array_sz_args.push_back(
66  cgen_state->llInt(static_cast<int32_t>(inline_int_null_value<int32_t>())));
67  }
68  array_operand_lvs.push_back(cgen_state->emitExternalCall(
69  size_fn_name, get_int_type(32, cgen_state->context_), array_sz_args));
70  return std::make_tuple(array_operand_lvs, nullptr);
71  }
72  CHECK_EQ(arg_lvs.size(), size_t(2)); // ptr, size
73  return std::make_tuple(arg_lvs, nullptr);
74  }
#define CHECK_EQ(x, y)
Definition: Logger.h:219
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)
Definition: CgenState.h:228
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
llvm::LLVMContext & context_
Definition: CgenState.h:338
size_t size() const final
Definition: StartEndPoint.h:33
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:307
#define CHECK(condition)
Definition: Logger.h:211
virtual const Analyzer::Expr * getOperand(const size_t index)
Definition: Codegen.cpp:63
uint32_t log2_bytes(const uint32_t bytes)
Definition: Execute.h:176

+ Here is the call graph for this function:

SQLTypeInfo spatial_type::StartEndPoint::getNullType ( ) const
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 35 of file StartEndPoint.h.

References kNULLT.

35 { return SQLTypeInfo(kNULLT); }
size_t spatial_type::StartEndPoint::size ( ) const
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 33 of file StartEndPoint.h.

Referenced by codegenLoads().

33 { return 1; }

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: