quasardb 3.14.2.dev3__cp39-cp39-win_amd64.whl → 3.14.2.dev5__cp39-cp39-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.cp39-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
@@ -1,83 +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 "handle.hpp"
34
- #include <qdb/direct.h>
35
- #include <memory>
36
- #include <string>
37
-
38
- namespace qdb
39
- {
40
-
41
- class direct_handle
42
- {
43
- public:
44
- explicit direct_handle() noexcept
45
- {}
46
-
47
- ~direct_handle()
48
- {
49
- if (_handle)
50
- {
51
- qdb_direct_close(_handle);
52
- _handle = nullptr;
53
- }
54
- }
55
-
56
- void connect(const handle_ptr handle, const std::string & uri)
57
- {
58
- _handle = qdb_direct_connect(*handle, uri.c_str());
59
- if (_handle == nullptr)
60
- {
61
- // Throw here to detect an error as soon as possible.
62
- // Otherwise, C API would throw only when using the null handle.
63
- qdb_throw_if_error(*handle, qdb_e_invalid_argument);
64
- }
65
- }
66
-
67
- operator qdb_direct_handle_t() const noexcept
68
- {
69
- return _handle;
70
- }
71
-
72
- private:
73
- qdb_direct_handle_t _handle{nullptr};
74
- };
75
-
76
- using direct_handle_ptr = std::shared_ptr<direct_handle>;
77
-
78
- static inline direct_handle_ptr make_direct_handle_ptr()
79
- {
80
- return std::make_shared<qdb::direct_handle>(direct_handle());
81
- }
82
-
83
- } // namespace qdb
@@ -1,94 +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 "direct_handle.hpp"
34
- #include <qdb/integer.h>
35
-
36
- namespace qdb
37
- {
38
-
39
- class direct_integer_entry
40
- {
41
- public:
42
- direct_integer_entry(handle_ptr h, direct_handle_ptr dh, std::string a) noexcept
43
- : _handle{h}
44
- , _direct_handle{dh}
45
- , _alias{a}
46
- {}
47
-
48
- public:
49
- qdb_int_t get()
50
- {
51
- qdb_int_t result;
52
- qdb::qdb_throw_if_error(*_handle, qdb_direct_int_get(*_direct_handle, _alias.c_str(), &result));
53
- return result;
54
- }
55
-
56
- void put(qdb_int_t integer)
57
- {
58
- qdb::qdb_throw_if_error(
59
- *_handle, qdb_direct_int_put(*_direct_handle, _alias.c_str(), integer, qdb_time_t{0}));
60
- }
61
-
62
- void update(qdb_int_t integer)
63
- {
64
- qdb::qdb_throw_if_error(
65
- *_handle, qdb_direct_int_update(*_direct_handle, _alias.c_str(), integer, qdb_time_t{0}));
66
- }
67
-
68
- void remove()
69
- {
70
- qdb::qdb_throw_if_error(*_handle, qdb_direct_remove(*_direct_handle, _alias.c_str()));
71
- }
72
-
73
- private:
74
- handle_ptr _handle;
75
- direct_handle_ptr _direct_handle;
76
- std::string _alias;
77
- };
78
-
79
- template <typename Module>
80
- static inline void register_direct_integer(Module & m)
81
- {
82
- namespace py = pybind11;
83
-
84
- py::class_<qdb::direct_integer_entry>(m, "DirectInteger")
85
- .def(py::init<qdb::handle_ptr, qdb::direct_handle_ptr, std::string>())
86
- .def("get", &qdb::direct_integer_entry::get)
87
- .def("put", &qdb::direct_integer_entry::put, py::arg("integer"))
88
- .def("update", &qdb::direct_integer_entry::update, py::arg("integer"))
89
- .def("remove", &qdb::direct_integer_entry::remove)
90
-
91
- ; //
92
- }
93
-
94
- } // namespace qdb
quasardb/dispatch.hpp DELETED
@@ -1,157 +0,0 @@
1
- #pragma once
2
-
3
- #include "concepts.hpp"
4
- #include "error.hpp"
5
- #include "numpy.hpp"
6
- #include "traits.hpp"
7
- #include <string>
8
-
9
- /**
10
- * Define various way to do runtime -> compile time template dispatch for the
11
- * types that we have.
12
- */
13
- namespace qdb::dispatch
14
- {
15
-
16
- ////////////////////////////////////////////////////////////////////////////////
17
- //
18
- // DTYPE DISPATCHER
19
- //
20
- // Most complex dispatcher: dispatch based on dtype size, kind, and could even
21
- // be extended to datetime precision and whatnot.
22
- //
23
- ////////////////////////////////////////////////////////////////////////////////
24
-
25
- template <template <qdb_ts_column_type_t, typename> class Callback,
26
- qdb_ts_column_type_t ColumnType,
27
- typename DType,
28
- typename... Args>
29
- concept valid_callback = requires(Args... args) {
30
- {
31
- Callback<ColumnType, DType>{}
32
- };
33
- {
34
- Callback<ColumnType, DType>{}(std::forward<Args>(args)...)
35
- };
36
- };
37
-
38
- template <template <qdb_ts_column_type_t, typename> class Callback,
39
- qdb_ts_column_type_t ColumnType,
40
- concepts::dtype DType,
41
- typename... Args>
42
- requires(not valid_callback<Callback, ColumnType, DType, Args...>)
43
- static inline constexpr void by_dtype_(Args &&... args)
44
- {
45
- throw qdb::incompatible_type_exception{"Dtype dispatcher not implemented for ColumnType '"
46
- + std::to_string(ColumnType)
47
- + "': " + numpy::detail::to_string(DType::dtype())};
48
- };
49
-
50
- // Template is only expanded when it actually has a dispatch function with the
51
- // correct signature.
52
- template <template <qdb_ts_column_type_t, typename> class Callback,
53
- qdb_ts_column_type_t ColumnType,
54
- concepts::dtype DType,
55
- typename... Args>
56
-
57
- requires(valid_callback<Callback, ColumnType, DType, Args...>)
58
- static inline constexpr decltype(auto) by_dtype_(Args &&... args)
59
- {
60
- return Callback<ColumnType, DType>{}(std::forward<Args>(args)...);
61
- };
62
-
63
- /**
64
- * Converts runtime kind/size into compile-time template function dispatch.
65
- *
66
- * TODO(leon): possibly allow choice whgether or not to raise a compile-time error
67
- * on unimplemented template functions, right now it assumes these are
68
- * just side effects on template expansion overload: the fact that a
69
- * C++ compiler decides to generate functions for all possible
70
- * combinations of dtype properties.
71
- */
72
- template <template <qdb_ts_column_type_t, typename> class Callback,
73
- qdb_ts_column_type_t ColumnType,
74
- typename... Args>
75
- static inline constexpr decltype(auto) by_dtype(
76
- traits::dtype_kind kind, py::ssize_t size, Args &&... args)
77
- {
78
- #define CASE(K, DT) \
79
- case K: \
80
- return by_dtype_<Callback, ColumnType, DT, Args...>(std::forward<Args>(args)...);
81
-
82
- switch (kind)
83
- {
84
- CASE(traits::unicode_kind, traits::unicode_dtype);
85
- CASE(traits::bytestring_kind, traits::bytestring_dtype);
86
- CASE(traits::datetime_kind, traits::datetime64_ns_dtype);
87
- CASE(traits::object_kind, traits::pyobject_dtype);
88
-
89
- case traits::int_kind:
90
- switch (size)
91
- {
92
- CASE(2, traits::int16_dtype);
93
- CASE(4, traits::int32_dtype);
94
- CASE(8, traits::int64_dtype);
95
- default:
96
- throw qdb::not_implemented_exception{
97
- "Integer dtype with size " + std::to_string(size) + " is not supported"};
98
- };
99
-
100
- case traits::float_kind:
101
- switch (size)
102
- {
103
- CASE(4, traits::float32_dtype);
104
- CASE(8, traits::float64_dtype);
105
- default:
106
- throw qdb::not_implemented_exception{
107
- "Integer dtype with size " + std::to_string(size) + " is not supported"};
108
- };
109
-
110
- default:
111
- throw qdb::not_implemented_exception{
112
- "Unable to dispatch: dtype with kind '" + std::string{(char)kind, 1} + "' not recognized"};
113
- };
114
-
115
- #undef SIZED_CASE3
116
- #undef SIZED_CASE2
117
- #undef CASE
118
- }
119
-
120
- template <template <qdb_ts_column_type_t, typename> class Callback,
121
- qdb_ts_column_type_t ColumnType,
122
- typename... Args>
123
- static inline constexpr decltype(auto) by_dtype(py::dtype const & dt, Args &&... args)
124
- {
125
- return by_dtype<Callback, ColumnType, Args...>(
126
- static_cast<traits::dtype_kind>(dt.kind()), dt.itemsize(), std::forward<Args>(args)...);
127
- }
128
-
129
- ////////////////////////////////////////////////////////////////////////////////
130
- //
131
- // COLUMN TYPE DISPATCHER
132
- //
133
- ////////////////////////////////////////////////////////////////////////////////
134
-
135
- template <template <qdb_ts_column_type_t> class Callback, typename... Args>
136
- static inline constexpr decltype(auto) by_column_type(qdb_ts_column_type_t ct, Args &&... args)
137
- {
138
- switch (ct)
139
- {
140
- #define CASE(CT) \
141
- case CT: \
142
- return Callback<CT>{}(std::forward<Args>(args)...);
143
-
144
- CASE(qdb_ts_column_int64);
145
- CASE(qdb_ts_column_double);
146
- CASE(qdb_ts_column_timestamp);
147
- CASE(qdb_ts_column_blob);
148
- CASE(qdb_ts_column_string);
149
- CASE(qdb_ts_column_symbol);
150
-
151
- default:
152
- throw qdb::not_implemented_exception{"Column type dispatch not handled: " + std::to_string(ct)};
153
- };
154
- #undef CASE
155
- }
156
-
157
- }; // namespace qdb::dispatch
quasardb/double.hpp DELETED
@@ -1,87 +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/double.h>
35
-
36
- namespace qdb
37
- {
38
-
39
- class double_entry : public expirable_entry
40
- {
41
- public:
42
- double_entry(handle_ptr h, std::string a) noexcept
43
- : expirable_entry{h, a}
44
- {}
45
-
46
- public:
47
- double get()
48
- {
49
- double result;
50
- qdb::qdb_throw_if_error(*_handle, qdb_double_get(*_handle, _alias.c_str(), &result));
51
- return result;
52
- }
53
-
54
- void put(double val)
55
- {
56
- qdb::qdb_throw_if_error(*_handle, qdb_double_put(*_handle, _alias.c_str(), val, qdb_time_t{0}));
57
- }
58
-
59
- void update(double val)
60
- {
61
- qdb::qdb_throw_if_error(
62
- *_handle, qdb_double_update(*_handle, _alias.c_str(), val, qdb_time_t{0}));
63
- }
64
-
65
- double add(double val)
66
- {
67
- double result;
68
- qdb::qdb_throw_if_error(*_handle, qdb_double_add(*_handle, _alias.c_str(), val, &result));
69
- return result;
70
- }
71
- };
72
-
73
- template <typename Module>
74
- static inline void register_double(Module & m)
75
- {
76
- namespace py = pybind11;
77
-
78
- py::class_<qdb::double_entry, qdb::expirable_entry>(m, "Double") //
79
- .def(py::init<qdb::handle_ptr, std::string>()) //
80
- .def("get", &qdb::double_entry::get) //
81
- .def("put", &qdb::double_entry::put, py::arg("double")) //
82
- .def("update", &qdb::double_entry::update, py::arg("double")) //
83
- .def("add", &qdb::double_entry::add, py::arg("addend")) //
84
- ; //
85
- }
86
-
87
- } // namespace qdb
quasardb/entry.hpp DELETED
@@ -1,273 +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 "handle.hpp"
35
- #include "pytypes.hpp"
36
- #include "utils.hpp"
37
- #include <qdb/tag.h>
38
- #include "convert/value.hpp"
39
- #include <pybind11/pybind11.h>
40
- #include <pybind11/stl.h>
41
- #include <chrono>
42
-
43
- namespace qdb
44
- {
45
-
46
- using hostname = std::pair<std::string, unsigned short>;
47
-
48
- class entry
49
- {
50
-
51
- public:
52
- struct metadata
53
- {
54
- metadata() noexcept
55
- {}
56
-
57
- // we need to adjust for timezone as quasardb is UTC and pybind11 will
58
- // assume local date time points
59
- metadata(qdb_entry_metadata_t const & md) noexcept
60
- : type{md.type}
61
- , size{md.size}
62
- , modification_time{md.modification_time.tv_sec}
63
- , expiry_time{md.expiry_time.tv_sec}
64
- {}
65
-
66
- qdb_entry_type_t type{qdb_entry_uninitialized};
67
- qdb_uint_t size{0};
68
- qdb_timespec_t modification_time;
69
- qdb_timespec_t expiry_time;
70
- };
71
-
72
- public:
73
- entry(handle_ptr h, std::string a)
74
- : _handle{h}
75
- , _alias{a}
76
- {}
77
-
78
- public:
79
- bool attach_tag(const std::string & tag)
80
- {
81
- const qdb_error_t err = qdb_attach_tag(*_handle, _alias.c_str(), tag.c_str());
82
-
83
- if (err != qdb_e_tag_already_set) [[likely]]
84
- {
85
- qdb_throw_if_error(*_handle, err);
86
- }
87
- return err != qdb_e_tag_already_set;
88
- }
89
-
90
- void attach_tags(const std::vector<std::string> & tags)
91
- {
92
- std::vector<const char *> tag_pointers(tags.size());
93
-
94
- std::transform(tags.cbegin(), tags.cend(), tag_pointers.begin(),
95
- [](const std::string & s) { return s.c_str(); });
96
-
97
- qdb::qdb_throw_if_error(*_handle,
98
- qdb_attach_tags(*_handle, _alias.c_str(), tag_pointers.data(), tag_pointers.size()));
99
- }
100
-
101
- bool detach_tag(const std::string & tag)
102
- {
103
- const qdb_error_t err = qdb_detach_tag(*_handle, _alias.c_str(), tag.c_str());
104
-
105
- if (err != qdb_e_tag_not_set) [[likely]]
106
- {
107
- qdb_throw_if_error(*_handle, err);
108
- }
109
-
110
- return err != qdb_e_tag_not_set;
111
- }
112
-
113
- void detach_tags(const std::vector<std::string> & tags)
114
- {
115
- std::vector<const char *> tag_pointers(tags.size());
116
-
117
- std::transform(tags.cbegin(), tags.cend(), tag_pointers.begin(),
118
- [](const std::string & s) { return s.c_str(); });
119
-
120
- qdb::qdb_throw_if_error(*_handle,
121
- qdb_detach_tags(*_handle, _alias.c_str(), tag_pointers.data(), tag_pointers.size()));
122
- }
123
-
124
- bool has_tag(const std::string & tag)
125
- {
126
- return qdb_has_tag(*_handle, _alias.c_str(), tag.c_str()) == qdb_e_ok;
127
- }
128
-
129
- std::vector<std::string> get_tags()
130
- {
131
- const char ** tags = nullptr;
132
- size_t tag_count = 0;
133
-
134
- qdb::qdb_throw_if_error(*_handle, qdb_get_tags(*_handle, _alias.c_str(), &tags, &tag_count));
135
-
136
- return convert_strings_and_release(_handle, tags, tag_count);
137
- }
138
-
139
- public:
140
- void remove()
141
- {
142
- qdb::qdb_throw_if_error(*_handle, qdb_remove(*_handle, _alias.c_str()));
143
- }
144
-
145
- inline qdb::hostname get_location() const
146
- {
147
- qdb_remote_node_t rn;
148
-
149
- qdb::qdb_throw_if_error(*_handle, qdb_get_location(*_handle, _alias.c_str(), &rn));
150
-
151
- qdb::hostname res{rn.address, rn.port};
152
-
153
- qdb_release(*_handle, &rn);
154
-
155
- return res;
156
- }
157
-
158
- inline bool exists() const
159
- {
160
- // There isn't an official way to do it, but quite reliable a way is
161
- // to just check whether an entry has metadata.
162
- qdb_entry_metadata_t md;
163
- qdb_error_t err = qdb_get_metadata(*_handle, _alias.c_str(), &md);
164
-
165
- return err == qdb_e_ok;
166
- }
167
-
168
- inline metadata get_metadata() const
169
- {
170
- qdb_entry_metadata_t md;
171
-
172
- qdb::qdb_throw_if_error(*_handle, qdb_get_metadata(*_handle, _alias.c_str(), &md));
173
-
174
- return metadata{md};
175
- }
176
-
177
- inline qdb_entry_type_t get_entry_type() const
178
- {
179
- return get_metadata().type;
180
- }
181
-
182
- const std::string & get_name() const noexcept
183
- {
184
- return _alias;
185
- }
186
-
187
- protected:
188
- handle_ptr _handle;
189
- std::string _alias;
190
- };
191
-
192
- class expirable_entry : public entry
193
- {
194
- public:
195
- expirable_entry(handle_ptr h, std::string a)
196
- : entry{h, a}
197
- {}
198
-
199
- public:
200
- static qdb_time_t from_pydatetime(qdb::pydatetime const & dt) noexcept
201
- {
202
- return qdb::convert::value<qdb::pydatetime, qdb_time_t>(dt);
203
- }
204
-
205
- public:
206
- void expires_at(const qdb::pydatetime & expiry_time)
207
- {
208
- qdb::qdb_throw_if_error(
209
- *_handle, qdb_expires_at(*_handle, _alias.c_str(), from_pydatetime(expiry_time)));
210
- }
211
-
212
- void expires_from_now(std::chrono::milliseconds expiry_delta)
213
- {
214
- qdb::qdb_throw_if_error(
215
- *_handle, qdb_expires_from_now(*_handle, _alias.c_str(), expiry_delta.count()));
216
- }
217
-
218
- qdb::pydatetime get_expiry_time()
219
- {
220
- return convert::value<qdb_timespec_t, qdb::pydatetime>(get_metadata().expiry_time);
221
- }
222
- };
223
-
224
- template <typename Module>
225
- static inline void register_entry(Module & m)
226
- {
227
- namespace py = pybind11;
228
-
229
- py::class_<qdb::entry> e{m, "Entry"};
230
-
231
- py::enum_<qdb_entry_type_t>{e, "Type", py::arithmetic(), "Entry type"} //
232
- .value("Uninitialized", qdb_entry_uninitialized) //
233
- .value("Integer", qdb_entry_integer) //
234
- .value("HashSet", qdb_entry_hset) //
235
- .value("Tag", qdb_entry_tag) //
236
- .value("Deque", qdb_entry_deque) //
237
- .value("Stream", qdb_entry_stream) //
238
- .value("Timeseries", qdb_entry_ts) //
239
- ;
240
-
241
- e.def(py::init<qdb::handle_ptr, std::string>()) //
242
- .def("attach_tag", &qdb::entry::attach_tag) //
243
- .def("attach_tags", &qdb::entry::attach_tags) //
244
- .def("detach_tag", &qdb::entry::detach_tag) //
245
- .def("detach_tags", &qdb::entry::detach_tags) //
246
- .def("has_tag", &qdb::entry::has_tag) //
247
- .def("get_tags", &qdb::entry::get_tags) //
248
- .def("remove", &qdb::entry::remove) //
249
- .def("exists", &qdb::entry::exists, //
250
- "Returns true if the entry exists") //
251
- .def("get_location", &qdb::entry::get_location) //
252
- .def("get_entry_type", &qdb::entry::get_entry_type) //
253
- .def("get_metadata", &qdb::entry::get_metadata) //
254
- .def("get_name", &qdb::entry::get_name) //
255
- ;
256
-
257
- py::class_<qdb::entry::metadata>{e, "Metadata"} //
258
- .def(py::init<>()) //
259
- .def_readwrite("type", &qdb::entry::metadata::type) //
260
- .def_readwrite("size", &qdb::entry::metadata::size) //
261
- .def_readwrite("modification_time", &qdb::entry::metadata::modification_time) //
262
- .def_readwrite("expiry_time", &qdb::entry::metadata::expiry_time) //
263
- ;
264
-
265
- py::class_<qdb::expirable_entry, qdb::entry>{m, "ExpirableEntry"} //
266
- .def(py::init<qdb::handle_ptr, std::string>()) //
267
- .def("expires_at", &qdb::expirable_entry::expires_at) //
268
- .def("expires_from_now", &qdb::expirable_entry::expires_from_now) //
269
- .def("get_expiry_time", &qdb::expirable_entry::get_expiry_time) //
270
- ;
271
- }
272
-
273
- } // namespace qdb