OmniSciDB  7bf56492aa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RelModify Class Reference

#include <RelAlgDagBuilder.h>

+ Inheritance diagram for RelModify:
+ Collaboration diagram for RelModify:

Public Types

enum  ModifyOperation { ModifyOperation::Insert, ModifyOperation::Delete, ModifyOperation::Update }
 
using RelAlgNodeInputPtr = std::shared_ptr< const RelAlgNode >
 
using TargetColumnList = std::vector< std::string >
 

Public Member Functions

 RelModify (Catalog_Namespace::Catalog const &cat, TableDescriptor const *const td, bool flattened, std::string const &op_string, TargetColumnList const &target_column_list, RelAlgNodeInputPtr input)
 
 RelModify (Catalog_Namespace::Catalog const &cat, TableDescriptor const *const td, bool flattened, ModifyOperation op, TargetColumnList const &target_column_list, RelAlgNodeInputPtr input)
 
TableDescriptor const *const getTableDescriptor () const
 
bool const isFlattened () const
 
ModifyOperation getOperation () const
 
TargetColumnList const & getUpdateColumnNames ()
 
int getUpdateColumnCount () const
 
size_t size () const override
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
std::string toString () const override
 
void applyUpdateModificationsToInputNode ()
 
void applyDeleteModificationsToInputNode ()
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode ()
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
void setContextData (const void *context_data) const
 
void setOutputMetainfo (const std::vector< TargetMetaInfo > &targets_metainfo) const
 
const std::vector
< TargetMetaInfo > & 
getOutputMetainfo () const
 
unsigned getId () const
 
bool hasContextData () const
 
const void * getContextData () const
 
const size_t inputCount () const
 
const RelAlgNodegetInput (const size_t idx) const
 
std::shared_ptr< const RelAlgNodegetAndOwnInput (const size_t idx) const
 
void addManagedInput (std::shared_ptr< const RelAlgNode > input)
 
bool hasInput (const RelAlgNode *needle) const
 
virtual void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
 
bool isNop () const
 
void markAsNop ()
 

Static Public Member Functions

static std::string yieldModifyOperationString (ModifyOperation const op)
 
static ModifyOperation yieldModifyOperationEnum (std::string const &op_string)
 
- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 

Private Attributes

Catalog_Namespace::Catalog const & catalog_
 
const TableDescriptortable_descriptor_
 
bool flattened_
 
ModifyOperation operation_
 
TargetColumnList target_column_list_
 

Additional Inherited Members

- Protected Attributes inherited from RelAlgNode
std::vector< std::shared_ptr
< const RelAlgNode > > 
inputs_
 
const unsigned id_
 

Detailed Description

Definition at line 1210 of file RelAlgDagBuilder.h.

Member Typedef Documentation

using RelModify::RelAlgNodeInputPtr = std::shared_ptr<const RelAlgNode>

Definition at line 1213 of file RelAlgDagBuilder.h.

using RelModify::TargetColumnList = std::vector<std::string>

Definition at line 1214 of file RelAlgDagBuilder.h.

Member Enumeration Documentation

Enumerator
Insert 
Delete 
Update 

Definition at line 1212 of file RelAlgDagBuilder.h.

1212 { Insert, Delete, Update };

Constructor & Destructor Documentation

RelModify::RelModify ( Catalog_Namespace::Catalog const &  cat,
TableDescriptor const *const  td,
bool  flattened,
std::string const &  op_string,
TargetColumnList const &  target_column_list,
RelAlgNodeInputPtr  input 
)
inline

Definition at line 1243 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

1249  : catalog_(cat)
1250  , table_descriptor_(td)
1251  , flattened_(flattened)
1252  , operation_(yieldModifyOperationEnum(op_string))
1253  , target_column_list_(target_column_list) {
1254  inputs_.push_back(input);
1255  }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
const TableDescriptor * table_descriptor_
Catalog_Namespace::Catalog const & catalog_
static ModifyOperation yieldModifyOperationEnum(std::string const &op_string)
ModifyOperation operation_
TargetColumnList target_column_list_
RelModify::RelModify ( Catalog_Namespace::Catalog const &  cat,
TableDescriptor const *const  td,
bool  flattened,
ModifyOperation  op,
TargetColumnList const &  target_column_list,
RelAlgNodeInputPtr  input 
)
inline

Definition at line 1257 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

1263  : catalog_(cat)
1264  , table_descriptor_(td)
1265  , flattened_(flattened)
1266  , operation_(op)
1267  , target_column_list_(target_column_list) {
1268  inputs_.push_back(input);
1269  }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
const TableDescriptor * table_descriptor_
Catalog_Namespace::Catalog const & catalog_
ModifyOperation operation_
TargetColumnList target_column_list_

Member Function Documentation

void RelModify::applyDeleteModificationsToInputNode ( )
inline

Definition at line 1360 of file RelAlgDagBuilder.h.

References CHECK(), RelAlgNode::inputs_, ModifyManipulationTarget::setDeleteViaSelectFlag(), and ModifyManipulationTarget::setModifiedTableDescriptor().

1360  {
1361  RelProject const* previous_project_node =
1362  dynamic_cast<RelProject const*>(inputs_[0].get());
1363  CHECK(previous_project_node != nullptr);
1364  previous_project_node->setDeleteViaSelectFlag();
1365  previous_project_node->setModifiedTableDescriptor(table_descriptor_);
1366  }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
void setDeleteViaSelectFlag() const
CHECK(cgen_state)
const TableDescriptor * table_descriptor_
void setModifiedTableDescriptor(TableDescriptor const *td) const

+ Here is the call graph for this function:

void RelModify::applyUpdateModificationsToInputNode ( )
inline

Definition at line 1298 of file RelAlgDagBuilder.h.

References catalog_(), CHECK(), RelAlgNode::inputs_, ModifyManipulationTarget::setModifiedTableDescriptor(), ModifyManipulationTarget::setTargetColumns(), ModifyManipulationTarget::setUpdateViaSelectFlag(), ModifyManipulationTarget::setVarlenUpdateRequired(), and RelProject::visitScalarExprs().

1298  {
1299  RelProject const* previous_project_node =
1300  dynamic_cast<RelProject const*>(inputs_[0].get());
1301  CHECK(previous_project_node != nullptr);
1302 
1303  previous_project_node->setUpdateViaSelectFlag();
1304  // remove the offset column in the projection for update handling
1305  target_column_list_.pop_back();
1306 
1307  previous_project_node->setModifiedTableDescriptor(table_descriptor_);
1308  previous_project_node->setTargetColumns(target_column_list_);
1309 
1310  int target_update_column_expr_start = 0;
1311  int target_update_column_expr_end = (int)(target_column_list_.size() - 1);
1312  CHECK(target_update_column_expr_start >= 0);
1313  CHECK(target_update_column_expr_end >= 0);
1314 
1315  bool varlen_update_required = false;
1316 
1317  auto varlen_scan_visitor = [this,
1318  &varlen_update_required,
1319  target_update_column_expr_start,
1320  target_update_column_expr_end](int index) {
1321  if (index >= target_update_column_expr_start &&
1322  index <= target_update_column_expr_end) {
1323  auto target_index = index - target_update_column_expr_start;
1324 
1325  auto* column_desc = catalog_.getMetadataForColumn(
1327  CHECK(column_desc);
1328 
1329  if (table_descriptor_->nShards) {
1330  const auto shard_cd =
1332  CHECK(shard_cd);
1333  if ((column_desc->columnName == shard_cd->columnName)) {
1334  throw std::runtime_error("UPDATE of a shard key is currently unsupported.");
1335  }
1336  }
1337 
1338  // Check for valid types
1339  if (is_feature_enabled<VarlenUpdates>()) {
1340  if (column_desc->columnType.is_varlen()) {
1341  varlen_update_required = true;
1342  }
1343 
1344  if (column_desc->columnType.is_geometry()) {
1345  throw std::runtime_error("UPDATE of a geo column is unsupported.");
1346  }
1347  } else {
1348  if (column_desc->columnType.is_varlen()) {
1349  throw std::runtime_error(
1350  "UPDATE of a none-encoded string, geo, or array column is unsupported.");
1351  }
1352  }
1353  }
1354  };
1355 
1356  previous_project_node->visitScalarExprs(varlen_scan_visitor);
1357  previous_project_node->setVarlenUpdateRequired(varlen_update_required);
1358  }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
void setVarlenUpdateRequired(bool required) const
void setTargetColumns(ColumnNameList const &target_columns) const
const ColumnDescriptor * getShardColumnMetadataForTable(const TableDescriptor *td) const
Definition: Catalog.cpp:3271
CHECK(cgen_state)
const TableDescriptor * table_descriptor_
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
Catalog_Namespace::Catalog const & catalog_
void visitScalarExprs(EXPR_VISITOR_FUNCTOR visitor_functor) const
void setModifiedTableDescriptor(TableDescriptor const *td) const
void setUpdateViaSelectFlag() const
TargetColumnList target_column_list_

+ Here is the call graph for this function:

std::shared_ptr<RelAlgNode> RelModify::deepCopy ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1278 of file RelAlgDagBuilder.h.

References catalog_(), and RelAlgNode::inputs_.

1278  {
1279  return std::make_shared<RelModify>(catalog_,
1281  flattened_,
1282  operation_,
1284  inputs_[0]);
1285  }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
const TableDescriptor * table_descriptor_
Catalog_Namespace::Catalog const & catalog_
ModifyOperation operation_
TargetColumnList target_column_list_

+ Here is the call graph for this function:

ModifyOperation RelModify::getOperation ( ) const
inline

Definition at line 1273 of file RelAlgDagBuilder.h.

1273 { return operation_; }
ModifyOperation operation_
TableDescriptor const* const RelModify::getTableDescriptor ( ) const
inline

Definition at line 1271 of file RelAlgDagBuilder.h.

1271 { return table_descriptor_; }
const TableDescriptor * table_descriptor_
int RelModify::getUpdateColumnCount ( ) const
inline

Definition at line 1275 of file RelAlgDagBuilder.h.

1275 { return target_column_list_.size(); }
TargetColumnList target_column_list_
TargetColumnList const& RelModify::getUpdateColumnNames ( )
inline

Definition at line 1274 of file RelAlgDagBuilder.h.

1274 { return target_column_list_; }
TargetColumnList target_column_list_
bool const RelModify::isFlattened ( ) const
inline

Definition at line 1272 of file RelAlgDagBuilder.h.

1272 { return flattened_; }
size_t RelModify::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1277 of file RelAlgDagBuilder.h.

1277 { return 0; }
std::string RelModify::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1287 of file RelAlgDagBuilder.h.

References to_string().

1287  {
1288  std::ostringstream result_stream;
1289  result_stream << std::boolalpha
1290  << "(RelModify<" + std::to_string(reinterpret_cast<uint64_t>(this)) +
1291  "> "
1292  << table_descriptor_->tableName << " flattened= " << flattened_
1293  << " operation= " << yieldModifyOperationString(operation_) << ")";
1294 
1295  return result_stream.str();
1296  }
std::string tableName
std::string to_string(char const *&&v)
const TableDescriptor * table_descriptor_
static std::string yieldModifyOperationString(ModifyOperation const op)
ModifyOperation operation_

+ Here is the call graph for this function:

static ModifyOperation RelModify::yieldModifyOperationEnum ( std::string const &  op_string)
inlinestatic

Definition at line 1230 of file RelAlgDagBuilder.h.

1230  {
1231  if (op_string == "INSERT") {
1232  return ModifyOperation::Insert;
1233  } else if (op_string == "DELETE") {
1234  return ModifyOperation::Delete;
1235  } else if (op_string == "UPDATE") {
1236  return ModifyOperation::Update;
1237  }
1238 
1239  throw std::runtime_error(
1240  std::string("Unsupported logical modify operation encountered " + op_string));
1241  }
static std::string RelModify::yieldModifyOperationString ( ModifyOperation const  op)
inlinestatic

Definition at line 1216 of file RelAlgDagBuilder.h.

1216  {
1217  switch (op) {
1219  return "DELETE";
1221  return "INSERT";
1223  return "UPDATE";
1224  default:
1225  break;
1226  }
1227  throw std::runtime_error("Unexpected ModifyOperation enum encountered.");
1228  }

Member Data Documentation

Catalog_Namespace::Catalog const& RelModify::catalog_
private

Definition at line 1369 of file RelAlgDagBuilder.h.

bool RelModify::flattened_
private

Definition at line 1371 of file RelAlgDagBuilder.h.

ModifyOperation RelModify::operation_
private

Definition at line 1372 of file RelAlgDagBuilder.h.

const TableDescriptor* RelModify::table_descriptor_
private

Definition at line 1370 of file RelAlgDagBuilder.h.

TargetColumnList RelModify::target_column_list_
private

Definition at line 1373 of file RelAlgDagBuilder.h.


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