quasardb 3.14.2.dev7__cp313-cp313-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.

Potentially problematic release.


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

Files changed (69) 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 +8 -0
  15. quasardb/extensions/writer.py +191 -0
  16. quasardb/firehose.py +103 -0
  17. quasardb/libqdb_api.so +0 -0
  18. quasardb/numpy/__init__.py +1045 -0
  19. quasardb/pandas/__init__.py +533 -0
  20. quasardb/pool.py +311 -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 +30 -0
  28. quasardb/quasardb/_blob.pyi +16 -0
  29. quasardb/quasardb/_cluster.pyi +100 -0
  30. quasardb/quasardb/_continuous.pyi +16 -0
  31. quasardb/quasardb/_double.pyi +7 -0
  32. quasardb/quasardb/_entry.pyi +60 -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 +105 -0
  37. quasardb/quasardb/_perf.pyi +5 -0
  38. quasardb/quasardb/_properties.pyi +5 -0
  39. quasardb/quasardb/_query.pyi +2 -0
  40. quasardb/quasardb/_reader.pyi +9 -0
  41. quasardb/quasardb/_retry.pyi +16 -0
  42. quasardb/quasardb/_string.pyi +12 -0
  43. quasardb/quasardb/_table.pyi +125 -0
  44. quasardb/quasardb/_tag.pyi +5 -0
  45. quasardb/quasardb/_timestamp.pyi +9 -0
  46. quasardb/quasardb/_writer.pyi +111 -0
  47. quasardb/quasardb/metrics/__init__.pyi +20 -0
  48. quasardb/quasardb.cpython-313-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 +358 -0
  64. quasardb/table_cache.py +56 -0
  65. quasardb-3.14.2.dev7.dist-info/METADATA +41 -0
  66. quasardb-3.14.2.dev7.dist-info/RECORD +69 -0
  67. quasardb-3.14.2.dev7.dist-info/WHEEL +6 -0
  68. quasardb-3.14.2.dev7.dist-info/licenses/LICENSE.md +11 -0
  69. quasardb-3.14.2.dev7.dist-info/top_level.txt +1 -0
quasardb/firehose.py ADDED
@@ -0,0 +1,103 @@
1
+ import time
2
+ import quasardb
3
+ import logging
4
+ import numpy as np
5
+
6
+ FIREHOSE_TABLE = "$qdb.firehose"
7
+ POLL_INTERVAL = 0.1
8
+
9
+ logger = logging.getLogger("quasardb.firehose")
10
+
11
+
12
+ def _init():
13
+ """
14
+ Initialize our internal state.
15
+ """
16
+ return {"last": None, "seen": set()}
17
+
18
+
19
+ def _get_transactions_since(conn, table_name, last):
20
+ """
21
+ Retrieve all transactions since a certain timestamp. `last` is expected to be a dict
22
+ firehose row with at least a $timestamp attached.
23
+ """
24
+ if last is None:
25
+ q = "SELECT $timestamp, transaction_id, begin, end FROM \"{}\" WHERE table = '{}' ORDER BY $timestamp".format(
26
+ FIREHOSE_TABLE, table_name
27
+ )
28
+ else:
29
+ q = "SELECT $timestamp, transaction_id, begin, end FROM \"{}\" IN RANGE ({}, +1y) WHERE table = '{}' ORDER BY $timestamp".format(
30
+ FIREHOSE_TABLE, last["$timestamp"], table_name
31
+ )
32
+
33
+ return conn.query(q)
34
+
35
+
36
+ def _get_transaction_data(conn, table_name, begin, end):
37
+ """
38
+ Gets all data from a certain table.
39
+ """
40
+ q = 'SELECT * FROM "{}" IN RANGE ({}, {}) '.format(table_name, begin, end)
41
+ return conn.query(q)
42
+
43
+
44
+ def _get_next(conn, table_name, state):
45
+
46
+ # Our flow to retrieve new data is as follows:
47
+ # 1. Based on the state's last processed transaction, retrieve all transactions
48
+ # that are logged into the firehose since then.
49
+ # 2. For each of the transactions, verify we haven't seen it before
50
+ # 3. For each of the transactions, pull in all data
51
+ # 4. Concatenate all this data (in order of quasardb transaction)
52
+
53
+ txs = _get_transactions_since(conn, table_name, state["last"])
54
+
55
+ xs = list()
56
+ for tx in txs:
57
+ txid = tx["transaction_id"]
58
+
59
+ if state["last"] is not None and tx["$timestamp"] > state["last"]["$timestamp"]:
60
+ # At this point we are guaranteed that the transaction we encounter is
61
+ # 'new', will not conflict with any other transaction ids. It is thus
62
+ # safe to reset the txid set.
63
+ state["seen"] = set()
64
+
65
+ if txid not in state["seen"]:
66
+ xs = xs + _get_transaction_data(
67
+ conn,
68
+ table_name,
69
+ tx["begin"],
70
+ # The firehose logs transaction `end` span as
71
+ # end inclusive, while our bulk reader and/or query
72
+ # language are end exclusive.
73
+ tx["end"] + np.timedelta64(1, "ns"),
74
+ )
75
+
76
+ # Because it is possible that multiple firehose changes are stored with the
77
+ # exact same $timestamp, we also keep track of the actually seen
78
+ # transaction ids.
79
+ state["seen"].add(txid)
80
+
81
+ state["last"] = tx
82
+
83
+ return (state, xs)
84
+
85
+
86
+ def subscribe(conn, table_name):
87
+ state = _init()
88
+
89
+ while True:
90
+ # Note how this is effectively a never-ending fold loop
91
+ # that transforms state into a new state. This state effectively
92
+ # functions as a checkpoint.
93
+ #
94
+ # At a later point, we could choose to provide the user
95
+ # direct access to this 'state' object, so that they can
96
+ # implement e.g. mechanisms to replay from a certain checkpoint.
97
+ (state, xs) = _get_next(conn, table_name, state)
98
+
99
+ for x in xs:
100
+ yield x
101
+
102
+ # Our poll interval
103
+ time.sleep(POLL_INTERVAL)
quasardb/libqdb_api.so ADDED
Binary file