quasardb 3.14.2.dev3__cp39-cp39-macosx_11_0_arm64.whl → 3.14.2.dev5__cp39-cp39-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 (105) hide show
  1. quasardb/CMakeFiles/CMakeDirectoryInformation.cmake +2 -2
  2. quasardb/Makefile +20 -20
  3. quasardb/__init__.py +21 -7
  4. quasardb/cmake_install.cmake +10 -4
  5. quasardb/date/CMakeFiles/CMakeDirectoryInformation.cmake +2 -2
  6. quasardb/date/CMakeFiles/Export/a52b05f964b070ee926bcad51d3288af/dateTargets.cmake +2 -2
  7. quasardb/date/Makefile +20 -20
  8. quasardb/date/cmake_install.cmake +10 -4
  9. quasardb/date/dateConfigVersion.cmake +0 -0
  10. quasardb/date/dateTargets.cmake +2 -2
  11. quasardb/extensions/writer.py +59 -61
  12. quasardb/firehose.py +24 -22
  13. quasardb/libqdb_api.dylib +0 -0
  14. quasardb/numpy/__init__.py +181 -120
  15. quasardb/pandas/__init__.py +145 -95
  16. quasardb/pool.py +13 -2
  17. quasardb/pybind11/CMakeFiles/CMakeDirectoryInformation.cmake +2 -2
  18. quasardb/pybind11/Makefile +20 -20
  19. quasardb/pybind11/cmake_install.cmake +7 -1
  20. quasardb/quasardb.cpython-39-darwin.so +0 -0
  21. quasardb/range-v3/CMakeFiles/CMakeDirectoryInformation.cmake +2 -2
  22. quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +2 -2
  23. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/build.make +18 -15
  24. quasardb/range-v3/Makefile +25 -25
  25. quasardb/range-v3/cmake_install.cmake +13 -7
  26. quasardb/range-v3/range-v3-config-version.cmake +0 -0
  27. quasardb/range-v3/range-v3-config.cmake +2 -2
  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 +45 -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 -115
  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/table.hpp DELETED
@@ -1,366 +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 "masked_array.hpp"
35
- #include "reader.hpp"
36
- #include "detail/ts_column.hpp"
37
-
38
- namespace qdb
39
- {
40
-
41
- class table : public entry
42
- {
43
- public:
44
- table(handle_ptr h, std::string a)
45
- : entry{h, a}
46
- , _has_indexed_columns(false)
47
- {
48
- _cache_metadata();
49
- }
50
-
51
- public:
52
- std::string repr() const
53
- {
54
- return "<quasardb.Table name='" + get_name() + "'>";
55
- }
56
-
57
- /**
58
- * Retrieves (and caches) table metadata. This mainly involves column information.
59
- */
60
- void retrieve_metadata()
61
- {
62
- _cache_metadata();
63
- }
64
-
65
- void create(const std::vector<detail::column_info> & columns,
66
- std::chrono::milliseconds shard_size = std::chrono::hours{24},
67
- std::chrono::milliseconds ttl = std::chrono::milliseconds::zero())
68
- {
69
- _handle->check_open();
70
-
71
- qdb_duration_t ttl_ = qdb_ttl_disabled;
72
- if (ttl != std::chrono::milliseconds::zero())
73
- {
74
- ttl_ = ttl.count();
75
- }
76
-
77
- const auto c_columns = detail::convert_columns_ex(columns);
78
- qdb::qdb_throw_if_error(*_handle, qdb_ts_create_ex(*_handle, _alias.c_str(), shard_size.count(),
79
- c_columns.data(), c_columns.size(), ttl_));
80
- }
81
-
82
- void insert_columns(const std::vector<detail::column_info> & columns)
83
- {
84
- _handle->check_open();
85
-
86
- const auto c_columns = detail::convert_columns_ex(columns);
87
- qdb::qdb_throw_if_error(*_handle,
88
- qdb_ts_insert_columns_ex(*_handle, _alias.c_str(), c_columns.data(), c_columns.size()));
89
- }
90
-
91
- std::vector<detail::column_info> const & list_columns() const
92
- {
93
- if (_columns.has_value()) [[likely]]
94
- {
95
- return _columns.value();
96
- }
97
-
98
- _cache_metadata();
99
-
100
- if (_columns.has_value()) [[likely]]
101
- {
102
- return _columns.value();
103
- }
104
-
105
- throw qdb::alias_not_found_exception{};
106
- }
107
-
108
- detail::indexed_column_info column_info_by_id(const std::string & alias) const
109
- {
110
- if (_has_indexed_columns == false)
111
- {
112
- // It's important to note that if additional columns are added during
113
- // the lifetime of this object, we will not pick up on this in our cache.
114
- _indexed_columns = detail::index_columns(list_columns());
115
- _has_indexed_columns = true;
116
- }
117
-
118
- detail::indexed_columns_t::const_iterator i = _indexed_columns.find(alias);
119
- if (i == _indexed_columns.end())
120
- throw qdb::exception{qdb_e_out_of_bounds, std::string("Column not found: ") + alias};
121
-
122
- return i->second;
123
- }
124
-
125
- detail::column_info column_info_by_index(qdb_size_t idx) const
126
- {
127
- auto cols = list_columns();
128
-
129
- // Not strictly necessary, but avoids an "ugly" exception being thrown when
130
- // using .at() below.
131
- if (cols.size() <= idx) [[unlikely]]
132
- {
133
- throw qdb::exception{
134
- qdb_e_out_of_bounds, std::string("Column index out of bounds: ") + std::to_string(idx)};
135
- }
136
-
137
- return cols.at(idx);
138
- }
139
-
140
- std::string column_id_by_index(qdb_size_t idx) const
141
- {
142
- return column_info_by_index(idx).name;
143
- }
144
-
145
- qdb_ts_column_type_t column_type_by_index(qdb_size_t idx) const
146
- {
147
- return column_info_by_index(idx).type;
148
- }
149
-
150
- qdb_size_t column_index_by_id(const std::string & alias) const
151
- {
152
- return column_info_by_id(alias).index;
153
- }
154
-
155
- qdb_ts_column_type_t column_type_by_id(const std::string & alias) const
156
- {
157
- return column_info_by_id(alias).type;
158
- }
159
-
160
- qdb::reader_ptr reader( //
161
- std::vector<std::string> const & column_names, //
162
- std::size_t batch_size, //
163
- std::vector<py::tuple> const & ranges) const //
164
- {
165
- std::vector<std::string> table_names{get_name()};
166
- return std::make_unique<qdb::reader>(_handle, table_names, column_names, batch_size, ranges);
167
- };
168
-
169
- /**
170
- * Returns true if this table has a TTL assigned.
171
- */
172
- inline bool has_ttl() const
173
- {
174
- if (_ttl.has_value()) [[likely]]
175
- {
176
- return _ttl.value() != std::chrono::milliseconds::zero();
177
- }
178
-
179
- _cache_metadata();
180
-
181
- if (_ttl.has_value()) [[likely]]
182
- {
183
- return _ttl.value() != std::chrono::milliseconds::zero();
184
- }
185
-
186
- throw qdb::alias_not_found_exception{};
187
- }
188
-
189
- inline std::chrono::milliseconds get_ttl() const
190
- {
191
- if (_ttl.has_value()) [[likely]]
192
- {
193
- return _ttl.value();
194
- }
195
-
196
- _cache_metadata();
197
-
198
- if (_ttl.has_value()) [[likely]]
199
- {
200
- return _ttl.value();
201
- }
202
-
203
- throw qdb::alias_not_found_exception{};
204
- }
205
-
206
- inline std::chrono::milliseconds get_shard_size() const
207
- {
208
- if (_shard_size.has_value()) [[likely]]
209
- {
210
- return _shard_size.value();
211
- }
212
-
213
- _cache_metadata();
214
-
215
- if (_shard_size.has_value()) [[likely]]
216
- {
217
- return _shard_size.value();
218
- }
219
-
220
- throw qdb::alias_not_found_exception{};
221
- }
222
-
223
- private:
224
- /**
225
- * Loads column info / metadata from server and caches it locally.
226
- */
227
- void _cache_metadata() const;
228
-
229
- /**
230
- * Loads column info / metadata from server if not yet cached locally.
231
- */
232
- void _maybe_cache_metadata() const
233
- {
234
- if (_columns.has_value() == false) [[unlikely]]
235
- {
236
- // We expect _ttl and _columns and _shard_size (i.e. all metadata) to have the same state
237
- assert(_ttl.has_value() == false);
238
- assert(_shard_size.has_value() == false);
239
- _cache_metadata();
240
- }
241
- }
242
-
243
- public:
244
- qdb_uint_t erase_ranges(const std::string & column, py::object ranges);
245
-
246
- public:
247
- void blob_insert(const std::string & column,
248
- const pybind11::array & timestamps,
249
- const qdb::masked_array & values);
250
- void string_insert(const std::string & column,
251
- const pybind11::array & timestamps,
252
- qdb::masked_array const & values);
253
- void double_insert(const std::string & column,
254
- const pybind11::array & timestamps,
255
- qdb::masked_array const & values);
256
- void int64_insert(const std::string & column,
257
- const pybind11::array & timestamps,
258
- qdb::masked_array const & values);
259
- void timestamp_insert(const std::string & column,
260
- const pybind11::array & timestamps,
261
- const qdb::masked_array & values);
262
-
263
- public:
264
- std::pair<pybind11::array, masked_array> blob_get_ranges(
265
- const std::string & column, py::object ranges);
266
-
267
- std::pair<pybind11::array, masked_array> string_get_ranges(
268
- const std::string & column, py::object ranges);
269
-
270
- std::pair<pybind11::array, masked_array> double_get_ranges(
271
- const std::string & column, py::object ranges);
272
-
273
- std::pair<pybind11::array, masked_array> int64_get_ranges(
274
- const std::string & column, py::object ranges);
275
-
276
- std::pair<pybind11::array, masked_array> timestamp_get_ranges(
277
- const std::string & column, py::object ranges);
278
-
279
- py::object subscribe(py::object conn)
280
- {
281
- auto firehose = py::module::import("quasardb.firehose");
282
- auto xs = firehose.attr("subscribe")(conn, get_name());
283
- return xs;
284
- }
285
-
286
- private:
287
- mutable bool _has_indexed_columns;
288
- mutable detail::indexed_columns_t _indexed_columns;
289
-
290
- mutable std::optional<std::vector<detail::column_info>> _columns;
291
- mutable std::optional<std::chrono::milliseconds> _ttl;
292
- mutable std::optional<std::chrono::milliseconds> _shard_size;
293
- };
294
-
295
- template <typename Module>
296
- static inline void register_table(Module & m)
297
- {
298
- namespace py = pybind11;
299
-
300
- py::enum_<qdb_ts_column_type_t>{m, "ColumnType", py::arithmetic(), "Column type"} //
301
- .value("Uninitialized", qdb_ts_column_uninitialized) //
302
- .value("Double", qdb_ts_column_double) //
303
- .value("Blob", qdb_ts_column_blob) //
304
- .value("String", qdb_ts_column_string) //
305
- .value("Symbol", qdb_ts_column_symbol) //
306
- .value("Int64", qdb_ts_column_int64) //
307
- .value("Timestamp", qdb_ts_column_timestamp); //
308
-
309
- py::class_<qdb::table, qdb::entry>{m, "Table", "Table representation"} //
310
- .def(py::init<qdb::handle_ptr, std::string>()) //
311
- .def("__repr__", &qdb::table::repr) //
312
- .def("create", &qdb::table::create, py::arg("columns"), //
313
- py::arg("shard_size") = std::chrono::hours{24}, //
314
- py::arg("ttl") = std::chrono::milliseconds::zero() //
315
- ) //
316
- .def("get_name", &qdb::table::get_name) //
317
- .def("retrieve_metadata", &qdb::table::retrieve_metadata) //
318
- .def("column_index_by_id", &qdb::table::column_index_by_id) //
319
- .def("column_type_by_id", &qdb::table::column_type_by_id) //
320
- .def("column_info_by_index", &qdb::table::column_info_by_index) //
321
- .def("column_type_by_index", &qdb::table::column_type_by_index) //
322
- .def("column_id_by_index", &qdb::table::column_id_by_index) //
323
- .def("insert_columns", &qdb::table::insert_columns) //
324
- .def("list_columns", &qdb::table::list_columns) //
325
- .def("has_ttl", &qdb::table::has_ttl) //
326
- .def("get_ttl", &qdb::table::get_ttl) //
327
- .def("get_shard_size", &qdb::table::get_shard_size) //
328
- //
329
- .def("reader", &qdb::table::reader, //
330
- py::kw_only(), //
331
- py::arg("column_names") = std::vector<std::string>{}, //
332
- py::arg("batch_size") = std::size_t{0}, //
333
- py::arg("ranges") = std::vector<py::tuple>{} //
334
- ) //
335
- //
336
- .def("subscribe", &qdb::table::subscribe) //
337
- .def("erase_ranges", &qdb::table::erase_ranges) //
338
- .def("blob_insert", &qdb::table::blob_insert) //
339
- .def("string_insert", &qdb::table::string_insert) //
340
- .def("double_insert", &qdb::table::double_insert) //
341
- .def("int64_insert", &qdb::table::int64_insert) //
342
- .def("timestamp_insert", &qdb::table::timestamp_insert) //
343
- //
344
- .def("blob_get_ranges", &qdb::table::blob_get_ranges, //
345
- py::arg("column"), //
346
- py::arg("ranges") = py::none{} //
347
- ) //
348
- .def("string_get_ranges", &qdb::table::string_get_ranges, //
349
- py::arg("column"), //
350
- py::arg("ranges") = py::none{} //
351
- ) //
352
- .def("double_get_ranges", &qdb::table::double_get_ranges, //
353
- py::arg("column"), //
354
- py::arg("ranges") = py::none{} //
355
- ) //
356
- .def("int64_get_ranges", &qdb::table::int64_get_ranges, //
357
- py::arg("column"), //
358
- py::arg("ranges") = py::none{} //
359
- ) //
360
- .def("timestamp_get_ranges", &qdb::table::timestamp_get_ranges, //
361
- py::arg("column"), //
362
- py::arg("ranges") = py::none{} //
363
- ); //
364
- }
365
-
366
- } // namespace qdb
quasardb/tag.hpp DELETED
@@ -1,77 +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
-
35
- namespace qdb
36
- {
37
-
38
- class tag : public entry
39
- {
40
- public:
41
- tag(qdb::handle_ptr h, const std::string & alias)
42
- : entry{h, alias}
43
- {}
44
-
45
- public:
46
- std::vector<std::string> get_entries()
47
- {
48
- const char ** aliases = nullptr;
49
- size_t count = 0;
50
-
51
- qdb::qdb_throw_if_error(*_handle, qdb_get_tagged(*_handle, _alias.c_str(), &aliases, &count));
52
-
53
- return convert_strings_and_release(_handle, aliases, count);
54
- }
55
-
56
- qdb_uint_t count()
57
- {
58
- qdb_uint_t count = 0;
59
-
60
- qdb::qdb_throw_if_error(*_handle, qdb_get_tagged_count(*_handle, _alias.c_str(), &count));
61
-
62
- return count;
63
- }
64
- };
65
-
66
- template <typename Module>
67
- static inline void register_tag(Module & m)
68
- {
69
- namespace py = pybind11;
70
-
71
- py::class_<qdb::tag, qdb::entry>(m, "Tag") //
72
- .def(py::init<qdb::handle_ptr, std::string>()) //
73
- .def("get_entries", &qdb::tag::get_entries) //
74
- .def("count", &qdb::tag::count); //
75
- }
76
-
77
- } // namespace qdb
quasardb/timestamp.hpp DELETED
@@ -1,97 +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 "pytypes.hpp"
35
- #include <qdb/timestamp.h>
36
- #include "convert/value.hpp"
37
- #include <chrono>
38
-
39
- namespace qdb
40
- {
41
-
42
- class timestamp_entry : public expirable_entry
43
- {
44
- using clock_t = std::chrono::system_clock;
45
-
46
- public:
47
- timestamp_entry(handle_ptr h, std::string a) noexcept
48
- : expirable_entry{h, a}
49
- {}
50
-
51
- public:
52
- qdb::pydatetime get()
53
- {
54
- qdb_timespec_t result;
55
- qdb::qdb_throw_if_error(*_handle, qdb_timestamp_get(*_handle, _alias.c_str(), &result));
56
- return qdb::convert::value<qdb_timespec_t, qdb::pydatetime>(result);
57
- }
58
-
59
- void put(qdb::pydatetime val)
60
- {
61
- qdb_timespec_t val_ = qdb::convert::value<qdb::pydatetime, qdb_timespec_t>(val);
62
- qdb::qdb_throw_if_error(
63
- *_handle, qdb_timestamp_put(*_handle, _alias.c_str(), &val_, qdb_time_t{0}));
64
- }
65
-
66
- void update(qdb::pydatetime val)
67
- {
68
- qdb_timespec_t val_ = qdb::convert::value<qdb::pydatetime, qdb_timespec_t>(val);
69
- qdb::qdb_throw_if_error(
70
- *_handle, qdb_timestamp_update(*_handle, _alias.c_str(), &val_, qdb_time_t{0}));
71
- }
72
-
73
- qdb::pydatetime add(qdb::pydatetime val)
74
- {
75
- qdb_timespec_t val_ = qdb::convert::value<qdb::pydatetime, qdb_timespec_t>(val);
76
- qdb_timespec_t result;
77
- qdb::qdb_throw_if_error(*_handle, qdb_timestamp_add(*_handle, _alias.c_str(), &val_, &result));
78
-
79
- return qdb::convert::value<qdb_timespec_t, qdb::pydatetime>(result);
80
- }
81
- };
82
-
83
- template <typename Module>
84
- static inline void register_timestamp(Module & m)
85
- {
86
- namespace py = pybind11;
87
-
88
- py::class_<qdb::timestamp_entry, qdb::expirable_entry>(m, "Timestamp") //
89
- .def(py::init<qdb::handle_ptr, std::string>()) //
90
- .def("get", &qdb::timestamp_entry::get) //
91
- .def("put", &qdb::timestamp_entry::put, py::arg("timestamp")) //
92
- .def("update", &qdb::timestamp_entry::update, py::arg("timestamp")) //
93
- .def("add", &qdb::timestamp_entry::add, py::arg("addend")) //
94
- ; //
95
- }
96
-
97
- } // namespace qdb