OmniSciDB  2e3a973ef4
EmbeddedDatabase::DBEngineImpl Class Reference
+ Inheritance diagram for EmbeddedDatabase::DBEngineImpl:
+ Collaboration diagram for EmbeddedDatabase::DBEngineImpl:

Public Member Functions

void reset ()
 
void executeDDL (const std::string &query)
 
CursorexecuteDML (const std::string &query)
 
 DBEngineImpl (const std::string &base_path)
 
- Public Member Functions inherited from EmbeddedDatabase::DBEngine
void reset ()
 
void executeDDL (std::string query)
 
CursorexecuteDML (std::string query)
 

Public Attributes

const int CALCITEPORT = 3279
 
const std::string OMNISCI_DEFAULT_DB = "omnisci"
 
const std::string OMNISCI_ROOT_USER = "admin"
 
const std::string OMNISCI_DATA_PATH = "//mapd_data"
 

Private Attributes

std::string base_path_
 
std::shared_ptr< Data_Namespace::DataMgrdata_mgr_
 
Catalog_Namespace::DBMetadata database_
 
Catalog_Namespace::UserMetadata user_
 
QueryRunner::QueryRunnerquery_runner_
 
std::vector< CursorImpl * > cursors_
 

Additional Inherited Members

- Static Public Member Functions inherited from EmbeddedDatabase::DBEngine
static DBEnginecreate (std::string path)
 
- Protected Member Functions inherited from EmbeddedDatabase::DBEngine
 DBEngine ()
 

Detailed Description

DBEngine internal implementation

Definition at line 91 of file DBEngine.cpp.

Constructor & Destructor Documentation

◆ DBEngineImpl()

EmbeddedDatabase::DBEngineImpl::DBEngineImpl ( const std::string &  base_path)
inline

Definition at line 121 of file DBEngine.cpp.

References CALCITEPORT, CPU, Catalog_Namespace::Catalog::get(), QueryRunner::QueryRunner::init(), and Catalog_Namespace::SysCatalog::instance().

122  : base_path_(base_path), query_runner_(nullptr) {
123  if (!boost::filesystem::exists(base_path_)) {
124  std::cerr << "Catalog basepath " + base_path_ + " does not exist.\n";
125  // TODO: Create database if it does not exist
126  } else {
127  SystemParameters system_parameters;
128  std::string data_path = base_path_ + OMNISCI_DATA_PATH;
129  data_mgr_ = std::make_shared<Data_Namespace::DataMgr>(
130  data_path, system_parameters, false, 0);
131  auto calcite = std::make_shared<Calcite>(-1, CALCITEPORT, base_path_, 1024, 5000);
132  auto& sys_cat = Catalog_Namespace::SysCatalog::instance();
133  sys_cat.init(base_path_, data_mgr_, {}, calcite, false, false, {});
134  if (!sys_cat.getSqliteConnector()) {
135  std::cerr << "SqliteConnector is null " << std::endl;
136  } else {
137  sys_cat.getMetadataForDB(OMNISCI_DEFAULT_DB, database_); // TODO: Check
138  auto catalog = Catalog_Namespace::Catalog::get(base_path_,
139  database_,
140  data_mgr_,
141  std::vector<LeafHostInfo>(),
142  calcite,
143  false);
144  sys_cat.getMetadataForUser(OMNISCI_ROOT_USER, user_);
145  auto session = std::make_unique<Catalog_Namespace::SessionInfo>(
146  catalog, user_, ExecutorDeviceType::CPU, "");
148  }
149  }
150  }
static std::shared_ptr< Catalog > get(const std::string &dbName)
Definition: Catalog.cpp:3753
const std::string OMNISCI_ROOT_USER
Definition: DBEngine.cpp:96
static QueryRunner * init(const char *db_path, const std::string &udf_filename="", const size_t max_gpu_mem=0, const int reserved_gpu_mem=256<< 20)
Definition: QueryRunner.h:61
static SysCatalog & instance()
Definition: SysCatalog.h:286
const std::string OMNISCI_DATA_PATH
Definition: DBEngine.cpp:97
const std::string OMNISCI_DEFAULT_DB
Definition: DBEngine.cpp:95
Catalog_Namespace::UserMetadata user_
Definition: DBEngine.cpp:156
QueryRunner::QueryRunner * query_runner_
Definition: DBEngine.cpp:157
Catalog_Namespace::DBMetadata database_
Definition: DBEngine.cpp:155
std::shared_ptr< Data_Namespace::DataMgr > data_mgr_
Definition: DBEngine.cpp:154
+ Here is the call graph for this function:

Member Function Documentation

◆ executeDDL()

void EmbeddedDatabase::DBEngineImpl::executeDDL ( const std::string &  query)
inline

Definition at line 106 of file DBEngine.cpp.

Referenced by EmbeddedDatabase::DBEngine::executeDDL().

106  {
107  if (query_runner_ != nullptr) {
109  }
110  }
virtual void runDDLStatement(const std::string &)
QueryRunner::QueryRunner * query_runner_
Definition: DBEngine.cpp:157
+ Here is the caller graph for this function:

◆ executeDML()

Cursor* EmbeddedDatabase::DBEngineImpl::executeDML ( const std::string &  query)
inline

Definition at line 112 of file DBEngine.cpp.

References CPU.

Referenced by EmbeddedDatabase::DBEngine::executeDML().

112  {
113  if (query_runner_ != nullptr) {
114  auto rs = query_runner_->runSQL(query, ExecutorDeviceType::CPU);
115  cursors_.emplace_back(new CursorImpl(rs, data_mgr_));
116  return cursors_.back();
117  }
118  return nullptr;
119  }
std::vector< CursorImpl * > cursors_
Definition: DBEngine.cpp:158
virtual std::shared_ptr< ResultSet > runSQL(const std::string &query_str, const ExecutorDeviceType device_type, const bool hoist_literals=true, const bool allow_loop_joins=true)
QueryRunner::QueryRunner * query_runner_
Definition: DBEngine.cpp:157
std::shared_ptr< Data_Namespace::DataMgr > data_mgr_
Definition: DBEngine.cpp:154
+ Here is the caller graph for this function:

◆ reset()

void EmbeddedDatabase::DBEngineImpl::reset ( )
inline

Definition at line 99 of file DBEngine.cpp.

Referenced by EmbeddedDatabase::DBEngine::reset().

99  {
100  // TODO: Destroy all cursors in the cursors_
101  if (query_runner_ != nullptr) {
102  query_runner_->reset();
103  }
104  }
QueryRunner::QueryRunner * query_runner_
Definition: DBEngine.cpp:157
+ Here is the caller graph for this function:

Member Data Documentation

◆ base_path_

std::string EmbeddedDatabase::DBEngineImpl::base_path_
private

Definition at line 153 of file DBEngine.cpp.

◆ CALCITEPORT

const int EmbeddedDatabase::DBEngineImpl::CALCITEPORT = 3279

Definition at line 94 of file DBEngine.cpp.

◆ cursors_

std::vector<CursorImpl*> EmbeddedDatabase::DBEngineImpl::cursors_
private

Definition at line 158 of file DBEngine.cpp.

◆ data_mgr_

std::shared_ptr<Data_Namespace::DataMgr> EmbeddedDatabase::DBEngineImpl::data_mgr_
private

Definition at line 154 of file DBEngine.cpp.

◆ database_

Catalog_Namespace::DBMetadata EmbeddedDatabase::DBEngineImpl::database_
private

Definition at line 155 of file DBEngine.cpp.

◆ OMNISCI_DATA_PATH

const std::string EmbeddedDatabase::DBEngineImpl::OMNISCI_DATA_PATH = "//mapd_data"

Definition at line 97 of file DBEngine.cpp.

◆ OMNISCI_DEFAULT_DB

const std::string EmbeddedDatabase::DBEngineImpl::OMNISCI_DEFAULT_DB = "omnisci"

Definition at line 95 of file DBEngine.cpp.

◆ OMNISCI_ROOT_USER

const std::string EmbeddedDatabase::DBEngineImpl::OMNISCI_ROOT_USER = "admin"

Definition at line 96 of file DBEngine.cpp.

◆ query_runner_

QueryRunner::QueryRunner* EmbeddedDatabase::DBEngineImpl::query_runner_
private

Definition at line 157 of file DBEngine.cpp.

◆ user_

Catalog_Namespace::UserMetadata EmbeddedDatabase::DBEngineImpl::user_
private

Definition at line 156 of file DBEngine.cpp.


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