OmniSciDB  04ee39c94c
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 (const Catalog_Namespace::SessionInfo &session, std::string &sql_query_string, bool validate_only)
 
AggregatedResult query (const Catalog_Namespace::SessionInfo &session, 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 1032 of file ParserNode.h.

Constructor & Destructor Documentation

◆ ~LocalConnector()

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

Definition at line 1033 of file ParserNode.h.

References anonymous_namespace{UpdateMetadataTest.cpp}::query.

1033 {}

Member Function Documentation

◆ checkpoint()

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

Implements Parser::InsertIntoTableAsSelectStmt::DistributedConnector.

Definition at line 2312 of file ParserNode.cpp.

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

2314  {
2315  auto& catalog = session.getCatalog();
2316  auto dbId = catalog.getCurrentDB().dbId;
2317  catalog.getDataMgr().checkpoint(dbId, tableId);
2318 }
Catalog & getCatalog() const
Definition: SessionInfo.h:90
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:176
+ Here is the call graph for this function:

◆ getColumnDescriptors()

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

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

2331  {
2332  std::list<ColumnDescriptor> column_descriptors;
2333  std::list<ColumnDescriptor> column_descriptors_for_create;
2334 
2335  int rowid_suffix = 0;
2336  for (const auto& target_metainfo : result.targets_meta) {
2337  ColumnDescriptor cd;
2338  cd.columnName = target_metainfo.get_resname();
2339  if (cd.columnName == "rowid") {
2340  cd.columnName += std::to_string(rowid_suffix++);
2341  }
2342  cd.columnType = target_metainfo.get_physical_type_info();
2343 
2344  ColumnDescriptor cd_for_create = cd;
2345 
2347  // we need to reset the comp param (as this points to the actual dictionary)
2348  if (cd.columnType.is_array()) {
2349  // for dict encoded arrays, it is always 4 bytes
2350  cd_for_create.columnType.set_comp_param(32);
2351  } else {
2352  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
2353  }
2354  }
2355 
2356  column_descriptors_for_create.push_back(cd_for_create);
2357  column_descriptors.push_back(cd);
2358  }
2359 
2360  if (for_create) {
2361  return column_descriptors_for_create;
2362  }
2363 
2364  return column_descriptors;
2365 }
HOST DEVICE int get_size() const
Definition: sqltypes.h:333
const std::vector< TargetMetaInfo > targets_meta
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
std::string to_string(char const *&&v)
bool is_array() const
Definition: sqltypes.h:458
specifies the content in-memory of a row in the column metadata table
void set_comp_param(int p)
Definition: sqltypes.h:424
SQLTypeInfo columnType
std::string columnName
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertDataToLeaf()

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 2294 of file ParserNode.cpp.

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

2297  {
2298  CHECK(leaf_idx == 0);
2299  auto& catalog = session.getCatalog();
2300  auto created_td = catalog.getMetadataForTable(insert_data.tableId);
2301  // get CheckpointLock on the table before trying to create
2302  // its 1st fragment
2303  ChunkKey chunkKey = {catalog.getCurrentDB().dbId, created_td->tableId};
2304  mapd_unique_lock<mapd_shared_mutex> chkptlLock(
2307  // [ TableWriteLock ] lock is deferred in
2308  // InsertOrderFragmenter::deleteFragments
2309  created_td->fragmenter->insertDataNoCheckpoint(insert_data);
2310 }
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
int tableId
identifies the database into which the data is being inserted
Definition: Fragmenter.h:61
Catalog & getCatalog() const
Definition: SessionInfo.h:90
#define CHECK(condition)
Definition: Logger.h:187
std::vector< int > ChunkKey
Definition: types.h:35
+ Here is the call graph for this function:

◆ leafCount()

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

Implements Fragmenter_Namespace::InsertDataLoader::DistributedConnector.

Definition at line 1041 of file ParserNode.h.

References run-benchmark-import::result.

1041 { return 1; };

◆ query() [1/2]

AggregatedResult Parser::InsertIntoTableAsSelectStmt::LocalConnector::query ( const Catalog_Namespace::SessionInfo session,
std::string &  sql_query_string,
bool  validate_only 
)

Definition at line 2272 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::getCatalog(), 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().

2275  {
2276  auto& catalog = session.getCatalog();
2277  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
2278  const auto query_ra = parse_to_ra(catalog, pg_shimmed_select_query, session);
2279 
2280  // Note that the below command should *only* get read locks on the source table for
2281  // InsertIntoAsSelect. Write locks will be taken on the target table in
2282  // InsertOrderFragmenter::deleteFragments. This potentially leaves a small window where
2283  // the target table is not locked, and should be investigated.
2284  std::vector<TableLock> table_locks;
2285  TableLockMgr::getTableLocks(session.getCatalog(), query_ra, table_locks);
2286 
2287  std::vector<TargetMetaInfo> target_metainfos;
2288 
2289  auto result_rows =
2290  getResultSet(session, sql_query_string, target_metainfos, validate_only);
2291  AggregatedResult res = {result_rows, target_metainfos};
2292  return res;
2293 }
Catalog & getCatalog() const
Definition: SessionInfo.h:90
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:98
std::shared_ptr< ResultSet > getResultSet(const Catalog_Namespace::SessionInfo &session, const std::string select_stmt, std::vector< TargetMetaInfo > &targets, bool validate_only=false)
std::string parse_to_ra(const Catalog_Namespace::Catalog &cat, const std::string &query_str, const Catalog_Namespace::SessionInfo &session_info)
Definition: LockMgr.cpp:76
std::string pg_shim(const std::string &query)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ query() [2/2]

AggregatedResult Parser::InsertIntoTableAsSelectStmt::LocalConnector::query ( const Catalog_Namespace::SessionInfo session,
std::string &  sql_query_string 
)
inlineoverridevirtual

Implements Parser::InsertIntoTableAsSelectStmt::DistributedConnector.

Definition at line 1037 of file ParserNode.h.

References anonymous_namespace{UpdateMetadataTest.cpp}::query.

1038  {
1039  return query(session, sql_query_string, false);
1040  }
AggregatedResult query(const Catalog_Namespace::SessionInfo &session, std::string &sql_query_string, bool validate_only)

◆ rollback()

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

Implements Parser::InsertIntoTableAsSelectStmt::DistributedConnector.

Definition at line 2320 of file ParserNode.cpp.

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

2322  {
2323  auto& catalog = session.getCatalog();
2324  auto dbId = catalog.getCurrentDB().dbId;
2325  catalog.getDataMgr().checkpoint(dbId, tableId);
2326 }
Catalog & getCatalog() const
Definition: SessionInfo.h:90
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:176
+ Here is the call graph for this function:

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