quasardb 3.14.2.dev1__cp38-cp38-macosx_11_0_arm64.whl → 3.14.2.dev4__cp38-cp38-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.

Files changed (95) hide show
  1. quasardb/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
  2. quasardb/Makefile +20 -20
  3. quasardb/__init__.py +33 -4
  4. quasardb/cmake_install.cmake +7 -1
  5. quasardb/date/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
  6. quasardb/date/CMakeFiles/Export/a52b05f964b070ee926bcad51d3288af/dateTargets.cmake +13 -13
  7. quasardb/date/Makefile +20 -20
  8. quasardb/date/cmake_install.cmake +7 -1
  9. quasardb/date/dateConfigVersion.cmake +9 -2
  10. quasardb/date/dateTargets.cmake +4 -8
  11. quasardb/libqdb_api.dylib +0 -0
  12. quasardb/numpy/__init__.py +58 -10
  13. quasardb/pandas/__init__.py +58 -102
  14. quasardb/pybind11/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
  15. quasardb/pybind11/Makefile +20 -20
  16. quasardb/pybind11/cmake_install.cmake +7 -1
  17. quasardb/quasardb.cpython-38-darwin.so +0 -0
  18. quasardb/range-v3/CMakeFiles/CMakeDirectoryInformation.cmake +1 -1
  19. quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +13 -13
  20. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/DependInfo.cmake +6 -2
  21. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/build.make +7 -4
  22. quasardb/range-v3/Makefile +20 -20
  23. quasardb/range-v3/cmake_install.cmake +19 -1
  24. quasardb/range-v3/range-v3-config-version.cmake +9 -2
  25. quasardb/range-v3/range-v3-config.cmake +4 -8
  26. {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/METADATA +5 -8
  27. quasardb-3.14.2.dev4.dist-info/RECORD +45 -0
  28. {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/WHEEL +1 -1
  29. quasardb/CMakeLists.txt +0 -510
  30. quasardb/batch_column.hpp +0 -80
  31. quasardb/batch_inserter.hpp +0 -248
  32. quasardb/blob.hpp +0 -150
  33. quasardb/cluster.cpp +0 -89
  34. quasardb/cluster.hpp +0 -551
  35. quasardb/concepts.hpp +0 -278
  36. quasardb/continuous.cpp +0 -149
  37. quasardb/continuous.hpp +0 -106
  38. quasardb/convert/array.hpp +0 -282
  39. quasardb/convert/point.hpp +0 -330
  40. quasardb/convert/range.hpp +0 -282
  41. quasardb/convert/unicode.hpp +0 -598
  42. quasardb/convert/util.hpp +0 -22
  43. quasardb/convert/value.hpp +0 -711
  44. quasardb/convert.hpp +0 -38
  45. quasardb/detail/qdb_resource.hpp +0 -129
  46. quasardb/detail/ts_column.hpp +0 -224
  47. quasardb/direct_blob.hpp +0 -108
  48. quasardb/direct_handle.hpp +0 -83
  49. quasardb/direct_integer.hpp +0 -94
  50. quasardb/dispatch.hpp +0 -157
  51. quasardb/double.hpp +0 -87
  52. quasardb/entry.hpp +0 -273
  53. quasardb/error.hpp +0 -318
  54. quasardb/handle.cpp +0 -29
  55. quasardb/handle.hpp +0 -98
  56. quasardb/integer.hpp +0 -88
  57. quasardb/logger.cpp +0 -106
  58. quasardb/logger.hpp +0 -228
  59. quasardb/masked_array.hpp +0 -651
  60. quasardb/metrics.cpp +0 -103
  61. quasardb/metrics.hpp +0 -112
  62. quasardb/module.cpp +0 -76
  63. quasardb/module.hpp +0 -24
  64. quasardb/node.hpp +0 -123
  65. quasardb/numpy.cpp +0 -6
  66. quasardb/numpy.hpp +0 -489
  67. quasardb/object_tracker.hpp +0 -283
  68. quasardb/options.hpp +0 -244
  69. quasardb/perf.hpp +0 -336
  70. quasardb/pytypes.hpp +0 -221
  71. quasardb/query.cpp +0 -420
  72. quasardb/query.hpp +0 -92
  73. quasardb/reader/ts_row.hpp +0 -281
  74. quasardb/reader/ts_value.hpp +0 -245
  75. quasardb/remove_cvref.hpp +0 -31
  76. quasardb/string.hpp +0 -160
  77. quasardb/table.cpp +0 -289
  78. quasardb/table.hpp +0 -325
  79. quasardb/table_reader.hpp +0 -220
  80. quasardb/tag.hpp +0 -77
  81. quasardb/timestamp.hpp +0 -97
  82. quasardb/traits.hpp +0 -619
  83. quasardb/ts_iterator.hpp +0 -193
  84. quasardb/utils/blob_deque.hpp +0 -96
  85. quasardb/utils/ostream.hpp +0 -17
  86. quasardb/utils/permutation.hpp +0 -50
  87. quasardb/utils/stable_sort.hpp +0 -25
  88. quasardb/utils/unzip_view.hpp +0 -89
  89. quasardb/utils.cpp +0 -28
  90. quasardb/utils.hpp +0 -174
  91. quasardb/writer.cpp +0 -534
  92. quasardb/writer.hpp +0 -396
  93. quasardb-3.14.2.dev1.dist-info/RECORD +0 -109
  94. {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/LICENSE.md +0 -0
  95. {quasardb-3.14.2.dev1.dist-info → quasardb-3.14.2.dev4.dist-info}/top_level.txt +0 -0
quasardb/ts_iterator.hpp DELETED
@@ -1,193 +0,0 @@
1
- #pragma once
2
-
3
- #include "remove_cvref.hpp"
4
- #include <iterator>
5
-
6
- // we need a std::swap(std::tuple<T&...>, std::tuple<T&...>) in sort
7
- // because we create a zip_iterator for both time_offsets and values
8
- // we need to swap them both at the same time
9
- namespace std
10
- {
11
-
12
- template <typename T>
13
- void swap(tuple<qdb_timespec_t &, T &> lhs, tuple<qdb_timespec_t &, T &> rhs)
14
- {
15
- std::swap(std::get<0>(lhs), std::get<0>(rhs));
16
- std::swap(std::get<1>(lhs), std::get<1>(rhs));
17
- }
18
-
19
- } // namespace std
20
-
21
- namespace qdb
22
- {
23
-
24
- template <typename T>
25
- class ts_iterator
26
- {
27
- using iterators =
28
- typename std::tuple<std::vector<qdb_timespec_t>::iterator, typename std::vector<T>::iterator>;
29
-
30
- public:
31
- using difference_type = std::ptrdiff_t;
32
- using value_type = std::tuple<qdb_timespec_t, T>;
33
- using reference = std::tuple<qdb_timespec_t &, T &>;
34
- using pointer = std::tuple<qdb_timespec_t *, T *>;
35
- using iterator_category = std::random_access_iterator_tag;
36
-
37
- ts_iterator() = default;
38
-
39
- explicit ts_iterator(
40
- std::vector<qdb_timespec_t>::iterator it_ts, typename std::vector<T>::iterator it_vs)
41
- : _its(std::make_tuple(it_ts, it_vs))
42
- {}
43
-
44
- ts_iterator(const ts_iterator & other)
45
- : _its(other._its)
46
- {}
47
-
48
- reference operator*() const
49
- {
50
- return std::tie((*std::get<0>(_its)), (*std::get<1>(_its)));
51
- }
52
-
53
- template <size_t I>
54
- decltype(auto) get()
55
- {
56
- static_assert(I < 2, "index must be less than 2");
57
- return std::get<I>(_its);
58
- }
59
-
60
- template <size_t I>
61
- decltype(auto) get() const
62
- {
63
- static_assert(I < 2, "index must be less than 2");
64
- return std::get<I>(_its);
65
- }
66
-
67
- reference operator[](difference_type i) const
68
- {
69
- return *(*this + i);
70
- }
71
-
72
- difference_type operator-(const ts_iterator & it) const
73
- {
74
- return std::get<0>(_its) - std::get<0>(it._its);
75
- }
76
-
77
- ts_iterator & operator+=(difference_type forward)
78
- {
79
- auto advance = [forward](auto & it) {
80
- auto forward_to =
81
- static_cast<typename std::iterator_traits<std::decay_t<decltype(it)>>::difference_type>(
82
- forward);
83
- it = std::next(it, forward_to);
84
- };
85
- advance(std::get<0>(_its));
86
- advance(std::get<1>(_its));
87
-
88
- return *this;
89
- }
90
-
91
- ts_iterator & operator-=(difference_type backward)
92
- {
93
- return *this += -backward;
94
- }
95
-
96
- ts_iterator & operator++()
97
- {
98
- return *this += 1;
99
- }
100
-
101
- ts_iterator & operator--()
102
- {
103
- return *this -= 1;
104
- }
105
-
106
- ts_iterator operator++(int)
107
- {
108
- ts_iterator it(*this);
109
-
110
- ++(*this);
111
-
112
- return it;
113
- }
114
-
115
- ts_iterator operator--(int)
116
- {
117
- ts_iterator it(*this);
118
-
119
- --(*this);
120
-
121
- return it;
122
- }
123
-
124
- ts_iterator operator-(difference_type backward) const
125
- {
126
-
127
- ts_iterator it(*this);
128
-
129
- return it -= backward;
130
- }
131
-
132
- ts_iterator operator+(difference_type forward) const
133
- {
134
-
135
- ts_iterator it(*this);
136
-
137
- return it += forward;
138
- }
139
-
140
- friend ts_iterator operator+(difference_type forward, const ts_iterator & it)
141
- {
142
- return it + forward;
143
- }
144
-
145
- bool operator==(const ts_iterator & it) const
146
- {
147
-
148
- return *this - it == 0;
149
- }
150
-
151
- bool operator!=(const ts_iterator & it) const
152
- {
153
- return !(*this == it);
154
- }
155
-
156
- bool operator<(const ts_iterator & it) const
157
- {
158
- return *this - it < 0;
159
- }
160
-
161
- bool operator>(const ts_iterator & it) const
162
- {
163
- return it < *this;
164
- }
165
-
166
- bool operator<=(const ts_iterator & it) const
167
- {
168
- return !(*this > it);
169
- }
170
-
171
- bool operator>=(const ts_iterator & it) const
172
- {
173
- return !(*this < it);
174
- }
175
-
176
- private:
177
- iterators _its;
178
- };
179
-
180
- template <size_t I, typename T>
181
- inline decltype(auto) get(const qdb::ts_iterator<T> & it)
182
- {
183
- return it.template get<I>();
184
- }
185
-
186
- } // namespace qdb
187
-
188
- template <typename Iterator>
189
- auto make_ts_iterator(std::vector<qdb_timespec_t>::iterator ts_it, Iterator vs_it)
190
- {
191
- using value_type = typename std::iterator_traits<Iterator>::value_type;
192
- return qdb::ts_iterator<value_type>(ts_it, vs_it);
193
- }
@@ -1,96 +0,0 @@
1
- #pragma once
2
-
3
- #include <qdb/client.h>
4
- #include <cassert>
5
- #include <cstddef>
6
- #include <cstring>
7
- #include <forward_list>
8
- #include <vector>
9
-
10
- namespace utils
11
- {
12
-
13
- /// Stores chunks of bytes. They stay stable in memory until the deque is cleared.
14
- class blob_deque
15
- {
16
- struct blob_block
17
- {
18
- std::unique_ptr<char[]> storage;
19
- size_t size;
20
- size_t capacity;
21
-
22
- explicit blob_block(size_t capacity)
23
- // TODO(C++20): Use std::make_unique_for_overwrite.
24
- : storage{std::make_unique<char[]>(capacity)}
25
- , size{}
26
- , capacity{capacity}
27
- {}
28
-
29
- bool can_store(size_t bytes_cnt) const noexcept
30
- {
31
- return bytes_cnt <= capacity - size;
32
- }
33
-
34
- qdb_blob_t add(qdb_blob_t blob) noexcept
35
- {
36
- assert(can_store(blob.content_length));
37
- auto dst = qdb_blob_t{static_cast<void *>(storage.get() + size), blob.content_length};
38
- std::memcpy(const_cast<void *>(dst.content), blob.content, blob.content_length);
39
- size += blob.content_length;
40
- return dst;
41
- }
42
-
43
- void clear() noexcept
44
- {
45
- size = 0;
46
- }
47
- };
48
-
49
- std::forward_list<blob_block> _blocks;
50
- decltype(_blocks)::iterator _cur_block;
51
- size_t _filled_blocks_size = 0;
52
-
53
- public:
54
- explicit blob_deque(size_t initial_capacity = 64)
55
- {
56
- _blocks.emplace_front(initial_capacity);
57
- _cur_block = _blocks.begin();
58
- }
59
-
60
- qdb_blob_t add(qdb_blob_t blob)
61
- {
62
-
63
- while (!_cur_block->can_store(blob.content_length))
64
- {
65
- _filled_blocks_size += _cur_block->size;
66
- auto next_it = _cur_block;
67
- ++next_it;
68
- if (next_it == _blocks.end())
69
- {
70
- const auto cap = std::max(blob.content_length, _cur_block->capacity * 2);
71
- _cur_block = _blocks.emplace_after(_cur_block, cap);
72
- break;
73
- }
74
- _cur_block = next_it;
75
- }
76
- return _cur_block->add(blob);
77
- }
78
-
79
- // Keep allocated memory to reuse it in subsequent 'add' calls.
80
- void clear()
81
- {
82
- for (auto & block : _blocks)
83
- {
84
- block.clear();
85
- }
86
- _cur_block = _blocks.begin();
87
- _filled_blocks_size = 0;
88
- }
89
-
90
- size_t bytes_count() const noexcept
91
- {
92
- return _filled_blocks_size + _cur_block->size;
93
- }
94
- };
95
-
96
- } // namespace utils
@@ -1,17 +0,0 @@
1
- #pragma once
2
-
3
- #include <qdb/ts.h>
4
-
5
- template <typename Ostream>
6
- Ostream & operator<<(Ostream & os, qdb_timespec_t timestamp)
7
- {
8
- os << "(" << timestamp.tv_sec << "," << timestamp.tv_nsec << ")";
9
- return os;
10
- }
11
-
12
- template <typename Ostream>
13
- Ostream & operator<<(Ostream & os, qdb_ts_range_t range)
14
- {
15
- os << "[" << range.begin << "," << range.end << "]";
16
- return os;
17
- }
@@ -1,50 +0,0 @@
1
- #pragma once
2
-
3
- #include "stable_sort.hpp"
4
- #include <vector>
5
-
6
- namespace utils
7
- {
8
-
9
- template <typename RandomAccessIterator1, typename RandomAccessIterator2>
10
- void apply_permutation(RandomAccessIterator1 item_begin,
11
- RandomAccessIterator1 item_end,
12
- RandomAccessIterator2 ind_begin,
13
- RandomAccessIterator2 ind_end)
14
- {
15
- using Diff = typename std::iterator_traits<RandomAccessIterator1>::difference_type;
16
- using std::swap;
17
- Diff size = std::distance(item_begin, item_end);
18
- for (Diff i = 0; i < size; i++)
19
- {
20
- auto current = i;
21
- while (i != ind_begin[current])
22
- {
23
- auto next = ind_begin[current];
24
- swap(item_begin[current], item_begin[next]);
25
- ind_begin[current] = current;
26
- current = next;
27
- }
28
- ind_begin[current] = current;
29
- }
30
- }
31
-
32
- template <typename Range1, typename Range2>
33
- void apply_permutation(Range1 & item_range, Range2 & ind_range)
34
- {
35
- apply_permutation(
36
- std::begin(item_range), std::end(item_range), std::begin(ind_range), std::end(ind_range));
37
- }
38
-
39
- template <typename T, typename Compare>
40
- std::vector<std::int64_t> sort_permutation(const std::vector<T> & vec, Compare && compare)
41
- {
42
- std::vector<std::int64_t> order;
43
- order.resize(vec.size());
44
- std::iota(std::begin(order), std::end(order), 0);
45
- stable_sort(std::begin(order), std::end(order),
46
- [&](std::size_t i, std::size_t j) { return compare(vec[i], vec[j]); });
47
- return order;
48
- }
49
-
50
- } // namespace utils
@@ -1,25 +0,0 @@
1
- #pragma once
2
-
3
- #include <algorithm>
4
- #include <functional>
5
-
6
- namespace utils
7
- {
8
-
9
- using std::stable_sort;
10
-
11
- template <class BidirContainer, class BinaryOp>
12
- void stable_sort(BidirContainer & c, BinaryOp && comparer)
13
- {
14
- using std::begin;
15
- using std::end;
16
- stable_sort(begin(c), end(c), comparer);
17
- }
18
-
19
- template <class BidirContainer>
20
- void stable_sort(BidirContainer & c)
21
- {
22
- stable_sort(c, std::less<typename BidirContainer::value_type>{});
23
- }
24
-
25
- } // namespace utils
@@ -1,89 +0,0 @@
1
- #pragma once
2
-
3
- #include <range/v3/range/concepts.hpp>
4
- #include <range/v3/view/transform.hpp>
5
- #include <iterator>
6
- #include <tuple>
7
- #include <type_traits>
8
- #include <utility>
9
-
10
- namespace qdb
11
- {
12
-
13
- template <std::size_t I, ranges::input_range R>
14
- inline decltype(auto) make_unzip_view(R const & input) noexcept
15
- {
16
- using tuple_type = ranges::range_value_t<R>;
17
-
18
- auto xform = [](tuple_type const & x) { return std::get<I>(x); };
19
-
20
- return ranges::views::transform(input, xform);
21
- }
22
-
23
- template <std::size_t I>
24
- struct view_unzipper
25
- {
26
- template <ranges::input_range R>
27
- inline decltype(auto) operator()(R const &) = delete;
28
- };
29
-
30
- template <>
31
- struct view_unzipper<1>
32
- {
33
- template <ranges::input_range R>
34
- inline decltype(auto) operator()(R const & input)
35
- {
36
- return std::make_tuple(make_unzip_view<0>(input));
37
- }
38
- };
39
-
40
- template <>
41
- struct view_unzipper<2>
42
- {
43
- template <ranges::input_range R>
44
- inline decltype(auto) operator()(R const & input)
45
- {
46
- return std::make_tuple(make_unzip_view<0>(input), make_unzip_view<1>(input));
47
- }
48
- };
49
-
50
- template <>
51
- struct view_unzipper<3>
52
- {
53
- template <ranges::input_range R>
54
- inline decltype(auto) operator()(R const & input)
55
- {
56
- return std::make_tuple(
57
- make_unzip_view<0>(input), make_unzip_view<1>(input), make_unzip_view<2>(input));
58
- }
59
- };
60
-
61
- template <>
62
- struct view_unzipper<4>
63
- {
64
- template <ranges::input_range R>
65
- inline decltype(auto) operator()(R const & input)
66
- {
67
- return std::make_tuple(make_unzip_view<0>(input), make_unzip_view<1>(input),
68
- make_unzip_view<2>(input), make_unzip_view<3>(input));
69
- }
70
- };
71
-
72
- /**
73
- * Transforms a single range of tuples to a tuple of ranges, such that
74
- * std::get<I>(std::next(in, N)) becomes std::next(std::get<I>(out), N)
75
- *
76
- * TODO(leon): It isn't perfect, as we iterate over the input array multiple
77
- * times, once for each type. A better approach would be to iterate
78
- * once and build all sub-ranges out of it, but that approach
79
- * doesn't map well to the existing ranges views / abstractions.
80
- */
81
- template <ranges::input_range R>
82
- inline constexpr decltype(auto) make_unzip_views(R const & input) noexcept
83
- {
84
- using tuple_type = typename ranges::range_value_t<R>;
85
- using tuple_size = std::tuple_size<tuple_type>;
86
- return view_unzipper<tuple_size::value>{}(input);
87
- }
88
-
89
- }; // namespace qdb
quasardb/utils.cpp DELETED
@@ -1,28 +0,0 @@
1
- #include "utils.hpp"
2
- #include "traits.hpp"
3
- #include "convert/value.hpp"
4
-
5
- namespace qdb
6
- {
7
-
8
- std::vector<qdb_ts_range_t> convert_ranges(py::object xs)
9
- {
10
- if (xs.is_none() == true)
11
- {
12
- return {traits::qdb_value<qdb_ts_range_t>::forever()};
13
- };
14
-
15
- std::vector<qdb_ts_range_t> ret;
16
-
17
- // Must be a list
18
- auto xs_ = xs.cast<py::list>();
19
-
20
- ret.resize(xs_.size());
21
- std::transform(xs_.begin(), xs_.end(), ret.begin(), [](py::handle x) -> qdb_ts_range_t {
22
- return convert::value<py::tuple, qdb_ts_range_t>(py::cast<py::tuple>(x));
23
- });
24
-
25
- return ret;
26
- };
27
-
28
- }; // namespace qdb
quasardb/utils.hpp DELETED
@@ -1,174 +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 "handle.hpp"
34
- #include <qdb/client.h>
35
- #include <qdb/ts.h>
36
- #include <pybind11/numpy.h>
37
- #include <algorithm>
38
- #include <chrono>
39
- #include <string>
40
- #include <vector>
41
-
42
- namespace qdb
43
- {
44
- struct scoped_timer
45
- {
46
- typedef std::chrono::time_point<std::chrono::high_resolution_clock> time_point_t;
47
- using clock = std::chrono::high_resolution_clock;
48
-
49
- std::string id_;
50
- time_point_t start_;
51
- scoped_timer(std::string id) noexcept
52
- : id_{id}
53
- , start_{clock::now()}
54
- {}
55
-
56
- ~scoped_timer() noexcept
57
- {
58
- done();
59
- };
60
-
61
- void done() noexcept
62
- {
63
- if (id_.empty() == false)
64
- {
65
- time_point_t end = clock::now();
66
- auto delta = end - start_;
67
- std::cout << "[" << id_ << "] elapsed: "
68
- << std::chrono::duration_cast<std::chrono::milliseconds>(delta).count() << "ms"
69
- << std::endl;
70
- };
71
-
72
- id_.clear();
73
- };
74
- };
75
- }; // namespace qdb
76
-
77
- static inline bool operator<(qdb_timespec_t const & lhs, qdb_timespec_t const & rhs)
78
- {
79
- if (lhs.tv_sec < rhs.tv_sec)
80
- {
81
- return true;
82
- }
83
- else if (lhs.tv_sec == rhs.tv_sec)
84
- {
85
- return lhs.tv_nsec < rhs.tv_nsec;
86
- }
87
- else
88
- {
89
- return false;
90
- }
91
- }
92
-
93
- static inline bool operator==(qdb_timespec_t const & lhs, qdb_timespec_t const & rhs)
94
- {
95
- return lhs.tv_sec == rhs.tv_sec && lhs.tv_nsec == rhs.tv_nsec;
96
- }
97
-
98
- namespace qdb
99
- {
100
-
101
- /**
102
- * Simple guard class which always releases tracked objects back to qdb api.
103
- */
104
- template <typename T>
105
- class release_guard
106
- {
107
- public:
108
- release_guard(handle_ptr handle) noexcept
109
- : _handle(handle)
110
- , _obj(nullptr)
111
- {}
112
-
113
- release_guard(handle_ptr handle, T obj) noexcept
114
- : _handle(handle)
115
- , _obj(obj)
116
- {}
117
-
118
- ~release_guard()
119
- {
120
- qdb_release(*_handle, _obj);
121
- }
122
-
123
- T get() const noexcept
124
- {
125
- return _obj;
126
- }
127
-
128
- T * ptr() noexcept
129
- {
130
- return &_obj;
131
- }
132
-
133
- T const * ptr() const noexcept
134
- {
135
- return &_obj;
136
- }
137
-
138
- private:
139
- handle_ptr _handle;
140
- T _obj;
141
- };
142
-
143
- static inline std::vector<std::string> convert_strings_and_release(
144
- qdb::handle_ptr h, const char ** ss, size_t c)
145
- {
146
- std::vector<std::string> res(c);
147
-
148
- std::transform(ss, ss + c, res.begin(), [](const char * s) { return std::string{s}; });
149
-
150
- qdb_release(*h, ss);
151
-
152
- return res;
153
- }
154
-
155
- std::vector<qdb_ts_range_t> convert_ranges(py::object xs);
156
-
157
- template <typename PointType>
158
- static inline size_t max_length(const PointType * points, size_t count)
159
- {
160
- if (!count) return 0;
161
-
162
- return std::max_element(points, points + count,
163
- [](const PointType & left, const PointType & right) {
164
- return left.content_length < right.content_length;
165
- })
166
- ->content_length;
167
- }
168
-
169
- static inline std::string to_string(qdb_string_t s)
170
- {
171
- return std::string(s.data, s.length);
172
- }
173
-
174
- } // namespace qdb