OmniSciDB  e465130ba1
 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 1046 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1047 of file ParserNode.h.

1047 {}

Member Function Documentation

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

Implements Parser::InsertIntoTableAsSelectStmt::DistributedConnector.

Definition at line 2376 of file ParserNode.cpp.

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

2378  {
2379  auto& catalog = session.getCatalog();
2380  auto dbId = catalog.getCurrentDB().dbId;
2381  catalog.getDataMgr().checkpoint(dbId, tableId);
2382 }
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:177
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 2393 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().

2395  {
2396  std::list<ColumnDescriptor> column_descriptors;
2397  std::list<ColumnDescriptor> column_descriptors_for_create;
2398 
2399  int rowid_suffix = 0;
2400  for (const auto& target_metainfo : result.targets_meta) {
2401  ColumnDescriptor cd;
2402  cd.columnName = target_metainfo.get_resname();
2403  if (cd.columnName == "rowid") {
2404  cd.columnName += std::to_string(rowid_suffix++);
2405  }
2406  cd.columnType = target_metainfo.get_physical_type_info();
2407 
2408  ColumnDescriptor cd_for_create = cd;
2409 
2411  // we need to reset the comp param (as this points to the actual dictionary)
2412  if (cd.columnType.is_array()) {
2413  // for dict encoded arrays, it is always 4 bytes
2414  cd_for_create.columnType.set_comp_param(32);
2415  } else {
2416  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
2417  }
2418  }
2419 
2420  column_descriptors_for_create.push_back(cd_for_create);
2421  column_descriptors.push_back(cd);
2422  }
2423 
2424  if (for_create) {
2425  return column_descriptors_for_create;
2426  }
2427 
2428  return column_descriptors;
2429 }
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:336
const std::vector< TargetMetaInfo > targets_meta
HOST DEVICE int get_size() const
Definition: sqltypes.h:338
std::string to_string(char const *&&v)
bool is_array() const
Definition: sqltypes.h:487
specifies the content in-memory of a row in the column metadata table
void set_comp_param(int p)
Definition: sqltypes.h:429
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 2358 of file ParserNode.cpp.

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

2361  {
2362  CHECK(leaf_idx == 0);
2363  auto& catalog = session.getCatalog();
2364  auto created_td = catalog.getMetadataForTable(insert_data.tableId);
2365  // get CheckpointLock on the table before trying to create
2366  // its 1st fragment
2367  ChunkKey chunkKey = {catalog.getCurrentDB().dbId, created_td->tableId};
2368  mapd_unique_lock<mapd_shared_mutex> chkptlLock(
2371  // [ TableWriteLock ] lock is deferred in
2372  // InsertOrderFragmenter::deleteFragments
2373  created_td->fragmenter->insertDataNoCheckpoint(insert_data);
2374 }
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 1052 of file ParserNode.h.

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

Definition at line 2329 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().

2332  {
2333  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2334  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
2335  const auto query_ra = parse_to_ra(query_state_proxy, pg_shimmed_select_query);
2336 
2337  // Note that the below command should *only* get read locks on the source table for
2338  // InsertIntoAsSelect. Write locks will be taken on the target table in
2339  // InsertOrderFragmenter::deleteFragments. This potentially leaves a small window where
2340  // the target table is not locked, and should be investigated.
2341  std::vector<TableLock> table_locks;
2342  TableLockMgr::getTableLocks(session->getCatalog(), query_ra, table_locks);
2343 
2344  std::vector<TargetMetaInfo> target_metainfos;
2345 
2346  auto result_rows =
2347  getResultSet(query_state_proxy, sql_query_string, target_metainfos, validate_only);
2348  AggregatedResult res = {result_rows, target_metainfos};
2349  return res;
2350 }
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:77
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 2352 of file ParserNode.cpp.

2354  {
2355  return query(query_state_proxy, sql_query_string, false);
2356 }
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 2384 of file ParserNode.cpp.

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

2386  {
2387  auto& catalog = session.getCatalog();
2388  auto dbId = catalog.getCurrentDB().dbId;
2389  catalog.getDataMgr().checkpoint(dbId, tableId);
2390 }
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:177
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: