OmniSciDB  ba1bac9284
 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, 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
virtual ~DistributedConnector ()
 

Detailed Description

Definition at line 1016 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1017 of file ParserNode.h.

1017 {}

Member Function Documentation

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

Implements Parser::DistributedConnector.

Definition at line 2734 of file ParserNode.cpp.

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

2735  {
2736  auto& catalog = session.getCatalog();
2737  catalog.checkpointWithAutoRollback(table_id);
2738 }
void checkpointWithAutoRollback(const int logical_table_id) const
Definition: Catalog.cpp:4218
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 2748 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().

2749  {
2750  std::list<ColumnDescriptor> column_descriptors;
2751  std::list<ColumnDescriptor> column_descriptors_for_create;
2752 
2753  int rowid_suffix = 0;
2754  for (const auto& target_metainfo : result.targets_meta) {
2755  ColumnDescriptor cd;
2756  cd.columnName = target_metainfo.get_resname();
2757  if (cd.columnName == "rowid") {
2758  cd.columnName += std::to_string(rowid_suffix++);
2759  }
2760  cd.columnType = target_metainfo.get_physical_type_info();
2761 
2762  ColumnDescriptor cd_for_create = cd;
2763 
2765  // we need to reset the comp param (as this points to the actual dictionary)
2766  if (cd.columnType.is_array()) {
2767  // for dict encoded arrays, it is always 4 bytes
2768  cd_for_create.columnType.set_comp_param(32);
2769  } else {
2770  cd_for_create.columnType.set_comp_param(cd.columnType.get_size() * 8);
2771  }
2772  }
2773 
2774  if (cd.columnType.is_date() && !cd.columnType.is_date_in_days()) {
2775  // default to kENCODING_DATE_IN_DAYS encoding
2777  cd_for_create.columnType.set_comp_param(0);
2778  }
2779 
2780  column_descriptors_for_create.push_back(cd_for_create);
2781  column_descriptors.push_back(cd);
2782  }
2783 
2784  if (for_create) {
2785  return column_descriptors_for_create;
2786  }
2787 
2788  return column_descriptors;
2789 }
void set_compression(EncodingType c)
Definition: sqltypes.h:414
HOST DEVICE int get_size() const
Definition: sqltypes.h:324
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:415
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:322
bool is_date_in_days() const
Definition: sqltypes.h:721
SQLTypeInfo columnType
std::string columnName
bool is_date() const
Definition: sqltypes.h:731
bool is_array() const
Definition: sqltypes.h:497

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

References CPU, query_state::QueryState::getConstSessionInfo(), Executor::getExecutor(), RelAlgExecutor::getParsedQueryHints(), query_state::QueryStateProxy::getQueryState(), RegisteredQueryHint::isHintRegistered(), kCpuMode, LoopStrengthReduction, pg_shim(), and Executor::UNITARY_EXECUTOR_ID.

2638  {
2639  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2640  auto& catalog = session->getCatalog();
2641 
2643 #ifdef HAVE_CUDA
2644  const auto device_type = session->get_executor_device_type();
2645 #else
2646  const auto device_type = ExecutorDeviceType::CPU;
2647 #endif // HAVE_CUDA
2648  auto calcite_mgr = catalog.getCalciteMgr();
2649 
2650  // TODO MAT this should actually get the global or the session parameter for
2651  // view optimization
2652  const auto query_ra =
2653  calcite_mgr
2654  ->process(
2655  query_state_proxy, pg_shim(sql_query_string), {}, true, false, false, true)
2656  .plan_result;
2657  RelAlgExecutor ra_executor(executor.get(), catalog, query_ra);
2658  const auto& query_hints = ra_executor.getParsedQueryHints();
2659  const bool cpu_mode_enabled = query_hints.isHintRegistered(QueryHint::kCpuMode);
2660  CompilationOptions co = {cpu_mode_enabled ? ExecutorDeviceType::CPU : device_type,
2661  true,
2663  false};
2664  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
2665  // struct
2666  ExecutionOptions eo = {false,
2667  true,
2668  false,
2669  true,
2670  false,
2671  false,
2672  false,
2673  false,
2674  10000,
2675  false,
2676  false,
2677  0.9,
2678  false};
2679  return ra_executor.getOuterFragmentCount(co, eo);
2680 }
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:166
QueryState & getQueryState()
Definition: QueryState.h:175
RegisteredQueryHint getParsedQueryHints()
const bool isHintRegistered(const QueryHint hint) const
Definition: QueryHint.h:203
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:79
std::string pg_shim(const std::string &query)
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:366

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

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

2724  {
2725  CHECK(leaf_idx == 0);
2726  auto& catalog = session.getCatalog();
2727  auto created_td = catalog.getMetadataForTable(insert_data.tableId);
2728  ChunkKey chunkKey = {catalog.getCurrentDB().dbId, created_td->tableId};
2729  // TODO(adb): Ensure that we have previously obtained a write lock for this table's
2730  // data.
2731  created_td->fragmenter->insertDataNoCheckpoint(insert_data);
2732 }
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:206
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 1030 of file ParserNode.h.

1030 { 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 2682 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().

2686  {
2687  // TODO(PS): Should we be using the shimmed query in getResultSet?
2688  std::string pg_shimmed_select_query = pg_shim(sql_query_string);
2689 
2690  std::vector<TargetMetaInfo> target_metainfos;
2692  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2693  auto query_session = session ? session->get_session_id() : "";
2694  auto query_submitted_time = query_state_proxy.getQueryState().getQuerySubmittedTime();
2695  if (allow_interrupt && !validate_only && !query_session.empty()) {
2696  executor->enrollQuerySession(query_session,
2697  sql_query_string,
2698  query_submitted_time,
2700  QuerySessionStatus::QueryStatus::PENDING_EXECUTOR);
2701  }
2702  auto result_rows = getResultSet(query_state_proxy,
2703  sql_query_string,
2704  target_metainfos,
2705  validate_only,
2706  outer_frag_indices,
2707  allow_interrupt);
2708  AggregatedResult res = {result_rows, target_metainfos};
2709  return res;
2710 }
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:166
QueryState & getQueryState()
Definition: QueryState.h:175
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:79
std::string pg_shim(const std::string &query)
const std::string getQuerySubmittedTime() const
Definition: QueryState.cpp:96
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:366

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

References run_benchmark_import::res.

2716  {
2717  auto res = query(
2718  query_state_proxy, sql_query_string, outer_frag_indices, false, allow_interrupt);
2719  return {res};
2720 }
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 Parser::DistributedConnector.

Definition at line 2740 of file ParserNode.cpp.

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

2741  {
2742  auto& catalog = session.getCatalog();
2743  auto db_id = catalog.getDatabaseId();
2744  auto table_epochs = catalog.getTableEpochs(db_id, table_id);
2745  catalog.setTableEpochs(db_id, table_epochs);
2746 }
int getDatabaseId() const
Definition: Catalog.h:277
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: