quasardb 3.14.2.dev3__cp310-cp310-win_amd64.whl → 3.14.2.dev5__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of quasardb might be problematic. Click here for more details.
- quasardb/INSTALL.vcxproj +6 -5
- quasardb/__init__.py +21 -7
- quasardb/cmake_install.cmake +6 -0
- quasardb/date/ALL_BUILD.vcxproj +10 -9
- quasardb/date/CMakeFiles/Export/df49adab93b9e0c10c64f72458b31971/dateTargets.cmake +2 -2
- quasardb/date/CMakeFiles/generate.stamp.depend +4 -4
- quasardb/date/INSTALL.vcxproj +6 -5
- quasardb/date/cmake_install.cmake +6 -0
- quasardb/date/dateTargets.cmake +2 -2
- quasardb/extensions/writer.py +59 -61
- quasardb/firehose.py +24 -22
- quasardb/numpy/__init__.py +181 -120
- quasardb/pandas/__init__.py +145 -95
- quasardb/pool.py +13 -2
- quasardb/pybind11/ALL_BUILD.vcxproj +10 -9
- quasardb/pybind11/CMakeFiles/generate.stamp.depend +14 -14
- quasardb/pybind11/INSTALL.vcxproj +6 -5
- quasardb/pybind11/cmake_install.cmake +6 -0
- quasardb/qdb_api.dll +0 -0
- quasardb/quasardb.cp310-win_amd64.pyd +0 -0
- quasardb/range-v3/ALL_BUILD.vcxproj +10 -9
- quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +2 -2
- quasardb/range-v3/CMakeFiles/generate.stamp.depend +11 -11
- quasardb/range-v3/INSTALL.vcxproj +6 -5
- quasardb/range-v3/cmake_install.cmake +6 -0
- quasardb/range-v3/range-v3-config.cmake +2 -2
- quasardb/range-v3/range.v3.headers.vcxproj +10 -9
- 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 +54 -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 -124
- {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/detail/writer.cpp
DELETED
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
#include "writer.hpp"
|
|
2
|
-
#include "../convert/array.hpp"
|
|
3
|
-
#include "concepts.hpp"
|
|
4
|
-
#include "dispatch.hpp"
|
|
5
|
-
#include "numpy.hpp"
|
|
6
|
-
#include "retry.hpp"
|
|
7
|
-
#include "traits.hpp"
|
|
8
|
-
|
|
9
|
-
namespace qdb::detail
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
13
|
-
//
|
|
14
|
-
// COLUMN SETTERS
|
|
15
|
-
//
|
|
16
|
-
// Effectively we delegate these to the appropriate convert:: function. Add an
|
|
17
|
-
// additional converter here if you're adding additional column types, *or* wish
|
|
18
|
-
// to support additional dtypes for existing column types (e.g. to also support
|
|
19
|
-
// py::str objects for string columns).
|
|
20
|
-
//
|
|
21
|
-
///////////////////
|
|
22
|
-
|
|
23
|
-
template <qdb_ts_column_type_t ColumnType, concepts::dtype Dtype>
|
|
24
|
-
struct column_setter;
|
|
25
|
-
|
|
26
|
-
#define COLUMN_SETTER_DECL(CTYPE, DTYPE, VALUE_TYPE) \
|
|
27
|
-
template <> \
|
|
28
|
-
struct column_setter<CTYPE, DTYPE> \
|
|
29
|
-
{ \
|
|
30
|
-
inline void operator()(qdb::masked_array const & xs, std::vector<VALUE_TYPE> & dst) \
|
|
31
|
-
{ \
|
|
32
|
-
convert::masked_array<DTYPE, VALUE_TYPE>(xs, dst); \
|
|
33
|
-
} \
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// np.dtype('int64') -> qdb_int_t column
|
|
37
|
-
COLUMN_SETTER_DECL(qdb_ts_column_int64, traits::int64_dtype, qdb_int_t);
|
|
38
|
-
|
|
39
|
-
// np.dtype('int32') -> qdb_int_t column
|
|
40
|
-
COLUMN_SETTER_DECL(qdb_ts_column_int64, traits::int32_dtype, qdb_int_t);
|
|
41
|
-
// np.dtype('int16') -> qdb_int_t column
|
|
42
|
-
COLUMN_SETTER_DECL(qdb_ts_column_int64, traits::int16_dtype, qdb_int_t);
|
|
43
|
-
|
|
44
|
-
// np.dtype('float64') -> double column
|
|
45
|
-
COLUMN_SETTER_DECL(qdb_ts_column_double, traits::float64_dtype, double);
|
|
46
|
-
// np.dtype('float32') -> double column
|
|
47
|
-
COLUMN_SETTER_DECL(qdb_ts_column_double, traits::float32_dtype, double);
|
|
48
|
-
|
|
49
|
-
// np.dtype('datetime64[ns]') -> qdb_timespec_t column
|
|
50
|
-
COLUMN_SETTER_DECL(qdb_ts_column_timestamp, traits::datetime64_ns_dtype, qdb_timespec_t);
|
|
51
|
-
|
|
52
|
-
// np.dtype('unicode') -> qdb_string_T column
|
|
53
|
-
COLUMN_SETTER_DECL(qdb_ts_column_string, traits::unicode_dtype, qdb_string_t);
|
|
54
|
-
|
|
55
|
-
// np.dtype('object') -> qdb_blob_t column
|
|
56
|
-
COLUMN_SETTER_DECL(qdb_ts_column_blob, traits::pyobject_dtype, qdb_blob_t);
|
|
57
|
-
|
|
58
|
-
// np.dtype('S') -> qdb_blob_t column
|
|
59
|
-
COLUMN_SETTER_DECL(qdb_ts_column_blob, traits::bytestring_dtype, qdb_blob_t);
|
|
60
|
-
|
|
61
|
-
#undef COLUMN_SETTER_DECL
|
|
62
|
-
|
|
63
|
-
template <qdb_ts_column_type_t ColumnType>
|
|
64
|
-
inline void set_column_dispatch(
|
|
65
|
-
std::size_t index, qdb::masked_array const & xs, std::vector<any_column> & columns)
|
|
66
|
-
{
|
|
67
|
-
dispatch::by_dtype<detail::column_setter, ColumnType>(
|
|
68
|
-
xs.dtype(), xs, detail::access_column<ColumnType>(columns, index));
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
template <qdb_ts_column_type_t T, typename AnyColumnType>
|
|
72
|
-
inline void prepare_column_of_type(AnyColumnType const & in, qdb_exp_batch_push_column_t & out);
|
|
73
|
-
|
|
74
|
-
template <>
|
|
75
|
-
inline void prepare_column_of_type<qdb_ts_column_int64>(
|
|
76
|
-
int64_column const & in, qdb_exp_batch_push_column_t & out)
|
|
77
|
-
{
|
|
78
|
-
out.data.ints = in.data();
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
template <>
|
|
82
|
-
inline void prepare_column_of_type<qdb_ts_column_double>(
|
|
83
|
-
double_column const & in, qdb_exp_batch_push_column_t & out)
|
|
84
|
-
{
|
|
85
|
-
out.data.doubles = in.data();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
template <>
|
|
89
|
-
inline void prepare_column_of_type<qdb_ts_column_timestamp>(
|
|
90
|
-
timestamp_column const & in, qdb_exp_batch_push_column_t & out)
|
|
91
|
-
{
|
|
92
|
-
out.data.timestamps = in.data();
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
template <>
|
|
96
|
-
inline void prepare_column_of_type<qdb_ts_column_blob>(
|
|
97
|
-
blob_column const & in, qdb_exp_batch_push_column_t & out)
|
|
98
|
-
{
|
|
99
|
-
out.data.blobs = in.data();
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
template <>
|
|
103
|
-
inline void prepare_column_of_type<qdb_ts_column_string>(
|
|
104
|
-
string_column const & in, qdb_exp_batch_push_column_t & out)
|
|
105
|
-
{
|
|
106
|
-
out.data.strings = in.data();
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
template <>
|
|
110
|
-
inline void prepare_column_of_type<qdb_ts_column_symbol>(
|
|
111
|
-
string_column const & in, qdb_exp_batch_push_column_t & out)
|
|
112
|
-
{
|
|
113
|
-
prepare_column_of_type<qdb_ts_column_string>(in, out);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
template <qdb_ts_column_type_t ctype>
|
|
117
|
-
struct fill_column_dispatch
|
|
118
|
-
{
|
|
119
|
-
using value_type = typename traits::qdb_column<ctype>::value_type;
|
|
120
|
-
using column_type = typename column_of_type<ctype>::value_type;
|
|
121
|
-
|
|
122
|
-
inline qdb_exp_batch_push_column_t operator()(any_column const & input)
|
|
123
|
-
{
|
|
124
|
-
qdb_exp_batch_push_column_t ret{};
|
|
125
|
-
|
|
126
|
-
ret.name = nullptr;
|
|
127
|
-
ret.data_type = ctype;
|
|
128
|
-
|
|
129
|
-
// We swap the pointer inside the `qdb_exp_batch_push_column_t` with the pointer
|
|
130
|
-
// to the data as it is inside the `any_column`.
|
|
131
|
-
//
|
|
132
|
-
// This works, because all these `any_column`'s lifecycle is scoped to the
|
|
133
|
-
// writer class, and as such will survive for a long time.
|
|
134
|
-
prepare_column_of_type<ctype>(std::get<column_type>(input), ret);
|
|
135
|
-
|
|
136
|
-
return ret;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// Handle symbols as if they are strings. Data should never be provided using a "symbol" type
|
|
141
|
-
// anyway, but it's good to handle
|
|
142
|
-
template <>
|
|
143
|
-
struct fill_column_dispatch<qdb_ts_column_symbol> : fill_column_dispatch<qdb_ts_column_string>
|
|
144
|
-
{};
|
|
145
|
-
|
|
146
|
-
void staged_table::set_index(py::array const & xs)
|
|
147
|
-
{
|
|
148
|
-
convert::array<traits::datetime64_ns_dtype, qdb_timespec_t>(
|
|
149
|
-
numpy::array::ensure<traits::datetime64_ns_dtype>(xs), _index);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
void staged_table::set_blob_column(std::size_t index, const masked_array & xs)
|
|
153
|
-
{
|
|
154
|
-
detail::set_column_dispatch<qdb_ts_column_blob>(index, xs, _columns);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
void staged_table::set_string_column(std::size_t index, const masked_array & xs)
|
|
158
|
-
{
|
|
159
|
-
detail::set_column_dispatch<qdb_ts_column_string>(index, xs, _columns);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
void staged_table::set_int64_column(std::size_t index, const masked_array_t<traits::int64_dtype> & xs)
|
|
163
|
-
{
|
|
164
|
-
detail::set_column_dispatch<qdb_ts_column_int64>(index, xs, _columns);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
void staged_table::set_double_column(
|
|
168
|
-
std::size_t index, const masked_array_t<traits::float64_dtype> & xs)
|
|
169
|
-
{
|
|
170
|
-
detail::set_column_dispatch<qdb_ts_column_double>(index, xs, _columns);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
void staged_table::set_timestamp_column(
|
|
174
|
-
std::size_t index, const masked_array_t<traits::datetime64_ns_dtype> & xs)
|
|
175
|
-
{
|
|
176
|
-
detail::set_column_dispatch<qdb_ts_column_timestamp>(index, xs, _columns);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
std::vector<qdb_exp_batch_push_column_t> const & staged_table::prepare_columns()
|
|
180
|
-
{
|
|
181
|
-
_columns_data.clear();
|
|
182
|
-
_columns_data.reserve(_columns.size());
|
|
183
|
-
|
|
184
|
-
for (size_t index = 0; index < _columns.size(); ++index)
|
|
185
|
-
{
|
|
186
|
-
qdb_exp_batch_push_column_t column = dispatch::by_column_type<detail::fill_column_dispatch>(
|
|
187
|
-
_column_infos[index].type, _columns.at(index));
|
|
188
|
-
|
|
189
|
-
assert(traits::is_null(column.name));
|
|
190
|
-
|
|
191
|
-
// XXX(leon): reuses lifecycle of _column_infos[index], which *should* be fine,
|
|
192
|
-
// but ensuring we take a reference is super important here!
|
|
193
|
-
std::string const & column_name = _column_infos[index].name;
|
|
194
|
-
column.name = column_name.c_str();
|
|
195
|
-
|
|
196
|
-
#ifndef NDEBUG
|
|
197
|
-
// Symbol column is actually string data
|
|
198
|
-
qdb_ts_column_type_t expected_data_type =
|
|
199
|
-
(_column_infos[index].type == qdb_ts_column_symbol ? qdb_ts_column_string
|
|
200
|
-
: _column_infos[index].type);
|
|
201
|
-
assert(column.data_type == expected_data_type);
|
|
202
|
-
#endif
|
|
203
|
-
|
|
204
|
-
_columns_data.push_back(column);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return _columns_data;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
void staged_table::prepare_table_data(qdb_exp_batch_push_table_data_t & table_data)
|
|
211
|
-
{
|
|
212
|
-
table_data.row_count = _index.size();
|
|
213
|
-
table_data.timestamps = _index.data();
|
|
214
|
-
|
|
215
|
-
const auto & columns = prepare_columns();
|
|
216
|
-
table_data.columns = columns.data();
|
|
217
|
-
table_data.column_count = columns.size();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
void staged_table::prepare_batch(qdb_exp_batch_push_mode_t mode,
|
|
221
|
-
detail::deduplicate_options const & deduplicate_options,
|
|
222
|
-
qdb_ts_range_t * ranges,
|
|
223
|
-
qdb_exp_batch_push_table_t & batch)
|
|
224
|
-
{
|
|
225
|
-
batch.name = _table_name.c_str();
|
|
226
|
-
|
|
227
|
-
prepare_table_data(batch.data);
|
|
228
|
-
if (mode == qdb_exp_batch_push_truncate)
|
|
229
|
-
{
|
|
230
|
-
batch.truncate_ranges = ranges;
|
|
231
|
-
batch.truncate_range_count = ranges == nullptr ? 0u : 1u;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// Zero-initialize these
|
|
235
|
-
batch.where_duplicate = nullptr;
|
|
236
|
-
batch.where_duplicate_count = 0;
|
|
237
|
-
batch.deduplication_mode = qdb_exp_batch_deduplication_mode_disabled;
|
|
238
|
-
batch.creation = qdb_exp_batch_dont_create;
|
|
239
|
-
|
|
240
|
-
enum detail::deduplication_mode_t mode_ = deduplicate_options.mode_;
|
|
241
|
-
|
|
242
|
-
std::visit(
|
|
243
|
-
[&mode_, &batch](auto const & columns) { _set_deduplication_mode(mode_, columns, batch); },
|
|
244
|
-
deduplicate_options.columns_);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/* static */ py::kwargs batch_push_mode::ensure(py::kwargs kwargs)
|
|
248
|
-
{
|
|
249
|
-
if (kwargs.contains(kw_push_mode) == false)
|
|
250
|
-
[[unlikely]] // Our pandas/numpy adapters always set this, so unlikely
|
|
251
|
-
{
|
|
252
|
-
|
|
253
|
-
kwargs[batch_push_mode::kw_push_mode] = batch_push_mode::default_push_mode;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return kwargs;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/* static */ py::kwargs batch_push_mode::set(py::kwargs kwargs, qdb_exp_batch_push_mode_t push_mode)
|
|
260
|
-
{
|
|
261
|
-
assert(kwargs.contains(kw_push_mode) == false);
|
|
262
|
-
|
|
263
|
-
kwargs[batch_push_mode::kw_push_mode] = push_mode;
|
|
264
|
-
|
|
265
|
-
return kwargs;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/* static */ qdb_exp_batch_push_mode_t batch_push_mode::from_kwargs(py::kwargs const & kwargs)
|
|
269
|
-
{
|
|
270
|
-
assert(kwargs.contains(batch_push_mode::kw_push_mode));
|
|
271
|
-
|
|
272
|
-
return py::cast<qdb_exp_batch_push_mode_t>(kwargs[batch_push_mode::kw_push_mode]);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/* static */ py::kwargs detail::batch_push_flags::ensure(py::kwargs kwargs)
|
|
276
|
-
{
|
|
277
|
-
if (kwargs.contains(batch_push_flags::kw_write_through) == false)
|
|
278
|
-
{
|
|
279
|
-
kwargs[batch_push_flags::kw_write_through] = batch_push_flags::default_write_through;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return kwargs;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/* static */ qdb_uint_t detail::batch_push_flags::from_kwargs(py::kwargs const & kwargs)
|
|
286
|
-
{
|
|
287
|
-
assert(kwargs.contains(batch_push_flags::kw_write_through));
|
|
288
|
-
|
|
289
|
-
// By default no flags are set
|
|
290
|
-
qdb_uint_t ret = qdb_exp_batch_push_flag_none;
|
|
291
|
-
|
|
292
|
-
try
|
|
293
|
-
{
|
|
294
|
-
bool write_through = py::cast<bool>(kwargs["write_through"]);
|
|
295
|
-
|
|
296
|
-
// Likely as it's the default, if not, this static assert should fail:
|
|
297
|
-
static_assert(batch_push_flags::default_write_through == true);
|
|
298
|
-
if (write_through == true) [[likely]]
|
|
299
|
-
{
|
|
300
|
-
ret |= static_cast<qdb_uint_t>(qdb_exp_batch_push_flag_write_through);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
catch (py::cast_error const & /*e*/)
|
|
304
|
-
{
|
|
305
|
-
std::string error_msg = "Invalid argument provided for `write_through`: expected bool, got: ";
|
|
306
|
-
error_msg += py::str(py::type::of(kwargs["write_through"])).cast<std::string>();
|
|
307
|
-
|
|
308
|
-
throw qdb::invalid_argument_exception{error_msg};
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return ret;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/* static */ qdb_exp_batch_options_t detail::batch_options::from_kwargs(py::kwargs const & kwargs)
|
|
315
|
-
{
|
|
316
|
-
auto kwargs_ = detail::batch_push_mode::ensure(kwargs);
|
|
317
|
-
|
|
318
|
-
return {
|
|
319
|
-
.mode = detail::batch_push_mode::from_kwargs(kwargs_), //
|
|
320
|
-
.push_flags = detail::batch_push_flags::from_kwargs(kwargs_) //
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/* static */ detail::deduplicate_options detail::deduplicate_options::from_kwargs(py::kwargs args)
|
|
325
|
-
{
|
|
326
|
-
if (!args.contains("deduplicate") || !args.contains("deduplication_mode"))
|
|
327
|
-
{
|
|
328
|
-
return {};
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
std::string deduplication_mode = args["deduplication_mode"].cast<std::string>();
|
|
332
|
-
|
|
333
|
-
enum detail::deduplication_mode_t deduplication_mode_;
|
|
334
|
-
if (deduplication_mode == "drop")
|
|
335
|
-
{
|
|
336
|
-
deduplication_mode_ = detail::deduplication_mode_drop;
|
|
337
|
-
}
|
|
338
|
-
else if (deduplication_mode == "upsert")
|
|
339
|
-
{
|
|
340
|
-
deduplication_mode_ = detail::deduplication_mode_upsert;
|
|
341
|
-
}
|
|
342
|
-
else
|
|
343
|
-
{
|
|
344
|
-
std::string error_msg = "Invalid argument provided for `deduplication_mode`: expected "
|
|
345
|
-
"'drop' or 'upsert', got: ";
|
|
346
|
-
error_msg += deduplication_mode;
|
|
347
|
-
|
|
348
|
-
throw qdb::invalid_argument_exception{error_msg};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
auto deduplicate = args["deduplicate"];
|
|
352
|
-
|
|
353
|
-
if (py::isinstance<py::list>(deduplicate))
|
|
354
|
-
{
|
|
355
|
-
return detail::deduplicate_options{
|
|
356
|
-
deduplication_mode_, py::cast<std::vector<std::string>>(deduplicate)};
|
|
357
|
-
}
|
|
358
|
-
else if (py::isinstance<py::bool_>(deduplicate))
|
|
359
|
-
{
|
|
360
|
-
return detail::deduplicate_options{deduplication_mode_, py::cast<bool>(deduplicate)};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
std::string error_msg = "Invalid argument provided for `deduplicate`: expected bool, list or "
|
|
364
|
-
"str('$timestamp'), got: ";
|
|
365
|
-
error_msg += deduplicate.cast<py::str>();
|
|
366
|
-
|
|
367
|
-
throw qdb::invalid_argument_exception{error_msg};
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
/* static */ staged_tables staged_tables::index(detail::writer_data const & data)
|
|
371
|
-
{
|
|
372
|
-
// XXX(leon): this function could potentially be moved to e.g. a free
|
|
373
|
-
// function as it doesn't really depend upon anything in writer, but
|
|
374
|
-
// then we'll have to globally declare staged_tables_t and it gets a
|
|
375
|
-
// bit messy.
|
|
376
|
-
|
|
377
|
-
detail::staged_tables ret;
|
|
378
|
-
|
|
379
|
-
for (detail::writer_data::value_type const & table_data : data.xs())
|
|
380
|
-
{
|
|
381
|
-
qdb::table table = table_data.table;
|
|
382
|
-
py::array index = table_data.index;
|
|
383
|
-
py::list column_data = table_data.column_data;
|
|
384
|
-
|
|
385
|
-
auto column_infos = table.list_columns();
|
|
386
|
-
|
|
387
|
-
if (column_infos.size() != column_data.size()) [[unlikely]]
|
|
388
|
-
{
|
|
389
|
-
throw qdb::invalid_argument_exception{
|
|
390
|
-
"data must be provided for every column of the table."};
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
detail::staged_table & staged_table = ret.get_or_create(table);
|
|
394
|
-
|
|
395
|
-
staged_table.set_index(index);
|
|
396
|
-
|
|
397
|
-
for (std::size_t i = 0; i < column_data.size(); ++i)
|
|
398
|
-
{
|
|
399
|
-
py::object x = column_data[i];
|
|
400
|
-
|
|
401
|
-
if (!x.is_none()) [[likely]]
|
|
402
|
-
{
|
|
403
|
-
switch (column_infos.at(i).type)
|
|
404
|
-
{
|
|
405
|
-
case qdb_ts_column_double:
|
|
406
|
-
staged_table.set_double_column(
|
|
407
|
-
i, x.cast<qdb::masked_array_t<traits::float64_dtype>>());
|
|
408
|
-
break;
|
|
409
|
-
case qdb_ts_column_blob:
|
|
410
|
-
staged_table.set_blob_column(i, x.cast<qdb::masked_array>());
|
|
411
|
-
break;
|
|
412
|
-
case qdb_ts_column_int64:
|
|
413
|
-
staged_table.set_int64_column(
|
|
414
|
-
i, x.cast<qdb::masked_array_t<traits::int64_dtype>>());
|
|
415
|
-
break;
|
|
416
|
-
case qdb_ts_column_timestamp:
|
|
417
|
-
staged_table.set_timestamp_column(
|
|
418
|
-
i, x.cast<qdb::masked_array_t<traits::datetime64_ns_dtype>>());
|
|
419
|
-
break;
|
|
420
|
-
case qdb_ts_column_string:
|
|
421
|
-
/* FALLTHROUGH */
|
|
422
|
-
case qdb_ts_column_symbol:
|
|
423
|
-
staged_table.set_string_column(i, x.cast<qdb::masked_array>());
|
|
424
|
-
break;
|
|
425
|
-
case qdb_ts_column_uninitialized:
|
|
426
|
-
// Likely a corruption
|
|
427
|
-
throw qdb::invalid_argument_exception{"Uninitialized column."};
|
|
428
|
-
|
|
429
|
-
break;
|
|
430
|
-
// Likely a corruption
|
|
431
|
-
default:
|
|
432
|
-
throw qdb::invalid_argument_exception{"Unrecognized column type."};
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return ret;
|
|
439
|
-
}
|
|
440
|
-
}; // namespace qdb::detail
|