OmniSciDB  bf83d84833
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{DdlCommandExecutor.cpp} Namespace Reference

Classes

struct  AggregratedStorageStats
 
class  JsonColumnSqlType
 declare this class scoped local to avoid exposing rapidjson in the header file More...
 
class  JsonColumnEncoding
 
class  DdlCommandDataImpl
 

Functions

template<class LockType >
std::tuple< const
TableDescriptor
*, std::unique_ptr
< lockmgr::TableSchemaLockContainer
< LockType > > > 
get_table_descriptor_with_lock (const Catalog_Namespace::Catalog &cat, const std::string &table_name, const bool populate_fragmenter)
 
AggregratedStorageStats get_agg_storage_stats (const TableDescriptor *td, const Catalog_Namespace::Catalog *catalog)
 
std::unique_ptr< RexLiteralgenLiteralStr (std::string val)
 
std::unique_ptr< RexLiteralgenLiteralTimestamp (time_t val)
 
std::unique_ptr< RexLiteralgenLiteralBigInt (int64_t val)
 
std::unique_ptr< RexLiteralgenLiteralBoolean (bool val)
 
void set_headers_with_type (std::vector< TargetMetaInfo > &label_infos, const std::vector< std::tuple< std::string, SQLTypes, bool >> &headers)
 
void add_table_details (std::vector< RelLogicalValues::RowValues > &logical_values, const TableDescriptor *logical_table, const AggregratedStorageStats &agg_storage_stats)
 
const rapidjson::Value & extractPayload (const DdlCommandData &ddl_data)
 
const rapidjson::Value * extractFilters (const rapidjson::Value &payload)
 

Function Documentation

void anonymous_namespace{DdlCommandExecutor.cpp}::add_table_details ( std::vector< RelLogicalValues::RowValues > &  logical_values,
const TableDescriptor logical_table,
const AggregratedStorageStats &  agg_storage_stats 
)

Definition at line 164 of file DdlCommandExecutor.cpp.

References File_Namespace::StorageStats::data_file_count, genLiteralBigInt(), genLiteralBoolean(), genLiteralStr(), anonymous_namespace{DdlCommandExecutor.cpp}::AggregratedStorageStats::max_epoch, anonymous_namespace{DdlCommandExecutor.cpp}::AggregratedStorageStats::max_epoch_floor, TableDescriptor::maxFragRows, TableDescriptor::maxRollbackEpochs, TableDescriptor::maxRows, File_Namespace::StorageStats::metadata_file_count, anonymous_namespace{DdlCommandExecutor.cpp}::AggregratedStorageStats::min_epoch, anonymous_namespace{DdlCommandExecutor.cpp}::AggregratedStorageStats::min_epoch_floor, TableDescriptor::nColumns, TableDescriptor::nShards, NULL_BIGINT, TableDescriptor::tableId, TableDescriptor::tableName, File_Namespace::StorageStats::total_data_file_size, File_Namespace::StorageStats::total_data_page_count, File_Namespace::StorageStats::total_free_data_page_count, File_Namespace::StorageStats::total_free_metadata_page_count, File_Namespace::StorageStats::total_metadata_file_size, and File_Namespace::StorageStats::total_metadata_page_count.

Referenced by ShowTableDetailsCommand::execute().

166  {
167  bool is_sharded_table = (logical_table->nShards > 0);
168  logical_values.emplace_back(RelLogicalValues::RowValues{});
169  logical_values.back().emplace_back(genLiteralBigInt(logical_table->tableId));
170  logical_values.back().emplace_back(genLiteralStr(logical_table->tableName));
171  logical_values.back().emplace_back(genLiteralBigInt(logical_table->nColumns));
172  logical_values.back().emplace_back(genLiteralBoolean(is_sharded_table));
173  logical_values.back().emplace_back(genLiteralBigInt(logical_table->nShards));
174  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxRows));
175  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxFragRows));
176  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxRollbackEpochs));
177  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.min_epoch));
178  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.max_epoch));
179  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.min_epoch_floor));
180  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.max_epoch_floor));
181  logical_values.back().emplace_back(
182  genLiteralBigInt(agg_storage_stats.metadata_file_count));
183  logical_values.back().emplace_back(
184  genLiteralBigInt(agg_storage_stats.total_metadata_file_size));
185  logical_values.back().emplace_back(
186  genLiteralBigInt(agg_storage_stats.total_metadata_page_count));
187 
188  if (agg_storage_stats.total_free_metadata_page_count) {
189  logical_values.back().emplace_back(
190  genLiteralBigInt(agg_storage_stats.total_free_metadata_page_count.value()));
191  } else {
192  logical_values.back().emplace_back(genLiteralBigInt(NULL_BIGINT));
193  }
194 
195  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.data_file_count));
196  logical_values.back().emplace_back(
197  genLiteralBigInt(agg_storage_stats.total_data_file_size));
198  logical_values.back().emplace_back(
199  genLiteralBigInt(agg_storage_stats.total_data_page_count));
200 
201  if (agg_storage_stats.total_free_data_page_count) {
202  logical_values.back().emplace_back(
203  genLiteralBigInt(agg_storage_stats.total_free_data_page_count.value()));
204  } else {
205  logical_values.back().emplace_back(genLiteralBigInt(NULL_BIGINT));
206  }
207 }
int32_t maxRollbackEpochs
std::string tableName
#define NULL_BIGINT
std::unique_ptr< RexLiteral > genLiteralBigInt(int64_t val)
std::unique_ptr< RexLiteral > genLiteralBoolean(bool val)
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:6399
std::vector< std::unique_ptr< const RexScalar >> RowValues

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const rapidjson::Value* anonymous_namespace{DdlCommandExecutor.cpp}::extractFilters ( const rapidjson::Value &  payload)

Definition at line 301 of file DdlCommandExecutor.cpp.

Referenced by ShowForeignServersCommand::execute().

301  {
302  const rapidjson::Value* filters = nullptr;
303  if (payload.HasMember("filters") && payload["filters"].IsArray()) {
304  filters = &payload["filters"];
305  }
306  return filters;
307 }

+ Here is the caller graph for this function:

const rapidjson::Value& anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload ( const DdlCommandData ddl_data)

Definition at line 296 of file DdlCommandExecutor.cpp.

References anonymous_namespace{DdlCommandExecutor.cpp}::DdlCommandDataImpl::payload().

Referenced by AlterForeignServerCommand::AlterForeignServerCommand(), AlterForeignTableCommand::AlterForeignTableCommand(), AlterForeignTableCommand::alterOptions(), AlterForeignServerCommand::changeForeignServerOwner(), CreateForeignServerCommand::CreateForeignServerCommand(), CreateForeignTableCommand::CreateForeignTableCommand(), DropForeignServerCommand::DropForeignServerCommand(), DropForeignTableCommand::DropForeignTableCommand(), CreateForeignServerCommand::execute(), AlterForeignServerCommand::execute(), DropForeignServerCommand::execute(), CreateForeignTableCommand::execute(), DropForeignTableCommand::execute(), AlterForeignTableCommand::execute(), ShowForeignServersCommand::execute(), RefreshForeignTablesCommand::execute(), DdlCommandExecutor::execute(), ShowTableDetailsCommand::getFilteredTableNames(), ShowDiskCacheUsageCommand::getFilteredTableNames(), DdlCommandExecutor::getTargetQuerySessionToKill(), AlterForeignServerCommand::hasAlterServerPrivileges(), RefreshForeignTablesCommand::RefreshForeignTablesCommand(), AlterForeignTableCommand::renameColumn(), AlterForeignServerCommand::renameForeignServer(), AlterForeignTableCommand::renameTable(), CreateForeignTableCommand::setColumnDetails(), AlterForeignServerCommand::setForeignServerDataWrapper(), AlterForeignServerCommand::setForeignServerOptions(), CreateForeignTableCommand::setTableDetails(), ShowDiskCacheUsageCommand::ShowDiskCacheUsageCommand(), ShowForeignServersCommand::ShowForeignServersCommand(), and ShowTableDetailsCommand::ShowTableDetailsCommand().

296  {
297  const DdlCommandDataImpl* data = static_cast<const DdlCommandDataImpl*>(&ddl_data);
298  return data->payload();
299 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralBigInt ( int64_t  val)

Definition at line 138 of file DdlCommandExecutor.cpp.

References kBIGINT.

Referenced by add_table_details(), and ShowDiskCacheUsageCommand::execute().

138  {
139  return std::unique_ptr<RexLiteral>(
140  new RexLiteral(val, SQLTypes::kBIGINT, SQLTypes::kBIGINT, 0, 8, 0, 8));
141 }

+ Here is the caller graph for this function:

std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralBoolean ( bool  val)

Definition at line 143 of file DdlCommandExecutor.cpp.

References kBIGINT.

Referenced by add_table_details().

143  {
144  return std::unique_ptr<RexLiteral>(
145  // new RexLiteral(val, SQLTypes::kBOOLEAN, SQLTypes::kBOOLEAN, 0, 0, 0, 0));
146  new RexLiteral(
147  (int64_t)(val ? 1 : 0), SQLTypes::kBIGINT, SQLTypes::kBIGINT, 0, 8, 0, 8));
148 }

+ Here is the caller graph for this function:

std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralStr ( std::string  val)

Definition at line 128 of file DdlCommandExecutor.cpp.

References kTEXT.

128  {
129  return std::unique_ptr<RexLiteral>(
130  new RexLiteral(val, SQLTypes::kTEXT, SQLTypes::kTEXT, 0, 0, 0, 0));
131 }
Definition: sqltypes.h:51
std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralTimestamp ( time_t  val)

Definition at line 133 of file DdlCommandExecutor.cpp.

References kTIMESTAMP.

Referenced by ShowForeignServersCommand::execute().

133  {
134  return std::unique_ptr<RexLiteral>(new RexLiteral(
135  (int64_t)val, SQLTypes::kTIMESTAMP, SQLTypes::kTIMESTAMP, 0, 8, 0, 8));
136 }

+ Here is the caller graph for this function:

AggregratedStorageStats anonymous_namespace{DdlCommandExecutor.cpp}::get_agg_storage_stats ( const TableDescriptor td,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 103 of file DdlCommandExecutor.cpp.

References CHECK, CHECK_EQ, Catalog_Namespace::Catalog::getDatabaseId(), Catalog_Namespace::Catalog::getDataMgr(), Data_Namespace::DataMgr::getGlobalFileMgr(), Catalog_Namespace::Catalog::getPhysicalTablesDescriptors(), TableDescriptor::nShards, and TableDescriptor::tableId.

Referenced by ShowTableDetailsCommand::execute().

104  {
105  const auto global_file_mgr = catalog->getDataMgr().getGlobalFileMgr();
106  std::optional<AggregratedStorageStats> agg_storage_stats;
107  if (td->nShards > 0) {
108  const auto physical_tables = catalog->getPhysicalTablesDescriptors(td);
109  CHECK_EQ(static_cast<size_t>(td->nShards), physical_tables.size());
110 
111  for (const auto physical_table : physical_tables) {
112  auto storage_stats = global_file_mgr->getStorageStats(catalog->getDatabaseId(),
113  physical_table->tableId);
114  if (agg_storage_stats) {
115  agg_storage_stats.value().aggregate(storage_stats);
116  } else {
117  agg_storage_stats = storage_stats;
118  }
119  }
120  } else {
121  agg_storage_stats =
122  global_file_mgr->getStorageStats(catalog->getDatabaseId(), td->tableId);
123  }
124  CHECK(agg_storage_stats.has_value());
125  return agg_storage_stats.value();
126 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:222
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logicalTableDesc) const
Definition: Catalog.cpp:3786
int getDatabaseId() const
Definition: Catalog.h:274
File_Namespace::GlobalFileMgr * getGlobalFileMgr() const
Definition: DataMgr.cpp:528
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class LockType >
std::tuple<const TableDescriptor*, std::unique_ptr<lockmgr::TableSchemaLockContainer<LockType> > > anonymous_namespace{DdlCommandExecutor.cpp}::get_table_descriptor_with_lock ( const Catalog_Namespace::Catalog cat,
const std::string &  table_name,
const bool  populate_fragmenter 
)

Definition at line 46 of file DdlCommandExecutor.cpp.

References CHECK.

48  {
49  const TableDescriptor* td{nullptr};
50  std::unique_ptr<lockmgr::TableSchemaLockContainer<LockType>> td_with_lock =
51  std::make_unique<lockmgr::TableSchemaLockContainer<LockType>>(
53  cat, table_name, populate_fragmenter));
54  CHECK(td_with_lock);
55  td = (*td_with_lock)();
56  CHECK(td);
57  return std::make_tuple(td, std::move(td_with_lock));
58 }
#define CHECK(condition)
Definition: Logger.h:197
void anonymous_namespace{DdlCommandExecutor.cpp}::set_headers_with_type ( std::vector< TargetMetaInfo > &  label_infos,
const std::vector< std::tuple< std::string, SQLTypes, bool >> &  headers 
)

Definition at line 150 of file DdlCommandExecutor.cpp.

References kBIGINT, kBOOLEAN, kTEXT, kTIMESTAMP, to_string(), and UNREACHABLE.

Referenced by ShowTableDetailsCommand::execute().

152  {
153  for (const auto& header : headers) {
154  auto [_val, _type, _notnull] = header;
155  if (_type == kBIGINT || _type == kTEXT || _type == kTIMESTAMP || _type == kBOOLEAN) {
156  label_infos.emplace_back(_val, SQLTypeInfo(_type, _notnull));
157  } else {
158  UNREACHABLE() << "Unsupported type provided for header. SQL type: "
159  << to_string(_type);
160  }
161  }
162 }
#define UNREACHABLE()
Definition: Logger.h:241
std::string to_string(char const *&&v)
Definition: sqltypes.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function: