quasardb 3.14.2.dev1__cp39-cp39-macosx_11_0_arm64.whl → 3.14.2.dev4__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.
- quasardb/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
- quasardb/Makefile +20 -20
- quasardb/__init__.py +33 -4
- quasardb/cmake_install.cmake +7 -1
- quasardb/date/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
- quasardb/date/CMakeFiles/Export/a52b05f964b070ee926bcad51d3288af/dateTargets.cmake +13 -13
- quasardb/date/Makefile +20 -20
- quasardb/date/cmake_install.cmake +7 -1
- quasardb/date/dateConfigVersion.cmake +9 -2
- quasardb/date/dateTargets.cmake +4 -8
- quasardb/libqdb_api.dylib +0 -0
- quasardb/numpy/__init__.py +58 -10
- quasardb/pandas/__init__.py +58 -102
- quasardb/pybind11/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
- quasardb/pybind11/Makefile +20 -20
- quasardb/pybind11/cmake_install.cmake +7 -1
- quasardb/quasardb.cpython-39-darwin.so +0 -0
- quasardb/range-v3/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
- quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +13 -13
- quasardb/range-v3/CMakeFiles/range.v3.headers.dir/DependInfo.cmake +6 -2
- quasardb/range-v3/CMakeFiles/range.v3.headers.dir/build.make +7 -4
- quasardb/range-v3/Makefile +20 -20
- quasardb/range-v3/cmake_install.cmake +19 -1
- quasardb/range-v3/range-v3-config-version.cmake +9 -2
- quasardb/range-v3/range-v3-config.cmake +4 -8
- {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/METADATA +15 -10
- quasardb-3.14.2.dev4.dist-info/RECORD +45 -0
- {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/WHEEL +1 -1
- quasardb/CMakeLists.txt +0 -510
- quasardb/batch_column.hpp +0 -80
- quasardb/batch_inserter.hpp +0 -248
- quasardb/blob.hpp +0 -150
- quasardb/cluster.cpp +0 -89
- quasardb/cluster.hpp +0 -551
- quasardb/concepts.hpp +0 -278
- quasardb/continuous.cpp +0 -149
- quasardb/continuous.hpp +0 -106
- quasardb/convert/array.hpp +0 -282
- quasardb/convert/point.hpp +0 -330
- quasardb/convert/range.hpp +0 -282
- quasardb/convert/unicode.hpp +0 -598
- quasardb/convert/util.hpp +0 -22
- quasardb/convert/value.hpp +0 -711
- quasardb/convert.hpp +0 -38
- quasardb/detail/qdb_resource.hpp +0 -129
- quasardb/detail/ts_column.hpp +0 -224
- quasardb/direct_blob.hpp +0 -108
- quasardb/direct_handle.hpp +0 -83
- quasardb/direct_integer.hpp +0 -94
- quasardb/dispatch.hpp +0 -157
- quasardb/double.hpp +0 -87
- quasardb/entry.hpp +0 -273
- quasardb/error.hpp +0 -318
- quasardb/handle.cpp +0 -29
- quasardb/handle.hpp +0 -98
- quasardb/integer.hpp +0 -88
- quasardb/logger.cpp +0 -106
- quasardb/logger.hpp +0 -228
- quasardb/masked_array.hpp +0 -651
- quasardb/metrics.cpp +0 -103
- quasardb/metrics.hpp +0 -112
- quasardb/module.cpp +0 -76
- quasardb/module.hpp +0 -24
- quasardb/node.hpp +0 -123
- quasardb/numpy.cpp +0 -6
- quasardb/numpy.hpp +0 -489
- quasardb/object_tracker.hpp +0 -283
- quasardb/options.hpp +0 -244
- quasardb/perf.hpp +0 -336
- quasardb/pytypes.hpp +0 -221
- quasardb/query.cpp +0 -420
- quasardb/query.hpp +0 -92
- quasardb/reader/ts_row.hpp +0 -281
- quasardb/reader/ts_value.hpp +0 -245
- quasardb/remove_cvref.hpp +0 -31
- quasardb/string.hpp +0 -160
- quasardb/table.cpp +0 -289
- quasardb/table.hpp +0 -325
- quasardb/table_reader.hpp +0 -220
- quasardb/tag.hpp +0 -77
- quasardb/timestamp.hpp +0 -97
- quasardb/traits.hpp +0 -619
- quasardb/ts_iterator.hpp +0 -193
- quasardb/utils/blob_deque.hpp +0 -96
- quasardb/utils/ostream.hpp +0 -17
- quasardb/utils/permutation.hpp +0 -50
- quasardb/utils/stable_sort.hpp +0 -25
- quasardb/utils/unzip_view.hpp +0 -89
- quasardb/utils.cpp +0 -28
- quasardb/utils.hpp +0 -174
- quasardb/writer.cpp +0 -534
- quasardb/writer.hpp +0 -396
- quasardb-3.14.2.dev1.dist-info/RECORD +0 -109
- {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/LICENSE.md +0 -0
- {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/top_level.txt +0 -0
quasardb/convert/array.hpp
DELETED
|
@@ -1,282 +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>) struct
|
|
83
|
-
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>) struct convert_array<From, To>
|
|
109
|
-
{
|
|
110
|
-
// Source value_type, e.g. std::int32_t
|
|
111
|
-
using value_type = typename From::value_type;
|
|
112
|
-
|
|
113
|
-
// Delegate dtype, e.g. traits::int64_dtype
|
|
114
|
-
using Delegate = typename From::delegate_type;
|
|
115
|
-
|
|
116
|
-
// Delegate value_type, e.g. std::int64_t
|
|
117
|
-
using delegate_value_type = typename Delegate::value_type;
|
|
118
|
-
|
|
119
|
-
static constexpr convert_array<Delegate, To> const delegate{};
|
|
120
|
-
|
|
121
|
-
[[nodiscard]] constexpr inline auto operator()() const noexcept
|
|
122
|
-
{
|
|
123
|
-
auto xform = [](value_type const & x) -> delegate_value_type {
|
|
124
|
-
if (From::is_null(x))
|
|
125
|
-
{
|
|
126
|
-
return Delegate::null_value();
|
|
127
|
-
}
|
|
128
|
-
else
|
|
129
|
-
{
|
|
130
|
-
return static_cast<delegate_value_type>(x);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
return ranges::views::transform(xform) | delegate();
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/////
|
|
138
|
-
//
|
|
139
|
-
// qdb->numpy
|
|
140
|
-
// "Regular" transforms
|
|
141
|
-
//
|
|
142
|
-
// Input: range of length N, type: qdb_primitive
|
|
143
|
-
// Output: range of length N, dtype: To
|
|
144
|
-
//
|
|
145
|
-
/////
|
|
146
|
-
template <typename From, typename To>
|
|
147
|
-
requires(concepts::qdb_primitive<From> && !concepts::delegate_dtype<To>) struct convert_array<From, To>
|
|
148
|
-
{
|
|
149
|
-
static constexpr value_converter<From, To> const xform_{};
|
|
150
|
-
|
|
151
|
-
[[nodiscard]] inline auto operator()() const noexcept
|
|
152
|
-
{
|
|
153
|
-
return ranges::views::transform(xform_);
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/////
|
|
158
|
-
//
|
|
159
|
-
// qdb->numpy
|
|
160
|
-
// "Delegate" transforms
|
|
161
|
-
//
|
|
162
|
-
// In some cases numpy's representations are more rich than what Quasardb's primitives
|
|
163
|
-
// support, e.g. int32. In this case, we first transform this to the "delegate type",
|
|
164
|
-
// int64, which can then figure out the rest.
|
|
165
|
-
//
|
|
166
|
-
// Input: range of length N, type: qdb_primitive
|
|
167
|
-
// Output: range of length N, dtype: To
|
|
168
|
-
//
|
|
169
|
-
/////
|
|
170
|
-
template <typename From, typename To>
|
|
171
|
-
requires(concepts::qdb_primitive<From> && concepts::delegate_dtype<To>) struct convert_array<From, To>
|
|
172
|
-
{
|
|
173
|
-
// Destination value_type, e.g. std::int32_t
|
|
174
|
-
using value_type = typename To::value_type;
|
|
175
|
-
|
|
176
|
-
// Delegate dtype, e.g. traits::int64_dtype
|
|
177
|
-
using Delegate = typename To::delegate_type;
|
|
178
|
-
|
|
179
|
-
// Delegate value_type, e.g. std::int64_t
|
|
180
|
-
using delegate_value_type = typename Delegate::value_type;
|
|
181
|
-
|
|
182
|
-
static constexpr convert_array<From, Delegate> const delegate{};
|
|
183
|
-
|
|
184
|
-
[[nodiscard]] constexpr inline auto operator()() const noexcept
|
|
185
|
-
{
|
|
186
|
-
auto xform = [](value_type const & x) -> delegate_value_type {
|
|
187
|
-
if (To::is_null(x))
|
|
188
|
-
{
|
|
189
|
-
return Delegate::null_value();
|
|
190
|
-
}
|
|
191
|
-
else
|
|
192
|
-
{
|
|
193
|
-
return static_cast<delegate_value_type>(x);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
return ranges::views::transform(xform) | delegate();
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
}; // namespace qdb::convert::detail
|
|
201
|
-
|
|
202
|
-
namespace qdb::convert
|
|
203
|
-
{
|
|
204
|
-
|
|
205
|
-
namespace py = pybind11;
|
|
206
|
-
|
|
207
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
208
|
-
//
|
|
209
|
-
// PUBLIC API
|
|
210
|
-
//
|
|
211
|
-
///////////////////
|
|
212
|
-
//
|
|
213
|
-
// Functions below define the public API. Their intent to handle boilerplate and
|
|
214
|
-
// and easier-to-use interface than the lower-level converters defined above.
|
|
215
|
-
//
|
|
216
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
217
|
-
|
|
218
|
-
// numpy -> qdb
|
|
219
|
-
// input: np.ndarray
|
|
220
|
-
// output: OutputIterator
|
|
221
|
-
template <concepts::dtype From, concepts::qdb_primitive To, ranges::output_iterator<To> OutputIterator>
|
|
222
|
-
static inline constexpr void array(py::array const & xs, OutputIterator dst)
|
|
223
|
-
{
|
|
224
|
-
if (xs.size() == 0) [[unlikely]]
|
|
225
|
-
{
|
|
226
|
-
return;
|
|
227
|
-
};
|
|
228
|
-
ranges::copy(detail::to_range<From>(xs) | detail::convert_array<From, To>{}(), dst);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// numpy -> qdb
|
|
232
|
-
// input: np.ndarray
|
|
233
|
-
// output: OutputRange
|
|
234
|
-
template <concepts::dtype From, concepts::qdb_primitive To>
|
|
235
|
-
static inline constexpr void array(py::array const & xs, std::vector<To> & dst)
|
|
236
|
-
{
|
|
237
|
-
dst.resize(xs.size()); // <- important!
|
|
238
|
-
array<From, To>(xs, ranges::begin(dst));
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// numpy -> qdb
|
|
242
|
-
// input: np.ndarray
|
|
243
|
-
// returns: vector
|
|
244
|
-
template <concepts::dtype From, concepts::qdb_primitive To>
|
|
245
|
-
static inline constexpr std::vector<To> array(py::array const & xs)
|
|
246
|
-
{
|
|
247
|
-
if (xs.size() == 0)
|
|
248
|
-
{
|
|
249
|
-
return {};
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
return ranges::to<std::vector>(detail::to_range<From>(xs) | detail::convert_array<From, To>{}());
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// numpy -> qdb
|
|
256
|
-
template <concepts::dtype From, concepts::qdb_primitive To>
|
|
257
|
-
static inline constexpr void masked_array(qdb::masked_array const & xs, std::vector<To> & dst)
|
|
258
|
-
{
|
|
259
|
-
array<From, To>(xs.filled<From>(), dst);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// numpy -> qdb
|
|
263
|
-
template <concepts::dtype From, concepts::qdb_primitive To>
|
|
264
|
-
static inline constexpr std::vector<To> masked_array(qdb::masked_array const & xs)
|
|
265
|
-
{
|
|
266
|
-
return array<From, To>(xs.filled<From>());
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// qdb -> numpy
|
|
270
|
-
template <concepts::qdb_primitive From, concepts::dtype To, ranges::input_range R>
|
|
271
|
-
requires(concepts::input_range_t<R, From>) static inline qdb::masked_array masked_array(R && xs)
|
|
272
|
-
{
|
|
273
|
-
if (ranges::empty(xs)) [[unlikely]]
|
|
274
|
-
{
|
|
275
|
-
return {};
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
py::array xs_ = detail::to_array<To>(xs | detail::convert_array<From, To>{}());
|
|
279
|
-
return qdb::masked_array(xs_, qdb::masked_array::masked_null<To>(xs_));
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
}; // namespace qdb::convert
|
quasardb/convert/point.hpp
DELETED
|
@@ -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
|