OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::LocalQueryConnector Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::LocalQueryConnector:
+ Collaboration diagram for Parser::LocalQueryConnector:

Public Member Functions

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, bool allow_interrupt)
 
std::vector< AggregatedResultquery (QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool allow_interrupt) override
 
std::list< ColumnDescriptorgetColumnDescriptors (AggregatedResult &result, bool for_create)
 
size_t leafCount () override
 
void insertChunksToLeaf (const Catalog_Namespace::SessionInfo &parent_session_info, const size_t leaf_idx, const Fragmenter_Namespace::InsertChunks &insert_chunks) override
 
void insertDataToLeaf (const Catalog_Namespace::SessionInfo &parent_session_info, const size_t leaf_idx, Fragmenter_Namespace::InsertData &insert_data) override
 
void checkpoint (const Catalog_Namespace::SessionInfo &parent_session_info, int tableId) override
 
void rollback (const Catalog_Namespace::SessionInfo &parent_session_info, int tableId) override
 
- Public Member Functions inherited from Parser::QueryConnector
 ~QueryConnector ()=default
 
- Public Member Functions inherited from Fragmenter_Namespace::InsertDataLoader::InsertConnector
virtual ~InsertConnector ()=default
 

Additional Inherited Members

- Private Member Functions inherited from Fragmenter_Namespace::InsertDataLoader::InsertConnector
virtual ~InsertConnector ()=default
 

Detailed Description

Definition at line 1041 of file ParserNode.h.

Member Function Documentation

void Parser::LocalQueryConnector::checkpoint ( const Catalog_Namespace::SessionInfo parent_session_info,
int  tableId 
)
inlineoverridevirtual

Reimplemented from Fragmenter_Namespace::LocalInsertConnector.

Definition at line 1071 of file ParserNode.h.

1072  {
1073  return LocalInsertConnector::checkpoint(parent_session_info, tableId);
1074  }
std::list< ColumnDescriptor > Parser::LocalQueryConnector::getColumnDescriptors ( AggregatedResult result,
bool  for_create 
)

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

3552  {
3553  std::list<ColumnDescriptor> column_descriptors;
3554  std::list<ColumnDescriptor> column_descriptors_for_create;
3555 
3556  int rowid_suffix = 0;
3557  for (const auto& target_metainfo : result.targets_meta) {
3558  ColumnDescriptor cd;
3559  cd.columnName = target_metainfo.get_resname();
3560  if (cd.columnName == "rowid") {
3561  cd.columnName += std::to_string(rowid_suffix++);
3562  }
3563  cd.columnType = target_metainfo.get_physical_type_info();
3564 
3565  ColumnDescriptor cd_for_create = cd;
3566 
3568  // we need to reset the comp param (as this points to the actual dictionary)
3569  if (cd.columnType.is_array()) {
3570  // for dict encoded arrays, it is always 4 bytes
3571  cd_for_create.columnType.set_comp_param(32);
3572  } else {
3573  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
3574  }
3575  }
3576 
3577  if (cd.columnType.is_date() && !cd.columnType.is_date_in_days()) {
3578  // default to kENCODING_DATE_IN_DAYS encoding
3580  cd_for_create.columnType.set_comp_param(0);
3581  }
3582 
3583  column_descriptors_for_create.push_back(cd_for_create);
3584  column_descriptors.push_back(cd);
3585  }
3586 
3587  if (for_create) {
3588  return column_descriptors_for_create;
3589  }
3590 
3591  return column_descriptors;
3592 }
void set_compression(EncodingType c)
Definition: sqltypes.h:525
HOST DEVICE int get_size() const
Definition: sqltypes.h:414
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:526
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:412
bool is_date_in_days() const
Definition: sqltypes.h:998
SQLTypeInfo columnType
std::string columnName
bool is_date() const
Definition: sqltypes.h:1008
bool is_array() const
Definition: sqltypes.h:608

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements Parser::QueryConnector.

Definition at line 3461 of file ParserNode.cpp.

References CPU, Default, g_enable_watchdog, query_state::QueryState::getConstSessionInfo(), Executor::getExecutor(), query_state::QueryStateProxy::getQueryState(), Catalog_Namespace::SysCatalog::instance(), Catalog_Namespace::SysCatalog::isAggregator(), pg_shim(), and Executor::UNITARY_EXECUTOR_ID.

3462  {
3463  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
3464  auto& catalog = session->getCatalog();
3465 
3467 #ifdef HAVE_CUDA
3468  const auto device_type = session->get_executor_device_type();
3469 #else
3470  const auto device_type = ExecutorDeviceType::CPU;
3471 #endif // HAVE_CUDA
3472  auto calcite_mgr = catalog.getCalciteMgr();
3473 
3474  // TODO MAT this should actually get the global or the session parameter for
3475  // view optimization
3476  const auto calciteQueryParsingOption =
3477  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
3478  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
3479  false,
3481  {},
3483  const auto query_ra = calcite_mgr
3484  ->process(query_state_proxy,
3485  pg_shim(sql_query_string),
3486  calciteQueryParsingOption,
3487  calciteOptimizationOption)
3488  .plan_result;
3489  RelAlgExecutor ra_executor(executor.get(), catalog, query_ra);
3490  CompilationOptions co = {device_type, true, ExecutorOptLevel::Default, false};
3491  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
3492  // struct
3493  ExecutionOptions eo = {false,
3494  false,
3495  true,
3496  false,
3497  true,
3498  false,
3499  false,
3500  false,
3501  false,
3502  10000,
3503  false,
3504  false,
3505  0.9,
3506  false};
3507  return ra_executor.getOuterFragmentCount(co, eo);
3508 }
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:477
static SysCatalog & instance()
Definition: SysCatalog.h:341
QueryState & getQueryState()
Definition: QueryState.h:181
bool g_enable_watchdog
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:88
std::string pg_shim(const std::string &query)
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:376

+ Here is the call graph for this function:

void Parser::LocalQueryConnector::insertChunksToLeaf ( const Catalog_Namespace::SessionInfo parent_session_info,
const size_t  leaf_idx,
const Fragmenter_Namespace::InsertChunks insert_chunks 
)
inlineoverridevirtual

Reimplemented from Fragmenter_Namespace::LocalInsertConnector.

Definition at line 1058 of file ParserNode.h.

1061  {
1062  return LocalInsertConnector::insertChunksToLeaf(
1063  parent_session_info, leaf_idx, insert_chunks);
1064  }
void Parser::LocalQueryConnector::insertDataToLeaf ( const Catalog_Namespace::SessionInfo parent_session_info,
const size_t  leaf_idx,
Fragmenter_Namespace::InsertData insert_data 
)
inlineoverridevirtual

Reimplemented from Fragmenter_Namespace::LocalInsertConnector.

Definition at line 1065 of file ParserNode.h.

1067  {
1068  return LocalInsertConnector::insertDataToLeaf(
1069  parent_session_info, leaf_idx, insert_data);
1070  }
size_t Parser::LocalQueryConnector::leafCount ( )
inlineoverridevirtual

Reimplemented from Fragmenter_Namespace::LocalInsertConnector.

Definition at line 1057 of file ParserNode.h.

1057 { return LocalInsertConnector::leafCount(); }
AggregatedResult Parser::LocalQueryConnector::query ( QueryStateProxy  query_state_proxy,
std::string &  sql_query_string,
std::vector< size_t >  outer_frag_indices,
bool  validate_only,
bool  allow_interrupt 
)

Definition at line 3510 of file ParserNode.cpp.

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

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

3514  {
3515  // TODO(PS): Should we be using the shimmed query in getResultSet?
3516  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
3517 
3518  std::vector<TargetMetaInfo> target_metainfos;
3520  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
3521  auto query_session = session ? session->get_session_id() : "";
3522  auto query_submitted_time = query_state_proxy.getQueryState().getQuerySubmittedTime();
3523  if (allow_interrupt && !validate_only && !query_session.empty()) {
3524  executor->enrollQuerySession(query_session,
3525  sql_query_string,
3526  query_submitted_time,
3528  QuerySessionStatus::QueryStatus::PENDING_EXECUTOR);
3529  }
3530  auto result_rows = getResultSet(query_state_proxy,
3531  sql_query_string,
3532  target_metainfos,
3533  validate_only,
3534  outer_frag_indices,
3535  allow_interrupt);
3536  AggregatedResult res = {result_rows, target_metainfos};
3537  return res;
3538 }
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={}, bool allow_interrupt=false)
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:477
QueryState & getQueryState()
Definition: QueryState.h:181
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:88
std::string pg_shim(const std::string &query)
const std::string getQuerySubmittedTime() const
Definition: QueryState.cpp:105
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:376

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements Parser::QueryConnector.

Definition at line 3540 of file ParserNode.cpp.

References query(), and run_benchmark_import::res.

3544  {
3545  auto res = query(
3546  query_state_proxy, sql_query_string, outer_frag_indices, false, allow_interrupt);
3547  return {res};
3548 }
AggregatedResult query(QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool validate_only, bool allow_interrupt)

+ Here is the call graph for this function:

void Parser::LocalQueryConnector::rollback ( const Catalog_Namespace::SessionInfo parent_session_info,
int  tableId 
)
inlineoverridevirtual

Reimplemented from Fragmenter_Namespace::LocalInsertConnector.

Definition at line 1075 of file ParserNode.h.

1076  {
1077  return LocalInsertConnector::rollback(parent_session_info, tableId);
1078  }

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