mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
mutable.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <mutable/mutable-config.hpp>
4
5#include <filesystem>
13#include <mutable/IR/CNF.hpp>
19#include <mutable/IR/Tuple.hpp>
20#include <mutable/lex/Token.hpp>
22#include <mutable/parse/AST.hpp>
25#include <mutable/util/ADT.hpp>
31#include <mutable/util/fn.hpp>
34#include <mutable/util/Pool.hpp>
37#include <mutable/version.hpp>
38
39
40namespace m {
41
46bool M_EXPORT init(void);
47
49std::unique_ptr<ast::Stmt> M_EXPORT statement_from_string(Diagnostic &diag, const std::string &str);
50
52std::unique_ptr<ast::Instruction> M_EXPORT instruction_from_string(Diagnostic &diag, const std::string &str);
53
55std::unique_ptr<DatabaseCommand> M_EXPORT command_from_string(Diagnostic &diag, const std::string &str);
56
58void M_EXPORT execute_statement(Diagnostic &diag, const ast::Stmt &stmt, bool is_stdin = false);
59
61void M_EXPORT process_stream(std::istream &in, const char *filename, Diagnostic diag);
62
64void M_EXPORT execute_instruction(Diagnostic &diag, const ast::Instruction &instruction);
65
67std::unique_ptr<Consumer> M_EXPORT logical_plan_from_statement(Diagnostic &diag, const ast::SelectStmt &stmt,
68 std::unique_ptr<Consumer> consumer);
70std::unique_ptr<MatchBase> M_EXPORT physical_plan_from_logical_plan(Diagnostic &diag, const Consumer &logical_plan);
72std::unique_ptr<MatchBase> M_EXPORT physical_plan_from_logical_plan(Diagnostic &diag, const Consumer &logical_plan,
73 const Backend &backend);
74
76void M_EXPORT execute_physical_plan(Diagnostic &diag, const MatchBase &physical_plan);
78void M_EXPORT execute_physical_plan(Diagnostic &diag, const MatchBase &physical_plan, const Backend &backend);
79
82[[deprecated("Use command_from_string() instead.")]]
83void M_EXPORT execute_query(Diagnostic &diag, const ast::SelectStmt &stmt, std::unique_ptr<Consumer> consumer);
85[[deprecated("Use command_from_string() instead.")]]
86void M_EXPORT execute_query(Diagnostic &diag, const ast::SelectStmt &stmt, std::unique_ptr<Consumer> consumer,
87 const Backend &backend);
88
99void M_EXPORT load_from_CSV(Diagnostic &diag,
100 Table &table,
101 const std::filesystem::path &path,
102 std::size_t num_rows = std::numeric_limits<std::size_t>::max(),
103 bool has_header = false,
104 bool skip_header = false);
105
112void M_EXPORT execute_file(Diagnostic &diag, const std::filesystem::path &path);
113
115struct M_EXPORT StoreWriter
116{
117 private:
120 mutable std::unique_ptr<m::StackMachine> writer_;
121 mutable const storage::DataLayout *layout_ = nullptr;
122
123 public:
124 StoreWriter(Store &store);
125 ~StoreWriter();
126
128 const Schema & schema() const { return S; }
129
131 void append(const Tuple &tup) const;
132};
133
134}
‍mutable namespace
Definition: Backend.hpp:10
void M_EXPORT load_from_CSV(Diagnostic &diag, Table &table, const std::filesystem::path &path, std::size_t num_rows=std::numeric_limits< std::size_t >::max(), bool has_header=false, bool skip_header=false)
Loads a CSV file into a Table.
Definition: mutable.cpp:385
std::unique_ptr< Consumer > M_EXPORT logical_plan_from_statement(Diagnostic &diag, const ast::SelectStmt &stmt, std::unique_ptr< Consumer > consumer)
Optimizes the given SelectStmt.
Definition: mutable.cpp:322
void M_EXPORT process_stream(std::istream &in, const char *filename, Diagnostic diag)
Extracts and executes statements from given stream.
Definition: mutable.cpp:67
std::unique_ptr< DatabaseCommand > M_EXPORT command_from_string(Diagnostic &diag, const std::string &str)
Create a DatabaseCommand from str.
Definition: mutable.cpp:46
void M_EXPORT execute_statement(Diagnostic &diag, const ast::Stmt &stmt, bool is_stdin=false)
Optimizes and executes the given Stmt.
Definition: mutable.cpp:112
std::unique_ptr< ast::Instruction > M_EXPORT instruction_from_string(Diagnostic &diag, const std::string &str)
Use lexer and parser to create an Instruction from str.
Definition: mutable.cpp:97
void M_EXPORT execute_instruction(Diagnostic &diag, const ast::Instruction &instruction)
Executes the given Instruction.
Definition: mutable.cpp:309
void M_EXPORT execute_physical_plan(Diagnostic &diag, const MatchBase &physical_plan)
Executes the given physical plan.
Definition: mutable.cpp:354
void M_EXPORT execute_file(Diagnostic &diag, const std::filesystem::path &path)
Execute the SQL file at path.
Definition: mutable.cpp:410
std::unique_ptr< ast::Stmt > M_EXPORT statement_from_string(Diagnostic &diag, const std::string &str)
Use lexer, parser, and semantic analysis to create a Stmt from str.
Definition: mutable.cpp:25
void M_EXPORT execute_query(Diagnostic &diag, const ast::SelectStmt &stmt, std::unique_ptr< Consumer > consumer)
Optimizes and executes the given SelectStmt.
Definition: mutable.cpp:368
bool M_EXPORT init(void)
Initializes the mu*t*able library.
Definition: mutable.cpp:23
std::unique_ptr< MatchBase > M_EXPORT physical_plan_from_logical_plan(Diagnostic &diag, const Consumer &logical_plan)
Computes a physical plan from the given logical plan.
Definition: mutable.cpp:336
A Schema represents a sequence of identifiers, optionally with a prefix, and their associated types.
Definition: Schema.hpp:39
This class provides direct write access to the contents of a Store.
Definition: mutable.hpp:116
Schema S
the schema of the tuples to read/write
Definition: mutable.hpp:119
std::unique_ptr< m::StackMachine > writer_
the writing StackMachine
Definition: mutable.hpp:120
Store & store_
the store to access
Definition: mutable.hpp:118
const Schema & schema() const
Returns the Schema of Tuples to write.
Definition: mutable.hpp:128
Defines a generic store interface.
Definition: Store.hpp:22
Models how data is laid out in a linear address space.
Definition: DataLayout.hpp:29