quasardb 3.14.1.dev5__cp310-cp310-win32.whl → 3.14.1.dev6__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/CMakeLists.txt +4 -0
- quasardb/cluster.cpp +89 -0
- quasardb/cluster.hpp +37 -50
- quasardb/handle.cpp +29 -0
- quasardb/handle.hpp +2 -14
- quasardb/logger.cpp +3 -0
- quasardb/metrics.cpp +103 -0
- quasardb/metrics.hpp +112 -0
- quasardb/module.cpp +2 -0
- quasardb/qdb_api.dll +0 -0
- quasardb/quasardb.cp310-win32.pyd +0 -0
- quasardb/query.cpp +13 -2
- quasardb/table.cpp +26 -0
- quasardb/table.hpp +2 -20
- quasardb/writer.cpp +4 -0
- {quasardb-3.14.1.dev5.dist-info → quasardb-3.14.1.dev6.dist-info}/METADATA +1 -1
- {quasardb-3.14.1.dev5.dist-info → quasardb-3.14.1.dev6.dist-info}/RECORD +20 -16
- {quasardb-3.14.1.dev5.dist-info → quasardb-3.14.1.dev6.dist-info}/LICENSE.md +0 -0
- {quasardb-3.14.1.dev5.dist-info → quasardb-3.14.1.dev6.dist-info}/WHEEL +0 -0
- {quasardb-3.14.1.dev5.dist-info → quasardb-3.14.1.dev6.dist-info}/top_level.txt +0 -0
quasardb/CMakeLists.txt
CHANGED
|
@@ -325,6 +325,7 @@ set(QDB_FILES
|
|
|
325
325
|
batch_inserter.hpp
|
|
326
326
|
blob.hpp
|
|
327
327
|
cluster.hpp
|
|
328
|
+
cluster.cpp
|
|
328
329
|
concepts.hpp
|
|
329
330
|
continuous.cpp
|
|
330
331
|
continuous.hpp
|
|
@@ -333,9 +334,12 @@ set(QDB_FILES
|
|
|
333
334
|
error.hpp
|
|
334
335
|
entry.hpp
|
|
335
336
|
handle.hpp
|
|
337
|
+
handle.cpp
|
|
336
338
|
logger.hpp
|
|
337
339
|
logger.cpp
|
|
338
340
|
masked_array.hpp
|
|
341
|
+
metrics.hpp
|
|
342
|
+
metrics.cpp
|
|
339
343
|
module.hpp
|
|
340
344
|
module.cpp
|
|
341
345
|
node.hpp
|
quasardb/cluster.cpp
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#include "cluster.hpp"
|
|
2
|
+
#include "metrics.hpp"
|
|
3
|
+
#include <chrono>
|
|
4
|
+
#include <thread>
|
|
5
|
+
|
|
6
|
+
namespace qdb
|
|
7
|
+
{
|
|
8
|
+
|
|
9
|
+
cluster::cluster(const std::string & uri,
|
|
10
|
+
const std::string & user_name,
|
|
11
|
+
const std::string & user_private_key,
|
|
12
|
+
const std::string & cluster_public_key,
|
|
13
|
+
const std::string & user_security_file,
|
|
14
|
+
const std::string & cluster_public_key_file,
|
|
15
|
+
std::chrono::milliseconds timeout,
|
|
16
|
+
bool do_version_check)
|
|
17
|
+
: _uri{uri}
|
|
18
|
+
, _handle{make_handle_ptr()}
|
|
19
|
+
, _json_loads{pybind11::module::import("json").attr("loads")}
|
|
20
|
+
, _logger("quasardb.cluster")
|
|
21
|
+
{
|
|
22
|
+
if (do_version_check == true)
|
|
23
|
+
{
|
|
24
|
+
_logger.warn(
|
|
25
|
+
"do_version_check parameter has been deprecated and a no-op. It will be removed from a "
|
|
26
|
+
"future release");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
options().apply_credentials(user_name, user_private_key, cluster_public_key, //
|
|
30
|
+
user_security_file, cluster_public_key_file);
|
|
31
|
+
|
|
32
|
+
options().set_timeout(timeout);
|
|
33
|
+
|
|
34
|
+
// HACKS(leon): we need to ensure there is always one callback active
|
|
35
|
+
// for qdb. Callbacks can be lost when the last active session
|
|
36
|
+
// gets closed. As such, the most pragmatic place to 'check'
|
|
37
|
+
// for this callback is when establishing a new connection.
|
|
38
|
+
qdb::native::swap_callback();
|
|
39
|
+
|
|
40
|
+
_logger.info("Connecting to cluster %s", _uri);
|
|
41
|
+
_handle->connect(_uri);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void cluster::close()
|
|
45
|
+
{
|
|
46
|
+
_logger.info("Closing connection to cluster");
|
|
47
|
+
|
|
48
|
+
try
|
|
49
|
+
{
|
|
50
|
+
if (is_open() == true) [[likely]]
|
|
51
|
+
{
|
|
52
|
+
_handle->close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (qdb::invalid_handle_exception const & e)
|
|
56
|
+
{
|
|
57
|
+
// This can happen if, for example, we call close() after an error occured; in those
|
|
58
|
+
// circumstances, we fully expect the connection to already be invalid, and we should
|
|
59
|
+
// not care if this specific exception is raised.
|
|
60
|
+
_logger.warn("Connection already closed");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_handle.reset();
|
|
64
|
+
|
|
65
|
+
assert(is_open() == false);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void cluster::wait_for_compaction()
|
|
69
|
+
{
|
|
70
|
+
|
|
71
|
+
// We define this function in the .cpp file so we can avoid including chrono and thread
|
|
72
|
+
// in the header file.
|
|
73
|
+
|
|
74
|
+
using namespace std::chrono_literals;
|
|
75
|
+
|
|
76
|
+
for (;;)
|
|
77
|
+
{
|
|
78
|
+
std::uint64_t progress = compact_progress();
|
|
79
|
+
|
|
80
|
+
if (progress == 0) [[unlikely]]
|
|
81
|
+
{
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
std::this_thread::sleep_for(100ms);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}; // namespace qdb
|
quasardb/cluster.hpp
CHANGED
|
@@ -72,58 +72,10 @@ public:
|
|
|
72
72
|
const std::string & user_security_file = {},
|
|
73
73
|
const std::string & cluster_public_key_file = {},
|
|
74
74
|
std::chrono::milliseconds timeout = std::chrono::minutes{1},
|
|
75
|
-
bool do_version_check = false)
|
|
76
|
-
: _uri{uri}
|
|
77
|
-
, _handle{make_handle_ptr()}
|
|
78
|
-
, _json_loads{pybind11::module::import("json").attr("loads")}
|
|
79
|
-
, _logger("quasardb.cluster")
|
|
80
|
-
{
|
|
81
|
-
if (do_version_check == true)
|
|
82
|
-
{
|
|
83
|
-
_logger.warn(
|
|
84
|
-
"do_version_check parameter has been deprecated and a no-op. It will be removed from a "
|
|
85
|
-
"future release");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
options().apply_credentials(user_name, user_private_key, cluster_public_key, //
|
|
89
|
-
user_security_file, cluster_public_key_file);
|
|
90
|
-
|
|
91
|
-
options().set_timeout(timeout);
|
|
92
|
-
|
|
93
|
-
// HACKS(leon): we need to ensure there is always one callback active
|
|
94
|
-
// for qdb. Callbacks can be lost when the last active session
|
|
95
|
-
// gets closed. As such, the most pragmatic place to 'check'
|
|
96
|
-
// for this callback is when establishing a new connection.
|
|
97
|
-
qdb::native::swap_callback();
|
|
98
|
-
|
|
99
|
-
_logger.info("Connecting to cluster %s", _uri);
|
|
100
|
-
_handle->connect(_uri);
|
|
101
|
-
}
|
|
75
|
+
bool do_version_check = false);
|
|
102
76
|
|
|
103
77
|
public:
|
|
104
|
-
void close()
|
|
105
|
-
{
|
|
106
|
-
_logger.info("Closing connection to cluster");
|
|
107
|
-
|
|
108
|
-
try
|
|
109
|
-
{
|
|
110
|
-
if (is_open() == true) [[likely]]
|
|
111
|
-
{
|
|
112
|
-
_handle->close();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
catch (qdb::invalid_handle_exception const & e)
|
|
116
|
-
{
|
|
117
|
-
// This can happen if, for example, we call close() after an error occured; in those
|
|
118
|
-
// circumstances, we fully expect the connection to already be invalid, and we should
|
|
119
|
-
// not care if this specific exception is raised.
|
|
120
|
-
_logger.warn("Connection already closed");
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
_handle.reset();
|
|
124
|
-
|
|
125
|
-
assert(is_open() == false);
|
|
126
|
-
}
|
|
78
|
+
void close();
|
|
127
79
|
|
|
128
80
|
bool is_open() const
|
|
129
81
|
{
|
|
@@ -463,6 +415,37 @@ public:
|
|
|
463
415
|
static_cast<int>(timeout_ms.count())));
|
|
464
416
|
}
|
|
465
417
|
|
|
418
|
+
void compact_full()
|
|
419
|
+
{
|
|
420
|
+
check_open();
|
|
421
|
+
|
|
422
|
+
qdb_compact_params_t params{};
|
|
423
|
+
params.options = qdb_compact_full;
|
|
424
|
+
|
|
425
|
+
qdb::qdb_throw_if_error(*_handle, qdb_cluster_compact(*_handle, ¶ms));
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// Returns 0 when finished / no compaction running
|
|
429
|
+
std::uint64_t compact_progress()
|
|
430
|
+
{
|
|
431
|
+
check_open();
|
|
432
|
+
|
|
433
|
+
std::uint64_t progress;
|
|
434
|
+
|
|
435
|
+
qdb::qdb_throw_if_error(*_handle, qdb_cluster_get_compact_progress(*_handle, &progress));
|
|
436
|
+
|
|
437
|
+
return progress;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
void compact_abort()
|
|
441
|
+
{
|
|
442
|
+
check_open();
|
|
443
|
+
|
|
444
|
+
qdb::qdb_throw_if_error(*_handle, qdb_cluster_abort_compact(*_handle));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
void wait_for_compaction();
|
|
448
|
+
|
|
466
449
|
public:
|
|
467
450
|
std::vector<std::string> endpoints()
|
|
468
451
|
{
|
|
@@ -558,6 +541,10 @@ static inline void register_cluster(Module & m)
|
|
|
558
541
|
.def("purge_all", &qdb::cluster::purge_all) //
|
|
559
542
|
.def("trim_all", &qdb::cluster::trim_all) //
|
|
560
543
|
.def("purge_cache", &qdb::cluster::purge_cache) //
|
|
544
|
+
.def("compact_full", &qdb::cluster::compact_full) //
|
|
545
|
+
.def("compact_progress", &qdb::cluster::compact_progress) //
|
|
546
|
+
.def("compact_abort", &qdb::cluster::compact_abort) //
|
|
547
|
+
.def("wait_for_compaction", &qdb::cluster::wait_for_compaction) //
|
|
561
548
|
.def("endpoints", &qdb::cluster::endpoints); //
|
|
562
549
|
}
|
|
563
550
|
|
quasardb/handle.cpp
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
CHANGED
|
@@ -54,26 +54,14 @@ public:
|
|
|
54
54
|
close();
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
void connect(const std::string & uri)
|
|
58
|
-
{
|
|
59
|
-
qdb::qdb_throw_if_error(handle_, qdb_connect(handle_, uri.c_str()));
|
|
60
|
-
}
|
|
57
|
+
void connect(const std::string & uri);
|
|
61
58
|
|
|
62
59
|
operator qdb_handle_t() const noexcept
|
|
63
60
|
{
|
|
64
61
|
return handle_;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
void close()
|
|
68
|
-
{
|
|
69
|
-
if (handle_ != nullptr)
|
|
70
|
-
{
|
|
71
|
-
qdb_close(handle_);
|
|
72
|
-
handle_ = nullptr;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
assert(handle_ == nullptr);
|
|
76
|
-
}
|
|
64
|
+
void close();
|
|
77
65
|
|
|
78
66
|
constexpr inline bool is_open() const
|
|
79
67
|
{
|
quasardb/logger.cpp
CHANGED
|
@@ -11,6 +11,8 @@ void qdb::native::swap_callback()
|
|
|
11
11
|
{
|
|
12
12
|
// Potential race condition avoidance!
|
|
13
13
|
std::lock_guard<std::mutex> guard(_buffer_lock);
|
|
14
|
+
|
|
15
|
+
#ifndef NDEBUG
|
|
14
16
|
qdb_error_t error;
|
|
15
17
|
|
|
16
18
|
error = qdb_log_remove_callback(local_callback_id);
|
|
@@ -26,6 +28,7 @@ void qdb::native::swap_callback()
|
|
|
26
28
|
// fprintf(stderr, "unable to add new callback: %s (%#x)\n", qdb_error(error), error);
|
|
27
29
|
// fflush(stderr);
|
|
28
30
|
}
|
|
31
|
+
#endif
|
|
29
32
|
|
|
30
33
|
_logger = qdb::logger("quasardb.native");
|
|
31
34
|
}
|
quasardb/metrics.cpp
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#include "metrics.hpp"
|
|
2
|
+
#include <mutex>
|
|
3
|
+
|
|
4
|
+
namespace qdb
|
|
5
|
+
{
|
|
6
|
+
|
|
7
|
+
static metrics_container_t metrics_totals_ = metrics_container_t{};
|
|
8
|
+
static std::mutex metrics_lock_ = std::mutex{};
|
|
9
|
+
|
|
10
|
+
metrics::scoped_capture::~scoped_capture()
|
|
11
|
+
{
|
|
12
|
+
using std::chrono::nanoseconds;
|
|
13
|
+
|
|
14
|
+
time_point_t stop = clock_t::now();
|
|
15
|
+
|
|
16
|
+
auto duration = std::chrono::duration_cast<nanoseconds>(stop - start_);
|
|
17
|
+
|
|
18
|
+
metrics::record(test_id_, duration.count());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
metrics::measure::measure()
|
|
22
|
+
: start_{metrics::totals()}
|
|
23
|
+
{}
|
|
24
|
+
|
|
25
|
+
metrics_container_t metrics::measure::get() const
|
|
26
|
+
{
|
|
27
|
+
metrics_container_t cur = metrics::totals();
|
|
28
|
+
|
|
29
|
+
metrics_container_t ret{};
|
|
30
|
+
|
|
31
|
+
for (auto i : cur)
|
|
32
|
+
{
|
|
33
|
+
assert(ret.find(i.first) == ret.end());
|
|
34
|
+
|
|
35
|
+
metrics_container_t::const_iterator prev = start_.find(i.first);
|
|
36
|
+
|
|
37
|
+
if (prev == start_.end())
|
|
38
|
+
{
|
|
39
|
+
// Previously, metric didn't exist yet, as such it's entirely new
|
|
40
|
+
// and all accumulated time was within the scope.
|
|
41
|
+
ret.emplace(i.first, i.second);
|
|
42
|
+
}
|
|
43
|
+
else if (i.second > prev->second)
|
|
44
|
+
{
|
|
45
|
+
// Accumulated time actually increased, record difference
|
|
46
|
+
ret.emplace(i.first, i.second - prev->second);
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
{
|
|
50
|
+
// Integrity check: we can only increase totals over time, never decrease
|
|
51
|
+
assert(i.second == prev->second);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return ret;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/* static */ void metrics::record(std::string const & test_id, std::uint64_t nsec)
|
|
59
|
+
{
|
|
60
|
+
std::lock_guard<std::mutex> guard(metrics_lock_);
|
|
61
|
+
|
|
62
|
+
metrics_container_t::iterator pos = metrics_totals_.lower_bound(test_id);
|
|
63
|
+
|
|
64
|
+
if (pos == metrics_totals_.end() || pos->first != test_id) [[unlikely]]
|
|
65
|
+
{
|
|
66
|
+
pos = metrics_totals_.emplace_hint(pos, test_id, 0);
|
|
67
|
+
|
|
68
|
+
assert(pos->second == 0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
assert(pos->first == test_id);
|
|
72
|
+
pos->second += nsec;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* static */ metrics_container_t metrics::totals()
|
|
76
|
+
{
|
|
77
|
+
std::lock_guard<std::mutex> guard(metrics_lock_);
|
|
78
|
+
return metrics_totals_;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* static */ void metrics::clear()
|
|
82
|
+
{
|
|
83
|
+
std::lock_guard<std::mutex> guard(metrics_lock_);
|
|
84
|
+
metrics_totals_.clear();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void register_metrics(py::module_ & m)
|
|
88
|
+
{
|
|
89
|
+
|
|
90
|
+
py::module_ metrics_module =
|
|
91
|
+
m.def_submodule("metrics", "Keep track of low-level performance metrics")
|
|
92
|
+
.def("totals", &qdb::metrics::totals)
|
|
93
|
+
.def("clear", &qdb::metrics::clear);
|
|
94
|
+
|
|
95
|
+
auto metrics_measure = py::class_<qdb::metrics::measure>(
|
|
96
|
+
metrics_module, "Measure", "Track all metrics within a block of code")
|
|
97
|
+
.def(py::init())
|
|
98
|
+
.def("__enter__", &qdb::metrics::measure::enter)
|
|
99
|
+
.def("__exit__", &qdb::metrics::measure::exit)
|
|
100
|
+
.def("get", &qdb::metrics::measure::get);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
}; // namespace qdb
|
quasardb/metrics.hpp
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Official Python API
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2009-2023, 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 <pybind11/pybind11.h>
|
|
34
|
+
#include <pybind11/stl.h>
|
|
35
|
+
#include <cassert>
|
|
36
|
+
#include <chrono>
|
|
37
|
+
#include <map>
|
|
38
|
+
#include <string>
|
|
39
|
+
|
|
40
|
+
namespace qdb
|
|
41
|
+
{
|
|
42
|
+
namespace py = pybind11;
|
|
43
|
+
using metrics_container_t = std::map<std::string, std::uint64_t>;
|
|
44
|
+
|
|
45
|
+
class metrics
|
|
46
|
+
{
|
|
47
|
+
private:
|
|
48
|
+
public:
|
|
49
|
+
/**
|
|
50
|
+
* Utility fixture that automatically records timings for a certain block of code.
|
|
51
|
+
* This is intended to be used from native C++ code only.
|
|
52
|
+
*/
|
|
53
|
+
class scoped_capture
|
|
54
|
+
{
|
|
55
|
+
using clock_t = std::chrono::high_resolution_clock;
|
|
56
|
+
using time_point_t = std::chrono::time_point<clock_t>;
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
scoped_capture(std::string const & test_id) noexcept
|
|
60
|
+
: test_id_{test_id}
|
|
61
|
+
, start_{clock_t::now()} {};
|
|
62
|
+
~scoped_capture();
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
std::string test_id_;
|
|
66
|
+
time_point_t start_;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Utility class that's exposed to Python which can be used to record metrics in
|
|
71
|
+
* a scope. It makes it easy to track the difference between the beginning and end
|
|
72
|
+
* of execution.
|
|
73
|
+
*/
|
|
74
|
+
class measure
|
|
75
|
+
{
|
|
76
|
+
public:
|
|
77
|
+
measure();
|
|
78
|
+
~measure(){};
|
|
79
|
+
|
|
80
|
+
public:
|
|
81
|
+
measure enter()
|
|
82
|
+
{
|
|
83
|
+
// No-op, all initialization is done in the constructor.
|
|
84
|
+
return *this;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void exit(py::object /* type */, py::object /* value */, py::object /* traceback */)
|
|
88
|
+
{}
|
|
89
|
+
|
|
90
|
+
metrics_container_t get() const;
|
|
91
|
+
|
|
92
|
+
private:
|
|
93
|
+
metrics_container_t start_;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
public:
|
|
97
|
+
metrics() noexcept {};
|
|
98
|
+
|
|
99
|
+
~metrics() noexcept {};
|
|
100
|
+
|
|
101
|
+
public:
|
|
102
|
+
static void record(std::string const & test_id, std::uint64_t nsec);
|
|
103
|
+
|
|
104
|
+
static metrics_container_t totals();
|
|
105
|
+
static void clear();
|
|
106
|
+
|
|
107
|
+
private:
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
void register_metrics(py::module_ & m);
|
|
111
|
+
|
|
112
|
+
} // namespace qdb
|
quasardb/module.cpp
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "module.hpp"
|
|
2
2
|
#include "cluster.hpp"
|
|
3
|
+
#include "metrics.hpp"
|
|
3
4
|
#include "node.hpp"
|
|
4
5
|
#include "writer.hpp"
|
|
5
6
|
#include <functional>
|
|
@@ -62,6 +63,7 @@ PYBIND11_MODULE(quasardb, m)
|
|
|
62
63
|
qdb::register_table_reader(m);
|
|
63
64
|
qdb::register_masked_array(m);
|
|
64
65
|
qdb::register_writer(m);
|
|
66
|
+
qdb::register_metrics(m);
|
|
65
67
|
|
|
66
68
|
qdb::detail::register_ts_column(m);
|
|
67
69
|
qdb::reader::register_ts_value(m);
|
quasardb/qdb_api.dll
CHANGED
|
Binary file
|
|
Binary file
|
quasardb/query.cpp
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
#include "query.hpp"
|
|
33
33
|
#include "masked_array.hpp"
|
|
34
|
+
#include "metrics.hpp"
|
|
34
35
|
#include "numpy.hpp"
|
|
35
36
|
#include "traits.hpp"
|
|
36
37
|
#include "utils.hpp"
|
|
@@ -390,7 +391,12 @@ numpy_query_result_t numpy_query_results(const qdb_query_result_t * r)
|
|
|
390
391
|
dict_query_result_t dict_query(qdb::handle_ptr h, const std::string & q, const py::object & blobs)
|
|
391
392
|
{
|
|
392
393
|
detail::qdb_resource<qdb_query_result_t> r{*h};
|
|
393
|
-
|
|
394
|
+
|
|
395
|
+
qdb_error_t err;
|
|
396
|
+
{
|
|
397
|
+
metrics::scoped_capture capture{"qdb_query"};
|
|
398
|
+
err = qdb_query(*h, q.c_str(), &r);
|
|
399
|
+
}
|
|
394
400
|
|
|
395
401
|
qdb::qdb_throw_if_query_error(*h, err, r.get());
|
|
396
402
|
|
|
@@ -400,7 +406,12 @@ dict_query_result_t dict_query(qdb::handle_ptr h, const std::string & q, const p
|
|
|
400
406
|
numpy_query_result_t numpy_query(qdb::handle_ptr h, const std::string & q)
|
|
401
407
|
{
|
|
402
408
|
detail::qdb_resource<qdb_query_result_t> r{*h};
|
|
403
|
-
|
|
409
|
+
|
|
410
|
+
qdb_error_t err;
|
|
411
|
+
{
|
|
412
|
+
metrics::scoped_capture capture{"qdb_query"};
|
|
413
|
+
err = qdb_query(*h, q.c_str(), &r);
|
|
414
|
+
}
|
|
404
415
|
qdb::qdb_throw_if_query_error(*h, err, r.get());
|
|
405
416
|
|
|
406
417
|
return numpy_query_results(r);
|
quasardb/table.cpp
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "table.hpp"
|
|
2
2
|
#include "dispatch.hpp"
|
|
3
|
+
#include "metrics.hpp"
|
|
3
4
|
#include "object_tracker.hpp"
|
|
4
5
|
#include "table_reader.hpp"
|
|
5
6
|
#include "traits.hpp"
|
|
@@ -68,6 +69,31 @@ inline void insert_column_dispatch(handle_ptr handle,
|
|
|
68
69
|
|
|
69
70
|
}; // namespace detail
|
|
70
71
|
|
|
72
|
+
void table::_cache_columns() const
|
|
73
|
+
{
|
|
74
|
+
_handle->check_open();
|
|
75
|
+
|
|
76
|
+
detail::qdb_resource<qdb_ts_column_info_ex_t> columns{*_handle};
|
|
77
|
+
qdb_size_t count = 0;
|
|
78
|
+
|
|
79
|
+
qdb_error_t err;
|
|
80
|
+
|
|
81
|
+
{
|
|
82
|
+
metrics::scoped_capture("qdb_ts_list_columns");
|
|
83
|
+
err = qdb_ts_list_columns_ex(*_handle, _alias.c_str(), &columns, &count);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (err == qdb_e_alias_not_found) [[unlikely]]
|
|
87
|
+
{
|
|
88
|
+
// Can happen if table does not yet exist, do nothing.
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
qdb::qdb_throw_if_error(*_handle, err);
|
|
93
|
+
|
|
94
|
+
_columns = detail::convert_columns(columns.get(), count);
|
|
95
|
+
}
|
|
96
|
+
|
|
71
97
|
py::object table::reader(
|
|
72
98
|
const std::vector<std::string> & columns, py::object ranges, bool dict_mode) const
|
|
73
99
|
{
|
quasardb/table.hpp
CHANGED
|
@@ -68,7 +68,7 @@ public:
|
|
|
68
68
|
|
|
69
69
|
const auto c_columns = detail::convert_columns_ex(columns);
|
|
70
70
|
qdb::qdb_throw_if_error(*_handle, qdb_ts_create_ex(*_handle, _alias.c_str(), shard_size.count(),
|
|
71
|
-
c_columns.data(), c_columns.size()));
|
|
71
|
+
c_columns.data(), c_columns.size(), qdb_ttl_disabled));
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
void insert_columns(const std::vector<detail::column_info> & columns)
|
|
@@ -156,25 +156,7 @@ private:
|
|
|
156
156
|
/**
|
|
157
157
|
* Loads column info / metadata from server and caches it locally.
|
|
158
158
|
*/
|
|
159
|
-
void _cache_columns() const
|
|
160
|
-
{
|
|
161
|
-
_handle->check_open();
|
|
162
|
-
|
|
163
|
-
detail::qdb_resource<qdb_ts_column_info_ex_t> columns{*_handle};
|
|
164
|
-
qdb_size_t count = 0;
|
|
165
|
-
|
|
166
|
-
auto err = qdb_ts_list_columns_ex(*_handle, _alias.c_str(), &columns, &count);
|
|
167
|
-
|
|
168
|
-
if (err == qdb_e_alias_not_found) [[unlikely]]
|
|
169
|
-
{
|
|
170
|
-
// Can happen if table does not yet exist, do nothing.
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
qdb::qdb_throw_if_error(*_handle, err);
|
|
175
|
-
|
|
176
|
-
_columns = detail::convert_columns(columns.get(), count);
|
|
177
|
-
}
|
|
159
|
+
void _cache_columns() const;
|
|
178
160
|
|
|
179
161
|
/**
|
|
180
162
|
* Loads column info / metadata from server if not yet cached locally.
|
quasardb/writer.cpp
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include "writer.hpp"
|
|
2
2
|
#include "concepts.hpp"
|
|
3
3
|
#include "dispatch.hpp"
|
|
4
|
+
#include "metrics.hpp"
|
|
4
5
|
#include "numpy.hpp"
|
|
5
6
|
#include "traits.hpp"
|
|
6
7
|
#include "convert/array.hpp"
|
|
@@ -491,6 +492,9 @@ void writer::_push_impl(writer::staged_tables_t & staged_tables,
|
|
|
491
492
|
batch_table.data.column_count, table_name);
|
|
492
493
|
}
|
|
493
494
|
|
|
495
|
+
// Make sure to measure the time it takes to do the actual push
|
|
496
|
+
qdb::metrics::scoped_capture capture{"qdb_batch_push"};
|
|
497
|
+
|
|
494
498
|
qdb::qdb_throw_if_error(
|
|
495
499
|
*_handle, qdb_exp_batch_push(*_handle, mode, batch.data(), nullptr, batch.size()));
|
|
496
500
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
quasardb/CMakeLists.txt,sha256=
|
|
1
|
+
quasardb/CMakeLists.txt,sha256=Rdpd6_7EfVD7F81k7OgxH57cVFIGZzz57O2haCTSrs8,15237
|
|
2
2
|
quasardb/INSTALL.vcxproj,sha256=aXHfnr7T7m59bPAhc04aDgGUAl79rH2Ys_yYSphXpyg,10474
|
|
3
3
|
quasardb/INSTALL.vcxproj.filters,sha256=jH5jt3D-5NW497ftXfdl9GFwtjj88m7DgCkN2xDfFjw,561
|
|
4
4
|
quasardb/__init__.py,sha256=S5HGH9idLoUES_9XSqHnEixEC6VKwzcubJlnVvWi22E,3801
|
|
5
5
|
quasardb/batch_column.hpp,sha256=txW9kYMgQzJiJlM5nD7LIVuAZpyidpS4MopPGKE95u0,3388
|
|
6
6
|
quasardb/batch_inserter.hpp,sha256=bM73Z-IKow89GqoYaxDLDd0YuaN5Il4C5TjIVx9bI-Y,9803
|
|
7
7
|
quasardb/blob.hpp,sha256=PObdSJxKNLIihBCLBxQHHH20t7VOmZG02wOfy8rB1-w,5846
|
|
8
|
-
quasardb/cluster.
|
|
8
|
+
quasardb/cluster.cpp,sha256=ytPCLRZVA7eTZgqIbLWKsmiugYLq80v9rSuoksKTE3c,2500
|
|
9
|
+
quasardb/cluster.hpp,sha256=AYZY2myVI1eeG3Cxe7yCPb7Kmlh1Ij_go4ryZdIEJHc,19405
|
|
9
10
|
quasardb/cmake_install.cmake,sha256=scFMkhkW6P3JMIyEQmLqnQW3hgo4bKmw60iNUQxa8S0,1497
|
|
10
11
|
quasardb/concepts.hpp,sha256=Ao-UKFVjh7kRqeqsYXioV1LXiKXBR_1l54hRvUCjxKU,9574
|
|
11
12
|
quasardb/continuous.cpp,sha256=18-VX7BZA60wkUq75ADU7yfgmwzT_CkG_tEAKxAVkLU,4566
|
|
@@ -19,12 +20,15 @@ quasardb/double.hpp,sha256=SW1z9QW09mC_8ggvleMZolivu2BHjF157IVKT_Jw638,3239
|
|
|
19
20
|
quasardb/entry.hpp,sha256=IE6uL341x6U5dos40LhVKSJPuYZwod-oRy4PoF5a_80,9451
|
|
20
21
|
quasardb/error.hpp,sha256=b3BvBn0wYqHlrkH48pZod6CMjtxFu6l7SQjt88zXlwc,10807
|
|
21
22
|
quasardb/firehose.py,sha256=DHYsew-aL1j5PKZonH30CrhXnwHEX1XIAhGbPrzd4PY,3593
|
|
22
|
-
quasardb/handle.
|
|
23
|
+
quasardb/handle.cpp,sha256=oyhzAj1k8UFhpLhwU5RL4cbdqt82KZexWacMFz5uXA0,536
|
|
24
|
+
quasardb/handle.hpp,sha256=o26dxmrXtfbxgj66QgKjW8wviUPbcZvmIAZ4L4CcdoQ,3051
|
|
23
25
|
quasardb/integer.hpp,sha256=H5x8SEqlyI2nQZL9iv4GnCL0uWYuq8l8YYUzI83t0aE,3304
|
|
24
|
-
quasardb/logger.cpp,sha256=
|
|
26
|
+
quasardb/logger.cpp,sha256=UThEO2V6UI-tbpG9suud7olmMjIMfHr3tNt-nM48DIE,3056
|
|
25
27
|
quasardb/logger.hpp,sha256=4trngfo31-OizuEkQUoYob77PVeXC283tPGaX3JRpPY,7278
|
|
26
28
|
quasardb/masked_array.hpp,sha256=nfuvkFZnNoGqqtJzBZ95h4e4PguhIr5kj3tVO4y8W4U,18988
|
|
27
|
-
quasardb/
|
|
29
|
+
quasardb/metrics.cpp,sha256=NuEBVYlIHQRgmPy4g9Eosq1Q28Z1jySSZHKDAMLURIA,2942
|
|
30
|
+
quasardb/metrics.hpp,sha256=oz_XDbcMCJ9fiaYi043rFakM-mmzsuONskDfMPDf4_U,3533
|
|
31
|
+
quasardb/module.cpp,sha256=Nx0d3xyqCb2Red1WgsGUotaXxX6NHoDCcp9PnUzmcB0,2236
|
|
28
32
|
quasardb/module.hpp,sha256=-zRcQ_lgVz4IEP3tokX4AeA33DYJ3jsq8vWX6OnE0Ic,604
|
|
29
33
|
quasardb/node.hpp,sha256=_rcwUA9mOFW7b7I3B3Ll3aaBO0RoKV3LS19JITaIi6A,4771
|
|
30
34
|
quasardb/numpy.cpp,sha256=0brRs6lnIpsCNvpu3twIcjizy3lMOvCBT0O4rjKAn0I,189
|
|
@@ -34,15 +38,15 @@ quasardb/options.hpp,sha256=hXNBVTQdrDwWkxGyFBOuRGYyJoD_IpqpitJPbDnabi0,10158
|
|
|
34
38
|
quasardb/perf.hpp,sha256=C7dM0ZZZ4Ln5pDnZpvvUMgdwLUp4Tom51JuZICSYGGI,11364
|
|
35
39
|
quasardb/pool.py,sha256=lqVZPFejmNHU7EdyeoPkl7yy_-N3BRyuLhNTzIdtg8g,8743
|
|
36
40
|
quasardb/pytypes.hpp,sha256=YTc6xdmxMGMWtrZHitAl3vudZxYctOX1NwL-QDuzz1g,6894
|
|
37
|
-
quasardb/qdb_api.dll,sha256=
|
|
38
|
-
quasardb/quasardb.cp310-win32.pyd,sha256=
|
|
39
|
-
quasardb/query.cpp,sha256=
|
|
41
|
+
quasardb/qdb_api.dll,sha256=l0QgXq9kl0_0yV_hzXOaBUE9JUw5ZKxxD_Hio82ySLw,13801984
|
|
42
|
+
quasardb/quasardb.cp310-win32.pyd,sha256=forx51jPQykTahX7HLpXaizKpCipr4lT_F4OQbRnOpA,1199616
|
|
43
|
+
quasardb/query.cpp,sha256=FhsA93s-mXqw6WnzQgYLooy02P-haTEHkTMpdgMbdKw,12752
|
|
40
44
|
quasardb/query.hpp,sha256=dBFJ0FVNJN-WdCwbHU1iNbEzDHarGGDQaZ5gto-xwkY,3357
|
|
41
45
|
quasardb/remove_cvref.hpp,sha256=vKUecNoA2-BIiZeP8NuO3GgBOMF-OVSn_43LJCuDozA,611
|
|
42
46
|
quasardb/stats.py,sha256=LDV4F5KTpEXa5sS_syFo_TYn9_W2X1D32Eb43GLutOs,7620
|
|
43
47
|
quasardb/string.hpp,sha256=xgvRf1TXy3nl45WeCHHhtO8toUYZ2Zo7RuvTAntIgZM,6071
|
|
44
|
-
quasardb/table.cpp,sha256=
|
|
45
|
-
quasardb/table.hpp,sha256=
|
|
48
|
+
quasardb/table.cpp,sha256=_LAltQoycIzkqg4Id4u5MHN9Uy4OD-wWZMtdxzReMDs,10725
|
|
49
|
+
quasardb/table.hpp,sha256=bu3n9jjNW_dH01vbXkCbl4TmwfbyQS_0a4_fitbcrUI,10941
|
|
46
50
|
quasardb/table_cache.py,sha256=t7FFQkms7pFlYDkOhCcLnLS8bWglZjlzX3Qs6gyBG6Q,1559
|
|
47
51
|
quasardb/table_reader.hpp,sha256=UYqpLtdMFr4MKho0A9y6sKb1-KoNLtYPdypl6zOrwm0,6941
|
|
48
52
|
quasardb/tag.hpp,sha256=gIs8LDa4o0JJBGuSQXsnyVeORax7KH0jHCyt0Zx6JMs,2732
|
|
@@ -51,7 +55,7 @@ quasardb/traits.hpp,sha256=RLSJBeZbFsWRQAsZSm6GbV2a2-5jounsJ_TX0iSvyHI,16383
|
|
|
51
55
|
quasardb/ts_iterator.hpp,sha256=faP1HVGYbWubKr98yhkS6gqvyMiKWkl3tgedJfj2u1E,4395
|
|
52
56
|
quasardb/utils.cpp,sha256=PkuVxrj1cQfeVujA-kefx9-P0B6IJNtYDQzedCAMjKY,634
|
|
53
57
|
quasardb/utils.hpp,sha256=ZedlY9Ahdphyi8tm2CySYb2k1RJTaDFqDBy3dvg-rJ8,4724
|
|
54
|
-
quasardb/writer.cpp,sha256=
|
|
58
|
+
quasardb/writer.cpp,sha256=5jPLFvOcJydiyBSbbtB-SDspKVoXcV9squEOQLuOvp0,19571
|
|
55
59
|
quasardb/writer.hpp,sha256=08S7HDgdCajNSwro4i0i1lzyvUkHFh6M1vn8TJpAz_A,12933
|
|
56
60
|
quasardb/CMakeFiles/generate.stamp,sha256=MC9-mgyGPAS3QAZa3gHSQ8dYfXJy_Hn7AChwEoqVWOs,55
|
|
57
61
|
quasardb/CMakeFiles/generate.stamp.depend,sha256=uY8FV-ceJ2Kk-6JfOnsIesDV7jKoUNfkKHNY2Nf7_E8,117
|
|
@@ -107,8 +111,8 @@ quasardb/utils/ostream.hpp,sha256=KYFwqXuZoxuZblHUM-z5xrd74P2Y5zWJqVpaQ9oedAo,39
|
|
|
107
111
|
quasardb/utils/permutation.hpp,sha256=BwJzgZmpS4G-oS7249GvnUFj_cmqSAbF2Fzb8wuihLo,1552
|
|
108
112
|
quasardb/utils/stable_sort.hpp,sha256=luIK9T76mT0NyDxpLxXjTt1eSSKEOY29jRANJNysJCo,489
|
|
109
113
|
quasardb/utils/unzip_view.hpp,sha256=nn6BSAI_cGsKgBh8WXhAUJ6Zzn3N0AnhtE6ePmhPeQM,2476
|
|
110
|
-
quasardb-3.14.1.
|
|
111
|
-
quasardb-3.14.1.
|
|
112
|
-
quasardb-3.14.1.
|
|
113
|
-
quasardb-3.14.1.
|
|
114
|
-
quasardb-3.14.1.
|
|
114
|
+
quasardb-3.14.1.dev6.dist-info/LICENSE.md,sha256=yqGeNifkwT_AQEPv0TwLxEdD9TgORqUjS01rgzG5EGY,1477
|
|
115
|
+
quasardb-3.14.1.dev6.dist-info/METADATA,sha256=E41lG6VbSKiA00UKf7Xkp6_zRTbJhIxReJ3HZs62N-o,1496
|
|
116
|
+
quasardb-3.14.1.dev6.dist-info/WHEEL,sha256=ayRWnvZLcgoYbBn-ztUNZ440Pn7a0epJikKJhL4kWzw,98
|
|
117
|
+
quasardb-3.14.1.dev6.dist-info/top_level.txt,sha256=wlprix4hCywuF1PkgKWYdZeJKq_kgJOqkAvukm_sZQ8,9
|
|
118
|
+
quasardb-3.14.1.dev6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|