quasardb 3.14.2.dev1__cp310-cp310-win32.whl → 3.14.2.dev4__cp310-cp310-win32.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 +10 -5
- quasardb/__init__.py +33 -4
- quasardb/cmake_install.cmake +6 -0
- quasardb/date/ALL_BUILD.vcxproj +10 -9
- quasardb/date/CMakeFiles/Export/df49adab93b9e0c10c64f72458b31971/dateTargets.cmake +13 -13
- quasardb/date/CMakeFiles/generate.stamp.depend +4 -4
- quasardb/date/INSTALL.vcxproj +10 -5
- quasardb/date/cmake_install.cmake +6 -0
- quasardb/date/dateConfigVersion.cmake +0 -5
- quasardb/date/dateTargets.cmake +4 -8
- quasardb/numpy/__init__.py +58 -10
- quasardb/pandas/__init__.py +58 -102
- quasardb/pybind11/ALL_BUILD.vcxproj +10 -9
- quasardb/pybind11/CMakeFiles/generate.stamp.depend +14 -14
- quasardb/pybind11/INSTALL.vcxproj +10 -5
- quasardb/pybind11/cmake_install.cmake +6 -0
- quasardb/qdb_api.dll +0 -0
- quasardb/quasardb.cp310-win32.pyd +0 -0
- quasardb/range-v3/ALL_BUILD.vcxproj +10 -9
- quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +13 -13
- quasardb/range-v3/CMakeFiles/generate.stamp.depend +11 -11
- quasardb/range-v3/INSTALL.vcxproj +10 -5
- quasardb/range-v3/cmake_install.cmake +42 -0
- quasardb/range-v3/range-v3-config-version.cmake +0 -5
- quasardb/range-v3/range-v3-config.cmake +4 -8
- quasardb/range-v3/range.v3.headers.vcxproj +10 -9
- {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 +54 -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 -118
- {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/error.hpp
DELETED
|
@@ -1,318 +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 "traits.hpp"
|
|
35
|
-
#include <qdb/client.h>
|
|
36
|
-
#include <qdb/error.h>
|
|
37
|
-
#include <qdb/query.h>
|
|
38
|
-
#include "detail/qdb_resource.hpp"
|
|
39
|
-
#include <pybind11/pybind11.h>
|
|
40
|
-
#include <iostream>
|
|
41
|
-
#include <utility>
|
|
42
|
-
|
|
43
|
-
namespace py = pybind11;
|
|
44
|
-
|
|
45
|
-
namespace qdb
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
class exception
|
|
49
|
-
{
|
|
50
|
-
public:
|
|
51
|
-
exception() noexcept
|
|
52
|
-
{}
|
|
53
|
-
|
|
54
|
-
explicit exception(qdb_error_t err, std::string msg) noexcept
|
|
55
|
-
: _error{err}
|
|
56
|
-
, _msg(msg)
|
|
57
|
-
{}
|
|
58
|
-
|
|
59
|
-
virtual const char * what() const noexcept
|
|
60
|
-
{
|
|
61
|
-
return _msg.c_str();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private:
|
|
65
|
-
qdb_error_t _error{qdb_e_ok};
|
|
66
|
-
std::string _msg;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
class input_buffer_too_small_exception : public exception
|
|
70
|
-
{
|
|
71
|
-
public:
|
|
72
|
-
input_buffer_too_small_exception() noexcept
|
|
73
|
-
: exception(qdb_e_network_inbuf_too_small,
|
|
74
|
-
std::string(
|
|
75
|
-
"Input buffer too small: result set too large. Hint: consider increasing the buffer "
|
|
76
|
-
"size using "
|
|
77
|
-
"cluster.options().set_client_max_in_buf_size(..) prior to address this error."))
|
|
78
|
-
{}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
class invalid_handle_exception : public exception
|
|
82
|
-
{
|
|
83
|
-
public:
|
|
84
|
-
invalid_handle_exception() noexcept
|
|
85
|
-
: exception(qdb_e_invalid_handle,
|
|
86
|
-
std::string("Invalid handle: the connection to the cluster has been closed. Please "
|
|
87
|
-
"re-establish a new connection"
|
|
88
|
-
"with the QuasarDB cluster."))
|
|
89
|
-
{}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
class incompatible_type_exception : public exception
|
|
93
|
-
{
|
|
94
|
-
public:
|
|
95
|
-
incompatible_type_exception() noexcept
|
|
96
|
-
: exception(qdb_e_incompatible_type, std::string("Incompatible type"))
|
|
97
|
-
{}
|
|
98
|
-
|
|
99
|
-
incompatible_type_exception(std::string const & what) noexcept
|
|
100
|
-
: exception(qdb_e_incompatible_type, what)
|
|
101
|
-
{}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
class not_implemented_exception : public exception
|
|
105
|
-
{
|
|
106
|
-
public:
|
|
107
|
-
not_implemented_exception() noexcept
|
|
108
|
-
: exception(qdb_e_not_implemented, std::string("Method or class not implemented"))
|
|
109
|
-
{}
|
|
110
|
-
|
|
111
|
-
not_implemented_exception(std::string const & what) noexcept
|
|
112
|
-
: exception(qdb_e_incompatible_type, what)
|
|
113
|
-
{}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
class invalid_argument_exception : public exception
|
|
117
|
-
{
|
|
118
|
-
public:
|
|
119
|
-
invalid_argument_exception() noexcept
|
|
120
|
-
: exception(qdb_e_invalid_argument, std::string("Invalid argument"))
|
|
121
|
-
{}
|
|
122
|
-
|
|
123
|
-
invalid_argument_exception(std::string const & what) noexcept
|
|
124
|
-
: exception(qdb_e_invalid_argument, what)
|
|
125
|
-
{}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
class invalid_query_exception : public exception
|
|
129
|
-
{
|
|
130
|
-
public:
|
|
131
|
-
invalid_query_exception() noexcept
|
|
132
|
-
: exception(qdb_e_invalid_query, std::string("Invalid query"))
|
|
133
|
-
{}
|
|
134
|
-
|
|
135
|
-
invalid_query_exception(std::string const & what) noexcept
|
|
136
|
-
: exception(qdb_e_invalid_query, what)
|
|
137
|
-
{}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
class internal_local_exception : public exception
|
|
141
|
-
{
|
|
142
|
-
public:
|
|
143
|
-
internal_local_exception() noexcept
|
|
144
|
-
: exception(qdb_e_internal_local, std::string("An unknown local internal error occurred"))
|
|
145
|
-
{}
|
|
146
|
-
|
|
147
|
-
internal_local_exception(std::string const & what) noexcept
|
|
148
|
-
: exception(qdb_e_internal_local, what)
|
|
149
|
-
{}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
class alias_already_exists_exception : public exception
|
|
153
|
-
{
|
|
154
|
-
public:
|
|
155
|
-
alias_already_exists_exception() noexcept
|
|
156
|
-
: exception(qdb_e_alias_already_exists, std::string("Alias already exists"))
|
|
157
|
-
{}
|
|
158
|
-
|
|
159
|
-
alias_already_exists_exception(std::string const & what) noexcept
|
|
160
|
-
: exception(qdb_e_alias_already_exists, what)
|
|
161
|
-
{}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
class alias_not_found_exception : public exception
|
|
165
|
-
{
|
|
166
|
-
public:
|
|
167
|
-
alias_not_found_exception() noexcept
|
|
168
|
-
: exception(qdb_e_alias_not_found, std::string("Alias not found"))
|
|
169
|
-
{}
|
|
170
|
-
|
|
171
|
-
alias_not_found_exception(std::string const & what) noexcept
|
|
172
|
-
: exception(qdb_e_alias_not_found, what)
|
|
173
|
-
{}
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
class invalid_datetime_exception : public exception
|
|
177
|
-
{
|
|
178
|
-
public:
|
|
179
|
-
invalid_datetime_exception() noexcept
|
|
180
|
-
: exception(qdb_e_incompatible_type,
|
|
181
|
-
std::string("Unable to interpret provided numpy datetime64. Hint: QuasarDB only works with "
|
|
182
|
-
"nanosecond precision datetime64. "
|
|
183
|
-
"You can correct this by explicitly casting your timestamps to the dtype "
|
|
184
|
-
"datetime64[ns]"))
|
|
185
|
-
{}
|
|
186
|
-
|
|
187
|
-
invalid_datetime_exception(py::object o)
|
|
188
|
-
: exception(qdb_e_incompatible_type,
|
|
189
|
-
std::string("Unable to interpret provided numpy datetime64: " + (std::string)(py::str(o))
|
|
190
|
-
+ ". Hint: QuasarDB only works with nanosecond precision datetime64. You can "
|
|
191
|
-
"correct this by explicitly casting "
|
|
192
|
-
"your timestamps to the dtype datetime64[ns]"))
|
|
193
|
-
|
|
194
|
-
{}
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
namespace detail
|
|
198
|
-
{
|
|
199
|
-
|
|
200
|
-
struct no_op
|
|
201
|
-
{
|
|
202
|
-
void operator()() const noexcept
|
|
203
|
-
{}
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
} // namespace detail
|
|
207
|
-
|
|
208
|
-
// Allow a callable to be run just before the throw, thus making nice clean-up possible
|
|
209
|
-
// (such as calls to `qdb_release`)
|
|
210
|
-
// `pre_throw` defaults to a `no_op` functor that does nothing.
|
|
211
|
-
template <typename PreThrowFtor = detail::no_op>
|
|
212
|
-
inline void qdb_throw_if_error(
|
|
213
|
-
qdb_handle_t h, qdb_error_t err, PreThrowFtor && pre_throw = detail::no_op{})
|
|
214
|
-
{
|
|
215
|
-
static_assert(
|
|
216
|
-
noexcept(std::forward<PreThrowFtor &&>(pre_throw)()), "`pre_throw` argument must be noexcept");
|
|
217
|
-
|
|
218
|
-
// HACKS(leon): we need to flush our log buffer a lot, ideally after every native qdb
|
|
219
|
-
// call. Guess which function is invoked exactly at those moments?
|
|
220
|
-
qdb::native::flush();
|
|
221
|
-
|
|
222
|
-
if ((qdb_e_ok != err) && (qdb_e_ok_created != err)) [[unlikely]]
|
|
223
|
-
{
|
|
224
|
-
detail::qdb_resource<qdb_string_t> msg_{h, nullptr};
|
|
225
|
-
qdb_error_t err_;
|
|
226
|
-
qdb_get_last_error(h, &err_, &msg_);
|
|
227
|
-
|
|
228
|
-
if (err_ != err)
|
|
229
|
-
{
|
|
230
|
-
// Error context returned is not the same, which means this thread already made
|
|
231
|
-
// another call to the QDB API, or the QDB API itself
|
|
232
|
-
|
|
233
|
-
switch (err)
|
|
234
|
-
{
|
|
235
|
-
case qdb_e_not_connected:
|
|
236
|
-
case qdb_e_invalid_handle:
|
|
237
|
-
throw qdb::invalid_handle_exception{};
|
|
238
|
-
default:
|
|
239
|
-
throw qdb::exception{err, qdb_error(err)};
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
assert(err_ == err);
|
|
243
|
-
assert(msg_ != nullptr);
|
|
244
|
-
|
|
245
|
-
pre_throw();
|
|
246
|
-
|
|
247
|
-
std::string msg_data_{msg_.get()->data};
|
|
248
|
-
|
|
249
|
-
switch (err)
|
|
250
|
-
{
|
|
251
|
-
|
|
252
|
-
case qdb_e_invalid_query:
|
|
253
|
-
throw qdb::invalid_query_exception{msg_data_};
|
|
254
|
-
|
|
255
|
-
case qdb_e_not_connected:
|
|
256
|
-
case qdb_e_invalid_handle:
|
|
257
|
-
throw qdb::invalid_handle_exception{};
|
|
258
|
-
|
|
259
|
-
case qdb_e_alias_already_exists:
|
|
260
|
-
throw qdb::alias_already_exists_exception{msg_data_};
|
|
261
|
-
|
|
262
|
-
case qdb_e_alias_not_found:
|
|
263
|
-
throw qdb::alias_not_found_exception{msg_data_};
|
|
264
|
-
|
|
265
|
-
case qdb_e_network_inbuf_too_small:
|
|
266
|
-
throw qdb::input_buffer_too_small_exception{};
|
|
267
|
-
|
|
268
|
-
case qdb_e_incompatible_type:
|
|
269
|
-
throw qdb::incompatible_type_exception{msg_data_};
|
|
270
|
-
|
|
271
|
-
case qdb_e_not_implemented:
|
|
272
|
-
throw qdb::not_implemented_exception{msg_data_};
|
|
273
|
-
|
|
274
|
-
case qdb_e_internal_local:
|
|
275
|
-
throw qdb::internal_local_exception{msg_data_};
|
|
276
|
-
|
|
277
|
-
case qdb_e_invalid_argument:
|
|
278
|
-
throw qdb::invalid_argument_exception{msg_data_};
|
|
279
|
-
|
|
280
|
-
default:
|
|
281
|
-
throw qdb::exception{err_, msg_data_};
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
template <typename PreThrowFtor = detail::no_op>
|
|
287
|
-
inline void qdb_throw_if_query_error(qdb_handle_t h, qdb_error_t err, qdb_query_result_t const * result)
|
|
288
|
-
{
|
|
289
|
-
if (err == qdb_e_invalid_query && result != nullptr
|
|
290
|
-
&& traits::is_null(result->error_message) == false) [[unlikely]]
|
|
291
|
-
{
|
|
292
|
-
throw qdb::invalid_query_exception{
|
|
293
|
-
std::string{result->error_message.data, result->error_message.length}};
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
return qdb_throw_if_error(h, err);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
template <typename Module>
|
|
300
|
-
static inline void register_errors(Module & m)
|
|
301
|
-
{
|
|
302
|
-
auto base_class = py::register_exception<qdb::exception>(m, "Error", PyExc_RuntimeError);
|
|
303
|
-
|
|
304
|
-
py::register_exception<qdb::input_buffer_too_small_exception>(
|
|
305
|
-
m, "InputBufferTooSmallError", base_class);
|
|
306
|
-
py::register_exception<qdb::alias_already_exists_exception>(
|
|
307
|
-
m, "AliasAlreadyExistsError", base_class);
|
|
308
|
-
py::register_exception<qdb::alias_not_found_exception>(m, "AliasNotFoundError", base_class);
|
|
309
|
-
py::register_exception<qdb::invalid_datetime_exception>(m, "InvalidDatetimeError", base_class);
|
|
310
|
-
py::register_exception<qdb::incompatible_type_exception>(m, "IncompatibleTypeError", base_class);
|
|
311
|
-
py::register_exception<qdb::not_implemented_exception>(m, "NotImplementedError", base_class);
|
|
312
|
-
py::register_exception<qdb::internal_local_exception>(m, "InternalLocalError", base_class);
|
|
313
|
-
py::register_exception<qdb::invalid_argument_exception>(m, "InvalidArgumentError", base_class);
|
|
314
|
-
py::register_exception<qdb::invalid_query_exception>(m, "InvalidQueryError", base_class);
|
|
315
|
-
py::register_exception<qdb::invalid_handle_exception>(m, "InvalidHandleError", base_class);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
} // namespace qdb
|
quasardb/handle.cpp
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#include "handle.hpp"
|
|
2
|
-
#include "metrics.hpp"
|
|
3
|
-
|
|
4
|
-
namespace qdb
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
void handle::connect(const std::string & uri)
|
|
8
|
-
{
|
|
9
|
-
qdb_error_t err;
|
|
10
|
-
{
|
|
11
|
-
metrics::scoped_capture{"qdb_connect"};
|
|
12
|
-
err = qdb_connect(handle_, uri.c_str());
|
|
13
|
-
}
|
|
14
|
-
qdb::qdb_throw_if_error(handle_, err);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
void handle::close()
|
|
18
|
-
{
|
|
19
|
-
if (handle_ != nullptr)
|
|
20
|
-
{
|
|
21
|
-
metrics::scoped_capture{"qdb_close"};
|
|
22
|
-
qdb_close(handle_);
|
|
23
|
-
handle_ = nullptr;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
assert(handle_ == nullptr);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
}; // namespace qdb
|
quasardb/handle.hpp
DELETED
|
@@ -1,98 +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 "error.hpp"
|
|
34
|
-
#include <qdb/client.h>
|
|
35
|
-
#include <memory>
|
|
36
|
-
#include <string>
|
|
37
|
-
|
|
38
|
-
namespace qdb
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
class handle
|
|
42
|
-
{
|
|
43
|
-
public:
|
|
44
|
-
handle() noexcept
|
|
45
|
-
: handle_{nullptr}
|
|
46
|
-
{}
|
|
47
|
-
|
|
48
|
-
explicit handle(qdb_handle_t h) noexcept
|
|
49
|
-
: handle_{h}
|
|
50
|
-
{}
|
|
51
|
-
|
|
52
|
-
~handle()
|
|
53
|
-
{
|
|
54
|
-
close();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
void connect(const std::string & uri);
|
|
58
|
-
|
|
59
|
-
operator qdb_handle_t() const noexcept
|
|
60
|
-
{
|
|
61
|
-
return handle_;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
void close();
|
|
65
|
-
|
|
66
|
-
constexpr inline bool is_open() const
|
|
67
|
-
{
|
|
68
|
-
return handle_ != nullptr;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Throws exception if the connection is not open. Should be invoked before any operation
|
|
73
|
-
* is done on the handle, as the QuasarDB C API only checks for a canary presence in the
|
|
74
|
-
* handle's memory arena. If a compiler is optimizing enough, the handle can be closed but
|
|
75
|
-
* the canary still present in memory, so it's UB.
|
|
76
|
-
*
|
|
77
|
-
* As such, we should check on a higher level.
|
|
78
|
-
*/
|
|
79
|
-
inline void check_open() const
|
|
80
|
-
{
|
|
81
|
-
if (is_open() == false) [[unlikely]]
|
|
82
|
-
{
|
|
83
|
-
throw qdb::invalid_handle_exception{};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private:
|
|
88
|
-
qdb_handle_t handle_{nullptr};
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
using handle_ptr = std::shared_ptr<handle>;
|
|
92
|
-
|
|
93
|
-
static inline handle_ptr make_handle_ptr()
|
|
94
|
-
{
|
|
95
|
-
return std::make_shared<qdb::handle>(qdb_open_tcp());
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
} // namespace qdb
|
quasardb/integer.hpp
DELETED
|
@@ -1,88 +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 "entry.hpp"
|
|
34
|
-
#include <qdb/integer.h>
|
|
35
|
-
|
|
36
|
-
namespace qdb
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
class integer_entry : public expirable_entry
|
|
40
|
-
{
|
|
41
|
-
public:
|
|
42
|
-
integer_entry(handle_ptr h, std::string a) noexcept
|
|
43
|
-
: expirable_entry{h, a}
|
|
44
|
-
{}
|
|
45
|
-
|
|
46
|
-
public:
|
|
47
|
-
qdb_int_t get()
|
|
48
|
-
{
|
|
49
|
-
qdb_int_t result;
|
|
50
|
-
qdb::qdb_throw_if_error(*_handle, qdb_int_get(*_handle, _alias.c_str(), &result));
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
void put(qdb_int_t integer)
|
|
55
|
-
{
|
|
56
|
-
qdb::qdb_throw_if_error(
|
|
57
|
-
*_handle, qdb_int_put(*_handle, _alias.c_str(), integer, qdb_time_t{0}));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
void update(qdb_int_t integer)
|
|
61
|
-
{
|
|
62
|
-
qdb::qdb_throw_if_error(
|
|
63
|
-
*_handle, qdb_int_update(*_handle, _alias.c_str(), integer, qdb_time_t{0}));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
qdb_int_t add(qdb_int_t integer)
|
|
67
|
-
{
|
|
68
|
-
qdb_int_t result;
|
|
69
|
-
qdb::qdb_throw_if_error(*_handle, qdb_int_add(*_handle, _alias.c_str(), integer, &result));
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
template <typename Module>
|
|
75
|
-
static inline void register_integer(Module & m)
|
|
76
|
-
{
|
|
77
|
-
namespace py = pybind11;
|
|
78
|
-
|
|
79
|
-
py::class_<qdb::integer_entry, qdb::expirable_entry>(m, "Integer") //
|
|
80
|
-
.def(py::init<qdb::handle_ptr, std::string>()) //
|
|
81
|
-
.def("get", &qdb::integer_entry::get) //
|
|
82
|
-
.def("put", &qdb::integer_entry::put, py::arg("integer")) //
|
|
83
|
-
.def("update", &qdb::integer_entry::update, py::arg("integer")) //
|
|
84
|
-
.def("add", &qdb::integer_entry::add, py::arg("addend")) //
|
|
85
|
-
; //
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
} // namespace qdb
|
quasardb/logger.cpp
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
#include "logger.hpp"
|
|
2
|
-
|
|
3
|
-
namespace py = pybind11;
|
|
4
|
-
|
|
5
|
-
static std::vector<qdb::native::message_t> _buffer;
|
|
6
|
-
static std::mutex _buffer_lock;
|
|
7
|
-
static qdb_log_callback_id local_callback_id;
|
|
8
|
-
static qdb::logger _logger;
|
|
9
|
-
|
|
10
|
-
void qdb::native::swap_callback()
|
|
11
|
-
{
|
|
12
|
-
// Potential race condition avoidance!
|
|
13
|
-
std::lock_guard<std::mutex> guard(_buffer_lock);
|
|
14
|
-
|
|
15
|
-
#ifndef NDEBUG
|
|
16
|
-
qdb_error_t error;
|
|
17
|
-
|
|
18
|
-
error = qdb_log_remove_callback(local_callback_id);
|
|
19
|
-
if (error)
|
|
20
|
-
{
|
|
21
|
-
// This error is quite common the first time a callback is set, because we did
|
|
22
|
-
// not have a callback yet.
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
error = qdb_log_add_callback(_callback, &local_callback_id);
|
|
26
|
-
if (error)
|
|
27
|
-
{
|
|
28
|
-
// fprintf(stderr, "unable to add new callback: %s (%#x)\n", qdb_error(error), error);
|
|
29
|
-
// fflush(stderr);
|
|
30
|
-
}
|
|
31
|
-
#endif
|
|
32
|
-
|
|
33
|
-
_logger = qdb::logger("quasardb.native");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
void qdb::native::_callback(qdb_log_level_t log_level,
|
|
37
|
-
const unsigned long * date,
|
|
38
|
-
unsigned long pid,
|
|
39
|
-
unsigned long tid,
|
|
40
|
-
const char * message_buffer,
|
|
41
|
-
size_t message_size)
|
|
42
|
-
{
|
|
43
|
-
message_t x{log_level,
|
|
44
|
-
{static_cast<int>(date[0]), static_cast<int>(date[1]), static_cast<int>(date[2]),
|
|
45
|
-
static_cast<int>(date[3]), static_cast<int>(date[4]), static_cast<int>(date[5])},
|
|
46
|
-
static_cast<int>(pid), static_cast<int>(tid), std::string(message_buffer, message_size)};
|
|
47
|
-
|
|
48
|
-
std::lock_guard<std::mutex> guard(_buffer_lock);
|
|
49
|
-
_buffer.push_back(x);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
void qdb::native::flush()
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
// TODO(leon): it would be much more appropriate to use a read/write lock here,
|
|
56
|
-
// since the buffer is typically empty.
|
|
57
|
-
std::lock_guard<std::mutex> guard(_buffer_lock);
|
|
58
|
-
|
|
59
|
-
// BUG(leon): I don't think it's practically possible, but there might be a case
|
|
60
|
-
// where our _buffer is somehow non-empty, but we haven't set our
|
|
61
|
-
// _logger yet. This will cause a segfault in _do_flush().
|
|
62
|
-
if (!_buffer.empty())
|
|
63
|
-
{
|
|
64
|
-
qdb::native::_do_flush();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
void qdb::native::_do_flush()
|
|
69
|
-
{
|
|
70
|
-
// NOTE: this assumes a lock to _buffer-lock has been acquired, never call this
|
|
71
|
-
// function directly!
|
|
72
|
-
assert(!_buffer_lock.try_lock());
|
|
73
|
-
|
|
74
|
-
// TODO(leon): we can improve native <> python vm context switching by folding all
|
|
75
|
-
// invocations below into a single call.
|
|
76
|
-
for (auto i = _buffer.begin(); i != _buffer.end(); ++i)
|
|
77
|
-
{
|
|
78
|
-
message_t const & m = *i;
|
|
79
|
-
|
|
80
|
-
switch (m.level)
|
|
81
|
-
{
|
|
82
|
-
case qdb_log_detailed:
|
|
83
|
-
case qdb_log_debug:
|
|
84
|
-
_logger.debug(m.message);
|
|
85
|
-
break;
|
|
86
|
-
|
|
87
|
-
case qdb_log_info:
|
|
88
|
-
_logger.info(m.message);
|
|
89
|
-
break;
|
|
90
|
-
|
|
91
|
-
case qdb_log_warning:
|
|
92
|
-
_logger.warn(m.message);
|
|
93
|
-
break;
|
|
94
|
-
|
|
95
|
-
case qdb_log_error:
|
|
96
|
-
_logger.error(m.message);
|
|
97
|
-
break;
|
|
98
|
-
|
|
99
|
-
case qdb_log_panic:
|
|
100
|
-
_logger.critical(m.message);
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_buffer.clear();
|
|
106
|
-
}
|