OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::LocalConnector Struct Reference

#include <ParserNode.h>

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

Public Member Functions

 ~LocalConnector () override
 
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
 
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
 ~DistributedConnector () override
 

Detailed Description

Definition at line 1038 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::LocalConnector::~LocalConnector ( )
inlineoverride

Definition at line 1039 of file ParserNode.h.

1039 {}

Member Function Documentation

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

Implements Fragmenter_Namespace::InsertDataLoader::DistributedConnector.

Definition at line 2863 of file ParserNode.cpp.

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

2864  {
2865  auto& catalog = session.getCatalog();
2866  catalog.checkpointWithAutoRollback(table_id);
2867 }
void checkpointWithAutoRollback(const int logical_table_id) const
Definition: Catalog.cpp:4286
Catalog & getCatalog() const
Definition: SessionInfo.h:67

+ Here is the call graph for this function:

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

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

2878  {
2879  std::list<ColumnDescriptor> column_descriptors;
2880  std::list<ColumnDescriptor> column_descriptors_for_create;
2881 
2882  int rowid_suffix = 0;
2883  for (const auto& target_metainfo : result.targets_meta) {
2884  ColumnDescriptor cd;
2885  cd.columnName = target_metainfo.get_resname();
2886  if (cd.columnName == "rowid") {
2887  cd.columnName += std::to_string(rowid_suffix++);
2888  }
2889  cd.columnType = target_metainfo.get_physical_type_info();
2890 
2891  ColumnDescriptor cd_for_create = cd;
2892 
2894  // we need to reset the comp param (as this points to the actual dictionary)
2895  if (cd.columnType.is_array()) {
2896  // for dict encoded arrays, it is always 4 bytes
2897  cd_for_create.columnType.set_comp_param(32);
2898  } else {
2899  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
2900  }
2901  }
2902 
2903  if (cd.columnType.is_date() && !cd.columnType.is_date_in_days()) {
2904  // default to kENCODING_DATE_IN_DAYS encoding
2906  cd_for_create.columnType.set_comp_param(0);
2907  }
2908 
2909  column_descriptors_for_create.push_back(cd_for_create);
2910  column_descriptors.push_back(cd);
2911  }
2912 
2913  if (for_create) {
2914  return column_descriptors_for_create;
2915  }
2916 
2917  return column_descriptors;
2918 }
void set_compression(EncodingType c)
Definition: sqltypes.h:439
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:440
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
bool is_date_in_days() const
Definition: sqltypes.h:869
SQLTypeInfo columnType
std::string columnName
bool is_date() const
Definition: sqltypes.h:879
bool is_array() const
Definition: sqltypes.h:527

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

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

2772  {
2773  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2774  auto& catalog = session->getCatalog();
2775 
2777 #ifdef HAVE_CUDA
2778  const auto device_type = session->get_executor_device_type();
2779 #else
2780  const auto device_type = ExecutorDeviceType::CPU;
2781 #endif // HAVE_CUDA
2782  auto calcite_mgr = catalog.getCalciteMgr();
2783 
2784  // TODO MAT this should actually get the global or the session parameter for
2785  // view optimization
2786  const auto query_ra =
2787  calcite_mgr
2788  ->process(
2789  query_state_proxy, pg_shim(sql_query_string), {}, true, false, false, true)
2790  .plan_result;
2791  RelAlgExecutor ra_executor(executor.get(), catalog, query_ra);
2792  CompilationOptions co = {device_type, true, ExecutorOptLevel::Default, false};
2793  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
2794  // struct
2795  ExecutionOptions eo = {false,
2796  true,
2797  false,
2798  true,
2799  false,
2800  false,
2801  false,
2802  false,
2803  10000,
2804  false,
2805  false,
2806  0.9,
2807  false};
2808  return ra_executor.getOuterFragmentCount(co, eo);
2809 }
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:177
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)
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:376

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

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

2853  {
2854  CHECK(leaf_idx == 0);
2855  auto& catalog = session.getCatalog();
2856  auto created_td = catalog.getMetadataForTable(insert_data.tableId);
2857  ChunkKey chunkKey = {catalog.getCurrentDB().dbId, created_td->tableId};
2858  // TODO(adb): Ensure that we have previously obtained a write lock for this table's
2859  // data.
2860  created_td->fragmenter->insertDataNoCheckpoint(insert_data);
2861 }
std::vector< int > ChunkKey
Definition: types.h:37
int tableId
identifies the database into which the data is being inserted
Definition: Fragmenter.h:61
Catalog & getCatalog() const
Definition: SessionInfo.h:67
#define CHECK(condition)
Definition: Logger.h:211
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 1052 of file ParserNode.h.

1052 { 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,
bool  allow_interrupt 
)

Definition at line 2811 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(), and Parser::InsertIntoTableAsSelectStmt::populateData().

2815  {
2816  // TODO(PS): Should we be using the shimmed query in getResultSet?
2817  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
2818 
2819  std::vector<TargetMetaInfo> target_metainfos;
2821  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2822  auto query_session = session ? session->get_session_id() : "";
2823  auto query_submitted_time = query_state_proxy.getQueryState().getQuerySubmittedTime();
2824  if (allow_interrupt && !validate_only && !query_session.empty()) {
2825  executor->enrollQuerySession(query_session,
2826  sql_query_string,
2827  query_submitted_time,
2829  QuerySessionStatus::QueryStatus::PENDING_EXECUTOR);
2830  }
2831  auto result_rows = getResultSet(query_state_proxy,
2832  sql_query_string,
2833  target_metainfos,
2834  validate_only,
2835  outer_frag_indices,
2836  allow_interrupt);
2837  AggregatedResult res = {result_rows, target_metainfos};
2838  return res;
2839 }
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:177
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::LocalConnector::query ( QueryStateProxy  query_state_proxy,
std::string &  sql_query_string,
std::vector< size_t >  outer_frag_indices,
bool  allow_interrupt 
)
overridevirtual

Implements Parser::DistributedConnector.

Definition at line 2841 of file ParserNode.cpp.

References run_benchmark_import::res.

2845  {
2846  auto res = query(
2847  query_state_proxy, sql_query_string, outer_frag_indices, false, allow_interrupt);
2848  return {res};
2849 }
AggregatedResult query(QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool validate_only, bool allow_interrupt)
void Parser::LocalConnector::rollback ( const Catalog_Namespace::SessionInfo session,
int  tableId 
)
overridevirtual

Implements Fragmenter_Namespace::InsertDataLoader::DistributedConnector.

Definition at line 2869 of file ParserNode.cpp.

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

2870  {
2871  auto& catalog = session.getCatalog();
2872  auto db_id = catalog.getDatabaseId();
2873  auto table_epochs = catalog.getTableEpochs(db_id, table_id);
2874  catalog.setTableEpochs(db_id, table_epochs);
2875 }
int getDatabaseId() const
Definition: Catalog.h:281
Catalog & getCatalog() const
Definition: SessionInfo.h:67

+ Here is the call graph for this function:


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