OmniSciDB  cde582ebc3
 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 3529 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().

3531  {
3532  std::list<ColumnDescriptor> column_descriptors;
3533  std::list<ColumnDescriptor> column_descriptors_for_create;
3534 
3535  int rowid_suffix = 0;
3536  for (const auto& target_metainfo : result.targets_meta) {
3537  ColumnDescriptor cd;
3538  cd.columnName = target_metainfo.get_resname();
3539  if (cd.columnName == "rowid") {
3540  cd.columnName += std::to_string(rowid_suffix++);
3541  }
3542  cd.columnType = target_metainfo.get_physical_type_info();
3543 
3544  ColumnDescriptor cd_for_create = cd;
3545 
3547  // we need to reset the comp param (as this points to the actual dictionary)
3548  if (cd.columnType.is_array()) {
3549  // for dict encoded arrays, it is always 4 bytes
3550  cd_for_create.columnType.set_comp_param(32);
3551  } else {
3552  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
3553  }
3554  }
3555 
3556  if (cd.columnType.is_date() && !cd.columnType.is_date_in_days()) {
3557  // default to kENCODING_DATE_IN_DAYS encoding
3559  cd_for_create.columnType.set_comp_param(0);
3560  }
3561 
3562  column_descriptors_for_create.push_back(cd_for_create);
3563  column_descriptors.push_back(cd);
3564  }
3565 
3566  if (for_create) {
3567  return column_descriptors_for_create;
3568  }
3569 
3570  return column_descriptors;
3571 }
void set_compression(EncodingType c)
Definition: sqltypes.h:440
HOST DEVICE int get_size() const
Definition: sqltypes.h:339
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:441
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
bool is_date_in_days() const
Definition: sqltypes.h:873
SQLTypeInfo columnType
std::string columnName
bool is_date() const
Definition: sqltypes.h:883
bool is_array() const
Definition: sqltypes.h:518

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

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

3444  {
3445  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
3446  auto& catalog = session->getCatalog();
3447 
3449 #ifdef HAVE_CUDA
3450  const auto device_type = session->get_executor_device_type();
3451 #else
3452  const auto device_type = ExecutorDeviceType::CPU;
3453 #endif // HAVE_CUDA
3454  auto calcite_mgr = catalog.getCalciteMgr();
3455 
3456  // TODO MAT this should actually get the global or the session parameter for
3457  // view optimization
3458  const auto calciteQueryParsingOption =
3459  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
3460  const auto calciteOptimizationOption =
3461  calcite_mgr->getCalciteOptimizationOption(false, g_enable_watchdog, {});
3462  const auto query_ra = calcite_mgr
3463  ->process(query_state_proxy,
3464  pg_shim(sql_query_string),
3465  calciteQueryParsingOption,
3466  calciteOptimizationOption)
3467  .plan_result;
3468  RelAlgExecutor ra_executor(executor.get(), catalog, query_ra);
3469  CompilationOptions co = {device_type, true, ExecutorOptLevel::Default, false};
3470  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
3471  // struct
3472  ExecutionOptions eo = {false,
3473  false,
3474  true,
3475  false,
3476  true,
3477  false,
3478  false,
3479  false,
3480  false,
3481  10000,
3482  false,
3483  false,
3484  0.9,
3485  false};
3486  return ra_executor.getOuterFragmentCount(co, eo);
3487 }
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:468
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 3489 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().

3493  {
3494  // TODO(PS): Should we be using the shimmed query in getResultSet?
3495  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
3496 
3497  std::vector<TargetMetaInfo> target_metainfos;
3499  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
3500  auto query_session = session ? session->get_session_id() : "";
3501  auto query_submitted_time = query_state_proxy.getQueryState().getQuerySubmittedTime();
3502  if (allow_interrupt && !validate_only && !query_session.empty()) {
3503  executor->enrollQuerySession(query_session,
3504  sql_query_string,
3505  query_submitted_time,
3507  QuerySessionStatus::QueryStatus::PENDING_EXECUTOR);
3508  }
3509  auto result_rows = getResultSet(query_state_proxy,
3510  sql_query_string,
3511  target_metainfos,
3512  validate_only,
3513  outer_frag_indices,
3514  allow_interrupt);
3515  AggregatedResult res = {result_rows, target_metainfos};
3516  return res;
3517 }
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:468
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 3519 of file ParserNode.cpp.

References query(), and run_benchmark_import::res.

3523  {
3524  auto res = query(
3525  query_state_proxy, sql_query_string, outer_frag_indices, false, allow_interrupt);
3526  return {res};
3527 }
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: