18 #include <boost/filesystem.hpp> 19 #include <boost/variant.hpp> 38 std::shared_ptr<Data_Namespace::DataMgr> data_mgr)
39 : result_set_(result_set), data_mgr_(data_mgr) {}
46 auto row = result_set_->getNextRow(
true,
false);
54 if (col_num < getColCount()) {
55 SQLTypeInfo type_info = result_set_->getColType(col_num);
97 const std::string OMNISCI_DATA_PATH =
"//mapd_data";
101 if (query_runner_ !=
nullptr) {
102 query_runner_->reset();
107 if (query_runner_ !=
nullptr) {
108 query_runner_->runDDLStatement(query);
113 if (query_runner_ !=
nullptr) {
115 cursors_.emplace_back(
new CursorImpl(rs, data_mgr_));
116 return cursors_.back();
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";
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);
133 sys_cat.init(base_path_, data_mgr_, {}, calcite,
false,
false, {});
134 if (!sys_cat.getSqliteConnector()) {
135 std::cerr <<
"SqliteConnector is null " << std::endl;
137 sys_cat.getMetadataForDB(OMNISCI_DEFAULT_DB, database_);
138 auto catalog = sys_cat.getCatalog(base_path_,
141 std::vector<LeafHostInfo>(),
144 sys_cat.getMetadataForUser(OMNISCI_ROOT_USER, user_);
145 auto session = std::make_unique<Catalog_Namespace::SessionInfo>(
203 if (col_num <
row_.size()) {
204 const auto scalar_value = boost::get<ScalarTargetValue>(&
row_[col_num]);
205 const auto value = boost::get<int64_t>(scalar_value);
212 if (col_num <
row_.size()) {
213 const auto scalar_value = boost::get<ScalarTargetValue>(&
row_[col_num]);
214 const auto value = boost::get<double>(scalar_value);
221 if (col_num <
row_.size()) {
222 const auto scalar_value = boost::get<ScalarTargetValue>(&
row_[col_num]);
223 auto value = boost::get<NullableString>(scalar_value);
224 bool is_null = !value || boost::get<void*>(value);
228 auto value_notnull = boost::get<std::string>(value);
229 return *value_notnull;
232 return "Out of range";
std::string getStr(size_t col_num)
std::vector< CursorImpl * > cursors_
double getDouble(size_t col_num)
Cursor * executeDML(const std::string &query)
void executeDDL(std::string query)
void executeDDL(const std::string &query)
Constants for Builtin SQL Types supported by OmniSci.
ColumnType getColType(uint32_t col_num)
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)
int64_t getInt(size_t col_num)
CursorImpl(std::shared_ptr< ResultSet > result_set, std::shared_ptr< Data_Namespace::DataMgr > data_mgr)
This file contains the class specification and related data structures for Catalog.
static SysCatalog & instance()
CONSTEXPR DEVICE bool is_null(const T &value)
std::shared_ptr< ResultSet > result_set_
const std::string OMNISCI_DEFAULT_DB
static DBEngine * create(std::string path)
std::weak_ptr< Data_Namespace::DataMgr > data_mgr_
Catalog_Namespace::UserMetadata user_
DBEngineImpl(const std::string &base_path)
const std::string OMNISCI_ROOT_USER
std::vector< TargetValue > row_
int getColType(uint32_t col_num)
QueryRunner::QueryRunner * query_runner_
Catalog_Namespace::DBMetadata database_
HOST DEVICE SQLTypes get_type() const
DBEngineImpl * getImpl(DBEngine *ptr)
Basic constructors and methods of the row set interface.
std::shared_ptr< Data_Namespace::DataMgr > data_mgr_
Cursor * executeDML(std::string query)