OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analyzer::GeoConstant Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::GeoConstant:
+ Collaboration diagram for Analyzer::GeoConstant:

Public Member Functions

 GeoConstant (std::unique_ptr< Geospatial::GeoBase > &&geo, const SQLTypeInfo &ti)
 
std::shared_ptr< Analyzer::Exprdeep_copy () const final
 
std::string toString () const final
 
bool operator== (const Expr &) const final
 
size_t physicalCols () const
 
std::shared_ptr
< Analyzer::Constant
makePhysicalConstant (const size_t index) const
 
std::shared_ptr< Analyzer::Expradd_cast (const SQLTypeInfo &new_type_info) final
 
std::string getWKTString () const
 
- Public Member Functions inherited from Analyzer::GeoExpr
 GeoExpr (const SQLTypeInfo &ti)
 
virtual std::vector
< Analyzer::Expr * > 
getChildExprs () const
 
- Public Member Functions inherited from Analyzer::Expr
 Expr (SQLTypes t, bool notnull)
 
 Expr (SQLTypes t, int d, bool notnull)
 
 Expr (SQLTypes t, int d, int s, bool notnull)
 
 Expr (const SQLTypeInfo &ti, bool has_agg=false)
 
virtual ~Expr ()
 
std::shared_ptr< Analyzer::Exprget_shared_ptr ()
 
const SQLTypeInfoget_type_info () const
 
void set_type_info (const SQLTypeInfo &ti)
 
bool get_contains_agg () const
 
void set_contains_agg (bool a)
 
virtual void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const
 
virtual std::shared_ptr
< Analyzer::Expr
normalize_simple_predicate (int &rte_idx) const
 
virtual void group_predicates (std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const
 
virtual void collect_rte_idx (std::set< int > &rte_idx_set) const
 
virtual void collect_column_var (std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const
 
virtual size_t get_num_column_vars (const bool include_agg) const
 
virtual std::shared_ptr
< Analyzer::Expr
rewrite_with_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
 
virtual std::shared_ptr
< Analyzer::Expr
rewrite_with_child_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
 
virtual std::shared_ptr
< Analyzer::Expr
rewrite_agg_to_var (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
 
virtual void print () const
 
virtual void add_unique (std::list< const Expr * > &expr_list) const
 
virtual void find_expr (std::function< bool(const Expr *)> f, std::list< const Expr * > &expr_list) const
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Private Attributes

std::unique_ptr
< Geospatial::GeoBase
geo_
 

Additional Inherited Members

- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 3248 of file Analyzer.h.

Constructor & Destructor Documentation

Analyzer::GeoConstant::GeoConstant ( std::unique_ptr< Geospatial::GeoBase > &&  geo,
const SQLTypeInfo ti 
)

Definition at line 4037 of file Analyzer.cpp.

References CHECK, geo_, Analyzer::anonymous_namespace{Analyzer.cpp}::get_ti_from_geo(), SQLTypeInfo::get_type(), and SQLTypeInfo::get_type_name().

4039  : GeoExpr(ti), geo_(std::move(geo)) {
4040  CHECK(geo_);
4041  if (get_ti_from_geo(geo_.get()) != ti.get_type()) {
4042  throw std::runtime_error("Conflicting types for geo data " + geo_->getWktString() +
4043  " (type provided: " + ti.get_type_name() + ")");
4044  }
4045 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
std::unique_ptr< Geospatial::GeoBase > geo_
Definition: Analyzer.h:3267
std::string get_type_name() const
Definition: sqltypes.h:484
#define CHECK(condition)
Definition: Logger.h:291
SQLTypes get_ti_from_geo(const Geospatial::GeoBase *geo)
Definition: Analyzer.cpp:4007
GeoExpr(const SQLTypeInfo &ti)
Definition: Analyzer.h:3218

+ Here is the call graph for this function:

Member Function Documentation

std::shared_ptr< Analyzer::Expr > Analyzer::GeoConstant::add_cast ( const SQLTypeInfo new_type_info)
finalvirtual

Reimplemented from Analyzer::Expr.

Definition at line 4130 of file Analyzer.cpp.

References CHECK, geo_, Geo::get_input_srid(), SQLTypeInfo::get_output_srid(), Analyzer::Expr::get_type_info(), SQLTypeInfo::set_input_srid(), and toString().

4130  {
4131  // TODO: we should eliminate the notion of input and output SRIDs on a type. A type can
4132  // only have 1 SRID. A cast or transforms changes the SRID of the type.
4133  // NOTE: SRID 0 indicates set srid, skip cast
4134  SQLTypeInfo cast_type_info = new_type_info;
4135  if (!(get_type_info().get_input_srid() == 0) &&
4136  (get_type_info().get_input_srid() != new_type_info.get_output_srid())) {
4137  // run cast
4138  CHECK(geo_);
4139  if (!geo_->transform(get_type_info().get_input_srid(),
4140  new_type_info.get_output_srid())) {
4141  throw std::runtime_error("Failed to transform constant geometry: " + toString());
4142  }
4143  // The geo constant has been transformed but the new type info still encodes
4144  // a transform. Need to reset it and eliminate srid transition.
4145  cast_type_info.set_input_srid(new_type_info.get_output_srid());
4146  }
4147  return makeExpr<GeoConstant>(std::move(geo_), cast_type_info);
4148 }
std::string toString() const final
Definition: Analyzer.cpp:4052
int32_t get_input_srid(const int8_t *flatbuffer)
std::unique_ptr< Geospatial::GeoBase > geo_
Definition: Analyzer.h:3267
void set_input_srid(int d)
Definition: sqltypes.h:474
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
#define CHECK(condition)
Definition: Logger.h:291
HOST DEVICE int get_output_srid() const
Definition: sqltypes.h:397

+ Here is the call graph for this function:

std::shared_ptr< Analyzer::Expr > Analyzer::GeoConstant::deep_copy ( ) const
finalvirtual

Implements Analyzer::Expr.

Definition at line 4047 of file Analyzer.cpp.

References CHECK, geo_, and Analyzer::Expr::type_info.

4047  {
4048  CHECK(geo_);
4049  return makeExpr<GeoConstant>(geo_->clone(), type_info);
4050 }
std::unique_ptr< Geospatial::GeoBase > geo_
Definition: Analyzer.h:3267
SQLTypeInfo type_info
Definition: Analyzer.h:180
#define CHECK(condition)
Definition: Logger.h:291
std::string Analyzer::GeoConstant::getWKTString ( ) const

Definition at line 4060 of file Analyzer.cpp.

References CHECK, and geo_.

4060  {
4061  CHECK(geo_);
4062  return geo_->getWktString();
4063 }
std::unique_ptr< Geospatial::GeoBase > geo_
Definition: Analyzer.h:3267
#define CHECK(condition)
Definition: Logger.h:291
std::shared_ptr< Analyzer::Constant > Analyzer::GeoConstant::makePhysicalConstant ( const size_t  index) const

Definition at line 4087 of file Analyzer.cpp.

References CHECK_GE, CHECK_LE, Geospatial::convert_coords(), Geospatial::convert_rings(), geo_, SQLTypeInfo::get_physical_coord_cols(), Geospatial::GeoTypesFactory::getGeoColumns(), Analyzer::Expr::type_info, and UNREACHABLE.

Referenced by CodeGenerator::codegenGeoConstant().

4088  {
4089  // TODO: handle bounds, etc
4090  const auto num_phys_coords = type_info.get_physical_coord_cols();
4091  CHECK_GE(num_phys_coords, 0);
4092  CHECK_LE(index, size_t(num_phys_coords));
4093  SQLTypeInfo ti = type_info;
4094 
4095  std::vector<double> coords;
4096  std::vector<double> bounds;
4097  std::vector<int> ring_sizes; // also linestring_sizes
4098  std::vector<int> poly_rings;
4099 
4100  const bool validate_with_geos_if_available = false;
4101  bool success =
4103  ti,
4104  coords,
4105  bounds,
4106  ring_sizes,
4107  poly_rings,
4108  validate_with_geos_if_available);
4109  if (!success) {
4110  std::ostringstream oss;
4111  oss << "Failed to create geometry from WKT string: " << geo_->getWktString();
4112  throw std::runtime_error(oss.str());
4113  }
4114 
4115  switch (index) {
4116  case 0: // coords
4117  return Geospatial::convert_coords(coords, ti);
4118  case 1: // ring sizes
4119  return Geospatial::convert_rings(ring_sizes);
4120  case 2: // poly rings
4121  return Geospatial::convert_rings(poly_rings);
4122  default:
4123  UNREACHABLE();
4124  }
4125 
4126  UNREACHABLE();
4127  return nullptr;
4128 }
#define UNREACHABLE()
Definition: Logger.h:338
#define CHECK_GE(x, y)
Definition: Logger.h:306
std::unique_ptr< Geospatial::GeoBase > geo_
Definition: Analyzer.h:3267
SQLTypeInfo type_info
Definition: Analyzer.h:180
static bool getGeoColumns(const std::string &wkt_or_wkb_hex, SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool validate_with_geos_if_available)
Definition: Types.cpp:1121
std::shared_ptr< Analyzer::Constant > convert_rings(const std::vector< int > &rings)
Definition: Conversion.h:44
#define CHECK_LE(x, y)
Definition: Logger.h:304
std::shared_ptr< Analyzer::Constant > convert_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
Definition: Conversion.h:26
int get_physical_coord_cols() const
Definition: sqltypes.h:451

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Analyzer::GeoConstant::operator== ( const Expr rhs) const
finalvirtual

Implements Analyzer::Expr.

Definition at line 4065 of file Analyzer.cpp.

References geo_, Analyzer::Expr::get_type_info(), and Analyzer::Expr::type_info.

4065  {
4066  if (typeid(rhs) != typeid(GeoConstant)) {
4067  return false;
4068  }
4069  const GeoConstant& rhs_c = dynamic_cast<const GeoConstant&>(rhs);
4070  if (type_info != rhs_c.get_type_info() /*|| is_null != rhs_c.get_is_null()*/) {
4071  return false;
4072  }
4073  /* TODO: constant nulls
4074  if (is_null && rhs_c.get_is_null()) {
4075  return true;
4076  }
4077 
4078  */
4079  return *geo_ == *rhs_c.geo_;
4080 }
GeoConstant(std::unique_ptr< Geospatial::GeoBase > &&geo, const SQLTypeInfo &ti)
Definition: Analyzer.cpp:4037
std::unique_ptr< Geospatial::GeoBase > geo_
Definition: Analyzer.h:3267
SQLTypeInfo type_info
Definition: Analyzer.h:180

+ Here is the call graph for this function:

size_t Analyzer::GeoConstant::physicalCols ( ) const

Definition at line 4082 of file Analyzer.cpp.

References CHECK, SQLTypeInfo::get_physical_coord_cols(), SQLTypeInfo::is_geometry(), and Analyzer::Expr::type_info.

Referenced by CodeGenerator::codegenGeoConstant().

4082  {
4085 }
SQLTypeInfo type_info
Definition: Analyzer.h:180
#define CHECK(condition)
Definition: Logger.h:291
bool is_geometry() const
Definition: sqltypes.h:597
int get_physical_coord_cols() const
Definition: sqltypes.h:451

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Analyzer::GeoConstant::toString ( ) const
finalvirtual

Implements Analyzer::Expr.

Definition at line 4052 of file Analyzer.cpp.

References CHECK, and geo_.

Referenced by add_cast().

4052  {
4053  std::string str{"(GeoConstant "};
4054  CHECK(geo_);
4055  str += geo_->getWktString();
4056  str += ") ";
4057  return str;
4058 }
std::unique_ptr< Geospatial::GeoBase > geo_
Definition: Analyzer.h:3267
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

Member Data Documentation

std::unique_ptr<Geospatial::GeoBase> Analyzer::GeoConstant::geo_
private

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