quasardb 3.14.2.dev0__cp310-cp310-macosx_11_0_arm64.whl → 3.14.2.dev4__cp310-cp310-macosx_11_0_arm64.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 (95) hide show
  1. quasardb/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
  2. quasardb/Makefile +20 -20
  3. quasardb/__init__.py +33 -4
  4. quasardb/cmake_install.cmake +7 -1
  5. quasardb/date/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
  6. quasardb/date/CMakeFiles/Export/a52b05f964b070ee926bcad51d3288af/dateTargets.cmake +13 -13
  7. quasardb/date/Makefile +20 -20
  8. quasardb/date/cmake_install.cmake +7 -1
  9. quasardb/date/dateConfigVersion.cmake +9 -2
  10. quasardb/date/dateTargets.cmake +4 -8
  11. quasardb/libqdb_api.dylib +0 -0
  12. quasardb/numpy/__init__.py +58 -10
  13. quasardb/pandas/__init__.py +58 -102
  14. quasardb/pybind11/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
  15. quasardb/pybind11/Makefile +20 -20
  16. quasardb/pybind11/cmake_install.cmake +7 -1
  17. quasardb/quasardb.cpython-310-darwin.so +0 -0
  18. quasardb/range-v3/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
  19. quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +13 -13
  20. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/DependInfo.cmake +6 -2
  21. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/build.make +7 -4
  22. quasardb/range-v3/Makefile +20 -20
  23. quasardb/range-v3/cmake_install.cmake +19 -1
  24. quasardb/range-v3/range-v3-config-version.cmake +9 -2
  25. quasardb/range-v3/range-v3-config.cmake +4 -8
  26. {quasardb-3.14.2.dev0.dist-info → quasardb-3.14.2.dev4.dist-info}/METADATA +15 -10
  27. quasardb-3.14.2.dev4.dist-info/RECORD +45 -0
  28. {quasardb-3.14.2.dev0.dist-info → quasardb-3.14.2.dev4.dist-info}/WHEEL +1 -1
  29. quasardb/CMakeLists.txt +0 -500
  30. quasardb/batch_column.hpp +0 -80
  31. quasardb/batch_inserter.hpp +0 -248
  32. quasardb/blob.hpp +0 -150
  33. quasardb/cluster.cpp +0 -89
  34. quasardb/cluster.hpp +0 -551
  35. quasardb/concepts.hpp +0 -278
  36. quasardb/continuous.cpp +0 -149
  37. quasardb/continuous.hpp +0 -106
  38. quasardb/convert/array.hpp +0 -282
  39. quasardb/convert/point.hpp +0 -330
  40. quasardb/convert/range.hpp +0 -282
  41. quasardb/convert/unicode.hpp +0 -598
  42. quasardb/convert/util.hpp +0 -22
  43. quasardb/convert/value.hpp +0 -711
  44. quasardb/convert.hpp +0 -38
  45. quasardb/detail/qdb_resource.hpp +0 -129
  46. quasardb/detail/ts_column.hpp +0 -224
  47. quasardb/direct_blob.hpp +0 -108
  48. quasardb/direct_handle.hpp +0 -83
  49. quasardb/direct_integer.hpp +0 -94
  50. quasardb/dispatch.hpp +0 -157
  51. quasardb/double.hpp +0 -87
  52. quasardb/entry.hpp +0 -273
  53. quasardb/error.hpp +0 -318
  54. quasardb/handle.cpp +0 -29
  55. quasardb/handle.hpp +0 -98
  56. quasardb/integer.hpp +0 -88
  57. quasardb/logger.cpp +0 -106
  58. quasardb/logger.hpp +0 -228
  59. quasardb/masked_array.hpp +0 -651
  60. quasardb/metrics.cpp +0 -103
  61. quasardb/metrics.hpp +0 -112
  62. quasardb/module.cpp +0 -76
  63. quasardb/module.hpp +0 -24
  64. quasardb/node.hpp +0 -123
  65. quasardb/numpy.cpp +0 -6
  66. quasardb/numpy.hpp +0 -489
  67. quasardb/object_tracker.hpp +0 -283
  68. quasardb/options.hpp +0 -244
  69. quasardb/perf.hpp +0 -336
  70. quasardb/pytypes.hpp +0 -221
  71. quasardb/query.cpp +0 -420
  72. quasardb/query.hpp +0 -92
  73. quasardb/reader/ts_row.hpp +0 -281
  74. quasardb/reader/ts_value.hpp +0 -245
  75. quasardb/remove_cvref.hpp +0 -31
  76. quasardb/string.hpp +0 -160
  77. quasardb/table.cpp +0 -289
  78. quasardb/table.hpp +0 -325
  79. quasardb/table_reader.hpp +0 -220
  80. quasardb/tag.hpp +0 -77
  81. quasardb/timestamp.hpp +0 -97
  82. quasardb/traits.hpp +0 -619
  83. quasardb/ts_iterator.hpp +0 -193
  84. quasardb/utils/blob_deque.hpp +0 -96
  85. quasardb/utils/ostream.hpp +0 -17
  86. quasardb/utils/permutation.hpp +0 -50
  87. quasardb/utils/stable_sort.hpp +0 -25
  88. quasardb/utils/unzip_view.hpp +0 -89
  89. quasardb/utils.cpp +0 -28
  90. quasardb/utils.hpp +0 -174
  91. quasardb/writer.cpp +0 -534
  92. quasardb/writer.hpp +0 -396
  93. quasardb-3.14.2.dev0.dist-info/RECORD +0 -109
  94. {quasardb-3.14.2.dev0.dist-info → quasardb-3.14.2.dev4.dist-info}/LICENSE.md +0 -0
  95. {quasardb-3.14.2.dev0.dist-info → quasardb-3.14.2.dev4.dist-info}/top_level.txt +0 -0
quasardb/batch_column.hpp DELETED
@@ -1,80 +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 "table.hpp"
34
- #include <qdb/ts.h>
35
- #include <pybind11/pybind11.h>
36
- #include <string>
37
-
38
- namespace qdb
39
- {
40
- struct batch_column_info
41
- {
42
- batch_column_info() = default;
43
- batch_column_info(
44
- const std::string & ts_name, const std::string & col_name, qdb_size_t size_hint = 0)
45
- : timeseries{ts_name}
46
- , column{col_name}
47
- , elements_count_hint{size_hint}
48
- {}
49
-
50
- operator qdb_ts_batch_column_info_t() const noexcept
51
- {
52
- qdb_ts_batch_column_info_t res;
53
-
54
- res.timeseries = timeseries.c_str();
55
- res.column = column.c_str();
56
- res.elements_count_hint = elements_count_hint;
57
- return res;
58
- }
59
-
60
- std::string timeseries;
61
- std::string column;
62
- qdb_size_t elements_count_hint{0};
63
- };
64
-
65
- template <typename Module>
66
- static inline void register_batch_column(Module & m)
67
- {
68
- namespace py = pybind11;
69
-
70
- py::class_<qdb::batch_column_info>{m, "BatchColumnInfo"} //
71
- .def(py::init<const std::string &, const std::string &, qdb_size_t>(), //
72
- py::arg("ts_name"), //
73
- py::arg("col_name"), //
74
- py::arg("size_hint") = 0) //
75
- .def_readwrite("timeseries", &qdb::batch_column_info::timeseries) //
76
- .def_readwrite("column", &qdb::batch_column_info::column) //
77
- .def_readwrite("elements_count_hint", &qdb::batch_column_info::elements_count_hint); //
78
- }
79
-
80
- } // namespace qdb
@@ -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