quasardb 3.14.2.dev1__cp310-cp310-win32.whl → 3.14.2.dev4__cp310-cp310-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of quasardb might be problematic. Click here for more details.

Files changed (96) hide show
  1. quasardb/INSTALL.vcxproj +10 -5
  2. quasardb/__init__.py +33 -4
  3. quasardb/cmake_install.cmake +6 -0
  4. quasardb/date/ALL_BUILD.vcxproj +10 -9
  5. quasardb/date/CMakeFiles/Export/df49adab93b9e0c10c64f72458b31971/dateTargets.cmake +13 -13
  6. quasardb/date/CMakeFiles/generate.stamp.depend +4 -4
  7. quasardb/date/INSTALL.vcxproj +10 -5
  8. quasardb/date/cmake_install.cmake +6 -0
  9. quasardb/date/dateConfigVersion.cmake +0 -5
  10. quasardb/date/dateTargets.cmake +4 -8
  11. quasardb/numpy/__init__.py +58 -10
  12. quasardb/pandas/__init__.py +58 -102
  13. quasardb/pybind11/ALL_BUILD.vcxproj +10 -9
  14. quasardb/pybind11/CMakeFiles/generate.stamp.depend +14 -14
  15. quasardb/pybind11/INSTALL.vcxproj +10 -5
  16. quasardb/pybind11/cmake_install.cmake +6 -0
  17. quasardb/qdb_api.dll +0 -0
  18. quasardb/quasardb.cp310-win32.pyd +0 -0
  19. quasardb/range-v3/ALL_BUILD.vcxproj +10 -9
  20. quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +13 -13
  21. quasardb/range-v3/CMakeFiles/generate.stamp.depend +11 -11
  22. quasardb/range-v3/INSTALL.vcxproj +10 -5
  23. quasardb/range-v3/cmake_install.cmake +42 -0
  24. quasardb/range-v3/range-v3-config-version.cmake +0 -5
  25. quasardb/range-v3/range-v3-config.cmake +4 -8
  26. quasardb/range-v3/range.v3.headers.vcxproj +10 -9
  27. {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/METADATA +15 -10
  28. quasardb-3.14.2.dev4.dist-info/RECORD +54 -0
  29. {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/WHEEL +1 -1
  30. quasardb/CMakeLists.txt +0 -510
  31. quasardb/batch_column.hpp +0 -80
  32. quasardb/batch_inserter.hpp +0 -248
  33. quasardb/blob.hpp +0 -150
  34. quasardb/cluster.cpp +0 -89
  35. quasardb/cluster.hpp +0 -551
  36. quasardb/concepts.hpp +0 -278
  37. quasardb/continuous.cpp +0 -149
  38. quasardb/continuous.hpp +0 -106
  39. quasardb/convert/array.hpp +0 -282
  40. quasardb/convert/point.hpp +0 -330
  41. quasardb/convert/range.hpp +0 -282
  42. quasardb/convert/unicode.hpp +0 -598
  43. quasardb/convert/util.hpp +0 -22
  44. quasardb/convert/value.hpp +0 -711
  45. quasardb/convert.hpp +0 -38
  46. quasardb/detail/qdb_resource.hpp +0 -129
  47. quasardb/detail/ts_column.hpp +0 -224
  48. quasardb/direct_blob.hpp +0 -108
  49. quasardb/direct_handle.hpp +0 -83
  50. quasardb/direct_integer.hpp +0 -94
  51. quasardb/dispatch.hpp +0 -157
  52. quasardb/double.hpp +0 -87
  53. quasardb/entry.hpp +0 -273
  54. quasardb/error.hpp +0 -318
  55. quasardb/handle.cpp +0 -29
  56. quasardb/handle.hpp +0 -98
  57. quasardb/integer.hpp +0 -88
  58. quasardb/logger.cpp +0 -106
  59. quasardb/logger.hpp +0 -228
  60. quasardb/masked_array.hpp +0 -651
  61. quasardb/metrics.cpp +0 -103
  62. quasardb/metrics.hpp +0 -112
  63. quasardb/module.cpp +0 -76
  64. quasardb/module.hpp +0 -24
  65. quasardb/node.hpp +0 -123
  66. quasardb/numpy.cpp +0 -6
  67. quasardb/numpy.hpp +0 -489
  68. quasardb/object_tracker.hpp +0 -283
  69. quasardb/options.hpp +0 -244
  70. quasardb/perf.hpp +0 -336
  71. quasardb/pytypes.hpp +0 -221
  72. quasardb/query.cpp +0 -420
  73. quasardb/query.hpp +0 -92
  74. quasardb/reader/ts_row.hpp +0 -281
  75. quasardb/reader/ts_value.hpp +0 -245
  76. quasardb/remove_cvref.hpp +0 -31
  77. quasardb/string.hpp +0 -160
  78. quasardb/table.cpp +0 -289
  79. quasardb/table.hpp +0 -325
  80. quasardb/table_reader.hpp +0 -220
  81. quasardb/tag.hpp +0 -77
  82. quasardb/timestamp.hpp +0 -97
  83. quasardb/traits.hpp +0 -619
  84. quasardb/ts_iterator.hpp +0 -193
  85. quasardb/utils/blob_deque.hpp +0 -96
  86. quasardb/utils/ostream.hpp +0 -17
  87. quasardb/utils/permutation.hpp +0 -50
  88. quasardb/utils/stable_sort.hpp +0 -25
  89. quasardb/utils/unzip_view.hpp +0 -89
  90. quasardb/utils.cpp +0 -28
  91. quasardb/utils.hpp +0 -174
  92. quasardb/writer.cpp +0 -534
  93. quasardb/writer.hpp +0 -396
  94. quasardb-3.14.2.dev1.dist-info/RECORD +0 -118
  95. {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/LICENSE.md +0 -0
  96. {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/top_level.txt +0 -0
@@ -1,248 +0,0 @@
1
- /*
2
- *
3
- * Official Python API
4
- *
5
- * Copyright (c) 2009-2024, quasardb SAS. All rights reserved.
6
- * All rights reserved.
7
- *
8
- * Redistribution and use in source and binary forms, with or without
9
- * modification, are permitted provided that the following conditions are met:
10
- *
11
- * * Redistributions of source code must retain the above copyright
12
- * notice, this list of conditions and the following disclaimer.
13
- * * Redistributions in binary form must reproduce the above copyright
14
- * notice, this list of conditions and the following disclaimer in the
15
- * documentation and/or other materials provided with the distribution.
16
- * * Neither the name of quasardb nor the names of its contributors may
17
- * be used to endorse or promote products derived from this software
18
- * without specific prior written permission.
19
- *
20
- * THIS SOFTWARE IS PROVIDED BY QUASARDB AND CONTRIBUTORS ``AS IS'' AND ANY
21
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
24
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- */
31
- #pragma once
32
-
33
- #include "batch_column.hpp"
34
- #include "entry.hpp"
35
- #include "logger.hpp"
36
- #include "table.hpp"
37
- #include "utils.hpp"
38
- #include "convert/value.hpp"
39
-
40
- namespace qdb
41
- {
42
-
43
- class batch_inserter
44
- {
45
-
46
- public:
47
- batch_inserter(qdb::handle_ptr h, const std::vector<batch_column_info> & ci)
48
- : _logger("quasardb.batch_inserter")
49
- , _handle{h}
50
- , _row_count{0}
51
- , _point_count{0}
52
- , _min_max_ts{qdb_min_timespec, qdb_min_timespec}
53
- {
54
- std::vector<qdb_ts_batch_column_info_t> converted(ci.size());
55
-
56
- std::transform(ci.cbegin(), ci.cend(), converted.begin(),
57
- [](const batch_column_info & ci) -> qdb_ts_batch_column_info_t { return ci; });
58
-
59
- qdb::qdb_throw_if_error(*_handle,
60
- qdb_ts_batch_table_init(*_handle, converted.data(), converted.size(), &_batch_table));
61
-
62
- _logger.debug("initialized batch reader with %d columns", ci.size());
63
- }
64
-
65
- // prevent copy because of the table object, use a unique_ptr of the batch in cluster
66
- // to return the object
67
- batch_inserter(const batch_inserter &) = delete;
68
-
69
- ~batch_inserter()
70
- {
71
- if (_handle && _batch_table)
72
- {
73
- qdb_release(*_handle, _batch_table);
74
- _batch_table = nullptr;
75
- }
76
- }
77
-
78
- public:
79
- void start_row(py::object ts)
80
- {
81
- qdb_timespec_t const converted = convert::value<py::object, qdb_timespec_t>(ts);
82
- qdb::qdb_throw_if_error(*_handle, qdb_ts_batch_start_row(_batch_table, &converted));
83
-
84
- // The block below is only necessary for insert_truncate, and even then if someone
85
- // does not explicitly provide a time range. It shouldn't be *too* much of a performance
86
- // impact, but maybe we can somehow optimize this away?
87
- if (_min_max_ts.begin == qdb_min_timespec && _min_max_ts.end == qdb_min_timespec)
88
- {
89
- assert(_row_count == 0); // sanity check
90
-
91
- // First row
92
- _min_max_ts.begin = converted;
93
- _min_max_ts.end = converted;
94
- }
95
- else
96
- {
97
- assert(_row_count > 0);
98
- _min_max_ts.begin = std::min(converted, _min_max_ts.begin);
99
- _min_max_ts.end = std::max(converted, _min_max_ts.end);
100
- }
101
-
102
- ++_row_count;
103
- }
104
-
105
- void set_blob(std::size_t index, const py::bytes & blob)
106
- {
107
- std::string tmp = static_cast<std::string>(blob);
108
- qdb::qdb_throw_if_error(*_handle, qdb_ts_batch_row_set_blob(_batch_table, index,
109
- static_cast<void const *>(tmp.c_str()), tmp.length()));
110
- ++_point_count;
111
- }
112
-
113
- void set_string(std::size_t index, const std::string & string)
114
- {
115
- qdb::qdb_throw_if_error(
116
- *_handle, qdb_ts_batch_row_set_string(_batch_table, index, string.data(), string.size()));
117
- }
118
-
119
- void set_double(std::size_t index, double v)
120
- {
121
- qdb::qdb_throw_if_error(*_handle, qdb_ts_batch_row_set_double(_batch_table, index, v));
122
- ++_point_count;
123
- }
124
-
125
- void set_int64(std::size_t index, std::int64_t v)
126
- {
127
- qdb::qdb_throw_if_error(*_handle, qdb_ts_batch_row_set_int64(_batch_table, index, v));
128
- ++_point_count;
129
- }
130
-
131
- void set_timestamp(std::size_t index, py::object v)
132
- {
133
- qdb_timespec_t const converted = convert::value<py::object, qdb_timespec_t>(v);
134
- qdb::qdb_throw_if_error(
135
- *_handle, qdb_ts_batch_row_set_timestamp(_batch_table, index, &converted));
136
- ++_point_count;
137
- }
138
-
139
- void push()
140
- {
141
- _logger.debug("pushing batch of %d rows with %d data points", _row_count, _point_count);
142
- qdb::qdb_throw_if_error(*_handle, qdb_ts_batch_push(_batch_table));
143
- _logger.debug("pushed batch of %d rows with %d data points", _row_count, _point_count);
144
-
145
- _reset_counters();
146
- }
147
-
148
- void push_async()
149
- {
150
- _logger.debug("async pushing batch of %d rows with %d data points", _row_count, _point_count);
151
- qdb::qdb_throw_if_error(*_handle, qdb_ts_batch_push_async(_batch_table));
152
- _logger.debug("async pushed batch of %d rows with %d data points", _row_count, _point_count);
153
-
154
- _reset_counters();
155
- }
156
-
157
- void push_fast()
158
- {
159
- _logger.debug("fast pushing batch of %d rows with %d data points", _row_count, _point_count);
160
- qdb::qdb_throw_if_error(*_handle, qdb_ts_batch_push_fast(_batch_table));
161
- _logger.debug("fast pushed batch of %d rows with %d data points", _row_count, _point_count);
162
-
163
- _reset_counters();
164
- }
165
-
166
- void push_truncate(py::kwargs args)
167
- {
168
- // As we are actively removing data, let's add an additional check to ensure the user
169
- // doesn't accidentally truncate his whole database without inserting anything.
170
- if (_row_count == 0)
171
- {
172
- throw qdb::invalid_argument_exception{
173
- "Batch inserter is empty: you did not provide any rows to push."};
174
- }
175
-
176
- qdb_ts_range_t tr;
177
-
178
- if (args.contains("range"))
179
- {
180
- tr = convert::value<py::tuple, qdb_ts_range_t>(py::cast<py::tuple>(args["range"]));
181
- }
182
- else
183
- {
184
- tr = _min_max_ts;
185
- // our range is end-exclusive, so let's move the pointer one nanosecond
186
- // *after* the last element in this batch.
187
- tr.end.tv_nsec++;
188
- }
189
- _logger.debug("truncate pushing batch of %d rows with %d data points, start timestamp = %d.%d, "
190
- "end timestamp = %d.%d",
191
- _row_count, _point_count, tr.begin.tv_sec, tr.begin.tv_nsec, tr.end.tv_sec, tr.end.tv_nsec);
192
-
193
- qdb::qdb_throw_if_error(*_handle, qdb_ts_batch_push_truncate(_batch_table, &tr, 1));
194
- _logger.debug("truncate pushed batch of %d rows with %d data points", _row_count, _point_count);
195
-
196
- _reset_counters();
197
- }
198
-
199
- private:
200
- void _reset_counters()
201
- {
202
- _row_count = 0;
203
- _point_count = 0;
204
- _min_max_ts.begin = qdb_min_timespec;
205
- _min_max_ts.end = qdb_min_timespec;
206
- }
207
-
208
- private:
209
- qdb::logger _logger;
210
- qdb::handle_ptr _handle;
211
- qdb_batch_table_t _batch_table{nullptr};
212
-
213
- int64_t _row_count;
214
- int64_t _point_count;
215
-
216
- qdb_ts_range_t _min_max_ts;
217
- };
218
-
219
- // don't use shared_ptr, let Python do the reference counting, otherwise you will have an undefined
220
- // behavior
221
- using batch_inserter_ptr = std::unique_ptr<batch_inserter>;
222
-
223
- template <typename Module>
224
- static inline void register_batch_inserter(Module & m)
225
- {
226
- namespace py = pybind11;
227
-
228
- py::class_<qdb::batch_inserter>{m, "TimeSeriesBatch"} //
229
- .def(py::init<qdb::handle_ptr, const std::vector<batch_column_info> &>()) //
230
- .def("start_row", &qdb::batch_inserter::start_row,
231
- "Calling this function marks the beginning of processing a new row.") //
232
- .def("set_blob", &qdb::batch_inserter::set_blob) //
233
- .def("set_string", &qdb::batch_inserter::set_string) //
234
- .def("set_double", &qdb::batch_inserter::set_double) //
235
- .def("set_int64", &qdb::batch_inserter::set_int64) //
236
- .def("set_timestamp", &qdb::batch_inserter::set_timestamp) //
237
- .def("push", &qdb::batch_inserter::push, "Regular batch push") //
238
- .def("push_async", &qdb::batch_inserter::push_async,
239
- "Asynchronous batch push that buffers data inside the QuasarDB daemon") //
240
- .def("push_fast", &qdb::batch_inserter::push_fast,
241
- "Fast, in-place batch push that is efficient when doing lots of small, incremental pushes.")
242
- .def("push_truncate", &qdb::batch_inserter::push_truncate,
243
- "Before inserting data, truncates any existing data. This is useful when you want your "
244
- "insertions to be idempotent, e.g. in "
245
- "case of a retry.");
246
- }
247
-
248
- } // namespace qdb
quasardb/blob.hpp DELETED
@@ -1,150 +0,0 @@
1
- /*
2
- *
3
- * Official Python API
4
- *
5
- * Copyright (c) 2009-2024, quasardb SAS. All rights reserved.
6
- * All rights reserved.
7
- *
8
- * Redistribution and use in source and binary forms, with or without
9
- * modification, are permitted provided that the following conditions are met:
10
- *
11
- * * Redistributions of source code must retain the above copyright
12
- * notice, this list of conditions and the following disclaimer.
13
- * * Redistributions in binary form must reproduce the above copyright
14
- * notice, this list of conditions and the following disclaimer in the
15
- * documentation and/or other materials provided with the distribution.
16
- * * Neither the name of quasardb nor the names of its contributors may
17
- * be used to endorse or promote products derived from this software
18
- * without specific prior written permission.
19
- *
20
- * THIS SOFTWARE IS PROVIDED BY QUASARDB AND CONTRIBUTORS ``AS IS'' AND ANY
21
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
24
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- */
31
- #pragma once
32
-
33
- #include "entry.hpp"
34
- #include <qdb/blob.h>
35
-
36
- namespace qdb
37
- {
38
-
39
- class blob_entry : public expirable_entry
40
- {
41
- public:
42
- blob_entry(handle_ptr h, std::string a) noexcept
43
- : expirable_entry{h, a}
44
- {}
45
-
46
- private:
47
- pybind11::bytes convert_and_release_content(const void * content, qdb_size_t content_length)
48
- {
49
- if (!content || !content_length) return pybind11::bytes{};
50
-
51
- std::string res(static_cast<const char *>(content), content_length);
52
-
53
- qdb_release(*_handle, content);
54
-
55
- return pybind11::bytes(res);
56
- }
57
-
58
- public:
59
- pybind11::bytes get()
60
- {
61
- const void * content = nullptr;
62
- qdb_size_t content_length = 0;
63
-
64
- qdb::qdb_throw_if_error(
65
- *_handle, qdb_blob_get(*_handle, _alias.c_str(), &content, &content_length));
66
-
67
- return convert_and_release_content(content, content_length);
68
- }
69
-
70
- void put(const std::string & data)
71
- {
72
- qdb::qdb_throw_if_error(
73
- *_handle, qdb_blob_put(*_handle, _alias.c_str(), data.data(), data.size(), qdb_time_t{0}));
74
- }
75
-
76
- void update(const std::string & data,
77
- std::chrono::system_clock::time_point expiry = std::chrono::system_clock::time_point{})
78
- {
79
- qdb::qdb_throw_if_error(*_handle,
80
- qdb_blob_update(*_handle, _alias.c_str(), data.data(), data.size(), qdb_time_t{0}));
81
- }
82
-
83
- void remove_if(const std::string & comparand)
84
- {
85
- qdb::qdb_throw_if_error(
86
- *_handle, qdb_blob_remove_if(*_handle, _alias.c_str(), comparand.data(), comparand.size()));
87
- }
88
-
89
- pybind11::bytes get_and_remove()
90
- {
91
- const void * content = nullptr;
92
- qdb_size_t content_length = 0;
93
-
94
- qdb::qdb_throw_if_error(
95
- *_handle, qdb_blob_get_and_remove(*_handle, _alias.c_str(), &content, &content_length));
96
-
97
- return convert_and_release_content(content, content_length);
98
- }
99
-
100
- pybind11::bytes get_and_update(const std::string & data)
101
- {
102
- const void * content = nullptr;
103
- qdb_size_t content_length = 0;
104
-
105
- qdb::qdb_throw_if_error(*_handle, qdb_blob_get_and_update(*_handle, _alias.c_str(), data.data(),
106
- data.size(), qdb_time_t{0}, &content, &content_length));
107
-
108
- return convert_and_release_content(content, content_length);
109
- }
110
-
111
- pybind11::bytes compare_and_swap(const std::string & new_value, const std::string & comparand)
112
- {
113
- const void * content = nullptr;
114
- qdb_size_t content_length = 0;
115
-
116
- qdb_error_t err =
117
- qdb_blob_compare_and_swap(*_handle, _alias.c_str(), new_value.data(), new_value.size(),
118
- comparand.data(), comparand.size(), qdb_time_t{0}, &content, &content_length);
119
-
120
- // we don't want to throw on "unmatching content", so we don't use the qdb::qdb_throw_if_error
121
- // function
122
- if (QDB_FAILURE(err))
123
- {
124
- qdb_throw_if_error(*_handle, err);
125
- }
126
-
127
- return convert_and_release_content(content, content_length);
128
- }
129
- };
130
-
131
- template <typename Module>
132
- static inline void register_blob(Module & m)
133
- {
134
- namespace py = pybind11;
135
-
136
- py::class_<qdb::blob_entry, qdb::expirable_entry>(m, "Blob") //
137
- .def(py::init<qdb::handle_ptr, std::string>()) //
138
- .def("get", &qdb::blob_entry::get) //
139
- .def("put", &qdb::blob_entry::put, py::arg("data")) //
140
- .def("update", &qdb::blob_entry::update, py::arg("data"),
141
- py::arg("expiry") = std::chrono::system_clock::time_point{}) //
142
- .def("remove_if", &qdb::blob_entry::remove_if, py::arg("comparand")) //
143
- .def("get_and_remove", &qdb::blob_entry::get_and_remove) //
144
- .def("get_and_update", &qdb::blob_entry::get_and_update, //
145
- py::arg("data")) //
146
- .def("compare_and_swap", &qdb::blob_entry::compare_and_swap, //
147
- py::arg("new_content"), py::arg("comparand")); //
148
- }
149
-
150
- } // namespace qdb
quasardb/cluster.cpp DELETED
@@ -1,89 +0,0 @@
1
- #include "cluster.hpp"
2
- #include "metrics.hpp"
3
- #include <chrono>
4
- #include <thread>
5
-
6
- namespace qdb
7
- {
8
-
9
- cluster::cluster(const std::string & uri,
10
- const std::string & user_name,
11
- const std::string & user_private_key,
12
- const std::string & cluster_public_key,
13
- const std::string & user_security_file,
14
- const std::string & cluster_public_key_file,
15
- std::chrono::milliseconds timeout,
16
- bool do_version_check)
17
- : _uri{uri}
18
- , _handle{make_handle_ptr()}
19
- , _json_loads{pybind11::module::import("json").attr("loads")}
20
- , _logger("quasardb.cluster")
21
- {
22
- if (do_version_check == true)
23
- {
24
- _logger.warn(
25
- "do_version_check parameter has been deprecated and a no-op. It will be removed from a "
26
- "future release");
27
- }
28
-
29
- options().apply_credentials(user_name, user_private_key, cluster_public_key, //
30
- user_security_file, cluster_public_key_file);
31
-
32
- options().set_timeout(timeout);
33
-
34
- // HACKS(leon): we need to ensure there is always one callback active
35
- // for qdb. Callbacks can be lost when the last active session
36
- // gets closed. As such, the most pragmatic place to 'check'
37
- // for this callback is when establishing a new connection.
38
- qdb::native::swap_callback();
39
-
40
- _logger.info("Connecting to cluster %s", _uri);
41
- _handle->connect(_uri);
42
- }
43
-
44
- void cluster::close()
45
- {
46
- _logger.info("Closing connection to cluster");
47
-
48
- try
49
- {
50
- if (is_open() == true) [[likely]]
51
- {
52
- _handle->close();
53
- }
54
- }
55
- catch (qdb::invalid_handle_exception const & e)
56
- {
57
- // This can happen if, for example, we call close() after an error occured; in those
58
- // circumstances, we fully expect the connection to already be invalid, and we should
59
- // not care if this specific exception is raised.
60
- _logger.warn("Connection already closed");
61
- }
62
-
63
- _handle.reset();
64
-
65
- assert(is_open() == false);
66
- }
67
-
68
- void cluster::wait_for_compaction()
69
- {
70
-
71
- // We define this function in the .cpp file so we can avoid including chrono and thread
72
- // in the header file.
73
-
74
- using namespace std::chrono_literals;
75
-
76
- for (;;)
77
- {
78
- std::uint64_t progress = compact_progress();
79
-
80
- if (progress == 0) [[unlikely]]
81
- {
82
- break;
83
- }
84
-
85
- std::this_thread::sleep_for(100ms);
86
- }
87
- }
88
-
89
- }; // namespace qdb