quasardb 3.14.2.dev1__cp312-cp312-macosx_11_0_arm64.whl → 3.14.2.dev4__cp312-cp312-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-312-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/reader/ts_row.hpp
DELETED
|
@@ -1,281 +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 "ts_value.hpp"
|
|
34
|
-
#include <qdb/ts.h>
|
|
35
|
-
#include <detail/ts_column.hpp>
|
|
36
|
-
#include <pybind11/numpy.h>
|
|
37
|
-
#include <pybind11/stl_bind.h>
|
|
38
|
-
#include <numpy.hpp>
|
|
39
|
-
|
|
40
|
-
namespace py = pybind11;
|
|
41
|
-
|
|
42
|
-
namespace qdb
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
namespace reader
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
using ts_columns_t = std::vector<detail::column_info>;
|
|
49
|
-
|
|
50
|
-
class ts_row
|
|
51
|
-
{
|
|
52
|
-
public:
|
|
53
|
-
// We need a default constructor to due being copied as part of an iterator.
|
|
54
|
-
ts_row() noexcept = default;
|
|
55
|
-
|
|
56
|
-
ts_row(handle_ptr handle, qdb_local_table_t local_table) noexcept
|
|
57
|
-
: _handle{handle}
|
|
58
|
-
, _local_table{local_table}
|
|
59
|
-
{}
|
|
60
|
-
|
|
61
|
-
bool operator==(const ts_row & rhs) const noexcept
|
|
62
|
-
{
|
|
63
|
-
auto tie = [](const auto & ts) { return std::tie(ts.tv_sec, ts.tv_nsec); };
|
|
64
|
-
|
|
65
|
-
// Since our row doesn't hold any intrinsic data itself and is merely
|
|
66
|
-
// an indirection to the data in the local table, it doesn't make a lot
|
|
67
|
-
// of sense to compare it with another other than comparing the timestamps
|
|
68
|
-
// and the local table references.
|
|
69
|
-
return (tie(_timestamp) == tie(rhs._timestamp)) && (_local_table == rhs._local_table);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
numpy::datetime64 timestamp() const noexcept
|
|
73
|
-
{
|
|
74
|
-
return numpy::datetime64(_timestamp);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Not exposed through Python, but allows the read_row operation to write the underlying
|
|
79
|
-
* timestamp object directly.
|
|
80
|
-
*/
|
|
81
|
-
qdb_timespec_t & mutable_timestamp() noexcept
|
|
82
|
-
{
|
|
83
|
-
return _timestamp;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
protected:
|
|
87
|
-
handle_ptr _handle{nullptr};
|
|
88
|
-
qdb_local_table_t _local_table{nullptr};
|
|
89
|
-
qdb_timespec_t _timestamp;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Our 'fast' row is a pure, lazy list-type row that uses a column's offset for
|
|
94
|
-
* constant-time access to the column values. E.g. row[0], row[1] which will return
|
|
95
|
-
* a (short-lived) ts_value.
|
|
96
|
-
*/
|
|
97
|
-
class ts_fast_row : public ts_row
|
|
98
|
-
{
|
|
99
|
-
public:
|
|
100
|
-
ts_fast_row() noexcept = default;
|
|
101
|
-
|
|
102
|
-
ts_fast_row(handle_ptr handle, qdb_local_table_t local_table, const ts_columns_t & columns) noexcept
|
|
103
|
-
: ts_row(handle, local_table)
|
|
104
|
-
, _columns(columns)
|
|
105
|
-
{}
|
|
106
|
-
|
|
107
|
-
std::vector<py::object> copy() const
|
|
108
|
-
{
|
|
109
|
-
int64_t size = _columns.size() + 1;
|
|
110
|
-
std::vector<py::object> res;
|
|
111
|
-
res.reserve(size);
|
|
112
|
-
|
|
113
|
-
for (auto index = 0; index < size; ++index)
|
|
114
|
-
{
|
|
115
|
-
// By first casting the value, we create a copy of the concrete type
|
|
116
|
-
// (e.g. the int64 or the blob) rather than the reference into the local
|
|
117
|
-
// table.
|
|
118
|
-
res.push_back(get_item(index));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return res;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
py::object get_item(uint64_t index) const
|
|
125
|
-
{
|
|
126
|
-
if (index == 0)
|
|
127
|
-
{
|
|
128
|
-
// TODO(leon): we construct this object every time; should be without any heap
|
|
129
|
-
// allocations,but can we do without this?
|
|
130
|
-
return timestamp();
|
|
131
|
-
}
|
|
132
|
-
else
|
|
133
|
-
{
|
|
134
|
-
uint64_t col_index = index - 1;
|
|
135
|
-
if (col_index > _columns.size())
|
|
136
|
-
{
|
|
137
|
-
throw py::index_error();
|
|
138
|
-
}
|
|
139
|
-
return py::cast(ts_value(_handle, _local_table, col_index, _columns.at(col_index).type),
|
|
140
|
-
py::return_value_policy::move);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
void set_item(int64_t /* index */, int64_t /* value */)
|
|
145
|
-
{
|
|
146
|
-
// not implemented
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
std::string repr() const
|
|
150
|
-
{
|
|
151
|
-
// This is inefficient because we first cast everything to Python objects, get the
|
|
152
|
-
// string representation and then cast back to c++ strings, but it's correct and
|
|
153
|
-
// effective, and it's used for debugging purposes only.
|
|
154
|
-
auto xs = copy();
|
|
155
|
-
std::string kvs =
|
|
156
|
-
std::accumulate(xs.cbegin(), xs.cend(), std::string(), [](std::string acc, auto x) {
|
|
157
|
-
std::string s = py::str(x);
|
|
158
|
-
return acc.empty() ? s : std::move(acc) + ", " + s;
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
return "[" + std::move(kvs) + "]";
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
private:
|
|
165
|
-
ts_columns_t _columns;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Our 'dict' row is a much slower, dict-based row type that provides very convenient
|
|
170
|
-
* access to the columns by their name. It does, however, index each and every row's
|
|
171
|
-
* columns eagerly, and as such will exhibit much worse performance.
|
|
172
|
-
*/
|
|
173
|
-
class ts_dict_row : public ts_row
|
|
174
|
-
{
|
|
175
|
-
public:
|
|
176
|
-
ts_dict_row() noexcept = default;
|
|
177
|
-
|
|
178
|
-
ts_dict_row(handle_ptr handle, qdb_local_table_t local_table, const ts_columns_t & columns)
|
|
179
|
-
: ts_row(handle, local_table)
|
|
180
|
-
, _indexed_columns(detail::index_columns(columns))
|
|
181
|
-
{
|
|
182
|
-
// We store '$timestamp' as a magic, uninitialized column. This column type
|
|
183
|
-
// is then recorgnized by get_item()
|
|
184
|
-
_indexed_columns.insert(detail::indexed_columns_t::value_type("$timestamp", {}));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
ts_dict_row(const ts_dict_row & rhs) noexcept
|
|
188
|
-
: ts_row(rhs._handle, rhs._local_table)
|
|
189
|
-
, _indexed_columns(rhs._indexed_columns)
|
|
190
|
-
{}
|
|
191
|
-
|
|
192
|
-
std::map<std::string, py::object> copy() const
|
|
193
|
-
{
|
|
194
|
-
using map_type = std::map<std::string, py::object>;
|
|
195
|
-
map_type res;
|
|
196
|
-
|
|
197
|
-
for (const auto & c : _indexed_columns)
|
|
198
|
-
{
|
|
199
|
-
qdb_size_t index = c.second.index;
|
|
200
|
-
|
|
201
|
-
// By first casting the value, we create a copy of the concrete type
|
|
202
|
-
// (e.g. the int64 or the blob) rather than the reference into the local
|
|
203
|
-
// table.
|
|
204
|
-
if (c.second.type == qdb_ts_column_uninitialized)
|
|
205
|
-
{
|
|
206
|
-
// assert (i.first == "$timestamp")
|
|
207
|
-
res.insert(map_type::value_type(c.first, timestamp()));
|
|
208
|
-
}
|
|
209
|
-
else
|
|
210
|
-
res.insert(map_type::value_type(
|
|
211
|
-
c.first, py::cast(ts_value(_handle, _local_table, index, c.second.type))));
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return res;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
py::object get_item(const std::string & alias) const
|
|
218
|
-
{
|
|
219
|
-
auto c = _indexed_columns.find(alias);
|
|
220
|
-
if (c == _indexed_columns.end())
|
|
221
|
-
{
|
|
222
|
-
throw pybind11::key_error();
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const auto & indexed_column = c->second;
|
|
226
|
-
if (c->second.type == qdb_ts_column_uninitialized)
|
|
227
|
-
{
|
|
228
|
-
// assert(alias == "$timestamp")
|
|
229
|
-
return timestamp();
|
|
230
|
-
}
|
|
231
|
-
else
|
|
232
|
-
{
|
|
233
|
-
return py::cast(ts_value(_handle, _local_table, indexed_column.index, indexed_column.type),
|
|
234
|
-
py::return_value_policy::move);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
void set_item(const std::string & /* alias */, const std::string & /* value */) const noexcept
|
|
239
|
-
{
|
|
240
|
-
// not implemented
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
std::string repr() const
|
|
244
|
-
{
|
|
245
|
-
// Same as ts_fast_row::repr, this is inefficient but it's ok
|
|
246
|
-
auto xs = copy();
|
|
247
|
-
std::string items =
|
|
248
|
-
std::accumulate(xs.cbegin(), xs.cend(), std::string(), [](std::string acc, const auto & x) {
|
|
249
|
-
std::string s = "'" + x.first + "': " + std::string(py::str(x.second));
|
|
250
|
-
return acc.empty() ? s : std::move(acc) + ", " + s;
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
return "{" + std::move(items) + "}";
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
private:
|
|
257
|
-
detail::indexed_columns_t _indexed_columns;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
template <typename Module>
|
|
261
|
-
static inline void register_ts_row(Module & m)
|
|
262
|
-
{
|
|
263
|
-
py::bind_vector<std::vector<py::object>>(m, "VectorObject");
|
|
264
|
-
|
|
265
|
-
py::class_<ts_fast_row>{m, "TimeSeriesReaderFastRow"}
|
|
266
|
-
.def("__repr__", &ts_fast_row::repr)
|
|
267
|
-
.def("__getitem__", &ts_fast_row::get_item, py::return_value_policy::move)
|
|
268
|
-
.def("__setitem__", &ts_fast_row::set_item)
|
|
269
|
-
.def("timestamp", &ts_fast_row::timestamp)
|
|
270
|
-
.def("copy", &ts_fast_row::copy);
|
|
271
|
-
|
|
272
|
-
py::class_<ts_dict_row>{m, "TimeSeriesReaderDictRow"}
|
|
273
|
-
.def("__repr__", &ts_dict_row::repr)
|
|
274
|
-
.def("__getitem__", &ts_dict_row::get_item, py::return_value_policy::move)
|
|
275
|
-
.def("__setitem__", &ts_dict_row::set_item)
|
|
276
|
-
.def("timestamp", &ts_dict_row::timestamp)
|
|
277
|
-
.def("copy", &ts_dict_row::copy);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
} // namespace reader
|
|
281
|
-
} // namespace qdb
|
quasardb/reader/ts_value.hpp
DELETED
|
@@ -1,245 +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 "../logger.hpp"
|
|
34
|
-
#include "../numpy.hpp"
|
|
35
|
-
#include <qdb/ts.h>
|
|
36
|
-
#include <pybind11/numpy.h>
|
|
37
|
-
#include <pybind11/stl_bind.h>
|
|
38
|
-
|
|
39
|
-
namespace py = pybind11;
|
|
40
|
-
|
|
41
|
-
namespace qdb
|
|
42
|
-
{
|
|
43
|
-
namespace reader
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Our value class points to a specific index in a local table, and provides
|
|
48
|
-
* the necessary conversion functions. It does not hold any value of itself.
|
|
49
|
-
*/
|
|
50
|
-
class ts_value
|
|
51
|
-
{
|
|
52
|
-
public:
|
|
53
|
-
ts_value() noexcept
|
|
54
|
-
: _logger("quasardb.reader.ts_value")
|
|
55
|
-
, _local_table{nullptr}
|
|
56
|
-
, _index{-1}
|
|
57
|
-
, _type{qdb_ts_column_uninitialized}
|
|
58
|
-
{}
|
|
59
|
-
|
|
60
|
-
ts_value(handle_ptr handle,
|
|
61
|
-
qdb_local_table_t local_table,
|
|
62
|
-
int64_t index,
|
|
63
|
-
qdb_ts_column_type_t type) noexcept
|
|
64
|
-
: _logger("quasardb.reader.ts_value")
|
|
65
|
-
, _handle(handle)
|
|
66
|
-
, _local_table{local_table}
|
|
67
|
-
, _index{index}
|
|
68
|
-
, _type{type}
|
|
69
|
-
{}
|
|
70
|
-
|
|
71
|
-
ts_value(const ts_value & rhs) noexcept
|
|
72
|
-
: _logger("quasardb.reader.ts_value")
|
|
73
|
-
, _handle(rhs._handle)
|
|
74
|
-
, _local_table{rhs._local_table}
|
|
75
|
-
, _index{rhs._index}
|
|
76
|
-
, _type{rhs._type}
|
|
77
|
-
{}
|
|
78
|
-
|
|
79
|
-
ts_value(ts_value && rhs) noexcept
|
|
80
|
-
: _logger("quasardb.reader.ts_value")
|
|
81
|
-
, _handle(rhs._handle)
|
|
82
|
-
, _local_table{rhs._local_table}
|
|
83
|
-
, _index{rhs._index}
|
|
84
|
-
, _type{rhs._type} {};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Coerce this value to a Python value, used by the automatic type caster
|
|
88
|
-
* defined at the bottom.
|
|
89
|
-
*/
|
|
90
|
-
py::handle cast() const
|
|
91
|
-
{
|
|
92
|
-
switch (_type)
|
|
93
|
-
{
|
|
94
|
-
case qdb_ts_column_uninitialized:
|
|
95
|
-
break;
|
|
96
|
-
|
|
97
|
-
case qdb_ts_column_double:
|
|
98
|
-
return double_();
|
|
99
|
-
case qdb_ts_column_blob:
|
|
100
|
-
return blob();
|
|
101
|
-
case qdb_ts_column_symbol: //! *FALLTHROUGH*
|
|
102
|
-
case qdb_ts_column_string:
|
|
103
|
-
return string();
|
|
104
|
-
case qdb_ts_column_int64:
|
|
105
|
-
return int64();
|
|
106
|
-
case qdb_ts_column_timestamp:
|
|
107
|
-
return timestamp();
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
throw std::runtime_error(
|
|
111
|
-
"Unable to cast QuasarDB type to Python type, unrecognized type: " + std::to_string(_type));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private:
|
|
115
|
-
py::handle int64() const
|
|
116
|
-
{
|
|
117
|
-
std::int64_t v;
|
|
118
|
-
|
|
119
|
-
auto res = qdb_ts_row_get_int64(_local_table, _index, &v);
|
|
120
|
-
if (res == qdb_e_element_not_found)
|
|
121
|
-
{
|
|
122
|
-
Py_RETURN_NONE;
|
|
123
|
-
// notreached
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
qdb::qdb_throw_if_error(*_handle, res);
|
|
127
|
-
|
|
128
|
-
return PyLong_FromLongLong(v);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
py::handle blob() const
|
|
132
|
-
{
|
|
133
|
-
qdb::release_guard<const void *> v(_handle);
|
|
134
|
-
qdb_size_t l = 0;
|
|
135
|
-
|
|
136
|
-
auto res = qdb_ts_row_get_blob(_local_table, _index, v.ptr(), &l);
|
|
137
|
-
if (res == qdb_e_element_not_found)
|
|
138
|
-
{
|
|
139
|
-
Py_RETURN_NONE;
|
|
140
|
-
// notreached
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
qdb::qdb_throw_if_error(*_handle, res);
|
|
144
|
-
return PyByteArray_FromStringAndSize(
|
|
145
|
-
static_cast<const char *>(v.get()), static_cast<Py_ssize_t>(l));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
py::handle string() const
|
|
149
|
-
{
|
|
150
|
-
qdb::release_guard<const char *> v(_handle);
|
|
151
|
-
qdb_size_t l = 0;
|
|
152
|
-
|
|
153
|
-
auto res = qdb_ts_row_get_string(_local_table, _index, v.ptr(), &l);
|
|
154
|
-
if (res == qdb_e_element_not_found)
|
|
155
|
-
{
|
|
156
|
-
Py_RETURN_NONE;
|
|
157
|
-
// notreached
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
qdb::qdb_throw_if_error(*_handle, res);
|
|
161
|
-
return PyUnicode_FromStringAndSize(v.get(), static_cast<Py_ssize_t>(l));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
py::handle double_() const
|
|
165
|
-
{
|
|
166
|
-
double v = 0.0;
|
|
167
|
-
auto res = qdb_ts_row_get_double(_local_table, _index, &v);
|
|
168
|
-
if (res == qdb_e_element_not_found)
|
|
169
|
-
{
|
|
170
|
-
Py_RETURN_NONE;
|
|
171
|
-
// notreached
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
qdb::qdb_throw_if_error(*_handle, res);
|
|
175
|
-
return PyFloat_FromDouble(v);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
py::handle timestamp() const
|
|
179
|
-
{
|
|
180
|
-
qdb_timespec_t v;
|
|
181
|
-
auto res = qdb_ts_row_get_timestamp(_local_table, _index, &v);
|
|
182
|
-
if (res == qdb_e_element_not_found)
|
|
183
|
-
{
|
|
184
|
-
Py_RETURN_NONE;
|
|
185
|
-
// notreached
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
qdb::qdb_throw_if_error(*_handle, res);
|
|
189
|
-
return qdb::numpy::datetime64(v);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
private:
|
|
193
|
-
qdb::logger _logger;
|
|
194
|
-
handle_ptr _handle;
|
|
195
|
-
qdb_local_table_t _local_table;
|
|
196
|
-
int64_t _index;
|
|
197
|
-
qdb_ts_column_type_t _type;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
template <typename Module>
|
|
201
|
-
static inline void register_ts_value(Module & m)
|
|
202
|
-
{
|
|
203
|
-
py::class_<ts_value>{m, "TimeSeriesReaderValue"};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
} // namespace reader
|
|
207
|
-
} // namespace qdb
|
|
208
|
-
|
|
209
|
-
namespace pybind11
|
|
210
|
-
{
|
|
211
|
-
namespace detail
|
|
212
|
-
{
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Implements custom type caster for our ts_value class, so that conversion
|
|
216
|
-
* to and from native python types is completely transparent.
|
|
217
|
-
*/
|
|
218
|
-
template <>
|
|
219
|
-
struct type_caster<qdb::reader::ts_value>
|
|
220
|
-
{
|
|
221
|
-
public:
|
|
222
|
-
/**
|
|
223
|
-
* Note that this macro magically sets a member variable called 'value'.
|
|
224
|
-
*/
|
|
225
|
-
PYBIND11_TYPE_CASTER(qdb::reader::ts_value, _("qdb::reader::ts_value"));
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* We do not support Python->C++
|
|
229
|
-
*/
|
|
230
|
-
bool load(handle src, bool) const noexcept
|
|
231
|
-
{
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* C++->Python
|
|
237
|
-
*/
|
|
238
|
-
static handle cast(qdb::reader::ts_value src, return_value_policy /* policy */, handle /* parent */)
|
|
239
|
-
{
|
|
240
|
-
return src.cast();
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
} // namespace detail
|
|
245
|
-
} // namespace pybind11
|
quasardb/remove_cvref.hpp
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <type_traits>
|
|
4
|
-
|
|
5
|
-
namespace qdb
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
// TODO(C++20): Use std::remove_cvref after upgrading GCC to version 9+ (ARM builds use GCC 8.3).
|
|
9
|
-
// #if (__cplusplus > 201703L) && defined(_LIBCPP_STD_VER) && (_LIBCPP_STD_VER > 17)
|
|
10
|
-
// #define QDB_HAS_REMOVE_CVREF
|
|
11
|
-
// #endif
|
|
12
|
-
|
|
13
|
-
#ifdef QDB_HAS_REMOVE_CVREF
|
|
14
|
-
|
|
15
|
-
using std::remove_cvref;
|
|
16
|
-
using std::remove_cvref_t;
|
|
17
|
-
|
|
18
|
-
#else
|
|
19
|
-
|
|
20
|
-
template <class T>
|
|
21
|
-
struct remove_cvref
|
|
22
|
-
{
|
|
23
|
-
typedef std::remove_cv_t<std::remove_reference_t<T>> type;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
template <class T>
|
|
27
|
-
using remove_cvref_t = typename remove_cvref<T>::type;
|
|
28
|
-
|
|
29
|
-
#endif
|
|
30
|
-
|
|
31
|
-
} // namespace qdb
|