OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBEngine.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <arrow/table.h>
20 #include "DBETypes.h"
21 
22 namespace EmbeddedDatabase {
23 
24 class Cursor {
25  public:
26  virtual ~Cursor() {}
27  size_t getColCount();
28  size_t getRowCount();
29  Row getNextRow();
30  ColumnType getColType(uint32_t col_num);
31  std::shared_ptr<arrow::RecordBatch> getArrowRecordBatch();
32 
33  protected:
34  Cursor() {}
35  Cursor(const Cursor&) = delete;
36  Cursor& operator=(const Cursor&) = delete;
37 };
38 
39 class DBEngine {
40  public:
41  virtual ~DBEngine() {}
42  void executeDDL(const std::string& query);
43  std::shared_ptr<Cursor> executeDML(const std::string& query);
44  std::shared_ptr<Cursor> executeRA(const std::string& query);
45  void importArrowTable(const std::string& name,
46  std::shared_ptr<arrow::Table>& table,
47  uint64_t fragment_size = 0);
48  static std::shared_ptr<DBEngine> create(const std::string& cmd_line);
49  std::vector<std::string> getTables();
50  std::vector<ColumnDetails> getTableDetails(const std::string& table_name);
51  bool setDatabase(std::string& db_name);
52  bool login(std::string& db_name, std::string& user_name, const std::string& password);
53 
54  protected:
55  DBEngine() {}
56  DBEngine(const DBEngine&) = delete;
57  DBEngine& operator=(const DBEngine&) = delete;
58 };
59 } // namespace EmbeddedDatabase
DBEngine & operator=(const DBEngine &)=delete
void importArrowTable(const std::string &name, std::shared_ptr< arrow::Table > &table, uint64_t fragment_size=0)
Definition: DBEngine.cpp:485
bool setDatabase(std::string &db_name)
Definition: DBEngine.cpp:502
std::vector< ColumnDetails > getTableDetails(const std::string &table_name)
Definition: DBEngine.cpp:497
std::shared_ptr< Cursor > executeDML(const std::string &query)
Definition: DBEngine.cpp:475
std::shared_ptr< arrow::RecordBatch > getArrowRecordBatch()
Definition: DBEngine.cpp:546
Cursor & operator=(const Cursor &)=delete
std::vector< std::string > getTables()
Definition: DBEngine.cpp:492
static std::shared_ptr< DBEngine > create(const std::string &cmd_line)
Definition: DBEngine.cpp:450
bool login(std::string &db_name, std::string &user_name, const std::string &password)
Definition: DBEngine.cpp:507
ColumnType getColType(uint32_t col_num)
Definition: DBEngine.cpp:541
string name
Definition: setup.in.py:72
void executeDDL(const std::string &query)
Definition: DBEngine.cpp:470
std::shared_ptr< Cursor > executeRA(const std::string &query)
Definition: DBEngine.cpp:480