quasardb 3.14.2.dev3__cp312-cp312-win_amd64.whl → 3.14.2.dev5__cp312-cp312-win_amd64.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 (105) hide show
  1. quasardb/INSTALL.vcxproj +5 -4
  2. quasardb/__init__.py +21 -7
  3. quasardb/cmake_install.cmake +6 -0
  4. quasardb/date/ALL_BUILD.vcxproj +9 -8
  5. quasardb/date/CMakeFiles/Export/df49adab93b9e0c10c64f72458b31971/dateTargets.cmake +2 -2
  6. quasardb/date/CMakeFiles/generate.stamp.depend +4 -4
  7. quasardb/date/INSTALL.vcxproj +5 -4
  8. quasardb/date/cmake_install.cmake +6 -0
  9. quasardb/date/dateTargets.cmake +2 -2
  10. quasardb/extensions/writer.py +59 -61
  11. quasardb/firehose.py +24 -22
  12. quasardb/numpy/__init__.py +181 -120
  13. quasardb/pandas/__init__.py +145 -95
  14. quasardb/pool.py +13 -2
  15. quasardb/pybind11/ALL_BUILD.vcxproj +9 -8
  16. quasardb/pybind11/CMakeFiles/generate.stamp.depend +14 -14
  17. quasardb/pybind11/INSTALL.vcxproj +5 -4
  18. quasardb/pybind11/cmake_install.cmake +6 -0
  19. quasardb/qdb_api.dll +0 -0
  20. quasardb/quasardb.cp312-win_amd64.pyd +0 -0
  21. quasardb/range-v3/ALL_BUILD.vcxproj +9 -8
  22. quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +2 -2
  23. quasardb/range-v3/CMakeFiles/generate.stamp.depend +11 -11
  24. quasardb/range-v3/INSTALL.vcxproj +5 -4
  25. quasardb/range-v3/cmake_install.cmake +6 -0
  26. quasardb/range-v3/range-v3-config.cmake +2 -2
  27. quasardb/range-v3/range.v3.headers.vcxproj +9 -8
  28. quasardb/stats.py +92 -80
  29. quasardb/table_cache.py +5 -1
  30. {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/METADATA +13 -8
  31. quasardb-3.14.2.dev5.dist-info/RECORD +54 -0
  32. {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/WHEEL +1 -1
  33. quasardb/CMakeLists.txt +0 -517
  34. quasardb/batch_column.hpp +0 -80
  35. quasardb/batch_inserter.hpp +0 -248
  36. quasardb/blob.hpp +0 -150
  37. quasardb/cluster.cpp +0 -102
  38. quasardb/cluster.hpp +0 -593
  39. quasardb/concepts.hpp +0 -322
  40. quasardb/continuous.cpp +0 -199
  41. quasardb/continuous.hpp +0 -109
  42. quasardb/convert/array.hpp +0 -299
  43. quasardb/convert/point.hpp +0 -330
  44. quasardb/convert/range.hpp +0 -282
  45. quasardb/convert/unicode.hpp +0 -598
  46. quasardb/convert/util.hpp +0 -22
  47. quasardb/convert/value.hpp +0 -782
  48. quasardb/convert.hpp +0 -38
  49. quasardb/detail/invoke.hpp +0 -0
  50. quasardb/detail/qdb_resource.hpp +0 -129
  51. quasardb/detail/retry.cpp +0 -30
  52. quasardb/detail/retry.hpp +0 -147
  53. quasardb/detail/sleep.hpp +0 -53
  54. quasardb/detail/ts_column.hpp +0 -224
  55. quasardb/detail/writer.cpp +0 -440
  56. quasardb/detail/writer.hpp +0 -550
  57. quasardb/direct_blob.hpp +0 -108
  58. quasardb/direct_handle.hpp +0 -83
  59. quasardb/direct_integer.hpp +0 -94
  60. quasardb/dispatch.hpp +0 -157
  61. quasardb/double.hpp +0 -87
  62. quasardb/entry.hpp +0 -273
  63. quasardb/error.hpp +0 -393
  64. quasardb/handle.cpp +0 -29
  65. quasardb/handle.hpp +0 -98
  66. quasardb/integer.hpp +0 -88
  67. quasardb/logger.cpp +0 -106
  68. quasardb/logger.hpp +0 -228
  69. quasardb/masked_array.hpp +0 -658
  70. quasardb/metrics.cpp +0 -103
  71. quasardb/metrics.hpp +0 -112
  72. quasardb/module.cpp +0 -92
  73. quasardb/module.hpp +0 -24
  74. quasardb/node.hpp +0 -132
  75. quasardb/numpy.cpp +0 -6
  76. quasardb/numpy.hpp +0 -489
  77. quasardb/object_tracker.hpp +0 -282
  78. quasardb/options.hpp +0 -273
  79. quasardb/perf.hpp +0 -336
  80. quasardb/properties.cpp +0 -41
  81. quasardb/properties.hpp +0 -85
  82. quasardb/pytypes.hpp +0 -221
  83. quasardb/query.cpp +0 -420
  84. quasardb/query.hpp +0 -92
  85. quasardb/reader.cpp +0 -282
  86. quasardb/reader.hpp +0 -256
  87. quasardb/remove_cvref.hpp +0 -31
  88. quasardb/string.hpp +0 -160
  89. quasardb/table.cpp +0 -257
  90. quasardb/table.hpp +0 -366
  91. quasardb/tag.hpp +0 -77
  92. quasardb/timestamp.hpp +0 -97
  93. quasardb/traits.hpp +0 -642
  94. quasardb/ts_iterator.hpp +0 -193
  95. quasardb/utils/blob_deque.hpp +0 -96
  96. quasardb/utils/ostream.hpp +0 -17
  97. quasardb/utils/permutation.hpp +0 -50
  98. quasardb/utils/stable_sort.hpp +0 -25
  99. quasardb/utils/unzip_view.hpp +0 -89
  100. quasardb/utils.cpp +0 -28
  101. quasardb/utils.hpp +0 -174
  102. quasardb/writer.hpp +0 -354
  103. quasardb-3.14.2.dev3.dist-info/RECORD +0 -124
  104. {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/LICENSE.md +0 -0
  105. {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/top_level.txt +0 -0
quasardb/error.hpp DELETED
@@ -1,393 +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 "logger.hpp"
34
- #include "traits.hpp"
35
- #include <qdb/client.h>
36
- #include <qdb/error.h>
37
- #include <qdb/query.h>
38
- #include "detail/qdb_resource.hpp"
39
- #include <pybind11/pybind11.h>
40
- #include <iostream>
41
- #include <utility>
42
-
43
- namespace py = pybind11;
44
-
45
- namespace qdb
46
- {
47
-
48
- class exception
49
- {
50
- public:
51
- exception() noexcept
52
- {}
53
-
54
- explicit exception(qdb_error_t err, std::string msg) noexcept
55
- : _error{err}
56
- , _msg(msg)
57
- {}
58
-
59
- virtual const char * what() const noexcept
60
- {
61
- return _msg.c_str();
62
- }
63
-
64
- private:
65
- qdb_error_t _error{qdb_e_ok};
66
- std::string _msg;
67
- };
68
-
69
- class input_buffer_too_small_exception : public exception
70
- {
71
- public:
72
- input_buffer_too_small_exception() noexcept
73
- : exception(qdb_e_network_inbuf_too_small,
74
- std::string(
75
- "Input buffer too small: result set too large. Hint: consider increasing the buffer "
76
- "size using "
77
- "cluster.options().set_client_max_in_buf_size(..) prior to address this error."))
78
- {}
79
- };
80
-
81
- class invalid_handle_exception : public exception
82
- {
83
- public:
84
- invalid_handle_exception() noexcept
85
- : exception(qdb_e_invalid_handle,
86
- std::string("Invalid handle: the connection to the cluster has been closed. Please "
87
- "re-establish a new connection"
88
- "with the QuasarDB cluster."))
89
- {}
90
- };
91
-
92
- class out_of_bounds_exception : public exception
93
- {
94
- public:
95
- out_of_bounds_exception() noexcept
96
- : exception(qdb_e_out_of_bounds, std::string("The requested operation is out of bounds"))
97
- {}
98
-
99
- out_of_bounds_exception(std::string const & what) noexcept
100
- : exception(qdb_e_out_of_bounds, what)
101
- {}
102
- };
103
-
104
- class uninitialized_exception : public exception
105
- {
106
- public:
107
- uninitialized_exception() noexcept
108
- : exception(qdb_e_uninitialized,
109
- std::string("The requested operation is unavailable because the resource is uninitialized"))
110
- {}
111
-
112
- uninitialized_exception(std::string const & what) noexcept
113
- : exception(qdb_e_uninitialized, what)
114
- {}
115
- };
116
-
117
- class incompatible_type_exception : public exception
118
- {
119
- public:
120
- incompatible_type_exception() noexcept
121
- : exception(qdb_e_incompatible_type, std::string("Incompatible type"))
122
- {}
123
-
124
- incompatible_type_exception(std::string const & what) noexcept
125
- : exception(qdb_e_incompatible_type, what)
126
- {}
127
- };
128
-
129
- class not_implemented_exception : public exception
130
- {
131
- public:
132
- not_implemented_exception() noexcept
133
- : exception(qdb_e_not_implemented, std::string("Method or class not implemented"))
134
- {}
135
-
136
- not_implemented_exception(std::string const & what) noexcept
137
- : exception(qdb_e_incompatible_type, what)
138
- {}
139
- };
140
-
141
- class invalid_argument_exception : public exception
142
- {
143
- public:
144
- invalid_argument_exception() noexcept
145
- : exception(qdb_e_invalid_argument, std::string("Invalid argument"))
146
- {}
147
-
148
- invalid_argument_exception(std::string const & what) noexcept
149
- : exception(qdb_e_invalid_argument, what)
150
- {}
151
- };
152
-
153
- class invalid_query_exception : public exception
154
- {
155
- public:
156
- invalid_query_exception() noexcept
157
- : exception(qdb_e_invalid_query, std::string("Invalid query"))
158
- {}
159
-
160
- invalid_query_exception(std::string const & what) noexcept
161
- : exception(qdb_e_invalid_query, what)
162
- {}
163
- };
164
-
165
- class internal_local_exception : public exception
166
- {
167
- public:
168
- internal_local_exception() noexcept
169
- : exception(qdb_e_internal_local, std::string("An unknown local internal error occurred"))
170
- {}
171
-
172
- internal_local_exception(std::string const & what) noexcept
173
- : exception(qdb_e_internal_local, what)
174
- {}
175
- };
176
-
177
- class alias_already_exists_exception : public exception
178
- {
179
- public:
180
- alias_already_exists_exception() noexcept
181
- : exception(qdb_e_alias_already_exists, std::string("Alias already exists"))
182
- {}
183
-
184
- alias_already_exists_exception(std::string const & what) noexcept
185
- : exception(qdb_e_alias_already_exists, what)
186
- {}
187
- };
188
-
189
- class alias_not_found_exception : public exception
190
- {
191
- public:
192
- alias_not_found_exception() noexcept
193
- : exception(qdb_e_alias_not_found, std::string("Alias not found"))
194
- {}
195
-
196
- alias_not_found_exception(std::string const & what) noexcept
197
- : exception(qdb_e_alias_not_found, what)
198
- {}
199
- };
200
-
201
- class try_again_exception : public exception
202
- {
203
- public:
204
- try_again_exception() noexcept
205
- : exception(qdb_e_try_again,
206
- std::string("The operation could not be completed at this time, please try again"))
207
- {}
208
-
209
- try_again_exception(std::string const & what) noexcept
210
- : exception(qdb_e_try_again, what)
211
- {}
212
- };
213
-
214
- class async_pipeline_full_exception : public exception
215
- {
216
- public:
217
- async_pipeline_full_exception() noexcept
218
- : exception(qdb_e_async_pipe_full,
219
- std::string("The async pipelines are currently full, please try again later or slow down "
220
- "your ingestion speed."))
221
- {}
222
-
223
- async_pipeline_full_exception(std::string const & what) noexcept
224
- : exception(qdb_e_async_pipe_full, what)
225
- {}
226
- };
227
-
228
- class invalid_datetime_exception : public exception
229
- {
230
- public:
231
- invalid_datetime_exception() noexcept
232
- : exception(qdb_e_incompatible_type,
233
- std::string("Unable to interpret provided numpy datetime64. Hint: QuasarDB only works with "
234
- "nanosecond precision datetime64. "
235
- "You can correct this by explicitly casting your timestamps to the dtype "
236
- "datetime64[ns]"))
237
- {}
238
-
239
- invalid_datetime_exception(py::object o)
240
- : exception(qdb_e_incompatible_type,
241
- std::string("Unable to interpret provided numpy datetime64: " + (std::string)(py::str(o))
242
- + ". Hint: QuasarDB only works with nanosecond precision datetime64. You can "
243
- "correct this by explicitly casting "
244
- "your timestamps to the dtype datetime64[ns]"))
245
-
246
- {}
247
- };
248
-
249
- namespace detail
250
- {
251
-
252
- struct no_op
253
- {
254
- void operator()() const noexcept
255
- {}
256
- };
257
-
258
- } // namespace detail
259
-
260
- // Allow a callable to be run just before the throw, thus making nice clean-up possible
261
- // (such as calls to `qdb_release`)
262
- // `pre_throw` defaults to a `no_op` functor that does nothing.
263
- template <typename PreThrowFtor = detail::no_op>
264
- inline void qdb_throw_if_error(
265
- qdb_handle_t h, qdb_error_t err, PreThrowFtor && pre_throw = detail::no_op{})
266
- {
267
- static_assert(
268
- noexcept(std::forward<PreThrowFtor &&>(pre_throw)()), "`pre_throw` argument must be noexcept");
269
-
270
- // HACKS(leon): we need to flush our log buffer a lot, ideally after every native qdb
271
- // call. Guess which function is invoked exactly at those moments?
272
- qdb::native::flush();
273
-
274
- if ((qdb_e_ok != err) && (qdb_e_ok_created != err)) [[unlikely]]
275
- {
276
- detail::qdb_resource<qdb_string_t> msg_{h, nullptr};
277
- qdb_error_t err_;
278
- qdb_get_last_error(h, &err_, &msg_);
279
-
280
- if (err_ != err) [[unlikely]]
281
- {
282
- // Error context returned is not the same, which means this thread already made
283
- // another call to the QDB API, or the QDB API itself
284
-
285
- switch (err)
286
- {
287
- case qdb_e_not_connected:
288
- case qdb_e_invalid_handle:
289
- throw qdb::invalid_handle_exception{};
290
-
291
- case qdb_e_invalid_argument:
292
- throw qdb::invalid_argument_exception{};
293
-
294
- case qdb_e_try_again:
295
- throw qdb::try_again_exception{};
296
-
297
- case qdb_e_async_pipe_full:
298
- throw qdb::async_pipeline_full_exception{};
299
-
300
- default:
301
- throw qdb::exception{err, qdb_error(err)};
302
- }
303
- }
304
- assert(err_ == err);
305
- assert(msg_ != nullptr);
306
-
307
- pre_throw();
308
-
309
- std::string msg_data_{msg_.get()->data};
310
-
311
- switch (err)
312
- {
313
-
314
- case qdb_e_invalid_query:
315
- throw qdb::invalid_query_exception{msg_data_};
316
-
317
- case qdb_e_out_of_bounds:
318
- throw qdb::out_of_bounds_exception{msg_data_};
319
-
320
- case qdb_e_not_connected:
321
- case qdb_e_invalid_handle:
322
- throw qdb::invalid_handle_exception{};
323
-
324
- case qdb_e_alias_already_exists:
325
- throw qdb::alias_already_exists_exception{msg_data_};
326
-
327
- case qdb_e_alias_not_found:
328
- throw qdb::alias_not_found_exception{msg_data_};
329
-
330
- case qdb_e_network_inbuf_too_small:
331
- throw qdb::input_buffer_too_small_exception{};
332
-
333
- case qdb_e_incompatible_type:
334
- throw qdb::incompatible_type_exception{msg_data_};
335
-
336
- case qdb_e_not_implemented:
337
- throw qdb::not_implemented_exception{msg_data_};
338
-
339
- case qdb_e_internal_local:
340
- throw qdb::internal_local_exception{msg_data_};
341
-
342
- case qdb_e_invalid_argument:
343
- throw qdb::invalid_argument_exception{msg_data_};
344
-
345
- case qdb_e_try_again:
346
- throw qdb::try_again_exception{msg_data_};
347
-
348
- case qdb_e_async_pipe_full:
349
- throw qdb::async_pipeline_full_exception{msg_data_};
350
-
351
- default:
352
- throw qdb::exception{err_, msg_data_};
353
- };
354
- }
355
- }
356
-
357
- template <typename PreThrowFtor = detail::no_op>
358
- inline void qdb_throw_if_query_error(qdb_handle_t h, qdb_error_t err, qdb_query_result_t const * result)
359
- {
360
- if (err == qdb_e_invalid_query && result != nullptr
361
- && traits::is_null(result->error_message) == false) [[unlikely]]
362
- {
363
- throw qdb::invalid_query_exception{
364
- std::string{result->error_message.data, result->error_message.length}};
365
- }
366
-
367
- return qdb_throw_if_error(h, err);
368
- }
369
-
370
- template <typename Module>
371
- static inline void register_errors(Module & m)
372
- {
373
- auto base_class = py::register_exception<qdb::exception>(m, "Error", PyExc_RuntimeError);
374
-
375
- py::register_exception<qdb::input_buffer_too_small_exception>(
376
- m, "InputBufferTooSmallError", base_class);
377
- py::register_exception<qdb::alias_already_exists_exception>(
378
- m, "AliasAlreadyExistsError", base_class);
379
- py::register_exception<qdb::alias_not_found_exception>(m, "AliasNotFoundError", base_class);
380
- py::register_exception<qdb::uninitialized_exception>(m, "UninitializedError", base_class);
381
- py::register_exception<qdb::invalid_datetime_exception>(m, "InvalidDatetimeError", base_class);
382
- py::register_exception<qdb::incompatible_type_exception>(m, "IncompatibleTypeError", base_class);
383
- py::register_exception<qdb::not_implemented_exception>(m, "NotImplementedError", base_class);
384
- py::register_exception<qdb::internal_local_exception>(m, "InternalLocalError", base_class);
385
- py::register_exception<qdb::invalid_argument_exception>(m, "InvalidArgumentError", base_class);
386
- py::register_exception<qdb::invalid_query_exception>(m, "InvalidQueryError", base_class);
387
- py::register_exception<qdb::invalid_handle_exception>(m, "InvalidHandleError", base_class);
388
- py::register_exception<qdb::try_again_exception>(m, "TryAgainError", base_class);
389
- py::register_exception<qdb::async_pipeline_full_exception>(m, "AsyncPipelineFullError", base_class);
390
- py::register_exception<qdb::out_of_bounds_exception>(m, "OutOfBoundsError", base_class);
391
- }
392
-
393
- } // namespace qdb
quasardb/handle.cpp DELETED
@@ -1,29 +0,0 @@
1
- #include "handle.hpp"
2
- #include "metrics.hpp"
3
-
4
- namespace qdb
5
- {
6
-
7
- void handle::connect(const std::string & uri)
8
- {
9
- qdb_error_t err;
10
- {
11
- metrics::scoped_capture{"qdb_connect"};
12
- err = qdb_connect(handle_, uri.c_str());
13
- }
14
- qdb::qdb_throw_if_error(handle_, err);
15
- }
16
-
17
- void handle::close()
18
- {
19
- if (handle_ != nullptr)
20
- {
21
- metrics::scoped_capture{"qdb_close"};
22
- qdb_close(handle_);
23
- handle_ = nullptr;
24
- }
25
-
26
- assert(handle_ == nullptr);
27
- }
28
-
29
- }; // namespace qdb
quasardb/handle.hpp DELETED
@@ -1,98 +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 "error.hpp"
34
- #include <qdb/client.h>
35
- #include <memory>
36
- #include <string>
37
-
38
- namespace qdb
39
- {
40
-
41
- class handle
42
- {
43
- public:
44
- handle() noexcept
45
- : handle_{nullptr}
46
- {}
47
-
48
- explicit handle(qdb_handle_t h) noexcept
49
- : handle_{h}
50
- {}
51
-
52
- ~handle()
53
- {
54
- close();
55
- }
56
-
57
- void connect(const std::string & uri);
58
-
59
- operator qdb_handle_t() const noexcept
60
- {
61
- return handle_;
62
- }
63
-
64
- void close();
65
-
66
- constexpr inline bool is_open() const
67
- {
68
- return handle_ != nullptr;
69
- }
70
-
71
- /**
72
- * Throws exception if the connection is not open. Should be invoked before any operation
73
- * is done on the handle, as the QuasarDB C API only checks for a canary presence in the
74
- * handle's memory arena. If a compiler is optimizing enough, the handle can be closed but
75
- * the canary still present in memory, so it's UB.
76
- *
77
- * As such, we should check on a higher level.
78
- */
79
- inline void check_open() const
80
- {
81
- if (is_open() == false) [[unlikely]]
82
- {
83
- throw qdb::invalid_handle_exception{};
84
- }
85
- }
86
-
87
- private:
88
- qdb_handle_t handle_{nullptr};
89
- };
90
-
91
- using handle_ptr = std::shared_ptr<handle>;
92
-
93
- static inline handle_ptr make_handle_ptr()
94
- {
95
- return std::make_shared<qdb::handle>(qdb_open_tcp());
96
- }
97
-
98
- } // namespace qdb
quasardb/integer.hpp DELETED
@@ -1,88 +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/integer.h>
35
-
36
- namespace qdb
37
- {
38
-
39
- class integer_entry : public expirable_entry
40
- {
41
- public:
42
- integer_entry(handle_ptr h, std::string a) noexcept
43
- : expirable_entry{h, a}
44
- {}
45
-
46
- public:
47
- qdb_int_t get()
48
- {
49
- qdb_int_t result;
50
- qdb::qdb_throw_if_error(*_handle, qdb_int_get(*_handle, _alias.c_str(), &result));
51
- return result;
52
- }
53
-
54
- void put(qdb_int_t integer)
55
- {
56
- qdb::qdb_throw_if_error(
57
- *_handle, qdb_int_put(*_handle, _alias.c_str(), integer, qdb_time_t{0}));
58
- }
59
-
60
- void update(qdb_int_t integer)
61
- {
62
- qdb::qdb_throw_if_error(
63
- *_handle, qdb_int_update(*_handle, _alias.c_str(), integer, qdb_time_t{0}));
64
- }
65
-
66
- qdb_int_t add(qdb_int_t integer)
67
- {
68
- qdb_int_t result;
69
- qdb::qdb_throw_if_error(*_handle, qdb_int_add(*_handle, _alias.c_str(), integer, &result));
70
- return result;
71
- }
72
- };
73
-
74
- template <typename Module>
75
- static inline void register_integer(Module & m)
76
- {
77
- namespace py = pybind11;
78
-
79
- py::class_<qdb::integer_entry, qdb::expirable_entry>(m, "Integer") //
80
- .def(py::init<qdb::handle_ptr, std::string>()) //
81
- .def("get", &qdb::integer_entry::get) //
82
- .def("put", &qdb::integer_entry::put, py::arg("integer")) //
83
- .def("update", &qdb::integer_entry::update, py::arg("integer")) //
84
- .def("add", &qdb::integer_entry::add, py::arg("addend")) //
85
- ; //
86
- }
87
-
88
- } // namespace qdb