quasardb 3.14.2.dev3__cp310-cp310-macosx_11_0_arm64.whl → 3.14.2.dev5__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 +2 -2
- quasardb/Makefile +20 -20
- quasardb/__init__.py +21 -7
- quasardb/cmake_install.cmake +10 -4
- quasardb/date/CMakeFiles/CMakeDirectoryInformation.cmake +2 -2
- quasardb/date/CMakeFiles/Export/a52b05f964b070ee926bcad51d3288af/dateTargets.cmake +2 -2
- quasardb/date/Makefile +20 -20
- quasardb/date/cmake_install.cmake +10 -4
- quasardb/date/dateConfigVersion.cmake +0 -0
- quasardb/date/dateTargets.cmake +2 -2
- quasardb/extensions/writer.py +59 -61
- quasardb/firehose.py +24 -22
- quasardb/libqdb_api.dylib +0 -0
- quasardb/numpy/__init__.py +181 -120
- quasardb/pandas/__init__.py +145 -95
- quasardb/pool.py +13 -2
- quasardb/pybind11/CMakeFiles/CMakeDirectoryInformation.cmake +2 -2
- 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 +2 -2
- quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +2 -2
- quasardb/range-v3/CMakeFiles/range.v3.headers.dir/build.make +18 -15
- quasardb/range-v3/Makefile +25 -25
- quasardb/range-v3/cmake_install.cmake +13 -7
- quasardb/range-v3/range-v3-config-version.cmake +0 -0
- quasardb/range-v3/range-v3-config.cmake +2 -2
- quasardb/stats.py +92 -80
- quasardb/table_cache.py +5 -1
- {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/METADATA +13 -8
- quasardb-3.14.2.dev5.dist-info/RECORD +45 -0
- {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/WHEEL +1 -1
- quasardb/CMakeLists.txt +0 -517
- quasardb/batch_column.hpp +0 -80
- quasardb/batch_inserter.hpp +0 -248
- quasardb/blob.hpp +0 -150
- quasardb/cluster.cpp +0 -102
- quasardb/cluster.hpp +0 -593
- quasardb/concepts.hpp +0 -322
- quasardb/continuous.cpp +0 -199
- quasardb/continuous.hpp +0 -109
- quasardb/convert/array.hpp +0 -299
- 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 -782
- quasardb/convert.hpp +0 -38
- quasardb/detail/invoke.hpp +0 -0
- quasardb/detail/qdb_resource.hpp +0 -129
- quasardb/detail/retry.cpp +0 -30
- quasardb/detail/retry.hpp +0 -147
- quasardb/detail/sleep.hpp +0 -53
- quasardb/detail/ts_column.hpp +0 -224
- quasardb/detail/writer.cpp +0 -440
- quasardb/detail/writer.hpp +0 -550
- 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 -393
- 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 -658
- quasardb/metrics.cpp +0 -103
- quasardb/metrics.hpp +0 -112
- quasardb/module.cpp +0 -92
- quasardb/module.hpp +0 -24
- quasardb/node.hpp +0 -132
- quasardb/numpy.cpp +0 -6
- quasardb/numpy.hpp +0 -489
- quasardb/object_tracker.hpp +0 -282
- quasardb/options.hpp +0 -273
- quasardb/perf.hpp +0 -336
- quasardb/properties.cpp +0 -41
- quasardb/properties.hpp +0 -85
- quasardb/pytypes.hpp +0 -221
- quasardb/query.cpp +0 -420
- quasardb/query.hpp +0 -92
- quasardb/reader.cpp +0 -282
- quasardb/reader.hpp +0 -256
- quasardb/remove_cvref.hpp +0 -31
- quasardb/string.hpp +0 -160
- quasardb/table.cpp +0 -257
- quasardb/table.hpp +0 -366
- quasardb/tag.hpp +0 -77
- quasardb/timestamp.hpp +0 -97
- quasardb/traits.hpp +0 -642
- 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.hpp +0 -354
- quasardb-3.14.2.dev3.dist-info/RECORD +0 -115
- {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/LICENSE.md +0 -0
- {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/top_level.txt +0 -0
quasardb/traits.hpp
DELETED
|
@@ -1,642 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#pragma once
|
|
3
|
-
|
|
4
|
-
#include <qdb/client.h>
|
|
5
|
-
#include <qdb/ts.h>
|
|
6
|
-
#include <pybind11/numpy.h>
|
|
7
|
-
#include <cassert>
|
|
8
|
-
#include <cmath>
|
|
9
|
-
|
|
10
|
-
namespace qdb::traits
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
namespace py = pybind11;
|
|
14
|
-
|
|
15
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
16
|
-
//
|
|
17
|
-
// BASE CLASSES
|
|
18
|
-
//
|
|
19
|
-
// The classes below define the "base classes" for all traits defined below.
|
|
20
|
-
// Typically only necessary to modify these if you want to add a completely new
|
|
21
|
-
// trait type, or change some defaults.
|
|
22
|
-
//
|
|
23
|
-
///////////////////
|
|
24
|
-
|
|
25
|
-
template <qdb_ts_column_type_t ColumnType>
|
|
26
|
-
struct qdb_column;
|
|
27
|
-
|
|
28
|
-
template <qdb_ts_column_type_t ColumnType>
|
|
29
|
-
struct qdb_column_base
|
|
30
|
-
{
|
|
31
|
-
static constexpr qdb_ts_column_type_t column_type = ColumnType;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
template <typename ValueType>
|
|
35
|
-
struct qdb_value;
|
|
36
|
-
|
|
37
|
-
template <typename ValueType>
|
|
38
|
-
struct qdb_value_base
|
|
39
|
-
{
|
|
40
|
-
using value_type = ValueType;
|
|
41
|
-
|
|
42
|
-
static constexpr bool is_qdb_primitive = false;
|
|
43
|
-
static constexpr bool is_qdb_point = false;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
47
|
-
//
|
|
48
|
-
// TRAIT DECLARATION MACROS
|
|
49
|
-
//
|
|
50
|
-
// Convenience macros that make it more concise to declare a new trait, and
|
|
51
|
-
// avoid any errors.
|
|
52
|
-
//
|
|
53
|
-
///////////////////
|
|
54
|
-
|
|
55
|
-
#define VALUE_TRAIT_DECL(VT) \
|
|
56
|
-
template <> \
|
|
57
|
-
struct qdb_value<VT> : public qdb_value_base<VT>
|
|
58
|
-
|
|
59
|
-
#define COLUMN_TRAIT_DECL(CT, VT) \
|
|
60
|
-
template <> \
|
|
61
|
-
struct qdb_column<CT> : public qdb_column_base<CT> \
|
|
62
|
-
{ \
|
|
63
|
-
using value_type = VT; \
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
#define DTYPE_TRAIT_DECL(DT) \
|
|
67
|
-
template <> \
|
|
68
|
-
struct npy_dtype<DT> : public npy_dtype_base<DT>
|
|
69
|
-
|
|
70
|
-
#define DTYPE_TRAIT_HEADER(DT, VALUE_TYPE) \
|
|
71
|
-
using value_type = VALUE_TYPE; \
|
|
72
|
-
\
|
|
73
|
-
static inline bool is_dtype(py::dtype dt) noexcept \
|
|
74
|
-
{ \
|
|
75
|
-
return DT::is_dtype(dt); \
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
#define DTYPE_DELEGATE_HEADER(DT1, VALUE_TYPE, DT2) \
|
|
79
|
-
DTYPE_TRAIT_HEADER(DT1, VALUE_TYPE); \
|
|
80
|
-
using delegate_type = DT2;
|
|
81
|
-
|
|
82
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
83
|
-
//
|
|
84
|
-
// COLUMN TRAITS
|
|
85
|
-
//
|
|
86
|
-
///////////////////
|
|
87
|
-
|
|
88
|
-
COLUMN_TRAIT_DECL(qdb_ts_column_int64, qdb_int_t);
|
|
89
|
-
COLUMN_TRAIT_DECL(qdb_ts_column_double, double);
|
|
90
|
-
COLUMN_TRAIT_DECL(qdb_ts_column_timestamp, qdb_timespec_t);
|
|
91
|
-
COLUMN_TRAIT_DECL(qdb_ts_column_blob, qdb_blob_t);
|
|
92
|
-
COLUMN_TRAIT_DECL(qdb_ts_column_string, qdb_string_t);
|
|
93
|
-
COLUMN_TRAIT_DECL(qdb_ts_column_symbol, qdb_string_t);
|
|
94
|
-
|
|
95
|
-
#undef COLUMN_TRAIT_DECL
|
|
96
|
-
|
|
97
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
98
|
-
//
|
|
99
|
-
// VALUE TRAITS
|
|
100
|
-
//
|
|
101
|
-
///////////////////
|
|
102
|
-
|
|
103
|
-
VALUE_TRAIT_DECL(qdb_int_t)
|
|
104
|
-
{
|
|
105
|
-
using point_type = qdb_ts_int64_point;
|
|
106
|
-
|
|
107
|
-
static constexpr bool is_qdb_primitive = true;
|
|
108
|
-
|
|
109
|
-
static constexpr qdb_int_t null_value() noexcept
|
|
110
|
-
{
|
|
111
|
-
return static_cast<qdb_int_t>(0x8000000000000000ll);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
static constexpr bool is_null(qdb_int_t x) noexcept
|
|
115
|
-
{
|
|
116
|
-
return x == null_value();
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
VALUE_TRAIT_DECL(double)
|
|
121
|
-
{
|
|
122
|
-
using point_type = qdb_ts_double_point;
|
|
123
|
-
|
|
124
|
-
static constexpr bool is_qdb_primitive = true;
|
|
125
|
-
|
|
126
|
-
static constexpr double null_value() noexcept
|
|
127
|
-
{
|
|
128
|
-
return NAN;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static bool is_null(double x) noexcept
|
|
132
|
-
{
|
|
133
|
-
// std::isnan is not a constexpr on windows
|
|
134
|
-
return std::isnan(x);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
VALUE_TRAIT_DECL(qdb_timespec_t)
|
|
139
|
-
{
|
|
140
|
-
using point_type = qdb_ts_timestamp_point;
|
|
141
|
-
|
|
142
|
-
static constexpr bool is_qdb_primitive = true;
|
|
143
|
-
|
|
144
|
-
static constexpr qdb_timespec_t null_value() noexcept
|
|
145
|
-
{
|
|
146
|
-
return qdb_timespec_t{qdb_min_time, qdb_min_time};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
static constexpr bool is_null(qdb_timespec_t x) noexcept
|
|
150
|
-
{
|
|
151
|
-
return x.tv_sec == qdb_min_time && x.tv_nsec == qdb_min_time;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
static constexpr qdb_timespec_t min() noexcept
|
|
155
|
-
{
|
|
156
|
-
return qdb_timespec_t{0, 0};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
static constexpr qdb_timespec_t max() noexcept
|
|
160
|
-
{
|
|
161
|
-
return qdb_timespec_t{std::numeric_limits<qdb_time_t>::max(), 0};
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
VALUE_TRAIT_DECL(qdb_ts_range_t)
|
|
166
|
-
{
|
|
167
|
-
static constexpr bool is_qdb_primitive = true;
|
|
168
|
-
|
|
169
|
-
static constexpr qdb_ts_range_t null_value() noexcept
|
|
170
|
-
{
|
|
171
|
-
return qdb_ts_range_t{
|
|
172
|
-
qdb_value<qdb_timespec_t>::null_value(), qdb_value<qdb_timespec_t>::null_value()};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
static constexpr qdb_ts_range_t forever() noexcept
|
|
176
|
-
{
|
|
177
|
-
return qdb_ts_range_t{qdb_timespec_t{0, 0},
|
|
178
|
-
|
|
179
|
-
// Don't hate the player, hate the game of poorly defined constants
|
|
180
|
-
qdb_timespec_t{9223372036, 854775807}};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
static constexpr bool is_null(qdb_timespec_t x) noexcept
|
|
184
|
-
{
|
|
185
|
-
return x.tv_sec == qdb_min_time && x.tv_nsec == qdb_min_time;
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
VALUE_TRAIT_DECL(qdb_string_t)
|
|
190
|
-
{
|
|
191
|
-
using point_type = qdb_ts_string_point;
|
|
192
|
-
static constexpr bool is_qdb_primitive = true;
|
|
193
|
-
|
|
194
|
-
static constexpr qdb_string_t null_value() noexcept
|
|
195
|
-
{
|
|
196
|
-
return qdb_string_t{nullptr, 0};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
static constexpr bool is_null(qdb_string_t x) noexcept
|
|
200
|
-
{
|
|
201
|
-
return x.length == 0;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
VALUE_TRAIT_DECL(qdb_blob_t)
|
|
206
|
-
{
|
|
207
|
-
using point_type = qdb_ts_blob_point;
|
|
208
|
-
static constexpr bool is_qdb_primitive = true;
|
|
209
|
-
|
|
210
|
-
static constexpr qdb_blob_t null_value() noexcept
|
|
211
|
-
{
|
|
212
|
-
return qdb_blob_t{nullptr, 0};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
static constexpr bool is_null(qdb_blob_t x) noexcept
|
|
216
|
-
{
|
|
217
|
-
return x.content_length == 0;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
VALUE_TRAIT_DECL(char const *)
|
|
222
|
-
{
|
|
223
|
-
static constexpr bool is_qdb_primitive = false;
|
|
224
|
-
|
|
225
|
-
static constexpr char const * null_value() noexcept
|
|
226
|
-
{
|
|
227
|
-
return nullptr;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
static constexpr bool is_null(char const * x) noexcept
|
|
231
|
-
{
|
|
232
|
-
return x == null_value();
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
VALUE_TRAIT_DECL(qdb_ts_double_point)
|
|
237
|
-
{
|
|
238
|
-
using primitive_type = double;
|
|
239
|
-
static constexpr bool is_qdb_point = true;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
VALUE_TRAIT_DECL(qdb_ts_int64_point)
|
|
243
|
-
{
|
|
244
|
-
using primitive_type = qdb_int_t;
|
|
245
|
-
static constexpr bool is_qdb_point = true;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
VALUE_TRAIT_DECL(qdb_ts_timestamp_point)
|
|
249
|
-
{
|
|
250
|
-
using primitive_type = qdb_timespec_t;
|
|
251
|
-
static constexpr bool is_qdb_point = true;
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
VALUE_TRAIT_DECL(qdb_ts_blob_point)
|
|
255
|
-
{
|
|
256
|
-
using primitive_type = qdb_blob_t;
|
|
257
|
-
static constexpr bool is_qdb_point = true;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
VALUE_TRAIT_DECL(qdb_ts_string_point)
|
|
261
|
-
{
|
|
262
|
-
using primitive_type = qdb_string_t;
|
|
263
|
-
static constexpr bool is_qdb_point = true;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
#undef VALUE_TRAIT_DECL
|
|
267
|
-
|
|
268
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
269
|
-
//
|
|
270
|
-
// DTYPE DEFINITIONS
|
|
271
|
-
//
|
|
272
|
-
// Not strictly a "trait" but rather a constant, but we use these to define traits.
|
|
273
|
-
// Effectively we declare our dtypes as template-dispatch tags.
|
|
274
|
-
//
|
|
275
|
-
// You will want to add new kinds / dtypes here, e.g. if we start supporting unsigned
|
|
276
|
-
// integers or whatever.
|
|
277
|
-
//
|
|
278
|
-
///////////////////
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* One of the things we want to be able to dispatch on is the "kind", e.g.
|
|
282
|
-
* "dispatch based on any integer-type".
|
|
283
|
-
*
|
|
284
|
-
* Redefine these character codes to enums
|
|
285
|
-
*/
|
|
286
|
-
enum dtype_kind
|
|
287
|
-
{
|
|
288
|
-
int_kind = 'i',
|
|
289
|
-
float_kind = 'f',
|
|
290
|
-
datetime_kind = 'M',
|
|
291
|
-
object_kind = 'O',
|
|
292
|
-
unicode_kind = 'U',
|
|
293
|
-
bytestring_kind = 'S'
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Dtype tag dispatch base struct, only has a "kind", but never directly constructed.
|
|
298
|
-
*/
|
|
299
|
-
template <dtype_kind Kind>
|
|
300
|
-
struct dtype
|
|
301
|
-
{
|
|
302
|
-
static constexpr dtype_kind kind = Kind;
|
|
303
|
-
|
|
304
|
-
static inline bool is_dtype(py::dtype dt) noexcept
|
|
305
|
-
{
|
|
306
|
-
return dt.kind() == Kind;
|
|
307
|
-
};
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Dtypes with a fixed width, which is most "simple" ones, including py::object.
|
|
312
|
-
*/
|
|
313
|
-
template <dtype_kind Kind, py::ssize_t Size>
|
|
314
|
-
struct fixed_width_dtype : public dtype<Kind>
|
|
315
|
-
{
|
|
316
|
-
static constexpr py::ssize_t size = Size;
|
|
317
|
-
|
|
318
|
-
static inline bool is_dtype(py::dtype dt) noexcept
|
|
319
|
-
{
|
|
320
|
-
return dt.kind() == Kind && dt.itemsize() == Size;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// By definition, fixed width dtypes always have a stride size of 1 (i.e.
|
|
324
|
-
// they move forward sizeof(value_type) bytes per item.
|
|
325
|
-
static constexpr py::ssize_t stride_size(py::ssize_t /* itemsize */) noexcept
|
|
326
|
-
{
|
|
327
|
-
return 1;
|
|
328
|
-
};
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Variable width dtypes require special parsing. Numpy variable width encoding
|
|
333
|
-
* encodes the entire array as a single, continuous block of memory, with items
|
|
334
|
-
* of length `CodePointSize`. This length is always the same for a single instance
|
|
335
|
-
* of an array, but differs for different instances.
|
|
336
|
-
*
|
|
337
|
-
* Before encoding the array, Numpy determines the length of the longest item
|
|
338
|
-
* in the array, and uses that as the stride size.
|
|
339
|
-
*
|
|
340
|
-
* There are two variable width dtypes we deal with:
|
|
341
|
-
*
|
|
342
|
-
* - unicode, that is represented using UTF-32, meaning the size of each
|
|
343
|
-
* code point is 4 bytes.
|
|
344
|
-
* - bytestrings, that are represented using "just" bytes, but are null
|
|
345
|
-
* terminated (!!). Numpy has deprecated it, in favor of just byte[] objects,
|
|
346
|
-
* but Pandas sometimes generates this type of data.
|
|
347
|
-
*
|
|
348
|
-
* Since it is very efficient way to encode blob data, we support it.
|
|
349
|
-
*
|
|
350
|
-
* StrideType is the type used to represent a single code point.
|
|
351
|
-
*
|
|
352
|
-
* CodePointSize defines the size (in bytes) of each code point, e.g. for
|
|
353
|
-
* UTF-32 / UCS-4 this would be 4, as each character is represented using 4 bytes.
|
|
354
|
-
*/
|
|
355
|
-
template <dtype_kind Kind, typename StrideType, py::ssize_t CodePointSize>
|
|
356
|
-
requires(CodePointSize == sizeof(typename StrideType::value_type))
|
|
357
|
-
struct variable_width_dtype : public dtype<Kind>
|
|
358
|
-
{
|
|
359
|
-
using dtype<Kind>::is_dtype;
|
|
360
|
-
using stride_type = StrideType;
|
|
361
|
-
|
|
362
|
-
static constexpr py::ssize_t code_point_size = CodePointSize;
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Given the number of bytes of a single item, calculate the number of characters
|
|
366
|
-
* (code points) in a single stride.
|
|
367
|
-
*
|
|
368
|
-
* By definition, n == stride_size(itemsize(n))
|
|
369
|
-
*/
|
|
370
|
-
static constexpr py::ssize_t stride_size(py::ssize_t itemsize) noexcept
|
|
371
|
-
{
|
|
372
|
-
assert(itemsize % code_point_size == 0);
|
|
373
|
-
return itemsize / code_point_size;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Based on the number of codepoints, calculates the numpy `itemsize()` value
|
|
378
|
-
* for this stride type (i.e. the number of bytes in a single item).
|
|
379
|
-
*
|
|
380
|
-
* By definition, n == itemsize(stride_size(n))
|
|
381
|
-
*/
|
|
382
|
-
static constexpr py::ssize_t itemsize(py::ssize_t codepoints) noexcept
|
|
383
|
-
{
|
|
384
|
-
return codepoints * code_point_size;
|
|
385
|
-
};
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
// Py_intptr_t is best described as a pointer-that-can-be-cast-to-integer and
|
|
389
|
-
// back.
|
|
390
|
-
//
|
|
391
|
-
// As such, it's a good proxy for the size of a py::object as it is represented
|
|
392
|
-
// in a np.ndarray.
|
|
393
|
-
static constexpr py::ssize_t pyobject_size = sizeof(Py_intptr_t);
|
|
394
|
-
|
|
395
|
-
template <typename ObjectType>
|
|
396
|
-
struct object_dtype : public fixed_width_dtype<object_kind, pyobject_size>
|
|
397
|
-
{
|
|
398
|
-
using fixed_width_dtype<object_kind, pyobject_size>::is_dtype;
|
|
399
|
-
using value_type = ObjectType;
|
|
400
|
-
|
|
401
|
-
static inline bool is_null(py::object x) noexcept
|
|
402
|
-
{
|
|
403
|
-
return x.is_none();
|
|
404
|
-
};
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* We may want to dispatch datetime64 based on the precision (ns, ms, etc), which
|
|
409
|
-
* is what we will allow for here.
|
|
410
|
-
*/
|
|
411
|
-
enum datetime64_precision
|
|
412
|
-
{
|
|
413
|
-
datetime64_ns
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
template <datetime64_precision Precision>
|
|
417
|
-
struct datetime64_dtype : public fixed_width_dtype<datetime_kind, 8>
|
|
418
|
-
{
|
|
419
|
-
static constexpr datetime64_precision precision = Precision;
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
struct int64_dtype : public fixed_width_dtype<int_kind, 8>
|
|
423
|
-
{
|
|
424
|
-
using value_type = std::int64_t;
|
|
425
|
-
using qdb_value = qdb_int_t;
|
|
426
|
-
|
|
427
|
-
static constexpr std::int64_t null_value() noexcept
|
|
428
|
-
{
|
|
429
|
-
return static_cast<std::int64_t>(0x8000000000000000ll);
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
static constexpr inline bool is_null(value_type x) noexcept
|
|
433
|
-
{
|
|
434
|
-
return x == null_value();
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
static inline py::dtype dtype() noexcept
|
|
438
|
-
{
|
|
439
|
-
return py::dtype("int64");
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
struct int32_dtype : public fixed_width_dtype<int_kind, 4>
|
|
444
|
-
{
|
|
445
|
-
using value_type = std::int32_t;
|
|
446
|
-
using delegate_type = int64_dtype;
|
|
447
|
-
|
|
448
|
-
static constexpr value_type null_value() noexcept
|
|
449
|
-
{
|
|
450
|
-
return std::numeric_limits<value_type>::min();
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
static constexpr inline bool is_null(value_type x) noexcept
|
|
454
|
-
{
|
|
455
|
-
return x == null_value();
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
static inline py::dtype dtype() noexcept
|
|
459
|
-
{
|
|
460
|
-
return py::dtype("int32");
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
struct int16_dtype : public fixed_width_dtype<int_kind, 2>
|
|
465
|
-
{
|
|
466
|
-
using value_type = std::int16_t;
|
|
467
|
-
using delegate_type = int64_dtype;
|
|
468
|
-
|
|
469
|
-
static constexpr value_type null_value() noexcept
|
|
470
|
-
{
|
|
471
|
-
return std::numeric_limits<value_type>::min();
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
static constexpr inline bool is_null(value_type x) noexcept
|
|
475
|
-
{
|
|
476
|
-
return x == null_value();
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
static inline py::dtype dtype() noexcept
|
|
480
|
-
{
|
|
481
|
-
return py::dtype("int16");
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
struct float64_dtype : public fixed_width_dtype<float_kind, 8>
|
|
486
|
-
{
|
|
487
|
-
using value_type = double;
|
|
488
|
-
using qdb_value = double;
|
|
489
|
-
|
|
490
|
-
static constexpr value_type null_value() noexcept
|
|
491
|
-
{
|
|
492
|
-
return NAN;
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
static inline bool is_null(value_type x) noexcept
|
|
496
|
-
{
|
|
497
|
-
return std::isnan(x);
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
static inline py::dtype dtype() noexcept
|
|
501
|
-
{
|
|
502
|
-
return py::dtype("float64");
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
struct float32_dtype : public fixed_width_dtype<float_kind, 4>
|
|
507
|
-
{
|
|
508
|
-
using value_type = float;
|
|
509
|
-
using delegate_type = float64_dtype;
|
|
510
|
-
|
|
511
|
-
static constexpr value_type null_value() noexcept
|
|
512
|
-
{
|
|
513
|
-
return NAN;
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
static inline py::dtype dtype() noexcept
|
|
517
|
-
{
|
|
518
|
-
return py::dtype("float32");
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
static inline bool is_null(value_type x) noexcept
|
|
522
|
-
{
|
|
523
|
-
return std::isnan(x);
|
|
524
|
-
};
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
struct unicode_dtype : public variable_width_dtype<unicode_kind, std::u32string, 4>
|
|
528
|
-
{
|
|
529
|
-
using value_type = std::u32string::value_type;
|
|
530
|
-
|
|
531
|
-
static constexpr value_type null_value() noexcept
|
|
532
|
-
{
|
|
533
|
-
return '\0';
|
|
534
|
-
};
|
|
535
|
-
static constexpr inline bool is_null(value_type x) noexcept
|
|
536
|
-
{
|
|
537
|
-
return x == null_value();
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
static inline py::dtype dtype() noexcept
|
|
541
|
-
{
|
|
542
|
-
return py::dtype("U");
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
static inline py::dtype dtype(py::ssize_t codepoints_per_word) noexcept
|
|
546
|
-
{
|
|
547
|
-
return py::dtype(std::string{"U"} + std::to_string(codepoints_per_word));
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
struct bytestring_dtype : public variable_width_dtype<bytestring_kind, std::string, 1>
|
|
552
|
-
{
|
|
553
|
-
using value_type = std::string::value_type;
|
|
554
|
-
|
|
555
|
-
static constexpr value_type null_value() noexcept
|
|
556
|
-
{
|
|
557
|
-
return '\0';
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
static constexpr inline bool is_null(value_type x) noexcept
|
|
561
|
-
{
|
|
562
|
-
return x == null_value();
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
static inline py::dtype dtype() noexcept
|
|
566
|
-
{
|
|
567
|
-
return py::dtype("S");
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
struct pyobject_dtype : public object_dtype<py::object>
|
|
572
|
-
{
|
|
573
|
-
using value_type = py::object;
|
|
574
|
-
|
|
575
|
-
static inline py::object null_value() noexcept
|
|
576
|
-
{
|
|
577
|
-
return py::none{};
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
static inline py::dtype dtype() noexcept
|
|
581
|
-
{
|
|
582
|
-
return py::dtype("O");
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
struct datetime64_ns_dtype : public datetime64_dtype<datetime64_ns>
|
|
587
|
-
{
|
|
588
|
-
static_assert(sizeof(int64_t) == sizeof(qdb_time_t));
|
|
589
|
-
using value_type = std::int64_t;
|
|
590
|
-
|
|
591
|
-
static constexpr std::int64_t null_value() noexcept
|
|
592
|
-
{
|
|
593
|
-
return static_cast<std::int64_t>(qdb_min_time);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
static constexpr inline bool is_null(value_type x) noexcept
|
|
597
|
-
{
|
|
598
|
-
return x == null_value();
|
|
599
|
-
};
|
|
600
|
-
|
|
601
|
-
static inline py::dtype dtype() noexcept
|
|
602
|
-
{
|
|
603
|
-
return py::dtype("datetime64[ns]");
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
|
|
607
|
-
// Easy accessors for some commonly requested functions
|
|
608
|
-
template <typename T>
|
|
609
|
-
inline bool is_null(T x) noexcept
|
|
610
|
-
{
|
|
611
|
-
return qdb_value<T>::is_null(x);
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
template <typename T>
|
|
615
|
-
inline T null_value() noexcept
|
|
616
|
-
{
|
|
617
|
-
return qdb_value<T>::null_value();
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
-
// Easy accessors for some commonly requested functions
|
|
621
|
-
template <typename T>
|
|
622
|
-
inline bool is_null(typename T::value_type x) noexcept
|
|
623
|
-
{
|
|
624
|
-
return T::is_null(x);
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
// Easy accessors for some commonly requested functions
|
|
628
|
-
template <typename T>
|
|
629
|
-
inline typename T::value_type null_value() noexcept
|
|
630
|
-
{
|
|
631
|
-
return T::null_value();
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
template <class T>
|
|
635
|
-
struct is_chrono_duration : std::false_type
|
|
636
|
-
{};
|
|
637
|
-
|
|
638
|
-
template <class Rep, class Period>
|
|
639
|
-
struct is_chrono_duration<std::chrono::duration<Rep, Period>> : std::true_type
|
|
640
|
-
{};
|
|
641
|
-
|
|
642
|
-
}; // namespace qdb::traits
|