-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocumentdb.hpp
More file actions
63 lines (51 loc) · 1.4 KB
/
Copy pathdocumentdb.hpp
File metadata and controls
63 lines (51 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <string>
#include <vector>
namespace documentdb {
struct ConnectionConfig {
std::string host = "localhost";
int port = 27017;
std::string database;
std::string user;
std::string password;
std::string auth_source;
bool tls = false;
bool tls_allow_invalid_certificates = false;
int server_selection_timeout_ms = 5000;
};
struct Document {
std::string raw_json;
std::string collection;
};
struct FieldType {
std::string name;
std::string duckdb_type;
};
struct ScanPlan {
std::string collection_name;
std::string filter;
std::vector<std::string> projections;
bool has_limit = false;
int limit = 0;
};
class Connection {
public:
explicit Connection(const ConnectionConfig& config);
std::vector<std::string> list_collections() const;
std::vector<Document> scan(const std::string& collection_name,
const std::string& filter_json = "{}") const;
private:
ConnectionConfig config_;
};
class SchemaResolver {
public:
static std::vector<FieldType> infer_from_samples(const std::vector<std::string>& samples);
};
class ScanPlanner {
public:
static ScanPlan plan(const std::string& collection_name,
const std::string& filter,
const std::vector<std::string>& selected_columns,
int limit);
};
} // namespace documentdb