OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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

Definition at line 1009 of file ParserNode.h.

1009 {}

Member Function Documentation

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

Implements Parser::DistributedConnector.

Definition at line 2478 of file ParserNode.cpp.

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

2479  {
2480  auto& catalog = session.getCatalog();
2481  auto dbId = catalog.getCurrentDB().dbId;
2482  catalog.getDataMgr().checkpoint(dbId, tableId);
2483 }
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:194
Catalog & getCatalog() const
Definition: SessionInfo.h:65

+ Here is the call graph for this function:

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

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

2493  {
2494  std::list<ColumnDescriptor> column_descriptors;
2495  std::list<ColumnDescriptor> column_descriptors_for_create;
2496 
2497  int rowid_suffix = 0;
2498  for (const auto& target_metainfo : result.targets_meta) {
2499  ColumnDescriptor cd;
2500  cd.columnName = target_metainfo.get_resname();
2501  if (cd.columnName == "rowid") {
2502  cd.columnName += std::to_string(rowid_suffix++);
2503  }
2504  cd.columnType = target_metainfo.get_physical_type_info();
2505 
2506  ColumnDescriptor cd_for_create = cd;
2507 
2509  // we need to reset the comp param (as this points to the actual dictionary)
2510  if (cd.columnType.is_array()) {
2511  // for dict encoded arrays, it is always 4 bytes
2512  cd_for_create.columnType.set_comp_param(32);
2513  } else {
2514  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
2515  }
2516  }
2517 
2518  if (cd.columnType.is_date() && !cd.columnType.is_date_in_days()) {
2519  // default to kENCODING_DATE_IN_DAYS encoding
2521  cd_for_create.columnType.set_comp_param(0);
2522  }
2523 
2524  column_descriptors_for_create.push_back(cd_for_create);
2525  column_descriptors.push_back(cd);
2526  }
2527 
2528  if (for_create) {
2529  return column_descriptors_for_create;
2530  }
2531 
2532  return column_descriptors;
2533 }
void set_compression(EncodingType c)
Definition: sqltypes.h:358
HOST DEVICE int get_size() const
Definition: sqltypes.h:268
const std::vector< TargetMetaInfo > targets_meta
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:359
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:266
bool is_date_in_days() const
Definition: sqltypes.h:630
SQLTypeInfo columnType
std::string columnName
bool is_date() const
Definition: sqltypes.h:640
bool is_array() const
Definition: sqltypes.h:423

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements Parser::DistributedConnector.

Definition at line 2407 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.

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

+ Here is the call graph for this function:

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

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

2468  {
2469  CHECK(leaf_idx == 0);
2470  auto& catalog = session.getCatalog();
2471  auto created_td = catalog.getMetadataForTable(insert_data.tableId);
2472  ChunkKey chunkKey = {catalog.getCurrentDB().dbId, created_td->tableId};
2473  // TODO(adb): Ensure that we have previously obtained a write lock for this table's
2474  // data.
2475  created_td->fragmenter->insertDataNoCheckpoint(insert_data);
2476 }
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:65
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::LocalConnector::leafCount ( )
inlineoverridevirtual

Implements Fragmenter_Namespace::InsertDataLoader::DistributedConnector.

Definition at line 1020 of file ParserNode.h.

1020 { return 1; };
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 2440 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().

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

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

References run_benchmark_import::res.

2461  {
2462  auto res = query(query_state_proxy, sql_query_string, outer_frag_indices, false);
2463  return {res};
2464 }
AggregatedResult query(QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool validate_only)
void Parser::LocalConnector::rollback ( const Catalog_Namespace::SessionInfo session,
int  tableId 
)
overridevirtual

Implements Parser::DistributedConnector.

Definition at line 2485 of file ParserNode.cpp.

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

2486  {
2487  auto& catalog = session.getCatalog();
2488  auto dbId = catalog.getCurrentDB().dbId;
2489  catalog.getDataMgr().checkpoint(dbId, tableId);
2490 }
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:194
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: