OmniSciDB  eb3a3d0a03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::OptimizeTableStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::OptimizeTableStmt:
+ Collaboration diagram for Parser::OptimizeTableStmt:

Public Member Functions

 OptimizeTableStmt (std::string *table, std::list< NameValueAssign * > *o)
 
 OptimizeTableStmt (const rapidjson::Value &payload)
 
const std::string getTableName () const
 
bool shouldVacuumDeletedRows () const
 
void execute (const Catalog_Namespace::SessionInfo &session) override
 
- Public Member Functions inherited from Parser::DDLStmt
void setColumnDescriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Private Attributes

std::unique_ptr< std::string > table_
 
std::list< std::unique_ptr
< NameValueAssign > > 
options_
 

Detailed Description

Definition at line 1231 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::OptimizeTableStmt::OptimizeTableStmt ( std::string *  table,
std::list< NameValueAssign * > *  o 
)
inline

Definition at line 1233 of file ParserNode.h.

References options_, and table_.

1233  : table_(table) {
1234  if (!table_) {
1235  throw std::runtime_error("Table name is required for OPTIMIZE command.");
1236  }
1237  if (o) {
1238  for (const auto e : *o) {
1239  options_.emplace_back(e);
1240  }
1241  delete o;
1242  }
1243  }
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1260
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:1261
Parser::OptimizeTableStmt::OptimizeTableStmt ( const rapidjson::Value &  payload)

Definition at line 3912 of file ParserNode.cpp.

References CHECK, json_str(), options_, Parser::anonymous_namespace{ParserNode.cpp}::parse_options(), and table_.

3912  {
3913  CHECK(payload.HasMember("tableName"));
3914  table_ = std::make_unique<std::string>(json_str(payload["tableName"]));
3915  parse_options(payload, options_);
3916 }
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1260
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:1261
void parse_options(const rapidjson::Value &payload, std::list< std::unique_ptr< NameValueAssign >> &nameValueList, bool stringToNull=false, bool stringToInteger=false)
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

Member Function Documentation

void Parser::OptimizeTableStmt::execute ( const Catalog_Namespace::SessionInfo session)
overridevirtual

Implements Parser::DDLStmt.

Definition at line 3934 of file ParserNode.cpp.

References AccessPrivileges::DELETE_FROM_TABLE, Catalog_Namespace::SessionInfo::getCatalog(), Executor::getExecutor(), TableDescriptor::isView, TableOptimizer::recomputeMetadata(), shouldVacuumDeletedRows(), table_, Executor::UNITARY_EXECUTOR_ID, Parser::anonymous_namespace{ParserNode.cpp}::user_can_access_table(), and TableOptimizer::vacuumDeletedRows().

Referenced by omnisci.cursor.Cursor::executemany().

3934  {
3935  auto& catalog = session.getCatalog();
3936 
3937  const auto td_with_lock =
3939  catalog, *table_);
3940  const auto td = td_with_lock();
3941 
3942  if (!td || !user_can_access_table(session, td, AccessPrivileges::DELETE_FROM_TABLE)) {
3943  throw std::runtime_error("Table " + *table_ + " does not exist.");
3944  }
3945 
3946  if (td->isView) {
3947  throw std::runtime_error("OPTIMIZE TABLE command is not supported on views.");
3948  }
3949 
3951  const TableOptimizer optimizer(td, executor, catalog);
3952  if (shouldVacuumDeletedRows()) {
3953  optimizer.vacuumDeletedRows();
3954  }
3955  optimizer.recomputeMetadata();
3956 }
bool user_can_access_table(const Catalog_Namespace::SessionInfo &session_info, const TableDescriptor *td, const AccessPrivileges access_priv)
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1260
Driver for running cleanup processes on a table. TableOptimizer provides functions for various cleanu...
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
Definition: Execute.cpp:171
static const AccessPrivileges DELETE_FROM_TABLE
Definition: DBObject.h:165
Catalog & getCatalog() const
Definition: SessionInfo.h:67
bool shouldVacuumDeletedRows() const
Definition: ParserNode.h:1248
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:384

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::string Parser::OptimizeTableStmt::getTableName ( ) const
inline

Definition at line 1246 of file ParserNode.h.

References table_.

1246 { return *(table_.get()); }
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1260
bool Parser::OptimizeTableStmt::shouldVacuumDeletedRows ( ) const
inline

Definition at line 1248 of file ParserNode.h.

References options_.

Referenced by execute().

1248  {
1249  for (const auto& e : options_) {
1250  if (boost::iequals(*(e->get_name()), "VACUUM")) {
1251  return true;
1252  }
1253  }
1254  return false;
1255  }
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:1261

+ Here is the caller graph for this function:

Member Data Documentation

std::list<std::unique_ptr<NameValueAssign> > Parser::OptimizeTableStmt::options_
private

Definition at line 1261 of file ParserNode.h.

Referenced by OptimizeTableStmt(), and shouldVacuumDeletedRows().

std::unique_ptr<std::string> Parser::OptimizeTableStmt::table_
private

Definition at line 1260 of file ParserNode.h.

Referenced by execute(), getTableName(), and OptimizeTableStmt().


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