OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::InsertIntoTableAsSelectStmt::LocalConnector Struct Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::InsertIntoTableAsSelectStmt::LocalConnector:
+ Collaboration diagram for Parser::InsertIntoTableAsSelectStmt::LocalConnector:

Public Member Functions

virtual ~LocalConnector ()
 
AggregatedResult query (QueryStateProxy, std::string &sql_query_string, bool validate_only)
 
AggregatedResult query (QueryStateProxy, std::string &sql_query_string) override
 
size_t leafCount () override
 
void insertDataToLeaf (const Catalog_Namespace::SessionInfo &session, const size_t leaf_idx, Fragmenter_Namespace::InsertData &insert_data) override
 
void checkpoint (const Catalog_Namespace::SessionInfo &session, int tableId) override
 
void rollback (const Catalog_Namespace::SessionInfo &session, int tableId) override
 
std::list< ColumnDescriptorgetColumnDescriptors (AggregatedResult &result, bool for_create)
 

Detailed Description

Definition at line 1041 of file ParserNode.h.

Constructor & Destructor Documentation

virtual Parser::InsertIntoTableAsSelectStmt::LocalConnector::~LocalConnector ( )
inlinevirtual

Definition at line 1042 of file ParserNode.h.

1042 {}

Member Function Documentation

void Parser::InsertIntoTableAsSelectStmt::LocalConnector::checkpoint ( const Catalog_Namespace::SessionInfo session,
int  tableId 
)
overridevirtual

Implements Parser::InsertIntoTableAsSelectStmt::DistributedConnector.

Definition at line 2347 of file ParserNode.cpp.

References Catalog_Namespace::DBMetadata::dbId, Catalog_Namespace::SessionInfo::getCatalog(), and Catalog_Namespace::Catalog::getCurrentDB().

2349  {
2350  auto& catalog = session.getCatalog();
2351  auto dbId = catalog.getCurrentDB().dbId;
2352  catalog.getDataMgr().checkpoint(dbId, tableId);
2353 }
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:176
Catalog & getCatalog() const
Definition: SessionInfo.h:90

+ Here is the call graph for this function:

std::list< ColumnDescriptor > Parser::InsertIntoTableAsSelectStmt::LocalConnector::getColumnDescriptors ( AggregatedResult result,
bool  for_create 
)

Definition at line 2364 of file ParserNode.cpp.

References ColumnDescriptor::columnName, ColumnDescriptor::columnType, SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_size(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_array(), kENCODING_DICT, SQLTypeInfoCore< TYPE_FACET_PACK >::set_comp_param(), AggregatedResult::targets_meta, and to_string().

Referenced by Parser::CreateTableAsSelectStmt::execute(), and Parser::InsertIntoTableAsSelectStmt::populateData().

2366  {
2367  std::list<ColumnDescriptor> column_descriptors;
2368  std::list<ColumnDescriptor> column_descriptors_for_create;
2369 
2370  int rowid_suffix = 0;
2371  for (const auto& target_metainfo : result.targets_meta) {
2372  ColumnDescriptor cd;
2373  cd.columnName = target_metainfo.get_resname();
2374  if (cd.columnName == "rowid") {
2375  cd.columnName += std::to_string(rowid_suffix++);
2376  }
2377  cd.columnType = target_metainfo.get_physical_type_info();
2378 
2379  ColumnDescriptor cd_for_create = cd;
2380 
2382  // we need to reset the comp param (as this points to the actual dictionary)
2383  if (cd.columnType.is_array()) {
2384  // for dict encoded arrays, it is always 4 bytes
2385  cd_for_create.columnType.set_comp_param(32);
2386  } else {
2387  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
2388  }
2389  }
2390 
2391  column_descriptors_for_create.push_back(cd_for_create);
2392  column_descriptors.push_back(cd);
2393  }
2394 
2395  if (for_create) {
2396  return column_descriptors_for_create;
2397  }
2398 
2399  return column_descriptors;
2400 }
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
const std::vector< TargetMetaInfo > targets_meta
HOST DEVICE int get_size() const
Definition: sqltypes.h:336
std::string to_string(char const *&&v)
bool is_array() const
Definition: sqltypes.h:485
specifies the content in-memory of a row in the column metadata table
void set_comp_param(int p)
Definition: sqltypes.h:427
SQLTypeInfo columnType
std::string columnName

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::InsertIntoTableAsSelectStmt::LocalConnector::insertDataToLeaf ( const Catalog_Namespace::SessionInfo session,
const size_t  leaf_idx,
Fragmenter_Namespace::InsertData insert_data 
)
overridevirtual

Implements Fragmenter_Namespace::InsertDataLoader::DistributedConnector.

Definition at line 2329 of file ParserNode.cpp.

References CHECK(), Lock_Namespace::CheckpointLock, Catalog_Namespace::SessionInfo::getCatalog(), Catalog_Namespace::Catalog::getMetadataForTable(), TableDescriptor::tableId, and Fragmenter_Namespace::InsertData::tableId.

2332  {
2333  CHECK(leaf_idx == 0);
2334  auto& catalog = session.getCatalog();
2335  auto created_td = catalog.getMetadataForTable(insert_data.tableId);
2336  // get CheckpointLock on the table before trying to create
2337  // its 1st fragment
2338  ChunkKey chunkKey = {catalog.getCurrentDB().dbId, created_td->tableId};
2339  mapd_unique_lock<mapd_shared_mutex> chkptlLock(
2342  // [ TableWriteLock ] lock is deferred in
2343  // InsertOrderFragmenter::deleteFragments
2344  created_td->fragmenter->insertDataNoCheckpoint(insert_data);
2345 }
std::vector< int > ChunkKey
Definition: types.h:35
int tableId
identifies the database into which the data is being inserted
Definition: Fragmenter.h:61
CHECK(cgen_state)
Catalog & getCatalog() const
Definition: SessionInfo.h:90
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

size_t Parser::InsertIntoTableAsSelectStmt::LocalConnector::leafCount ( )
inlineoverridevirtual

Implements Fragmenter_Namespace::InsertDataLoader::DistributedConnector.

Definition at line 1047 of file ParserNode.h.

1047 { return 1; };
AggregatedResult Parser::InsertIntoTableAsSelectStmt::LocalConnector::query ( QueryStateProxy  query_state_proxy,
std::string &  sql_query_string,
bool  validate_only 
)

Definition at line 2300 of file ParserNode.cpp.

References query_state::QueryState::getConstSessionInfo(), query_state::QueryStateProxy::getQueryState(), Parser::getResultSet(), Lock_Namespace::TableLockMgrImpl< TableLockMgr >::getTableLocks(), Lock_Namespace::parse_to_ra(), pg_shim(), and run_benchmark_import::res.

Referenced by Parser::CreateTableAsSelectStmt::execute(), and Parser::InsertIntoTableAsSelectStmt::populateData().

2303  {
2304  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2305  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
2306  const auto query_ra = parse_to_ra(query_state_proxy, pg_shimmed_select_query);
2307 
2308  // Note that the below command should *only* get read locks on the source table for
2309  // InsertIntoAsSelect. Write locks will be taken on the target table in
2310  // InsertOrderFragmenter::deleteFragments. This potentially leaves a small window where
2311  // the target table is not locked, and should be investigated.
2312  std::vector<TableLock> table_locks;
2313  TableLockMgr::getTableLocks(session->getCatalog(), query_ra, table_locks);
2314 
2315  std::vector<TargetMetaInfo> target_metainfos;
2316 
2317  auto result_rows =
2318  getResultSet(query_state_proxy, sql_query_string, target_metainfos, validate_only);
2319  AggregatedResult res = {result_rows, target_metainfos};
2320  return res;
2321 }
std::string parse_to_ra(query_state::QueryStateProxy query_state_proxy, const std::string &query_str)
Definition: LockMgr.cpp:77
std::shared_ptr< ResultSet > getResultSet(QueryStateProxy query_state_proxy, const std::string select_stmt, std::vector< TargetMetaInfo > &targets, bool validate_only=false)
QueryState & getQueryState()
Definition: QueryState.h:172
void getTableLocks(const Catalog_Namespace::Catalog &cat, const std::map< std::string, bool > &tableNames, std::vector< std::shared_ptr< LockTypeContainer >> &tableLocks, const Lock_Namespace::LockType lockType)
Definition: LockMgr.h:97
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:75
std::string pg_shim(const std::string &query)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AggregatedResult Parser::InsertIntoTableAsSelectStmt::LocalConnector::query ( QueryStateProxy  query_state_proxy,
std::string &  sql_query_string 
)
overridevirtual

Implements Parser::InsertIntoTableAsSelectStmt::DistributedConnector.

Definition at line 2323 of file ParserNode.cpp.

2325  {
2326  return query(query_state_proxy, sql_query_string, false);
2327 }
AggregatedResult query(QueryStateProxy, std::string &sql_query_string, bool validate_only)
void Parser::InsertIntoTableAsSelectStmt::LocalConnector::rollback ( const Catalog_Namespace::SessionInfo session,
int  tableId 
)
overridevirtual

Implements Parser::InsertIntoTableAsSelectStmt::DistributedConnector.

Definition at line 2355 of file ParserNode.cpp.

References Catalog_Namespace::DBMetadata::dbId, Catalog_Namespace::SessionInfo::getCatalog(), and Catalog_Namespace::Catalog::getCurrentDB().

2357  {
2358  auto& catalog = session.getCatalog();
2359  auto dbId = catalog.getCurrentDB().dbId;
2360  catalog.getDataMgr().checkpoint(dbId, tableId);
2361 }
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:176
Catalog & getCatalog() const
Definition: SessionInfo.h:90

+ Here is the call graph for this function:


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