quasardb 3.14.2.dev3__cp38-cp38-win32.whl → 3.14.2.dev5__cp38-cp38-win32.whl

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

Potentially problematic release.


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

Files changed (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.cp38-win32.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 +3 -6
  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,299 +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 "../concepts.hpp"
34
- #include "../masked_array.hpp"
35
- #include "../numpy.hpp"
36
- #include "../traits.hpp"
37
- #include "../utils.hpp"
38
- #include "range.hpp"
39
- #include "util.hpp"
40
- #include "value.hpp"
41
- #include <qdb/ts.h>
42
- #include <pybind11/pybind11.h>
43
- #include <range/v3/algorithm/max_element.hpp>
44
- #include <range/v3/range/conversion.hpp>
45
- #include <range/v3/range/traits.hpp>
46
- #include <range/v3/view/common.hpp>
47
- #include <range/v3/view/transform.hpp>
48
- #include <range/v3/view/zip.hpp>
49
- #include <cstring>
50
-
51
- namespace qdb::convert::detail
52
- {
53
-
54
- namespace py = pybind11;
55
-
56
- ////////////////////////////////////////////////////////////////////////////////
57
- //
58
- // ARRAY CONVERTERS
59
- //
60
- ///////////////////
61
- //
62
- // These converters operate on arrays of any type. For simplicity sake, their
63
- // interface assumes the destination is a pre-allocated pointer. Their purpose
64
- // is to make use of the fastest numpy API available to handle high-perf
65
- // array conversion.
66
- //
67
- ////////////////////////////////////////////////////////////////////////////////
68
-
69
- template <typename From, typename To>
70
- struct convert_array;
71
-
72
- /////
73
- //
74
- // numpy->qdb
75
- // "Regular" transforms
76
- //
77
- // Input: range of length N, dtype: any fixed-width dtype
78
- // Output: range of length N, type: qdb_primitive
79
- //
80
- /////
81
- template <typename From, typename To>
82
- requires(concepts::dtype<From> && !concepts::delegate_dtype<From> && concepts::qdb_primitive<To>)
83
- struct convert_array<From, To>
84
- {
85
- using value_type = typename From::value_type;
86
- static constexpr value_converter<From, To> const xform_{};
87
-
88
- [[nodiscard]] constexpr inline auto operator()() const noexcept
89
- {
90
- return ranges::views::transform(xform_);
91
- };
92
- };
93
-
94
- /////
95
- //
96
- // numpy->qdb
97
- // "Delegate" transforms
98
- //
99
- // In some cases numpy's representations are more rich than what Quasardb's primitives
100
- // support, e.g. int32. In this case, we first transform this to the "delegate type",
101
- // int64, which can then figure out the rest.
102
- //
103
- // Input: range of length N, type: fixed-width ("regular") numpy data
104
- // Output: range of length N, type: qdb primitives
105
- //
106
- /////
107
- template <typename From, typename To>
108
- requires(concepts::delegate_dtype<From> && concepts::qdb_primitive<To>)
109
- struct convert_array<From, To>
110
- {
111
- // Source value_type, e.g. std::int32_t
112
- using value_type = typename From::value_type;
113
-
114
- // Delegate dtype, e.g. traits::int64_dtype
115
- using Delegate = typename From::delegate_type;
116
-
117
- // Delegate value_type, e.g. std::int64_t
118
- using delegate_value_type = typename Delegate::value_type;
119
-
120
- static constexpr convert_array<Delegate, To> const delegate{};
121
-
122
- [[nodiscard]] constexpr inline auto operator()() const noexcept
123
- {
124
- auto xform = [](value_type const & x) -> delegate_value_type {
125
- if (From::is_null(x))
126
- {
127
- return Delegate::null_value();
128
- }
129
- else
130
- {
131
- return static_cast<delegate_value_type>(x);
132
- }
133
- };
134
- return ranges::views::transform(xform) | delegate();
135
- };
136
- };
137
-
138
- /////
139
- //
140
- // qdb->numpy
141
- // "Regular" transforms
142
- //
143
- // Input: range of length N, type: qdb_primitive
144
- // Output: range of length N, dtype: To
145
- //
146
- /////
147
- template <typename From, typename To>
148
- requires(concepts::qdb_primitive<From> && !concepts::delegate_dtype<To>)
149
- struct convert_array<From, To>
150
- {
151
- static constexpr value_converter<From, To> const xform_{};
152
-
153
- [[nodiscard]] inline auto operator()() const noexcept
154
- {
155
- return ranges::views::transform(xform_);
156
- };
157
- };
158
-
159
- /////
160
- //
161
- // qdb->numpy
162
- // "Delegate" transforms
163
- //
164
- // In some cases numpy's representations are more rich than what Quasardb's primitives
165
- // support, e.g. int32. In this case, we first transform this to the "delegate type",
166
- // int64, which can then figure out the rest.
167
- //
168
- // Input: range of length N, type: qdb_primitive
169
- // Output: range of length N, dtype: To
170
- //
171
- /////
172
- template <typename From, typename To>
173
- requires(concepts::qdb_primitive<From> && concepts::delegate_dtype<To>)
174
- struct convert_array<From, To>
175
- {
176
- // Destination value_type, e.g. std::int32_t
177
- using value_type = typename To::value_type;
178
-
179
- // Delegate dtype, e.g. traits::int64_dtype
180
- using Delegate = typename To::delegate_type;
181
-
182
- // Delegate value_type, e.g. std::int64_t
183
- using delegate_value_type = typename Delegate::value_type;
184
-
185
- static constexpr convert_array<From, Delegate> const delegate{};
186
-
187
- [[nodiscard]] constexpr inline auto operator()() const noexcept
188
- {
189
- auto xform = [](value_type const & x) -> delegate_value_type {
190
- if (To::is_null(x))
191
- {
192
- return Delegate::null_value();
193
- }
194
- else
195
- {
196
- return static_cast<delegate_value_type>(x);
197
- }
198
- };
199
- return ranges::views::transform(xform) | delegate();
200
- };
201
- };
202
-
203
- }; // namespace qdb::convert::detail
204
-
205
- namespace qdb::convert
206
- {
207
-
208
- namespace py = pybind11;
209
-
210
- ////////////////////////////////////////////////////////////////////////////////
211
- //
212
- // PUBLIC API
213
- //
214
- ///////////////////
215
- //
216
- // Functions below define the public API. Their intent to handle boilerplate and
217
- // and easier-to-use interface than the lower-level converters defined above.
218
- //
219
- ////////////////////////////////////////////////////////////////////////////////
220
-
221
- // numpy -> qdb
222
- // input: np.ndarray
223
- // output: OutputIterator
224
- template <concepts::dtype From, concepts::qdb_primitive To, ranges::output_iterator<To> OutputIterator>
225
- static inline constexpr void array(py::array const & xs, OutputIterator dst)
226
- {
227
- if (xs.size() == 0) [[unlikely]]
228
- {
229
- return;
230
- };
231
- ranges::copy(detail::to_range<From>(xs) | detail::convert_array<From, To>{}(), dst);
232
- }
233
-
234
- // numpy -> qdb
235
- // input: np.ndarray
236
- // output: OutputRange
237
- template <concepts::dtype From, concepts::qdb_primitive To>
238
- static inline constexpr void array(py::array const & xs, std::vector<To> & dst)
239
- {
240
- dst.resize(xs.size()); // <- important!
241
- array<From, To>(xs, ranges::begin(dst));
242
- }
243
-
244
- // numpy -> qdb
245
- // input: np.ndarray
246
- // returns: vector
247
- template <concepts::dtype From, concepts::qdb_primitive To>
248
- static inline constexpr std::vector<To> array(py::array const & xs)
249
- {
250
- if (xs.size() == 0)
251
- {
252
- return {};
253
- };
254
-
255
- return ranges::to<std::vector>(detail::to_range<From>(xs) | detail::convert_array<From, To>{}());
256
- }
257
-
258
- // qdb -> numpy
259
- template <concepts::qdb_primitive From, concepts::dtype To, ranges::input_range R>
260
- requires(concepts::input_range_t<R, From>)
261
- static inline py::array array(R && xs)
262
- {
263
- if (ranges::empty(xs)) [[unlikely]]
264
- {
265
- return {};
266
- };
267
-
268
- return detail::to_array<To>(xs | detail::convert_array<From, To>{}());
269
- }
270
-
271
- // numpy -> qdb
272
- template <concepts::dtype From, concepts::qdb_primitive To>
273
- static inline constexpr void masked_array(qdb::masked_array const & xs, std::vector<To> & dst)
274
- {
275
- array<From, To>(xs.filled<From>(), dst);
276
- }
277
-
278
- // numpy -> qdb
279
- template <concepts::dtype From, concepts::qdb_primitive To>
280
- static inline constexpr std::vector<To> masked_array(qdb::masked_array const & xs)
281
- {
282
- return array<From, To>(xs.filled<From>());
283
- }
284
-
285
- // qdb -> numpy
286
- template <concepts::qdb_primitive From, concepts::dtype To, ranges::input_range R>
287
- requires(concepts::input_range_t<R, From>)
288
- static inline qdb::masked_array masked_array(R && xs)
289
- {
290
- if (ranges::empty(xs)) [[unlikely]]
291
- {
292
- return {};
293
- };
294
-
295
- py::array xs_ = detail::to_array<To>(xs | detail::convert_array<From, To>{}());
296
- return qdb::masked_array(xs_, qdb::masked_array::masked_null<To>(xs_));
297
- }
298
-
299
- }; // namespace qdb::convert
@@ -1,330 +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 "../concepts.hpp"
34
- #include "../masked_array.hpp"
35
- #include "../traits.hpp"
36
- #include "../utils/unzip_view.hpp"
37
- #include "array.hpp"
38
- #include "range.hpp"
39
- #include "value.hpp"
40
- #include <qdb/ts.h>
41
- #include <pybind11/pybind11.h>
42
-
43
- namespace qdb::convert::detail
44
- {
45
-
46
- namespace py = pybind11;
47
-
48
- ////////////////////////////////////////////////////////////////////////////////
49
- //
50
- // 'POINT' <> PAIR CONVERTORS
51
- //
52
- ///////////////////
53
- //
54
- // Allows splitting of qdb_ts_*_point to a pair<qdb_timespec_t, value> and back.
55
- // calling point_to_pair(pair_to_point(x)) will always give you the original
56
- // value back.
57
- //
58
- ////////////////////////////////////////////////////////////////////////////////
59
-
60
- template <typename T>
61
- requires(concepts::qdb_primitive<T>) using point_type = typename traits::qdb_value<T>::point_type;
62
-
63
- template <typename T>
64
- requires(concepts::qdb_point<T>) using primitive_type = typename traits::qdb_value<T>::primitive_type;
65
-
66
- // Base declaration of pair-to-point function
67
- template <concepts::qdb_primitive T>
68
- inline point_type<T> pair_to_point(std::pair<qdb_timespec_t, T> const & x)
69
- {
70
- return {std::get<0>(x), std::get<1>(x)};
71
- };
72
-
73
- // Base declaration of point-to-pair function
74
- template <concepts::qdb_point T>
75
- inline std::pair<qdb_timespec_t, primitive_type<T>> point_to_pair(T const & x)
76
- {
77
- return std::make_pair(x.timestamp, x.value);
78
- };
79
-
80
- // Specific overloads: qdb_blob_t <> qdb_ts_blob_point
81
- template <>
82
- constexpr inline qdb_ts_blob_point pair_to_point<qdb_blob_t>(
83
- std::pair<qdb_timespec_t, qdb_blob_t> const & x)
84
- {
85
- qdb_blob_t const & x_ = std::get<1>(x);
86
- return {std::get<0>(x), x_.content, x_.content_length};
87
- };
88
-
89
- template <>
90
- constexpr inline std::pair<qdb_timespec_t, qdb_blob_t> point_to_pair<qdb_ts_blob_point>(
91
- qdb_ts_blob_point const & x)
92
- {
93
- return std::make_pair(x.timestamp, qdb_blob_t{x.content, x.content_length});
94
- };
95
-
96
- // Specific overloads: qdb_string_t <> qdb_ts_string_point
97
- template <>
98
- constexpr inline qdb_ts_string_point pair_to_point<qdb_string_t>(
99
- std::pair<qdb_timespec_t, qdb_string_t> const & x)
100
- {
101
- qdb_string_t const & x_ = std::get<1>(x);
102
- return {std::get<0>(x), x_.data, x_.length};
103
- };
104
-
105
- template <>
106
- constexpr inline std::pair<qdb_timespec_t, qdb_string_t> point_to_pair<qdb_ts_string_point>(
107
- qdb_ts_string_point const & x)
108
- {
109
- return std::make_pair(x.timestamp, qdb_string_t{x.content, x.content_length});
110
- };
111
-
112
- ////////////////////////////////////////////////////////////////////////////////
113
- //
114
- // 'POINT' ARRAY CONVERTERS
115
- //
116
- ///////////////////
117
- //
118
- // These converters apply to all the qdb_ts_*_point structs. They are effectively
119
- // a timestamp array and a 'value' array, and most of the work is dispatched to
120
- // the array and value converters.
121
- //
122
- ////////////////////////////////////////////////////////////////////////////////
123
-
124
- template <typename From, typename To>
125
- struct convert_point_array;
126
-
127
- /////
128
- //
129
- // numpy->qdb transforms
130
- //
131
- // Input 1: range of length N, dtype: np.datetime64[ns]
132
- // Input 2: range of length N, dtype: From (e.g. float64 or unicode)
133
- // Output: range of length N, type: qdb_point, e.g. qdb_ts_double_point or qdb_ts_string_point
134
- //
135
- /////
136
- template <typename From, typename To>
137
- requires(concepts::dtype<From> && concepts::qdb_primitive<To>) struct convert_point_array<From, To>
138
- {
139
- static constexpr convert_array<From, To> const value_delegate_{};
140
- static constexpr convert_array<traits::datetime64_ns_dtype, qdb_timespec_t> const ts_delegate_{};
141
-
142
- template <ranges::input_range TimestampRange, ranges::input_range ValueRange>
143
- constexpr inline auto operator()(TimestampRange && timestamps, ValueRange && values) const
144
- {
145
- assert(ranges::size(timestamps) == ranges::size(values));
146
- assert(ranges::empty(timestamps) == false);
147
-
148
- // Our flow:
149
- // * take two separate ranges;
150
- // * convert values from numpy to qdb, e.g. np.datetime64 (which is
151
- // std::int64_t) to qdb_timespec_t)
152
- // * zips them together as pairs;
153
- // * convert pairs into qdb point structs
154
- // * profit
155
-
156
- auto timestamps_ = timestamps | ts_delegate_();
157
- auto values_ = values | value_delegate_();
158
-
159
- return ranges::zip_view(std::move(timestamps_), std::move(values_))
160
- | ranges::views::transform(pair_to_point<To>);
161
- }
162
- };
163
-
164
- /////
165
- //
166
- // qdb->numpy transforms
167
- //
168
- // Input: range of length N, type: qdb_point, e.g. qdb_ts_double_point or qdb_ts_string_point
169
- // Output: pair<range of length N, range of length N>
170
- //
171
- // First output range is $timestamp array, dtype: np.datetime64[ns]
172
- // Second output range is values array, dtype: To
173
- //
174
- /////
175
- template <typename From, typename To>
176
- requires(concepts::qdb_primitive<From> && concepts::dtype<To>) struct convert_point_array<From, To>
177
- {
178
- static constexpr convert_array<From, To> const value_delegate_{};
179
- static constexpr convert_array<qdb_timespec_t, traits::datetime64_ns_dtype> const ts_delegate_{};
180
-
181
- template <ranges::input_range R>
182
- constexpr inline auto operator()(R && xs) const
183
- {
184
- assert(ranges::empty(xs) == false);
185
- auto range_of_pairs = xs | ranges::views::transform(point_to_pair<point_type<From>>);
186
-
187
- auto const && [timestamps, values] = qdb::make_unzip_views(range_of_pairs);
188
-
189
- auto timestamps_ = timestamps | ts_delegate_();
190
- auto values_ = values | value_delegate_();
191
-
192
- return std::make_pair(timestamps_, values_);
193
- }
194
- };
195
-
196
- }; // namespace qdb::convert::detail
197
-
198
- namespace qdb::convert
199
- {
200
-
201
- namespace py = pybind11;
202
-
203
- ////////////////////////////////////////////////////////////////////////////////
204
- //
205
- // PUBLIC API
206
- //
207
- ///////////////////
208
- //
209
- // Functions below define the public API. Their intent to handle boilerplate and
210
- // and easier-to-use interface than the lower-level converters defined above.
211
- //
212
- ////////////////////////////////////////////////////////////////////////////////
213
-
214
- template <typename Type>
215
- using point_type = typename traits::qdb_value<Type>::point_type;
216
-
217
- // numpy -> qdb
218
- // input1: np.ndarray, dtype: datetime64[ns]
219
- // input2: np.ndarray, dtype: From
220
- // output: OutputIterator
221
- template <concepts::dtype From,
222
- concepts::qdb_primitive To,
223
- ranges::output_iterator<point_type<To>> OutputIterator>
224
- static inline void point_array(
225
- py::array const & timestamps, py::array const & values, OutputIterator dst)
226
- {
227
- assert(timestamps.size() == values.size());
228
-
229
- if (ranges::empty(timestamps)) [[unlikely]]
230
- {
231
- return;
232
- }
233
-
234
- static constexpr detail::convert_point_array<From, To> const xform{};
235
- auto timestamps_ = detail::to_range<traits::datetime64_ns_dtype>(timestamps);
236
- auto values_ = detail::to_range<From>(values);
237
-
238
- ranges::copy(xform(timestamps_, values_), dst);
239
- };
240
-
241
- // numpy -> qdb
242
- // input1: np.ndarray, dtype: datetime64[ns]
243
- // input2: np.ndarray, dtype: From
244
- // output: std::vector<To>
245
- template <concepts::dtype From, concepts::qdb_primitive To>
246
- static inline std::vector<point_type<To>> point_array(
247
- py::array const & timestamps, py::array const & values)
248
- {
249
- assert(timestamps.size() == values.size());
250
-
251
- if (ranges::empty(timestamps)) [[unlikely]]
252
- {
253
- return {};
254
- }
255
-
256
- static constexpr detail::convert_point_array<From, To> const xform{};
257
- auto timestamps_ = detail::to_range<traits::datetime64_ns_dtype>(timestamps);
258
- auto values_ = detail::to_range<From>(values);
259
-
260
- return ranges::to<std::vector>(xform(timestamps_, values_));
261
- };
262
-
263
- // numpy -> qdb
264
- template <concepts::dtype From, concepts::qdb_primitive To>
265
- static inline void point_array(
266
- py::array const & timestamps, py::array const & values, std::vector<point_type<To>> & dst)
267
- {
268
- dst.resize(timestamps.size()); // <- important!
269
- point_array<From, To>(timestamps, values, ranges::begin(dst));
270
- };
271
-
272
- // numpy -> qdb
273
- template <concepts::dtype From, concepts::qdb_primitive To>
274
- static inline void point_array(
275
- py::array const & timestamps, qdb::masked_array const & values, std::vector<point_type<To>> & dst)
276
- {
277
- point_array<From, To>(timestamps, values.filled<From>(), dst);
278
- };
279
-
280
- // numpy -> qdb
281
- template <concepts::dtype From, concepts::qdb_primitive To>
282
- static inline std::vector<point_type<To>> point_array(
283
- py::array const & timestamps, qdb::masked_array const & values)
284
- {
285
- return point_array<From, To>(timestamps, values.filled<From>());
286
- };
287
-
288
- // numpy -> qdb
289
- template <concepts::dtype From, concepts::qdb_primitive To>
290
- static inline std::vector<point_type<To>> point_array(
291
- std::pair<py::array, qdb::masked_array> const & xs)
292
- {
293
- return point_array<From, To>(std::get<0>(xs), std::get<1>(xs));
294
- };
295
-
296
- // qdb -> numpy
297
- //
298
- // Takes a range of qdb point structs (eg qdb_ts_double_point) and returns a pair of two
299
- // numpy ndarrays, one for timestamps and another for the values.
300
- template <concepts::qdb_primitive From, concepts::dtype To, ranges::input_range R>
301
- requires(concepts::input_range_t<R, point_type<From>>) static inline std::pair<py::array,
302
- qdb::masked_array> point_array(R && xs)
303
- {
304
- if (ranges::empty(xs)) [[unlikely]]
305
- {
306
- return {};
307
- };
308
-
309
- static constexpr detail::convert_point_array<From, To> const xform{};
310
-
311
- auto const && [timestamps, values] = xform(xs);
312
-
313
- py::array timestamps_ = detail::to_array<traits::datetime64_ns_dtype>(std::move(timestamps));
314
- py::array values_ = detail::to_array<To>(std::move(values));
315
-
316
- assert(timestamps_.size() == values_.size());
317
-
318
- return std::make_pair(
319
- timestamps_, qdb::masked_array(values_, qdb::masked_array::masked_null<To>(values_)));
320
- }
321
-
322
- // qdb -> numpy
323
- template <concepts::qdb_primitive From, concepts::dtype To>
324
- static inline std::pair<py::array, qdb::masked_array> point_array(
325
- point_type<From> const * input, std::size_t n)
326
- {
327
- return point_array<From, To>(ranges::views::counted(input, n));
328
- };
329
-
330
- }; // namespace qdb::convert