quasardb 3.14.2.dev8__cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.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.
Files changed (70) hide show
  1. quasardb/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  2. quasardb/CMakeFiles/progress.marks +1 -0
  3. quasardb/Makefile +189 -0
  4. quasardb/__init__.py +140 -0
  5. quasardb/__init__.pyi +72 -0
  6. quasardb/cmake_install.cmake +58 -0
  7. quasardb/date/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  8. quasardb/date/CMakeFiles/Export/b76006b2b7125baf1b0b4d4ca4db82bd/dateTargets.cmake +108 -0
  9. quasardb/date/CMakeFiles/progress.marks +1 -0
  10. quasardb/date/Makefile +189 -0
  11. quasardb/date/cmake_install.cmake +81 -0
  12. quasardb/date/dateConfigVersion.cmake +65 -0
  13. quasardb/date/dateTargets.cmake +63 -0
  14. quasardb/extensions/__init__.py +9 -0
  15. quasardb/extensions/writer.py +195 -0
  16. quasardb/firehose.py +112 -0
  17. quasardb/libqdb_api.so +0 -0
  18. quasardb/numpy/__init__.py +1106 -0
  19. quasardb/pandas/__init__.py +696 -0
  20. quasardb/pool.py +338 -0
  21. quasardb/pybind11/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  22. quasardb/pybind11/CMakeFiles/progress.marks +1 -0
  23. quasardb/pybind11/Makefile +189 -0
  24. quasardb/pybind11/cmake_install.cmake +50 -0
  25. quasardb/quasardb/__init__.pyi +97 -0
  26. quasardb/quasardb/_batch_column.pyi +5 -0
  27. quasardb/quasardb/_batch_inserter.pyi +32 -0
  28. quasardb/quasardb/_blob.pyi +16 -0
  29. quasardb/quasardb/_cluster.pyi +106 -0
  30. quasardb/quasardb/_continuous.pyi +18 -0
  31. quasardb/quasardb/_double.pyi +7 -0
  32. quasardb/quasardb/_entry.pyi +61 -0
  33. quasardb/quasardb/_error.pyi +15 -0
  34. quasardb/quasardb/_integer.pyi +7 -0
  35. quasardb/quasardb/_node.pyi +26 -0
  36. quasardb/quasardb/_options.pyi +106 -0
  37. quasardb/quasardb/_perf.pyi +7 -0
  38. quasardb/quasardb/_properties.pyi +5 -0
  39. quasardb/quasardb/_query.pyi +2 -0
  40. quasardb/quasardb/_reader.pyi +15 -0
  41. quasardb/quasardb/_retry.pyi +16 -0
  42. quasardb/quasardb/_string.pyi +12 -0
  43. quasardb/quasardb/_table.pyi +140 -0
  44. quasardb/quasardb/_tag.pyi +5 -0
  45. quasardb/quasardb/_timestamp.pyi +9 -0
  46. quasardb/quasardb/_writer.pyi +112 -0
  47. quasardb/quasardb/metrics/__init__.pyi +28 -0
  48. quasardb/quasardb.cpython-310-x86_64-linux-gnu.so +0 -0
  49. quasardb/range-v3/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  50. quasardb/range-v3/CMakeFiles/Export/48a02d54b5e9e60c30c5f249b431a911/range-v3-targets.cmake +128 -0
  51. quasardb/range-v3/CMakeFiles/progress.marks +1 -0
  52. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/DependInfo.cmake +22 -0
  53. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/build.make +86 -0
  54. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/cmake_clean.cmake +5 -0
  55. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/compiler_depend.make +2 -0
  56. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/compiler_depend.ts +2 -0
  57. quasardb/range-v3/CMakeFiles/range.v3.headers.dir/progress.make +1 -0
  58. quasardb/range-v3/Makefile +204 -0
  59. quasardb/range-v3/cmake_install.cmake +93 -0
  60. quasardb/range-v3/include/range/v3/version.hpp +24 -0
  61. quasardb/range-v3/range-v3-config-version.cmake +83 -0
  62. quasardb/range-v3/range-v3-config.cmake +80 -0
  63. quasardb/stats.py +376 -0
  64. quasardb/table_cache.py +60 -0
  65. quasardb/typing.py +23 -0
  66. quasardb-3.14.2.dev8.dist-info/METADATA +41 -0
  67. quasardb-3.14.2.dev8.dist-info/RECORD +70 -0
  68. quasardb-3.14.2.dev8.dist-info/WHEEL +6 -0
  69. quasardb-3.14.2.dev8.dist-info/licenses/LICENSE.md +11 -0
  70. quasardb-3.14.2.dev8.dist-info/top_level.txt +1 -0
@@ -0,0 +1,93 @@
1
+ # Install script for directory: /home/teamcity/buildAgent/work/938b0bdf6727d1ad/thirdparty/range-v3
2
+
3
+ # Set the install prefix
4
+ if(NOT DEFINED CMAKE_INSTALL_PREFIX)
5
+ set(CMAKE_INSTALL_PREFIX "/usr/local")
6
+ endif()
7
+ string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
8
+
9
+ # Set the install configuration name.
10
+ if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
11
+ if(BUILD_TYPE)
12
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
13
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
14
+ else()
15
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
16
+ endif()
17
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
18
+ endif()
19
+
20
+ # Set the component getting installed.
21
+ if(NOT CMAKE_INSTALL_COMPONENT)
22
+ if(COMPONENT)
23
+ message(STATUS "Install component: \"${COMPONENT}\"")
24
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
25
+ else()
26
+ set(CMAKE_INSTALL_COMPONENT)
27
+ endif()
28
+ endif()
29
+
30
+ # Install shared libraries without execute permission?
31
+ if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
32
+ set(CMAKE_INSTALL_SO_NO_EXE "0")
33
+ endif()
34
+
35
+ # Is this installation the result of a crosscompile?
36
+ if(NOT DEFINED CMAKE_CROSSCOMPILING)
37
+ set(CMAKE_CROSSCOMPILING "FALSE")
38
+ endif()
39
+
40
+ # Set path to fallback-tool for dependency-resolution.
41
+ if(NOT DEFINED CMAKE_OBJDUMP)
42
+ set(CMAKE_OBJDUMP "/opt/rh/gcc-toolset-14/root/usr/bin/objdump")
43
+ endif()
44
+
45
+ if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
46
+ include("/home/teamcity/buildAgent/work/938b0bdf6727d1ad/build/lib.linux-x86_64-cpython-310/quasardb/range-v3/CMakeFiles/range-v3-concepts.dir/install-cxx-module-bmi-Release.cmake" OPTIONAL)
47
+ endif()
48
+
49
+ if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
50
+ include("/home/teamcity/buildAgent/work/938b0bdf6727d1ad/build/lib.linux-x86_64-cpython-310/quasardb/range-v3/CMakeFiles/range-v3-meta.dir/install-cxx-module-bmi-Release.cmake" OPTIONAL)
51
+ endif()
52
+
53
+ if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
54
+ include("/home/teamcity/buildAgent/work/938b0bdf6727d1ad/build/lib.linux-x86_64-cpython-310/quasardb/range-v3/CMakeFiles/range-v3.dir/install-cxx-module-bmi-Release.cmake" OPTIONAL)
55
+ endif()
56
+
57
+ if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
58
+ if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib64/cmake/range-v3/range-v3-targets.cmake")
59
+ file(DIFFERENT _cmake_export_file_changed FILES
60
+ "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib64/cmake/range-v3/range-v3-targets.cmake"
61
+ "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/build/lib.linux-x86_64-cpython-310/quasardb/range-v3/CMakeFiles/Export/48a02d54b5e9e60c30c5f249b431a911/range-v3-targets.cmake")
62
+ if(_cmake_export_file_changed)
63
+ file(GLOB _cmake_old_config_files "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib64/cmake/range-v3/range-v3-targets-*.cmake")
64
+ if(_cmake_old_config_files)
65
+ string(REPLACE ";" ", " _cmake_old_config_files_text "${_cmake_old_config_files}")
66
+ message(STATUS "Old export file \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib64/cmake/range-v3/range-v3-targets.cmake\" will be replaced. Removing files [${_cmake_old_config_files_text}].")
67
+ unset(_cmake_old_config_files_text)
68
+ file(REMOVE ${_cmake_old_config_files})
69
+ endif()
70
+ unset(_cmake_old_config_files)
71
+ endif()
72
+ unset(_cmake_export_file_changed)
73
+ endif()
74
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib64/cmake/range-v3" TYPE FILE FILES "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/build/lib.linux-x86_64-cpython-310/quasardb/range-v3/CMakeFiles/Export/48a02d54b5e9e60c30c5f249b431a911/range-v3-targets.cmake")
75
+ endif()
76
+
77
+ if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
78
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib64/cmake/range-v3" TYPE FILE FILES
79
+ "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/build/lib.linux-x86_64-cpython-310/quasardb/range-v3/range-v3-config-version.cmake"
80
+ "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/thirdparty/range-v3/cmake/range-v3-config.cmake"
81
+ )
82
+ endif()
83
+
84
+ if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
85
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/include" TYPE DIRECTORY FILES "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/thirdparty/range-v3/include/" FILES_MATCHING REGEX "/[^/]*$")
86
+ endif()
87
+
88
+ string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
89
+ "${CMAKE_INSTALL_MANIFEST_FILES}")
90
+ if(CMAKE_INSTALL_LOCAL_ONLY)
91
+ file(WRITE "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/build/lib.linux-x86_64-cpython-310/quasardb/range-v3/install_local_manifest.txt"
92
+ "${CMAKE_INSTALL_MANIFEST_CONTENT}")
93
+ endif()
@@ -0,0 +1,24 @@
1
+ /// \file
2
+ // Range v3 library
3
+ //
4
+ // Copyright Eric Niebler 2017-present
5
+ //
6
+ // Use, modification and distribution is subject to the
7
+ // Boost Software License, Version 1.0. (See accompanying
8
+ // file LICENSE_1_0.txt or copy at
9
+ // http://www.boost.org/LICENSE_1_0.txt)
10
+ //
11
+ // Project home: https://github.com/ericniebler/range-v3
12
+ //
13
+
14
+ #ifndef RANGES_V3_VERSION_HPP
15
+ #define RANGES_V3_VERSION_HPP
16
+
17
+ #define RANGE_V3_MAJOR 0
18
+ #define RANGE_V3_MINOR 11
19
+ #define RANGE_V3_PATCHLEVEL 0
20
+
21
+ #define RANGE_V3_VERSION \
22
+ (RANGE_V3_MAJOR * 10000 + RANGE_V3_MINOR * 100 + RANGE_V3_PATCHLEVEL)
23
+
24
+ #endif
@@ -0,0 +1,83 @@
1
+ # This is a basic version file for the Config-mode of find_package().
2
+ # It is used by write_basic_package_version_file() as input file for configure_file()
3
+ # to create a version-file which can be installed along a config.cmake file.
4
+ #
5
+ # The created file sets PACKAGE_VERSION_EXACT if the current version string and
6
+ # the requested version string are exactly the same and it sets
7
+ # PACKAGE_VERSION_COMPATIBLE if the current version is equal to the requested version.
8
+ # The tweak version component is ignored.
9
+ # The variable CVF_VERSION must be set before calling configure_file().
10
+
11
+
12
+ if (PACKAGE_FIND_VERSION_RANGE)
13
+ message(AUTHOR_WARNING
14
+ "`find_package()` specify a version range but the version strategy "
15
+ "(ExactVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible "
16
+ "with this request. Only the lower endpoint of the range will be used.")
17
+ endif()
18
+
19
+ set(PACKAGE_VERSION "0.11.0")
20
+
21
+ if("0.11.0" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version
22
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
23
+ set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}")
24
+ set(CVF_VERSION_PATCH "${CMAKE_MATCH_3}")
25
+
26
+ if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
27
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
28
+ endif()
29
+ if(NOT CVF_VERSION_MINOR VERSION_EQUAL 0)
30
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MINOR "${CVF_VERSION_MINOR}")
31
+ endif()
32
+ if(NOT CVF_VERSION_PATCH VERSION_EQUAL 0)
33
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_PATCH "${CVF_VERSION_PATCH}")
34
+ endif()
35
+
36
+ set(CVF_VERSION_NO_TWEAK "${CVF_VERSION_MAJOR}.${CVF_VERSION_MINOR}.${CVF_VERSION_PATCH}")
37
+ else()
38
+ set(CVF_VERSION_NO_TWEAK "0.11.0")
39
+ endif()
40
+
41
+ if(PACKAGE_FIND_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version
42
+ set(REQUESTED_VERSION_MAJOR "${CMAKE_MATCH_1}")
43
+ set(REQUESTED_VERSION_MINOR "${CMAKE_MATCH_2}")
44
+ set(REQUESTED_VERSION_PATCH "${CMAKE_MATCH_3}")
45
+
46
+ if(NOT REQUESTED_VERSION_MAJOR VERSION_EQUAL 0)
47
+ string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MAJOR "${REQUESTED_VERSION_MAJOR}")
48
+ endif()
49
+ if(NOT REQUESTED_VERSION_MINOR VERSION_EQUAL 0)
50
+ string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MINOR "${REQUESTED_VERSION_MINOR}")
51
+ endif()
52
+ if(NOT REQUESTED_VERSION_PATCH VERSION_EQUAL 0)
53
+ string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_PATCH "${REQUESTED_VERSION_PATCH}")
54
+ endif()
55
+
56
+ set(REQUESTED_VERSION_NO_TWEAK
57
+ "${REQUESTED_VERSION_MAJOR}.${REQUESTED_VERSION_MINOR}.${REQUESTED_VERSION_PATCH}")
58
+ else()
59
+ set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}")
60
+ endif()
61
+
62
+ if(REQUESTED_VERSION_NO_TWEAK STREQUAL CVF_VERSION_NO_TWEAK)
63
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
64
+ else()
65
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
66
+ endif()
67
+
68
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
69
+ set(PACKAGE_VERSION_EXACT TRUE)
70
+ endif()
71
+
72
+
73
+ # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
74
+ if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "" STREQUAL "")
75
+ return()
76
+ endif()
77
+
78
+ # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
79
+ if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "")
80
+ math(EXPR installedBits " * 8")
81
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
82
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
83
+ endif()
@@ -0,0 +1,80 @@
1
+ # Generated by CMake
2
+
3
+ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
4
+ message(FATAL_ERROR "CMake >= 3.0.0 required")
5
+ endif()
6
+ if(CMAKE_VERSION VERSION_LESS "3.0.0")
7
+ message(FATAL_ERROR "CMake >= 3.0.0 required")
8
+ endif()
9
+ cmake_policy(PUSH)
10
+ cmake_policy(VERSION 3.0.0...3.31)
11
+ #----------------------------------------------------------------
12
+ # Generated CMake target import file.
13
+ #----------------------------------------------------------------
14
+
15
+ # Commands may need to know the format version.
16
+ set(CMAKE_IMPORT_FILE_VERSION 1)
17
+
18
+ # Protect against multiple inclusion, which would fail when already imported targets are added once more.
19
+ set(_cmake_targets_defined "")
20
+ set(_cmake_targets_not_defined "")
21
+ set(_cmake_expected_targets "")
22
+ foreach(_cmake_expected_target IN ITEMS range-v3-concepts range-v3-meta range-v3)
23
+ list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
24
+ if(TARGET "${_cmake_expected_target}")
25
+ list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
26
+ else()
27
+ list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
28
+ endif()
29
+ endforeach()
30
+ unset(_cmake_expected_target)
31
+ if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
32
+ unset(_cmake_targets_defined)
33
+ unset(_cmake_targets_not_defined)
34
+ unset(_cmake_expected_targets)
35
+ unset(CMAKE_IMPORT_FILE_VERSION)
36
+ cmake_policy(POP)
37
+ return()
38
+ endif()
39
+ if(NOT _cmake_targets_defined STREQUAL "")
40
+ string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
41
+ string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
42
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
43
+ endif()
44
+ unset(_cmake_targets_defined)
45
+ unset(_cmake_targets_not_defined)
46
+ unset(_cmake_expected_targets)
47
+
48
+
49
+ # Create imported target range-v3-concepts
50
+ add_library(range-v3-concepts INTERFACE IMPORTED)
51
+
52
+ set_target_properties(range-v3-concepts PROPERTIES
53
+ INTERFACE_COMPILE_OPTIONS "\$<\$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->;\$<\$<COMPILE_LANG_AND_ID:CUDA,MSVC>:-Xcompiler=/permissive->"
54
+ INTERFACE_INCLUDE_DIRECTORIES "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/thirdparty/range-v3/include/"
55
+ INTERFACE_LINK_LIBRARIES "range-v3-meta"
56
+ )
57
+
58
+ # Create imported target range-v3-meta
59
+ add_library(range-v3-meta INTERFACE IMPORTED)
60
+
61
+ set_target_properties(range-v3-meta PROPERTIES
62
+ INTERFACE_COMPILE_OPTIONS "\$<\$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->;\$<\$<COMPILE_LANG_AND_ID:CUDA,MSVC>:-Xcompiler=/permissive->"
63
+ INTERFACE_INCLUDE_DIRECTORIES "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/thirdparty/range-v3/include/"
64
+ )
65
+
66
+ # Create imported target range-v3
67
+ add_library(range-v3 INTERFACE IMPORTED)
68
+
69
+ set_target_properties(range-v3 PROPERTIES
70
+ INTERFACE_COMPILE_OPTIONS "\$<\$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->;\$<\$<COMPILE_LANG_AND_ID:CUDA,MSVC>:-Xcompiler=/permissive->"
71
+ INTERFACE_INCLUDE_DIRECTORIES "/home/teamcity/buildAgent/work/938b0bdf6727d1ad/thirdparty/range-v3/include/"
72
+ INTERFACE_LINK_LIBRARIES "range-v3-concepts;range-v3-meta"
73
+ )
74
+
75
+ # This file does not depend on other imported targets which have
76
+ # been exported from the same project but in a separate export set.
77
+
78
+ # Commands beyond this point should not need to know the version.
79
+ set(CMAKE_IMPORT_FILE_VERSION)
80
+ cmake_policy(POP)
quasardb/stats.py ADDED
@@ -0,0 +1,376 @@
1
+ import logging
2
+ import re
3
+ from collections import defaultdict
4
+ from datetime import datetime
5
+ from enum import Enum
6
+ from typing import Any, DefaultDict, Dict, List, TypeVar, Union
7
+
8
+ import quasardb
9
+ from quasardb.quasardb import Cluster, Node
10
+
11
+ logger = logging.getLogger("quasardb.stats")
12
+
13
+ MAX_KEYS = 4 * 1024 * 1024 # 4 million max keys
14
+ stats_prefix = "$qdb.statistics."
15
+
16
+ # Compile these regexes once for speed
17
+ user_pattern = re.compile(r"\$qdb.statistics.(.*).uid_([0-9]+)$")
18
+ total_pattern = re.compile(r"\$qdb.statistics.(.*)$")
19
+ user_clean_pattern = re.compile(r"\.uid_\d+")
20
+
21
+
22
+ def is_user_stat(s: str) -> bool:
23
+ return user_pattern.match(s) is not None
24
+
25
+
26
+ def is_cumulative_stat(s: str) -> bool:
27
+ # NOTE(leon): It's quite difficult to express in Python that you don't want any
28
+ # regex to _end_ with uid_[0-9]+, because Python's regex engine doesn't support
29
+ # variable width look-behind.
30
+ #
31
+ # An alternative would be to use the PyPi regex library (for POSIX regexes), but
32
+ # want to stay light on dependencies#
33
+ #
34
+ # As such, we define a 'cumulative' stat as anything that's not a user stat.
35
+ # Simple but effective.
36
+ return user_pattern.match(s) is None
37
+
38
+
39
+ def by_node(conn: Cluster) -> Dict[str, Dict[str, Any]]:
40
+ """
41
+ Returns statistic grouped by node URI.
42
+
43
+ Parameters:
44
+ conn: quasardb.Cluster
45
+ Active connection to the QuasarDB cluster
46
+ """
47
+ return {x: of_node(conn.node(x)) for x in conn.endpoints()}
48
+
49
+
50
+ def of_node(dconn: Node) -> Dict[str, Any]:
51
+ """
52
+ Returns statistic for a single node.
53
+
54
+ Parameters:
55
+ dconn: quasardb.Node
56
+ Direct node connection to the node we wish to connect to
57
+
58
+ """
59
+
60
+ start = datetime.now()
61
+
62
+ ks = _get_all_keys(dconn)
63
+ idx = _index_keys(dconn, ks)
64
+ raw = {k: _get_stat_value(dconn, k) for k in ks}
65
+
66
+ ret: Dict[str, Any] = {
67
+ "by_uid": _by_uid(raw, idx),
68
+ "cumulative": _cumulative(raw, idx),
69
+ }
70
+
71
+ check_duration = datetime.now() - start
72
+
73
+ ret["cumulative"]["check.online"] = {
74
+ "value": 1,
75
+ "type": Type.ACCUMULATOR,
76
+ "unit": Unit.NONE,
77
+ }
78
+ ret["cumulative"]["check.duration_ms"] = {
79
+ "value": int(check_duration.total_seconds() * 1000),
80
+ "type": Type.ACCUMULATOR,
81
+ "unit": Unit.MILLISECONDS,
82
+ }
83
+
84
+ return ret
85
+
86
+
87
+ async_pipeline_bytes_pattern = re.compile(
88
+ r"async_pipelines.pipe_[0-9]+.merge_map.bytes"
89
+ )
90
+ async_pipeline_count_pattern = re.compile(
91
+ r"async_pipelines.pipe_[0-9]+.merge_map.count"
92
+ )
93
+
94
+
95
+ def stat_type(stat_id: str) -> None:
96
+ """
97
+ Returns the statistic type by a stat id. Returns one of:
98
+
99
+ - 'gauge'
100
+ - 'counter'
101
+ - None in case of unrecognized statistics
102
+
103
+ This is useful for determining which value should be reported in a dashboard.
104
+ """
105
+ import warnings
106
+
107
+ warnings.warn(
108
+ "The 'stat_type' method is deprecated and will be removed in a future release."
109
+ "The stat type and unit are now part of the return value of invocations to the 'of_node' and 'by_node' methods.",
110
+ DeprecationWarning,
111
+ stacklevel=2,
112
+ )
113
+
114
+ return None
115
+
116
+
117
+ def _get_all_keys(dconn: Node, n: int = 1024) -> List[str]:
118
+ """
119
+ Returns all keys from a single node.
120
+
121
+ Parameters:
122
+ dconn: quasardb.Node
123
+ Direct node connection to the node we wish to connect to.
124
+
125
+ n: int
126
+ Number of keys to retrieve.
127
+ """
128
+ xs = None
129
+ increase_rate = 8
130
+ # keep getting keys while number of results exceeds the given "n"
131
+ while xs is None or len(xs) >= n:
132
+ if xs is not None:
133
+ n = n * increase_rate
134
+ if n >= MAX_KEYS:
135
+ raise Exception(f"ERROR: Cannot fetch more than {MAX_KEYS} keys.")
136
+ xs = dconn.prefix_get(stats_prefix, n)
137
+
138
+ return xs
139
+
140
+
141
+ class Type(Enum):
142
+ ACCUMULATOR = 1
143
+ GAUGE = 2
144
+ LABEL = 3
145
+
146
+
147
+ class Unit(Enum):
148
+ NONE = 0
149
+ COUNT = 1
150
+
151
+ # Size units
152
+ BYTES = 32
153
+
154
+ # Time/duration units
155
+ EPOCH = 64
156
+ NANOSECONDS = 65
157
+ MICROSECONDS = 66
158
+ MILLISECONDS = 67
159
+ SECONDS = 68
160
+
161
+
162
+ _type_string_to_enum = {
163
+ "accumulator": Type.ACCUMULATOR,
164
+ "gauge": Type.GAUGE,
165
+ "label": Type.LABEL,
166
+ }
167
+
168
+ _unit_string_to_enum = {
169
+ "none": Unit.NONE,
170
+ "count": Unit.COUNT,
171
+ "bytes": Unit.BYTES,
172
+ "epoch": Unit.EPOCH,
173
+ "nanoseconds": Unit.NANOSECONDS,
174
+ "microseconds": Unit.MICROSECONDS,
175
+ "milliseconds": Unit.MILLISECONDS,
176
+ "seconds": Unit.SECONDS,
177
+ }
178
+
179
+ T = TypeVar("T", Type, Unit)
180
+
181
+
182
+ def _lookup_enum(dconn: Node, k: str, m: Dict[str, T]) -> T:
183
+ """
184
+ Utility function to avoid code duplication: automatically looks up a key's value
185
+ from QuasarDB and looks it up in provided dict.
186
+ """
187
+
188
+ _x = dconn.blob(k).get()
189
+ x = _clean_blob(_x)
190
+
191
+ if x not in m:
192
+ raise Exception(f"Unrecognized unit/type {x} from key {k}")
193
+
194
+ return m[x]
195
+
196
+
197
+ def _lookup_type(dconn: Node, k: str) -> Type:
198
+ """
199
+ Looks up and parses/validates the metric type.
200
+ """
201
+ assert k.endswith(".type")
202
+
203
+ return _lookup_enum(dconn, k, _type_string_to_enum)
204
+
205
+
206
+ def _lookup_unit(dconn: Node, k: str) -> Unit:
207
+ """
208
+ Looks up and parses/validates the metric type.
209
+ """
210
+ assert k.endswith(".unit")
211
+
212
+ return _lookup_enum(dconn, k, _unit_string_to_enum)
213
+
214
+
215
+ def _index_keys(dconn: Node, ks: List[str]) -> DefaultDict[str, Dict[str, Any]]:
216
+ """
217
+ Takes all statistics keys that are retrieved, and "indexes" them in such a way
218
+ that we end up with a dict of all statistic keys, their type and their unit.
219
+ """
220
+
221
+ ###
222
+ # The keys generally look like this, for example:
223
+ #
224
+ # $qdb.statistics.requests.out_bytes
225
+ # $qdb.statistics.requests.out_bytes.type
226
+ # $qdb.statistics.requests.out_bytes.uid_1
227
+ # $qdb.statistics.requests.out_bytes.uid_1.type
228
+ # $qdb.statistics.requests.out_bytes.uid_1.unit
229
+ # $qdb.statistics.requests.out_bytes.unit
230
+ #
231
+ # For this purpose, we simply get rid of the "uid" part, as the per-uid metrics are guaranteed
232
+ # to be of the exact same type as all the others. So after trimming those, the keys will look
233
+ # like this:
234
+ #
235
+ # $qdb.statistics.requests.out_bytes
236
+ # $qdb.statistics.requests.out_bytes.type
237
+ # $qdb.statistics.requests.out_bytes
238
+ # $qdb.statistics.requests.out_bytes.type
239
+ # $qdb.statistics.requests.out_bytes.unit
240
+ # $qdb.statistics.requests.out_bytes.unit
241
+ #
242
+ # And after deduplication like this:
243
+ #
244
+ # $qdb.statistics.requests.out_bytes
245
+ # $qdb.statistics.requests.out_bytes.type
246
+ # $qdb.statistics.requests.out_bytes.unit
247
+ #
248
+ # In which case we'll store `requests.out_bytes` as the statistic type, and look up the type
249
+ # and unit for those metrics and add a placeholder value.
250
+
251
+ ret: DefaultDict[str, Dict[str, Any]] = defaultdict(
252
+ lambda: {"value": None, "type": None, "unit": None}
253
+ )
254
+
255
+ for k in ks:
256
+ # Remove any 'uid_[0-9]+' part from the string
257
+ k_ = user_clean_pattern.sub("", k)
258
+
259
+ matches = total_pattern.match(k_)
260
+ if matches is None:
261
+ continue
262
+
263
+ parts = matches.groups()[0].rsplit(".", 1)
264
+ metric_id = parts[0]
265
+
266
+ if len(parts) > 1 and parts[1] == "type":
267
+ if ret[metric_id]["type"] == None:
268
+ # We haven't seen this particular statistic yet
269
+ ret[metric_id]["type"] = _lookup_type(dconn, k)
270
+ elif len(parts) > 1 and parts[1] == "unit":
271
+ if ret[metric_id]["unit"] == None:
272
+ # We haven't seen this particular statistic yet
273
+ ret[metric_id]["unit"] = _lookup_unit(dconn, k)
274
+ else:
275
+ # It's a value, we look those up later
276
+ pass
277
+
278
+ return ret
279
+
280
+
281
+ def _clean_blob(x: bytes) -> str:
282
+ """
283
+ Utility function that decodes a blob as an UTF-8 string, as the direct node C API
284
+ does not yet support 'string' types and as such all statistics are stored as blobs.
285
+ """
286
+ x_ = x.decode("utf-8", "replace")
287
+
288
+ # remove trailing zero-terminator
289
+ return "".join(c for c in x_ if ord(c) != 0)
290
+
291
+
292
+ def _get_stat_value(dconn: Node, k: str) -> Union[int, str]:
293
+ # Ugly, but works: try to retrieve as integer, if not an int, retrieve as
294
+ # blob
295
+ #
296
+ # XXX(leon): we could use the index we built to get a much stronger hint
297
+ # on what the type is.
298
+ try:
299
+ return dconn.integer(k).get()
300
+
301
+ # Older versions of qdb api returned 'alias not found'
302
+ except quasardb.AliasNotFoundError:
303
+ return _clean_blob(dconn.blob(k).get())
304
+
305
+ # Since ~ 3.14.2, it returns 'Incompatible Type'
306
+ except quasardb.IncompatibleTypeError:
307
+ return _clean_blob(dconn.blob(k).get())
308
+
309
+
310
+ def _by_uid(
311
+ stats: Dict[str, Union[int, str]], idx: DefaultDict[str, Dict[str, Any]]
312
+ ) -> Dict[int, Dict[str, Dict[str, Any]]]:
313
+ xs: Dict[int, Dict[str, Dict[str, Any]]] = {}
314
+
315
+ for k, v in stats.items():
316
+ matches = user_pattern.match(k)
317
+ if is_user_stat(k) and matches:
318
+ (metric, uid_str) = matches.groups()
319
+
320
+ if metric.split(".")[-1] in ["type", "unit"]:
321
+ # We already indexed the type and unit in our idx, this is not interesting
322
+ continue
323
+
324
+ if metric.startswith("serialized"):
325
+ # Internal stuff we don't care about nor cannot do anything with
326
+ continue
327
+
328
+ if not metric in idx:
329
+ logger.warning("Metric not in internal index: %s", metric)
330
+ continue
331
+
332
+ # Parse user id
333
+ uid = int(uid_str)
334
+
335
+ # Prepare our metric dict
336
+ x = idx[metric].copy()
337
+ x["value"] = v
338
+
339
+ if uid not in xs:
340
+ xs[uid] = {}
341
+
342
+ xs[uid][metric] = x
343
+
344
+ return xs
345
+
346
+
347
+ def _cumulative(
348
+ stats: Dict[str, Union[int, str]], idx: DefaultDict[str, Dict[str, Any]]
349
+ ) -> Dict[str, Dict[str, Any]]:
350
+ xs: Dict[str, Dict[str, Any]] = {}
351
+
352
+ for k, v in stats.items():
353
+ matches = total_pattern.match(k)
354
+ if is_cumulative_stat(k) and matches:
355
+ metric = matches.groups()[0]
356
+
357
+ if metric.split(".")[-1] in ["type", "unit"]:
358
+ # We already indexed the type and unit in our idx, this is not interesting
359
+ continue
360
+
361
+ if metric.startswith("serialized"):
362
+ # Internal stuff we don't care about nor cannot do anything with
363
+ continue
364
+
365
+ if not metric in idx:
366
+ logger.warning("Metric not in internal index: %s", metric)
367
+ continue
368
+
369
+ x = idx[metric].copy()
370
+ x["value"] = v
371
+ xs[metric] = x
372
+
373
+ return xs
374
+
375
+
376
+ # async_pipelines.buffer.total_bytes