OmniSciDB  dfae7c3b14
Parser::LocalConnector Struct Reference

#include <ParserNode.h>

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

Public Member Functions

virtual ~LocalConnector ()
 
size_t getOuterFragmentCount (QueryStateProxy, std::string &sql_query_string) override
 
AggregatedResult query (QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool validate_only)
 
std::vector< AggregatedResultquery (QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices) 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)
 
- Public Member Functions inherited from Parser::DistributedConnector
virtual ~DistributedConnector ()
 

Detailed Description

Definition at line 1008 of file ParserNode.h.

Constructor & Destructor Documentation

◆ ~LocalConnector()

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

Definition at line 1009 of file ParserNode.h.

1009 {}

Member Function Documentation

◆ checkpoint()

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

Implements Parser::DistributedConnector.

Definition at line 2477 of file ParserNode.cpp.

References Catalog_Namespace::Catalog::checkpointWithAutoRollback(), and Catalog_Namespace::SessionInfo::getCatalog().

2478  {
2479  auto& catalog = session.getCatalog();
2480  catalog.checkpointWithAutoRollback(table_id);
2481 }
void checkpointWithAutoRollback(const int logical_table_id)
Definition: Catalog.cpp:3731
Catalog & getCatalog() const
Definition: SessionInfo.h:65
+ Here is the call graph for this function:

◆ getColumnDescriptors()

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

Definition at line 2491 of file ParserNode.cpp.

References ColumnDescriptor::columnName, ColumnDescriptor::columnType, SQLTypeInfo::get_compression(), SQLTypeInfo::get_size(), SQLTypeInfo::is_array(), SQLTypeInfo::is_date(), SQLTypeInfo::is_date_in_days(), kENCODING_DATE_IN_DAYS, kENCODING_DICT, SQLTypeInfo::set_comp_param(), SQLTypeInfo::set_compression(), AggregatedResult::targets_meta, and to_string().

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

2492  {
2493  std::list<ColumnDescriptor> column_descriptors;
2494  std::list<ColumnDescriptor> column_descriptors_for_create;
2495 
2496  int rowid_suffix = 0;
2497  for (const auto& target_metainfo : result.targets_meta) {
2498  ColumnDescriptor cd;
2499  cd.columnName = target_metainfo.get_resname();
2500  if (cd.columnName == "rowid") {
2501  cd.columnName += std::to_string(rowid_suffix++);
2502  }
2503  cd.columnType = target_metainfo.get_physical_type_info();
2504 
2505  ColumnDescriptor cd_for_create = cd;
2506 
2508  // we need to reset the comp param (as this points to the actual dictionary)
2509  if (cd.columnType.is_array()) {
2510  // for dict encoded arrays, it is always 4 bytes
2511  cd_for_create.columnType.set_comp_param(32);
2512  } else {
2513  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
2514  }
2515  }
2516 
2517  if (cd.columnType.is_date() && !cd.columnType.is_date_in_days()) {
2518  // default to kENCODING_DATE_IN_DAYS encoding
2520  cd_for_create.columnType.set_comp_param(0);
2521  }
2522 
2523  column_descriptors_for_create.push_back(cd_for_create);
2524  column_descriptors.push_back(cd);
2525  }
2526 
2527  if (for_create) {
2528  return column_descriptors_for_create;
2529  }
2530 
2531  return column_descriptors;
2532 }
void set_compression(EncodingType c)
Definition: sqltypes.h:359
bool is_array() const
Definition: sqltypes.h:425
const std::vector< TargetMetaInfo > targets_meta
bool is_date() const
Definition: sqltypes.h:642
HOST DEVICE int get_size() const
Definition: sqltypes.h:269
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:267
std::string to_string(char const *&&v)
specifies the content in-memory of a row in the column metadata table
void set_comp_param(int p)
Definition: sqltypes.h:360
SQLTypeInfo columnType
std::string columnName
bool is_date_in_days() const
Definition: sqltypes.h:632
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOuterFragmentCount()

size_t Parser::LocalConnector::getOuterFragmentCount ( QueryStateProxy  query_state_proxy,
std::string &  sql_query_string 
)
overridevirtual

Implements Parser::DistributedConnector.

Definition at line 2406 of file ParserNode.cpp.

References CPU, query_state::QueryState::getConstSessionInfo(), Executor::getExecutor(), RelAlgExecutor::getParsedQueryHints(), query_state::QueryStateProxy::getQueryState(), LoopStrengthReduction, pg_shim(), and Executor::UNITARY_EXECUTOR_ID.

2407  {
2408  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2409  auto& catalog = session->getCatalog();
2410 
2412 #ifdef HAVE_CUDA
2413  const auto device_type = session->get_executor_device_type();
2414 #else
2415  const auto device_type = ExecutorDeviceType::CPU;
2416 #endif // HAVE_CUDA
2417  auto calcite_mgr = catalog.getCalciteMgr();
2418 
2419  // TODO MAT this should actually get the global or the session parameter for
2420  // view optimization
2421  const auto query_ra =
2422  calcite_mgr
2423  ->process(
2424  query_state_proxy, pg_shim(sql_query_string), {}, true, false, false, true)
2425  .plan_result;
2426  RelAlgExecutor ra_executor(executor.get(), catalog, query_ra);
2427  const auto& query_hints = ra_executor.getParsedQueryHints();
2428  CompilationOptions co = {query_hints.cpu_mode ? ExecutorDeviceType::CPU : device_type,
2429  true,
2431  false};
2432  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
2433  // struct
2434  ExecutionOptions eo = {
2435  false, true, false, true, false, false, false, false, 10000, false, false, 0.9};
2436  return ra_executor.getOuterFragmentCount(co, eo);
2437 }
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:150
QueryState & getQueryState()
Definition: QueryState.h:172
const QueryHint getParsedQueryHints() const
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:77
std::string pg_shim(const std::string &query)
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:337
+ Here is the call graph for this function:

◆ insertDataToLeaf()

void Parser::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 2465 of file ParserNode.cpp.

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

2467  {
2468  CHECK(leaf_idx == 0);
2469  auto& catalog = session.getCatalog();
2470  auto created_td = catalog.getMetadataForTable(insert_data.tableId);
2471  ChunkKey chunkKey = {catalog.getCurrentDB().dbId, created_td->tableId};
2472  // TODO(adb): Ensure that we have previously obtained a write lock for this table's
2473  // data.
2474  created_td->fragmenter->insertDataNoCheckpoint(insert_data);
2475 }
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:65
#define CHECK(condition)
Definition: Logger.h:197
std::vector< int > ChunkKey
Definition: types.h:37
+ Here is the call graph for this function:

◆ leafCount()

size_t Parser::LocalConnector::leafCount ( )
inlineoverridevirtual

Implements Fragmenter_Namespace::InsertDataLoader::DistributedConnector.

Definition at line 1020 of file ParserNode.h.

References run_benchmark_import::result.

1020 { return 1; };

◆ query() [1/2]

AggregatedResult Parser::LocalConnector::query ( QueryStateProxy  query_state_proxy,
std::string &  sql_query_string,
std::vector< size_t >  outer_frag_indices,
bool  validate_only 
)

Definition at line 2439 of file ParserNode.cpp.

References query_state::QueryState::getConstSessionInfo(), query_state::QueryStateProxy::getQueryState(), Parser::getResultSet(), pg_shim(), and run_benchmark_import::res.

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

2442  {
2443  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2444  // TODO(PS): Should we be using the shimmed query in getResultSet?
2445  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
2446 
2447  std::vector<TargetMetaInfo> target_metainfos;
2448  auto result_rows = getResultSet(query_state_proxy,
2449  sql_query_string,
2450  target_metainfos,
2451  validate_only,
2452  outer_frag_indices);
2453  AggregatedResult res = {result_rows, target_metainfos};
2454  return res;
2455 }
QueryState & getQueryState()
Definition: QueryState.h:172
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:77
std::shared_ptr< ResultSet > getResultSet(QueryStateProxy query_state_proxy, const std::string select_stmt, std::vector< TargetMetaInfo > &targets, bool validate_only=false, std::vector< size_t > outer_fragment_indices={})
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]

std::vector< AggregatedResult > Parser::LocalConnector::query ( QueryStateProxy  query_state_proxy,
std::string &  sql_query_string,
std::vector< size_t >  outer_frag_indices 
)
overridevirtual

Implements Parser::DistributedConnector.

Definition at line 2457 of file ParserNode.cpp.

References run_benchmark_import::res.

2460  {
2461  auto res = query(query_state_proxy, sql_query_string, outer_frag_indices, false);
2462  return {res};
2463 }
AggregatedResult query(QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool validate_only)

◆ rollback()

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

Implements Parser::DistributedConnector.

Definition at line 2483 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::getCatalog(), and Catalog_Namespace::Catalog::getDatabaseId().

2484  {
2485  auto& catalog = session.getCatalog();
2486  auto db_id = catalog.getDatabaseId();
2487  auto table_epochs = catalog.getTableEpochs(db_id, table_id);
2488  catalog.setTableEpochs(db_id, table_epochs);
2489 }
int getDatabaseId() const
Definition: Catalog.h:246
Catalog & getCatalog() const
Definition: SessionInfo.h:65
+ Here is the call graph for this function:

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