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

#include <NPoints.h>

+ Inheritance diagram for spatial_type::NPoints:
+ Collaboration diagram for spatial_type::NPoints:

Public Member Functions

 NPoints (const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
 
size_t size () const final
 
SQLTypeInfo getNullType () const final
 
const Analyzer::ExprgetOperand (const size_t index) 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 ~Codegen ()
 

Protected Attributes

SQLTypeInfo geo_ti_
 
std::unique_ptr
< Analyzer::ColumnVar
operand_owned_
 
- Protected Attributes inherited from spatial_type::Codegen
const Analyzer::GeoOperatoroperator_
 
const Catalog_Namespace::Catalogcat_
 
bool is_nullable_ {true}
 

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)
 

Detailed Description

Definition at line 23 of file NPoints.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file NPoints.h.

27  : Codegen(geo_operator, catalog) {}
Codegen(const Analyzer::GeoOperator *geo_operator, const Catalog_Namespace::Catalog *catalog)
Definition: Codegen.h:28

Member Function Documentation

std::vector<llvm::Value*> spatial_type::NPoints::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 85 of file NPoints.h.

References run_benchmark_import::args, CHECK, CHECK_EQ, geo_ti_, SQLTypeInfo::get_compression(), spatial_type::Codegen::getTypeInfo(), spatial_type::Codegen::isNullable(), and kENCODING_GEOINT.

88  {
89  CHECK_EQ(args.size(), size_t(1));
90 
91  // divide the coord size by the constant compression value and return it
92  auto& builder = cgen_state->ir_builder_;
93  llvm::Value* conversion_constant{nullptr};
95  conversion_constant = cgen_state->llInt(4);
96  } else {
97  conversion_constant = cgen_state->llInt(8);
98  }
99  CHECK(conversion_constant);
100  const auto total_num_pts = builder.CreateUDiv(args.front(), conversion_constant);
101  const auto ret = builder.CreateUDiv(total_num_pts, cgen_state->llInt(2));
102  if (isNullable()) {
103  CHECK(nullcheck_codegen);
104  return {nullcheck_codegen->finalize(cgen_state->inlineIntNull(getTypeInfo()), ret)};
105  } else {
106  return {ret};
107  }
108  }
#define CHECK_EQ(x, y)
Definition: Logger.h:219
llvm::IRBuilder ir_builder_
Definition: CgenState.h:340
auto getTypeInfo() const
Definition: Codegen.h:37
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
Definition: CgenState.cpp:29
auto isNullable() const
Definition: Codegen.h:35
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
SQLTypeInfo geo_ti_
Definition: NPoints.h:111
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:307
llvm::Value * finalize(llvm::Value *null_lv, llvm::Value *notnull_lv)
Definition: IRCodegen.cpp:1447
#define CHECK(condition)
Definition: Logger.h:211

+ Here is the call graph for this function:

std::tuple<std::vector<llvm::Value*>, llvm::Value*> spatial_type::NPoints::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 60 of file NPoints.h.

References CHECK_EQ, SQLTypeInfo::get_elem_type(), get_int_type(), Analyzer::Expr::get_type_info(), getOperand(), spatial_type::Codegen::getTypeInfo(), spatial_type::Codegen::isNullable(), and log2_bytes().

63  {
64  CHECK_EQ(arg_lvs.size(), size_t(1));
65  auto& argument_lv = arg_lvs.front();
66  std::string fn_name("array_size");
67 
68  const auto& elem_ti = getOperand(0)->get_type_info().get_elem_type();
69  std::vector<llvm::Value*> array_size_args{
70  argument_lv,
71  pos_lvs.front(),
72  cgen_state->llInt(log2_bytes(elem_ti.get_logical_size()))};
73 
74  const bool is_nullable = isNullable();
75 
76  if (is_nullable) {
77  fn_name += "_nullable";
78  array_size_args.push_back(cgen_state->inlineIntNull(getTypeInfo()));
79  }
80  const auto coords_arr_sz_lv = cgen_state->emitExternalCall(
81  fn_name, get_int_type(32, cgen_state->context_), array_size_args);
82  return std::make_tuple(std::vector<llvm::Value*>{coords_arr_sz_lv}, coords_arr_sz_lv);
83  }
#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)
auto getTypeInfo() const
Definition: Codegen.h:37
const Analyzer::Expr * getOperand(const size_t index) final
Definition: NPoints.h:33
llvm::LLVMContext & context_
Definition: CgenState.h:338
llvm::ConstantInt * inlineIntNull(const SQLTypeInfo &)
Definition: CgenState.cpp:29
auto isNullable() const
Definition: Codegen.h:35
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
llvm::ConstantInt * llInt(const T v) const
Definition: CgenState.h:307
uint32_t log2_bytes(const uint32_t bytes)
Definition: Execute.h:176
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:861

+ Here is the call graph for this function:

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

Implements spatial_type::Codegen.

Definition at line 31 of file NPoints.h.

References kINT.

31 { return SQLTypeInfo(kINT); }
Definition: sqltypes.h:45
const Analyzer::Expr* spatial_type::NPoints::getOperand ( const size_t  index)
inlinefinalvirtual

Reimplemented from spatial_type::Codegen.

Definition at line 33 of file NPoints.h.

References spatial_type::Codegen::cat_, CHECK, CHECK_EQ, geo_ti_, get_column_descriptor(), SQLTypeInfo::get_notnull(), Analyzer::GeoOperator::getOperand(), SQLTypeInfo::is_geometry(), spatial_type::Codegen::is_nullable_, operand_owned_, and spatial_type::Codegen::operator_.

Referenced by codegenLoads().

33  {
34  CHECK_EQ(index, size_t(0));
35  if (operand_owned_) {
36  return operand_owned_.get();
37  }
38 
39  const auto operand = operator_->getOperand(0);
40  auto col_var = dynamic_cast<const Analyzer::ColumnVar*>(operand);
41  CHECK(col_var);
42 
43  geo_ti_ = col_var->get_type_info();
46 
47  // create a new operand which is just the coords and codegen it
48  const auto coords_column_id = col_var->get_column_id() + 1; // + 1 for coords
49  auto coords_cd =
50  get_column_descriptor(coords_column_id, col_var->get_table_id(), *cat_);
51  CHECK(coords_cd);
52 
53  operand_owned_ = std::make_unique<Analyzer::ColumnVar>(coords_cd->columnType,
54  col_var->get_table_id(),
55  coords_column_id,
56  col_var->get_rte_idx());
57  return operand_owned_.get();
58  }
std::unique_ptr< Analyzer::ColumnVar > operand_owned_
Definition: NPoints.h:112
#define CHECK_EQ(x, y)
Definition: Logger.h:219
const Catalog_Namespace::Catalog * cat_
Definition: Codegen.h:71
const Analyzer::GeoOperator * operator_
Definition: Codegen.h:70
SQLTypeInfo geo_ti_
Definition: NPoints.h:111
#define CHECK(condition)
Definition: Logger.h:211
bool is_geometry() const
Definition: sqltypes.h:531
Analyzer::Expr * getOperand(const size_t index) const
Definition: Analyzer.cpp:3648
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:336
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t spatial_type::NPoints::size ( ) const
inlinefinalvirtual

Implements spatial_type::Codegen.

Definition at line 29 of file NPoints.h.

29 { return 1; }

Member Data Documentation

SQLTypeInfo spatial_type::NPoints::geo_ti_
protected

Definition at line 111 of file NPoints.h.

Referenced by codegen(), and getOperand().

std::unique_ptr<Analyzer::ColumnVar> spatial_type::NPoints::operand_owned_
protected

Definition at line 112 of file NPoints.h.

Referenced by getOperand().


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