quasardb 3.14.2.dev1__cp310-cp310-macosx_11_0_arm64.whl → 3.14.2.dev4__cp310-cp310-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-310-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/range.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 "../error.hpp"
|
|
35
|
-
#include "unicode.hpp"
|
|
36
|
-
#include "util.hpp"
|
|
37
|
-
#include <range/v3/algorithm/all_of.hpp>
|
|
38
|
-
#include <range/v3/algorithm/copy.hpp>
|
|
39
|
-
#include <range/v3/algorithm/find.hpp>
|
|
40
|
-
#include <range/v3/algorithm/for_each.hpp>
|
|
41
|
-
#include <range/v3/algorithm/max_element.hpp>
|
|
42
|
-
#include <range/v3/range/traits.hpp>
|
|
43
|
-
#include <range/v3/view/chunk.hpp>
|
|
44
|
-
#include <range/v3/view/counted.hpp>
|
|
45
|
-
#include <range/v3/view/remove_if.hpp>
|
|
46
|
-
#include <range/v3/view/stride.hpp>
|
|
47
|
-
#include <range/v3/view/transform.hpp>
|
|
48
|
-
|
|
49
|
-
namespace qdb::convert::detail
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
namespace py = pybind11;
|
|
53
|
-
|
|
54
|
-
template <concepts::dtype DType>
|
|
55
|
-
requires(concepts::variable_width_dtype<DType>) struct clean_stride
|
|
56
|
-
{
|
|
57
|
-
using stride_type = typename DType::stride_type; // e.g. std::u32string
|
|
58
|
-
using value_type = typename stride_type::value_type; // e.g. wchar_t
|
|
59
|
-
|
|
60
|
-
static constexpr value_type const null_value_ = DType::null_value();
|
|
61
|
-
|
|
62
|
-
template <concepts::input_range_t<value_type> InputRange>
|
|
63
|
-
requires(ranges::sized_range<InputRange>) inline decltype(auto) operator()(
|
|
64
|
-
InputRange && stride) const noexcept
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
auto first = ranges::begin(stride);
|
|
68
|
-
auto last = ranges::find(stride, null_value_);
|
|
69
|
-
|
|
70
|
-
using iterator_type = decltype(first);
|
|
71
|
-
using sentinel_type = decltype(last);
|
|
72
|
-
|
|
73
|
-
// There were some template deduction issues in this function for the
|
|
74
|
-
// subrange<> call below, these static assertions are here to make this a bit
|
|
75
|
-
// easier to deal with
|
|
76
|
-
|
|
77
|
-
static_assert(ranges::input_iterator<iterator_type>);
|
|
78
|
-
static_assert(ranges::sized_sentinel_for<sentinel_type, iterator_type>);
|
|
79
|
-
|
|
80
|
-
return ranges::subrange<iterator_type, sentinel_type, ranges::subrange_kind::sized>(
|
|
81
|
-
first, last);
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
template <concepts::dtype DType>
|
|
86
|
-
requires(concepts::fixed_width_dtype<DType>) inline decltype(auto) to_range(py::array const & xs)
|
|
87
|
-
{
|
|
88
|
-
// Lowest-level codepoint representation inside numpy, e.g. wchar_t for unicode
|
|
89
|
-
// or short for int16.
|
|
90
|
-
using value_type = typename DType::value_type;
|
|
91
|
-
value_type const * xs_ = xs.unchecked<value_type>().data();
|
|
92
|
-
|
|
93
|
-
// Numpy can sometimes use larger strides, e.g. pack int64 in a container with
|
|
94
|
-
// 128-byte strides. In these case, we need to increase the size of our step.
|
|
95
|
-
//
|
|
96
|
-
// Related ticket: SC-11057
|
|
97
|
-
py::ssize_t stride_size{0};
|
|
98
|
-
switch (xs.ndim())
|
|
99
|
-
{
|
|
100
|
-
// This can happen in case an array contains only a single number, then it will
|
|
101
|
-
// not have any dimensions. In this case, it's best to just use the itemsize as
|
|
102
|
-
// the stride size, because we'll not have to forward the iterator anyway.
|
|
103
|
-
[[unlikely]] case 0 : stride_size = xs.itemsize();
|
|
104
|
-
break;
|
|
105
|
-
|
|
106
|
-
// Default case: use stride size of the first (and only) dimension. Most of the
|
|
107
|
-
// time this will be identical to the itemsize.
|
|
108
|
-
[[likely]] case 1 : stride_size = xs.strides(0);
|
|
109
|
-
break;
|
|
110
|
-
default:
|
|
111
|
-
throw qdb::incompatible_type_exception{
|
|
112
|
-
"Multi-dimensional arrays are not supported. Eexpected 0 or 1 dimensions, got: "
|
|
113
|
-
+ std::to_string(xs.ndim())};
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
assert(stride_size > 0);
|
|
117
|
-
|
|
118
|
-
py::ssize_t item_size = xs.itemsize();
|
|
119
|
-
|
|
120
|
-
// Sanity check; stride_size is number of bytes per item for a whole "step", item_size
|
|
121
|
-
// is the number of bytes per item. As such, stride_size should always be a multiple
|
|
122
|
-
// of item_size.
|
|
123
|
-
assert(stride_size % item_size == 0);
|
|
124
|
-
|
|
125
|
-
// The number of "steps" of <value_type> we need to take per iteration.
|
|
126
|
-
py::ssize_t step_size = stride_size / item_size;
|
|
127
|
-
|
|
128
|
-
return ranges::views::stride(ranges::views::counted(xs_, (xs.size() * step_size)), step_size);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Variable length encoding: split into chunks of <itemsize() / codepoint_size>
|
|
132
|
-
template <concepts::dtype DType>
|
|
133
|
-
requires(concepts::variable_width_dtype<DType>) inline decltype(auto) to_range(py::array const & xs)
|
|
134
|
-
{
|
|
135
|
-
using stride_type = typename DType::stride_type;
|
|
136
|
-
using value_type = typename stride_type::value_type;
|
|
137
|
-
|
|
138
|
-
// (Note: a "code point" is a single character as defined by unicode. For
|
|
139
|
-
// example, in UTF-16, each code point is 2 bytes).
|
|
140
|
-
//
|
|
141
|
-
// For numpy's variable-length encoding, numpy arrays use the following values:
|
|
142
|
-
//
|
|
143
|
-
// xs.size -> the total number of items
|
|
144
|
-
// xs.itemsize -> the number of bytes of each item
|
|
145
|
-
//
|
|
146
|
-
// Numpy encodes, say, unicode as a single continuous range of wchar_t. For
|
|
147
|
-
// example, given the three unicode words "yes", "no", and "wombat", the encoding
|
|
148
|
-
// may look as follows (X -> string value, 0 -> zero padding)
|
|
149
|
-
//
|
|
150
|
-
// longest_word: 6 (wombat)
|
|
151
|
-
// stride_type: u32string_t
|
|
152
|
-
// stride_size: 4 (sizeof(stride_type::value_type))
|
|
153
|
-
// => itemsize: 24 (longest_word * stride_size)
|
|
154
|
-
// => size: 3 (amount of items)
|
|
155
|
-
// => stride_size: 6 (amount of characters in longest word)
|
|
156
|
-
//
|
|
157
|
-
// Encoded, this will then look like this:
|
|
158
|
-
//
|
|
159
|
-
// [XXX000XX0000XXXXXX]
|
|
160
|
-
// yes no wombat
|
|
161
|
-
//
|
|
162
|
-
// What we will do below is to convert this single, continuous range of data
|
|
163
|
-
// to a range of strings. We do that by:
|
|
164
|
-
//
|
|
165
|
-
// 1. Converting the continuous numpy array to a continuous range
|
|
166
|
-
// 2. Split this up in strides of `stride_size`; our range thus becomes
|
|
167
|
-
// a range of subranges that all point to the start/stop of each stride
|
|
168
|
-
// 3. Clear any null padding bytes on the right.
|
|
169
|
-
//
|
|
170
|
-
// A "stride" is defined as just a range, i.e. a pair of start/end iterator.
|
|
171
|
-
//
|
|
172
|
-
// No memory is copied, the emitted data still refers to the same numpy array
|
|
173
|
-
// data under-the-hood.
|
|
174
|
-
py::ssize_t stride_size = DType::stride_size(xs.itemsize());
|
|
175
|
-
|
|
176
|
-
// First. let's gather a view of "all" bytes in the dataset: xs.size() repres
|
|
177
|
-
auto all_bytes = ranges::views::counted(xs.unchecked<value_type>().data(), xs.size() * stride_size);
|
|
178
|
-
|
|
179
|
-
// Now, "split" these in strides
|
|
180
|
-
auto strides = ranges::chunk_view(all_bytes, stride_size);
|
|
181
|
-
|
|
182
|
-
return ranges::views::transform(strides, clean_stride<DType>{});
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Converts range R to np.ndarray of dtype DType. Copies underlying data.
|
|
187
|
-
*/
|
|
188
|
-
template <concepts::dtype DType, ranges::input_range R>
|
|
189
|
-
requires(concepts::fixed_width_dtype<DType>) inline py::array to_array(R && xs)
|
|
190
|
-
{
|
|
191
|
-
using value_type = typename DType::value_type;
|
|
192
|
-
|
|
193
|
-
py::ssize_t size = ranges::size(xs);
|
|
194
|
-
|
|
195
|
-
py::array ret(DType::dtype(), size);
|
|
196
|
-
|
|
197
|
-
ranges::copy(xs, ret.mutable_unchecked<value_type>().mutable_data());
|
|
198
|
-
|
|
199
|
-
return ret;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Converts range R to np.ndarray of dtype DType. Copies underlying data.
|
|
204
|
-
*/
|
|
205
|
-
template <concepts::dtype Dtype, ranges::input_range R>
|
|
206
|
-
requires(concepts::variable_width_dtype<Dtype>) inline py::array to_array(R && xs)
|
|
207
|
-
{
|
|
208
|
-
using out_char_type = typename Dtype::value_type;
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
// Our input range is a view of words with varying lengths, which may
|
|
212
|
-
// have a complicated range view pipeline which does unicode conversions
|
|
213
|
-
// and whatnot.
|
|
214
|
-
//
|
|
215
|
-
// In order to encode this data as a numpy contiguous, variable width
|
|
216
|
-
// array (i.e. of dtype('U') or dtype('S')), we need to:
|
|
217
|
-
//
|
|
218
|
-
////
|
|
219
|
-
// 1. know the length of the longest word:
|
|
220
|
-
//
|
|
221
|
-
std::size_t stride_size = largest_word_length(xs);
|
|
222
|
-
|
|
223
|
-
////
|
|
224
|
-
// 2. know the size (in bytes) of a single character;
|
|
225
|
-
//
|
|
226
|
-
py::array::StridesContainer strides{Dtype::itemsize(stride_size)};
|
|
227
|
-
|
|
228
|
-
////
|
|
229
|
-
// 3. know the total number of words;
|
|
230
|
-
//
|
|
231
|
-
py::array::ShapeContainer shape{ranges::size(xs)};
|
|
232
|
-
|
|
233
|
-
////
|
|
234
|
-
// 4. allocate a single, contiguous array of [1] * [2] * [3] bytes;
|
|
235
|
-
//
|
|
236
|
-
py::array arr{Dtype::dtype(stride_size), shape, strides};
|
|
237
|
-
assert(arr.itemsize() >= 0);
|
|
238
|
-
assert(static_cast<std::size_t>(Dtype::stride_size(arr.itemsize())) == stride_size);
|
|
239
|
-
|
|
240
|
-
////
|
|
241
|
-
// 5. expose this contiguous array as chunks of `stride_size`
|
|
242
|
-
//
|
|
243
|
-
out_char_type * ptr = arr.mutable_unchecked<out_char_type>().mutable_data();
|
|
244
|
-
auto dst =
|
|
245
|
-
ranges::views::counted(ptr, stride_size * arr.size()) | ranges::views::chunk(stride_size);
|
|
246
|
-
assert(ranges::size(dst) == ranges::size(xs));
|
|
247
|
-
|
|
248
|
-
////
|
|
249
|
-
// 6. zip in and out ranges
|
|
250
|
-
//
|
|
251
|
-
// This will align each input stride (input range of length [0...stride_size>) next to
|
|
252
|
-
// the output stride (output range of fixed size `stride_size`.
|
|
253
|
-
//
|
|
254
|
-
auto inout = ranges::zip_view(std::move(xs), std::move(dst));
|
|
255
|
-
|
|
256
|
-
////
|
|
257
|
-
// 7. skip null values
|
|
258
|
-
//
|
|
259
|
-
// It's now safe to skip any null values
|
|
260
|
-
auto inout_ = ranges::views::remove_if(
|
|
261
|
-
std::move(inout), [](auto const & x) -> bool { return ranges::empty(std::get<0>(x)); });
|
|
262
|
-
|
|
263
|
-
////
|
|
264
|
-
// 7. write the results into each stride.
|
|
265
|
-
//
|
|
266
|
-
ranges::for_each(inout_, [stride_size](auto && x) -> void {
|
|
267
|
-
auto && [in, out] = x;
|
|
268
|
-
|
|
269
|
-
static_assert(ranges::input_range<decltype(in)>);
|
|
270
|
-
static_assert(ranges::output_range<decltype(out), out_char_type>);
|
|
271
|
-
|
|
272
|
-
// assert(ranges::size(out) == stride_size);
|
|
273
|
-
// assert(ranges::size(in) <= ranges::size(out));
|
|
274
|
-
// assert(ranges::empty(in) == false);
|
|
275
|
-
|
|
276
|
-
ranges::copy(in, ranges::begin(out));
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
return arr;
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
}; // namespace qdb::convert::detail
|