quasardb 3.14.2.dev3__cp39-cp39-win_amd64.whl → 3.14.2.dev5__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of quasardb might be problematic. Click here for more details.

Files changed (105) hide show
  1. quasardb/INSTALL.vcxproj +5 -4
  2. quasardb/__init__.py +21 -7
  3. quasardb/cmake_install.cmake +6 -0
  4. quasardb/date/ALL_BUILD.vcxproj +9 -8
  5. quasardb/date/CMakeFiles/Export/df49adab93b9e0c10c64f72458b31971/dateTargets.cmake +2 -2
  6. quasardb/date/CMakeFiles/generate.stamp.depend +4 -4
  7. quasardb/date/INSTALL.vcxproj +5 -4
  8. quasardb/date/cmake_install.cmake +6 -0
  9. quasardb/date/dateTargets.cmake +2 -2
  10. quasardb/extensions/writer.py +59 -61
  11. quasardb/firehose.py +24 -22
  12. quasardb/numpy/__init__.py +181 -120
  13. quasardb/pandas/__init__.py +145 -95
  14. quasardb/pool.py +13 -2
  15. quasardb/pybind11/ALL_BUILD.vcxproj +9 -8
  16. quasardb/pybind11/CMakeFiles/generate.stamp.depend +14 -14
  17. quasardb/pybind11/INSTALL.vcxproj +5 -4
  18. quasardb/pybind11/cmake_install.cmake +6 -0
  19. quasardb/qdb_api.dll +0 -0
  20. quasardb/quasardb.cp39-win_amd64.pyd +0 -0
  21. quasardb/range-v3/ALL_BUILD.vcxproj +9 -8
  22. quasardb/range-v3/CMakeFiles/Export/d94ef200eca10a819b5858b33e808f5b/range-v3-targets.cmake +2 -2
  23. quasardb/range-v3/CMakeFiles/generate.stamp.depend +11 -11
  24. quasardb/range-v3/INSTALL.vcxproj +5 -4
  25. quasardb/range-v3/cmake_install.cmake +6 -0
  26. quasardb/range-v3/range-v3-config.cmake +2 -2
  27. quasardb/range-v3/range.v3.headers.vcxproj +9 -8
  28. quasardb/stats.py +92 -80
  29. quasardb/table_cache.py +5 -1
  30. {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/METADATA +13 -8
  31. quasardb-3.14.2.dev5.dist-info/RECORD +54 -0
  32. {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/WHEEL +1 -1
  33. quasardb/CMakeLists.txt +0 -517
  34. quasardb/batch_column.hpp +0 -80
  35. quasardb/batch_inserter.hpp +0 -248
  36. quasardb/blob.hpp +0 -150
  37. quasardb/cluster.cpp +0 -102
  38. quasardb/cluster.hpp +0 -593
  39. quasardb/concepts.hpp +0 -322
  40. quasardb/continuous.cpp +0 -199
  41. quasardb/continuous.hpp +0 -109
  42. quasardb/convert/array.hpp +0 -299
  43. quasardb/convert/point.hpp +0 -330
  44. quasardb/convert/range.hpp +0 -282
  45. quasardb/convert/unicode.hpp +0 -598
  46. quasardb/convert/util.hpp +0 -22
  47. quasardb/convert/value.hpp +0 -782
  48. quasardb/convert.hpp +0 -38
  49. quasardb/detail/invoke.hpp +0 -0
  50. quasardb/detail/qdb_resource.hpp +0 -129
  51. quasardb/detail/retry.cpp +0 -30
  52. quasardb/detail/retry.hpp +0 -147
  53. quasardb/detail/sleep.hpp +0 -53
  54. quasardb/detail/ts_column.hpp +0 -224
  55. quasardb/detail/writer.cpp +0 -440
  56. quasardb/detail/writer.hpp +0 -550
  57. quasardb/direct_blob.hpp +0 -108
  58. quasardb/direct_handle.hpp +0 -83
  59. quasardb/direct_integer.hpp +0 -94
  60. quasardb/dispatch.hpp +0 -157
  61. quasardb/double.hpp +0 -87
  62. quasardb/entry.hpp +0 -273
  63. quasardb/error.hpp +0 -393
  64. quasardb/handle.cpp +0 -29
  65. quasardb/handle.hpp +0 -98
  66. quasardb/integer.hpp +0 -88
  67. quasardb/logger.cpp +0 -106
  68. quasardb/logger.hpp +0 -228
  69. quasardb/masked_array.hpp +0 -658
  70. quasardb/metrics.cpp +0 -103
  71. quasardb/metrics.hpp +0 -112
  72. quasardb/module.cpp +0 -92
  73. quasardb/module.hpp +0 -24
  74. quasardb/node.hpp +0 -132
  75. quasardb/numpy.cpp +0 -6
  76. quasardb/numpy.hpp +0 -489
  77. quasardb/object_tracker.hpp +0 -282
  78. quasardb/options.hpp +0 -273
  79. quasardb/perf.hpp +0 -336
  80. quasardb/properties.cpp +0 -41
  81. quasardb/properties.hpp +0 -85
  82. quasardb/pytypes.hpp +0 -221
  83. quasardb/query.cpp +0 -420
  84. quasardb/query.hpp +0 -92
  85. quasardb/reader.cpp +0 -282
  86. quasardb/reader.hpp +0 -256
  87. quasardb/remove_cvref.hpp +0 -31
  88. quasardb/string.hpp +0 -160
  89. quasardb/table.cpp +0 -257
  90. quasardb/table.hpp +0 -366
  91. quasardb/tag.hpp +0 -77
  92. quasardb/timestamp.hpp +0 -97
  93. quasardb/traits.hpp +0 -642
  94. quasardb/ts_iterator.hpp +0 -193
  95. quasardb/utils/blob_deque.hpp +0 -96
  96. quasardb/utils/ostream.hpp +0 -17
  97. quasardb/utils/permutation.hpp +0 -50
  98. quasardb/utils/stable_sort.hpp +0 -25
  99. quasardb/utils/unzip_view.hpp +0 -89
  100. quasardb/utils.cpp +0 -28
  101. quasardb/utils.hpp +0 -174
  102. quasardb/writer.hpp +0 -354
  103. quasardb-3.14.2.dev3.dist-info/RECORD +0 -124
  104. {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/LICENSE.md +0 -0
  105. {quasardb-3.14.2.dev3.dist-info → quasardb-3.14.2.dev5.dist-info}/top_level.txt +0 -0
quasardb/convert.hpp DELETED
@@ -1,38 +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
- // Convenience include, includes $everything
34
-
35
- #include "convert/array.hpp"
36
- #include "convert/point.hpp"
37
- #include "convert/range.hpp"
38
- #include "convert/value.hpp"
File without changes
@@ -1,129 +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 <qdb/client.h> // for qdb_handle_t
34
-
35
- namespace qdb
36
- {
37
-
38
- namespace detail
39
- {
40
-
41
- /**
42
- * Resource guard for QDB-native allocated resources. Automatically invokes
43
- * qdb_release() when the guard goes out of scope.
44
- */
45
- template <typename ValueType>
46
- class qdb_resource
47
- {
48
- public:
49
- /**
50
- * Default constructor, initializes nullpointer.
51
- */
52
- qdb_resource(qdb_handle_t h)
53
- : qdb_resource(h, nullptr)
54
- {}
55
-
56
- /**
57
- * Constructor and immediately initialize with pointer.
58
- */
59
- qdb_resource(qdb_handle_t h, ValueType * p)
60
- : h_(h)
61
- , p_(p)
62
- {}
63
-
64
- qdb_resource(qdb_resource const &) = delete;
65
- qdb_resource & operator=(qdb_resource const &) = delete;
66
-
67
- ~qdb_resource()
68
- {
69
- if (p_ != nullptr)
70
- {
71
- qdb_release(h_, p_);
72
- }
73
-
74
- p_ = nullptr;
75
- }
76
-
77
- constexpr operator ValueType *() const
78
- {
79
- return get();
80
- }
81
-
82
- operator ValueType *()
83
- {
84
- return get();
85
- }
86
-
87
- ValueType * get()
88
- {
89
- return p_;
90
- }
91
-
92
- constexpr ValueType const * get() const
93
- {
94
- return p_;
95
- }
96
-
97
- ValueType ** operator&()
98
- {
99
- return &p_;
100
- }
101
-
102
- ValueType & operator*()
103
- {
104
- return *p_;
105
- }
106
-
107
- ValueType * operator->()
108
- {
109
- return p_;
110
- }
111
-
112
- constexpr ValueType const * operator->() const
113
- {
114
- return p_;
115
- }
116
-
117
- constexpr ValueType const & operator*() const
118
- {
119
- return *p_;
120
- }
121
-
122
- private:
123
- qdb_handle_t h_;
124
- ValueType * p_;
125
- };
126
-
127
- } // namespace detail
128
-
129
- } // namespace qdb
quasardb/detail/retry.cpp DELETED
@@ -1,30 +0,0 @@
1
- #include "retry.hpp"
2
- #include <pybind11/chrono.h>
3
-
4
- namespace qdb::detail
5
- {
6
-
7
- void register_retry_options(py::module_ & m)
8
- {
9
- namespace py = pybind11;
10
-
11
- py::class_<retry_options>{m, "RetryOptions"} //
12
- .def(py::init<std::size_t, std::chrono::milliseconds, std::size_t, double>(), //
13
- py::arg("retries") = std::size_t{3}, //
14
- py::kw_only(), //
15
- py::arg("delay") = std::chrono::milliseconds{3000}, //
16
- py::arg("exponent") = std::size_t{2}, //
17
- py::arg("jitter") = double{0.1} //
18
- ) //
19
- //
20
- .def_readwrite("retries_left", &retry_options::retries_left) //
21
- .def_readwrite("delay", &retry_options::delay) //
22
- .def_readwrite("exponent", &retry_options::exponent) //
23
- .def_readwrite("jitter", &retry_options::jitter) //
24
- //
25
- .def("has_next", &retry_options::has_next) //
26
- .def("next", &retry_options::next) //
27
- ;
28
- }
29
-
30
- }; // namespace qdb::detail
quasardb/detail/retry.hpp DELETED
@@ -1,147 +0,0 @@
1
- /*
2
- *
3
- * Official Python API
4
- *
5
- * Copyright (c) 2009-2021, 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 <chrono>
35
-
36
- namespace qdb::detail
37
- {
38
-
39
- struct retry_options
40
- {
41
- qdb::logger logger_;
42
-
43
- // how many retries are left. 0 means no retries
44
- std::size_t retries_left;
45
-
46
- // delay for the next retry
47
- std::chrono::milliseconds delay;
48
-
49
- // factor by which delay is increased every retry
50
- std::size_t exponent;
51
-
52
- // random jitter added/removed to delay_. Jitter of 0.1 means that 10% is automatically
53
- // added or removed from delay_
54
- double jitter;
55
-
56
- /**
57
- * Retry options constructor
58
- */
59
- retry_options(std::size_t retries = 3,
60
- std::chrono::milliseconds delay = std::chrono::milliseconds{3000},
61
- std::size_t exponent = 2,
62
- double jitter = 0.1)
63
- : logger_("quasardb.detail.retry")
64
- , retries_left{retries}
65
- , delay{delay}
66
- , exponent{exponent}
67
- , jitter{jitter}
68
- {}
69
-
70
- static inline retry_options from_kwargs(py::kwargs args)
71
- {
72
- if (args.contains("retries") == false)
73
- {
74
- return {};
75
- }
76
-
77
- auto retries = args["retries"];
78
-
79
- // We're going to assume that retries is an actual RetryOptions class, because
80
- // our Numpy and Pandas adapters always coerce it to that type. By making this
81
- // assumption, we can slightly optimize this code path.
82
- //
83
- // By providing an explicit RetryOptions object is also the only way to fine-tune
84
- // other parameters.
85
-
86
- try
87
- {
88
- return retries.cast<retry_options>();
89
- }
90
- catch (py::cast_error const & /*e*/)
91
- {
92
- // For convenience, we also give the user the choice to just provide `retries`
93
- // as an integer, in which case we'll assume this is the number of retries the
94
- // user wants to perform.
95
- //
96
- // In all likelihood, this is the only parameter the user will want to tune.
97
- return {retries.cast<std::size_t>()};
98
- }
99
- }
100
-
101
- inline constexpr bool has_next() const noexcept
102
- {
103
- return retries_left > 0;
104
- }
105
-
106
- /**
107
- * Returns new object, with `retries_left_` and `delay_` adjusted accordingly.
108
- */
109
- inline retry_options next() const
110
- {
111
- if (has_next() == false) [[unlikely]]
112
- {
113
- throw qdb::out_of_bounds_exception{
114
- "RetryOptions.next() called but retries already exhausted."};
115
- }
116
-
117
- assert(has_next() == true);
118
-
119
- return retry_options{retries_left - 1, delay * exponent, exponent, jitter};
120
- }
121
-
122
- /**
123
- * Returns true if we have retries left and the error is retryable.
124
- */
125
- inline constexpr bool should_retry(qdb_error_t e) const noexcept
126
- {
127
- // We check for `is_retryable` first, because in all likelihood e is qdb_e_ok
128
- return retry_options::is_retryable(e) && has_next();
129
- }
130
-
131
- static constexpr bool is_retryable(qdb_error_t e) noexcept
132
- {
133
- switch (e)
134
- {
135
- case qdb_e_async_pipe_full:
136
- case qdb_e_try_again:
137
- return true;
138
- break;
139
- default:
140
- return false;
141
- };
142
- }
143
- };
144
-
145
- void register_retry_options(py::module_ & m);
146
-
147
- }; // namespace qdb::detail
quasardb/detail/sleep.hpp DELETED
@@ -1,53 +0,0 @@
1
- /*
2
- *
3
- * Official Python API
4
- *
5
- * Copyright (c) 2009-2021, 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 "../concepts.hpp"
34
- #include <chrono>
35
-
36
- namespace qdb::detail
37
- {
38
-
39
- template <typename Duration = std::chrono::milliseconds>
40
- struct default_sleep_strategy
41
- {
42
- using duration_t = Duration;
43
-
44
- static void sleep(duration_t const & delay)
45
- {
46
- std::this_thread::sleep_for(delay);
47
- };
48
- };
49
-
50
- static_assert(qdb::concepts::sleep_strategy<default_sleep_strategy<>>);
51
- static_assert(qdb::concepts::sleep_strategy<default_sleep_strategy<std::chrono::seconds>>);
52
-
53
- }; // namespace qdb::detail
@@ -1,224 +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/ts.h>
35
- #include <cassert>
36
- #include <string>
37
-
38
- namespace qdb
39
- {
40
-
41
- namespace detail
42
- {
43
-
44
- inline std::string type_to_string(qdb_ts_column_type_t t)
45
- {
46
- switch (t)
47
- {
48
- case qdb_ts_column_double:
49
- return "double";
50
- case qdb_ts_column_blob:
51
- return "blob";
52
- case qdb_ts_column_int64:
53
- return "int64";
54
- case qdb_ts_column_timestamp:
55
- return "timestamp";
56
- case qdb_ts_column_string:
57
- return "string";
58
- case qdb_ts_column_symbol:
59
- return "symbol";
60
- default:
61
- return "uninitialized";
62
- }
63
- }
64
-
65
- struct column_info
66
- {
67
- column_info() = default;
68
-
69
- explicit column_info(qdb_ts_column_type_t t, const std::string & n)
70
- : column_info{t, n, std::string{}}
71
- {}
72
-
73
- explicit column_info(qdb_ts_column_type_t t, const std::string & n, const std::string & s)
74
- : type{t}
75
- , name{n}
76
- , symtable{s}
77
- {
78
- if (t == qdb_ts_column_symbol && s.empty()) [[unlikely]]
79
- {
80
- throw qdb::invalid_argument_exception{
81
- "column '" + n + "' is a symbol but no symbol table provided"};
82
- }
83
- else if (t != qdb_ts_column_symbol && s.empty() == false) [[unlikely]]
84
- {
85
- throw qdb::invalid_argument_exception{
86
- "column '" + n + "' is a not a symbol but symbol table provided: '" + s + "'"};
87
- }
88
- }
89
-
90
- explicit column_info(const qdb_ts_column_info_t & ci)
91
- : column_info{ci.type, ci.name, {}}
92
- {}
93
-
94
- explicit column_info(const qdb_ts_column_info_ex_t & ci)
95
- : column_info{ci.type, ci.name, ci.symtable}
96
- {}
97
-
98
- std::string repr() const
99
- {
100
- return "<quasardb.ColumnInfo name='" + name + "' type='" + type_to_string(type) + "'>";
101
- }
102
-
103
- operator qdb_ts_column_info_t() const noexcept
104
- {
105
- qdb_ts_column_info_t res;
106
-
107
- // WARNING(leon): we assume that the lifetime of `this` is longer
108
- // than `res`, and that the string does not need to be deep-copied.
109
- //
110
- // In our current code, this is the case.
111
- res.type = type;
112
- res.name = name.c_str();
113
-
114
- return res;
115
- }
116
-
117
- operator qdb_ts_column_info_ex_t() const noexcept
118
- {
119
- qdb_ts_column_info_ex_t res;
120
-
121
- // WARNING(leon): we assume that the lifetime of `this` is longer
122
- // than `res`, and that the string does not need to be deep-copied.
123
- //
124
- // In our current code, this is the case.
125
- res.type = type;
126
- res.name = name.c_str();
127
- res.symtable = symtable.c_str();
128
-
129
- return res;
130
- }
131
-
132
- qdb_ts_column_type_t type{qdb_ts_column_uninitialized};
133
- std::string name;
134
- std::string symtable;
135
- };
136
-
137
- static inline std::vector<qdb_ts_column_info_t> convert_columns(
138
- const std::vector<column_info> & columns)
139
- {
140
- std::vector<qdb_ts_column_info_t> res(columns.size());
141
-
142
- std::transform(columns.cbegin(), columns.cend(), res.begin(),
143
- [](const column_info & ci) -> qdb_ts_column_info_t { return ci; });
144
-
145
- return res;
146
- }
147
- static inline std::vector<qdb_ts_column_info_ex_t> convert_columns_ex(
148
- const std::vector<column_info> & columns)
149
- {
150
- std::vector<qdb_ts_column_info_ex_t> res(columns.size());
151
-
152
- std::transform(columns.cbegin(), columns.cend(), res.begin(),
153
- [](const column_info & ci) -> qdb_ts_column_info_ex_t { return ci; });
154
-
155
- return res;
156
- }
157
-
158
- static inline std::vector<column_info> convert_columns(
159
- const qdb_ts_column_info_ex_t * columns, size_t count)
160
- {
161
- std::vector<column_info> res(count);
162
-
163
- std::transform(columns, columns + count, res.begin(),
164
- [](const qdb_ts_column_info_ex_t & ci) { return column_info{ci}; });
165
-
166
- return res;
167
- }
168
-
169
- struct indexed_column_info
170
- {
171
- indexed_column_info() = default;
172
-
173
- indexed_column_info(qdb_ts_column_type_t t, qdb_size_t i, const std::string & s = {})
174
- : type{t}
175
- , index{i}
176
- , symtable{s}
177
- {
178
- assert((t != qdb_ts_column_symbol) == s.empty());
179
- }
180
-
181
- qdb_ts_column_type_t type{qdb_ts_column_uninitialized};
182
- qdb_size_t index;
183
- std::string symtable;
184
- };
185
-
186
- using indexed_columns_t = std::map<std::string, indexed_column_info>;
187
-
188
- template <typename ColumnType>
189
- static indexed_columns_t index_columns(const std::vector<ColumnType> & columns)
190
- {
191
- indexed_columns_t i_columns;
192
- for (qdb_size_t i = 0; i < columns.size(); ++i)
193
- {
194
- i_columns.insert(
195
- indexed_columns_t::value_type(columns[i].name, {columns[i].type, i, columns[i].symtable}));
196
- }
197
-
198
- return i_columns;
199
- }
200
-
201
- template <typename Module>
202
- static inline void register_ts_column(Module & m)
203
- {
204
- namespace py = pybind11;
205
-
206
- py::class_<column_info>{m, "ColumnInfo"} //
207
- .def(py::init<qdb_ts_column_type_t, const std::string &>()) //
208
- .def(py::init<qdb_ts_column_type_t, const std::string &, const std::string &>()) //
209
- .def("__repr__", &column_info::repr)
210
- .def_readwrite("type", &column_info::type) //
211
- .def_readwrite("name", &column_info::name) //
212
- .def_readwrite("symtable", &column_info::symtable); //
213
-
214
- py::class_<indexed_column_info>{m, "IndexedColumnInfo"} //
215
- .def(py::init<qdb_ts_column_type_t, qdb_size_t>()) //
216
- .def(py::init<qdb_ts_column_type_t, qdb_size_t, const std::string &>()) //
217
- .def_readonly("type", &indexed_column_info::type) //
218
- .def_readonly("index", &indexed_column_info::index) //
219
- .def_readonly("symtable", &indexed_column_info::symtable); //
220
- }
221
-
222
- } // namespace detail
223
-
224
- } // namespace qdb