OmniSciDB  a5dc49c757
 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 1042 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 1072 of file ParserNode.h.

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

Definition at line 4036 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::CreateModelStmt::build_model_query(), EvaluateModelCommand::execute(), Parser::CreateTableAsSelectStmt::execute(), and Parser::InsertIntoTableAsSelectStmt::populateData().

4038  {
4039  std::list<ColumnDescriptor> column_descriptors;
4040  std::list<ColumnDescriptor> column_descriptors_for_create;
4041 
4042  int rowid_suffix = 0;
4043  for (const auto& target_metainfo : result.targets_meta) {
4044  ColumnDescriptor cd;
4045  cd.columnName = target_metainfo.get_resname();
4046  if (cd.columnName == "rowid") {
4047  cd.columnName += std::to_string(rowid_suffix++);
4048  }
4049  cd.columnType = target_metainfo.get_physical_type_info();
4050 
4051  ColumnDescriptor cd_for_create = cd;
4052 
4054  // we need to reset the comp param (as this points to the actual dictionary)
4055  if (cd.columnType.is_array()) {
4056  // for dict encoded arrays, it is always 4 bytes
4057  cd_for_create.columnType.set_comp_param(32);
4058  } else {
4059  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
4060  }
4061  }
4062 
4063  if (cd.columnType.is_date() && !cd.columnType.is_date_in_days()) {
4064  // default to kENCODING_DATE_IN_DAYS encoding
4066  cd_for_create.columnType.set_comp_param(0);
4067  }
4068 
4069  column_descriptors_for_create.push_back(cd_for_create);
4070  column_descriptors.push_back(cd);
4071  }
4072 
4073  if (for_create) {
4074  return column_descriptors_for_create;
4075  }
4076 
4077  return column_descriptors;
4078 }
void set_compression(EncodingType c)
Definition: sqltypes.h:481
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
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:482
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
bool is_date_in_days() const
Definition: sqltypes.h:1018
SQLTypeInfo columnType
std::string columnName
bool is_date() const
Definition: sqltypes.h:1028
bool is_array() const
Definition: sqltypes.h:585

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

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

3947  {
3948  auto const session = query_state_proxy->getConstSessionInfo();
3949  auto& catalog = session->getCatalog();
3950 
3952 #ifdef HAVE_CUDA
3953  const auto device_type = session->get_executor_device_type();
3954 #else
3955  const auto device_type = ExecutorDeviceType::CPU;
3956 #endif // HAVE_CUDA
3957  auto calcite_mgr = catalog.getCalciteMgr();
3958 
3959  // TODO MAT this should actually get the global or the session parameter for
3960  // view optimization
3961  const auto calciteQueryParsingOption =
3962  calcite_mgr->getCalciteQueryParsingOption(true, false, true, false);
3963  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
3964  false,
3966  {},
3968  const auto query_ra = calcite_mgr
3969  ->process(query_state_proxy,
3970  pg_shim(sql_query_string),
3971  calciteQueryParsingOption,
3972  calciteOptimizationOption)
3973  .plan_result;
3974  RelAlgExecutor ra_executor(executor.get(), query_ra);
3975  CompilationOptions co = {device_type, true, ExecutorOptLevel::Default, false};
3976  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
3977  // struct
3978  ExecutionOptions eo = {false,
3979  false,
3980  true,
3981  false,
3982  true,
3983  false,
3984  false,
3985  false,
3986  false,
3987  10000,
3988  false,
3989  false,
3990  0.9,
3991  false,
3992  false};
3993  return ra_executor.getOuterFragmentCount(co, eo);
3994 }
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:513
static SysCatalog & instance()
Definition: SysCatalog.h:343
bool g_enable_watchdog
std::string pg_shim(std::string const &query)
static constexpr ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:423
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:84

+ 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 1059 of file ParserNode.h.

1062  {
1063  return LocalInsertConnector::insertChunksToLeaf(
1064  parent_session_info, leaf_idx, insert_chunks);
1065  }
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 1066 of file ParserNode.h.

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

Reimplemented from Fragmenter_Namespace::LocalInsertConnector.

Definition at line 1058 of file ParserNode.h.

1058 { 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 3996 of file ParserNode.cpp.

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

Referenced by Parser::CreateModelStmt::build_model_query(), EvaluateModelCommand::execute(), Parser::CreateTableAsSelectStmt::execute(), Parser::ExportQueryStmt::execute(), Parser::InsertIntoTableAsSelectStmt::populateData(), query(), and Parser::CreateModelStmt::train_model().

4000  {
4001  // TODO(PS): Should we be using the shimmed query in getResultSet?
4002  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
4003 
4004  std::vector<TargetMetaInfo> target_metainfos;
4006  auto const session = query_state_proxy->getConstSessionInfo();
4007  auto query_session = session ? session->get_session_id() : "";
4008  auto query_submitted_time = query_state_proxy->getQuerySubmittedTime();
4009  if (allow_interrupt && !validate_only && !query_session.empty()) {
4010  executor->enrollQuerySession(query_session,
4011  sql_query_string,
4012  query_submitted_time,
4014  QuerySessionStatus::QueryStatus::PENDING_EXECUTOR);
4015  }
4016  auto result_rows = getResultSet(query_state_proxy,
4017  sql_query_string,
4018  target_metainfos,
4019  validate_only,
4020  outer_frag_indices,
4021  allow_interrupt);
4022  AggregatedResult res = {result_rows, target_metainfos};
4023  return res;
4024 }
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:513
std::string pg_shim(std::string const &query)
static constexpr ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:423
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:84
const std::string getQuerySubmittedTime() const
Definition: QueryState.cpp:101

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

References query(), and run_benchmark_import::res.

4030  {
4031  auto res = query(
4032  query_state_proxy, sql_query_string, outer_frag_indices, false, allow_interrupt);
4033  return {res};
4034 }
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 1076 of file ParserNode.h.

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

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