diff --git a/.gitignore b/.gitignore index ef6fa9f..c2327e5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ _version.py .pytest_cache/ .mypy_cache/ .ruff_cache/ +_bqredis*.so diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..995d690 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3607 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "const-random", + "getrandom 0.3.4", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "arc-swap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a3a1fd6f75306b68087b831f025c712524bcb19aad54e557b1129cfa0a2b207" +dependencies = [ + "rustversion", +] + +[[package]] +name = "arrow" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e833808ff2d94ed40d9379848a950d995043c7fb3e81a30b383f4c6033821cc" +dependencies = [ + "arrow-arith 56.2.0", + "arrow-array 56.2.0", + "arrow-buffer 56.2.0", + "arrow-cast 56.2.0", + "arrow-data 56.2.0", + "arrow-ipc 56.2.0", + "arrow-ord 56.2.0", + "arrow-row 56.2.0", + "arrow-schema 56.2.0", + "arrow-select 56.2.0", + "arrow-string 56.2.0", +] + +[[package]] +name = "arrow" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d441fdda254b65f3e9025910eb2c2066b6295d9c8ed409522b8d2ace1ff8574c" +dependencies = [ + "arrow-arith 58.1.0", + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-cast 58.1.0", + "arrow-csv", + "arrow-data 58.1.0", + "arrow-ipc 58.1.0", + "arrow-json", + "arrow-ord 58.1.0", + "arrow-row 58.1.0", + "arrow-schema 58.1.0", + "arrow-select 58.1.0", + "arrow-string 58.1.0", +] + +[[package]] +name = "arrow-arith" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad08897b81588f60ba983e3ca39bda2b179bdd84dced378e7df81a5313802ef8" +dependencies = [ + "arrow-array 56.2.0", + "arrow-buffer 56.2.0", + "arrow-data 56.2.0", + "arrow-schema 56.2.0", + "chrono", + "num", +] + +[[package]] +name = "arrow-arith" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced5406f8b720cc0bc3aa9cf5758f93e8593cda5490677aa194e4b4b383f9a59" +dependencies = [ + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "chrono", + "num-traits", +] + +[[package]] +name = "arrow-array" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8548ca7c070d8db9ce7aa43f37393e4bfcf3f2d3681df278490772fd1673d08d" +dependencies = [ + "ahash", + "arrow-buffer 56.2.0", + "arrow-data 56.2.0", + "arrow-schema 56.2.0", + "chrono", + "half", + "hashbrown 0.16.1", + "num", +] + +[[package]] +name = "arrow-array" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772bd34cacdda8baec9418d80d23d0fb4d50ef0735685bd45158b83dfeb6e62d" +dependencies = [ + "ahash", + "arrow-buffer 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "chrono", + "chrono-tz", + "half", + "hashbrown 0.16.1", + "num-complex", + "num-integer", + "num-traits", +] + +[[package]] +name = "arrow-buffer" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e003216336f70446457e280807a73899dd822feaf02087d31febca1363e2fccc" +dependencies = [ + "bytes", + "half", + "num", +] + +[[package]] +name = "arrow-buffer" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "898f4cf1e9598fdb77f356fdf2134feedfd0ee8d5a4e0a5f573e7d0aec16baa4" +dependencies = [ + "bytes", + "half", + "num-bigint", + "num-traits", +] + +[[package]] +name = "arrow-cast" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "919418a0681298d3a77d1a315f625916cb5678ad0d74b9c60108eb15fd083023" +dependencies = [ + "arrow-array 56.2.0", + "arrow-buffer 56.2.0", + "arrow-data 56.2.0", + "arrow-schema 56.2.0", + "arrow-select 56.2.0", + "atoi", + "base64", + "chrono", + "half", + "lexical-core", + "num", + "ryu", +] + +[[package]] +name = "arrow-cast" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0127816c96533d20fc938729f48c52d3e48f99717e7a0b5ade77d742510736d" +dependencies = [ + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-data 58.1.0", + "arrow-ord 58.1.0", + "arrow-schema 58.1.0", + "arrow-select 58.1.0", + "atoi", + "base64", + "chrono", + "comfy-table", + "half", + "lexical-core", + "num-traits", + "ryu", +] + +[[package]] +name = "arrow-csv" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca025bd0f38eeecb57c2153c0123b960494138e6a957bbda10da2b25415209fe" +dependencies = [ + "arrow-array 58.1.0", + "arrow-cast 58.1.0", + "arrow-schema 58.1.0", + "chrono", + "csv", + "csv-core", + "regex", +] + +[[package]] +name = "arrow-data" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5c64fff1d142f833d78897a772f2e5b55b36cb3e6320376f0961ab0db7bd6d0" +dependencies = [ + "arrow-buffer 56.2.0", + "arrow-schema 56.2.0", + "half", + "num", +] + +[[package]] +name = "arrow-data" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d10beeab2b1c3bb0b53a00f7c944a178b622173a5c7bcabc3cb45d90238df4" +dependencies = [ + "arrow-buffer 58.1.0", + "arrow-schema 58.1.0", + "half", + "num-integer", + "num-traits", +] + +[[package]] +name = "arrow-ipc" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3594dcddccc7f20fd069bc8e9828ce37220372680ff638c5e00dea427d88f5" +dependencies = [ + "arrow-array 56.2.0", + "arrow-buffer 56.2.0", + "arrow-data 56.2.0", + "arrow-schema 56.2.0", + "arrow-select 56.2.0", + "flatbuffers", +] + +[[package]] +name = "arrow-ipc" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "609a441080e338147a84e8e6904b6da482cefb957c5cdc0f3398872f69a315d0" +dependencies = [ + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "arrow-select 58.1.0", + "flatbuffers", +] + +[[package]] +name = "arrow-json" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ead0914e4861a531be48fe05858265cf854a4880b9ed12618b1d08cba9bebc8" +dependencies = [ + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-cast 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "chrono", + "half", + "indexmap", + "itoa", + "lexical-core", + "memchr", + "num-traits", + "ryu", + "serde_core", + "serde_json", + "simdutf8", +] + +[[package]] +name = "arrow-ord" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8f82583eb4f8d84d4ee55fd1cb306720cddead7596edce95b50ee418edf66f" +dependencies = [ + "arrow-array 56.2.0", + "arrow-buffer 56.2.0", + "arrow-data 56.2.0", + "arrow-schema 56.2.0", + "arrow-select 56.2.0", +] + +[[package]] +name = "arrow-ord" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763a7ba279b20b52dad300e68cfc37c17efa65e68623169076855b3a9e941ca5" +dependencies = [ + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "arrow-select 58.1.0", +] + +[[package]] +name = "arrow-row" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d07ba24522229d9085031df6b94605e0f4b26e099fb7cdeec37abd941a73753" +dependencies = [ + "arrow-array 56.2.0", + "arrow-buffer 56.2.0", + "arrow-data 56.2.0", + "arrow-schema 56.2.0", + "half", +] + +[[package]] +name = "arrow-row" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14fe367802f16d7668163ff647830258e6e0aeea9a4d79aaedf273af3bdcd3e" +dependencies = [ + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "half", +] + +[[package]] +name = "arrow-schema" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3aa9e59c611ebc291c28582077ef25c97f1975383f1479b12f3b9ffee2ffabe" + +[[package]] +name = "arrow-schema" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c30a1365d7a7dc50cc847e54154e6af49e4c4b0fddc9f607b687f29212082743" +dependencies = [ + "bitflags", +] + +[[package]] +name = "arrow-select" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c41dbbd1e97bfcaee4fcb30e29105fb2c75e4d82ae4de70b792a5d3f66b2e7a" +dependencies = [ + "ahash", + "arrow-array 56.2.0", + "arrow-buffer 56.2.0", + "arrow-data 56.2.0", + "arrow-schema 56.2.0", + "num", +] + +[[package]] +name = "arrow-select" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78694888660a9e8ac949853db393af2a8b8fc82c19ce333132dfa2e72cc1a7fe" +dependencies = [ + "ahash", + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "num-traits", +] + +[[package]] +name = "arrow-string" +version = "56.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53f5183c150fbc619eede22b861ea7c0eebed8eaac0333eaa7f6da5205fd504d" +dependencies = [ + "arrow-array 56.2.0", + "arrow-buffer 56.2.0", + "arrow-data 56.2.0", + "arrow-schema 56.2.0", + "arrow-select 56.2.0", + "memchr", + "num", + "regex", + "regex-syntax", +] + +[[package]] +name = "arrow-string" +version = "58.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e04a01f8bb73ce54437514c5fd3ee2aa3e8abe4c777ee5cc55853b1652f79e" +dependencies = [ + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "arrow-select 58.1.0", + "memchr", + "num-traits", + "regex", + "regex-syntax", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "aws-lc-rs" +version = "1.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a054912289d18629dc78375ba2c3726a3afe3ff71b4edba9dedfca0e3446d1fc" +dependencies = [ + "aws-lc-sys", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a25cf98105baa966497416dbd42565ce3a8cf8dbfd59803ec9ad46f3126399" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + +[[package]] +name = "backon" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cffb0e931875b666fc4fcb20fee52e9bbd1ef836fd9e9e04ec21555f9f85f7ef" +dependencies = [ + "fastrand", + "tokio", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bigdecimal" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d6867f1565b3aad85681f1015055b087fcfd840d6aeee6eee7f2da317603695" +dependencies = [ + "autocfg", + "libm", + "num-bigint", + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bqredis" +version = "0.1.0" +dependencies = [ + "arrow 58.1.0", + "chrono", + "futures", + "gcloud-auth", + "gcloud-bigquery", + "gcloud-gax", + "gcloud-googleapis", + "hex", + "pyo3", + "pyo3-arrow", + "redis", + "sha2", + "thiserror 1.0.69", + "tokio", + "tracing", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "chrono-tz" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6139a8597ed92cf816dfb33f5dd6cf0bb93a6adc938f11039f371bc5bcd26c3" +dependencies = [ + "chrono", + "phf", +] + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "comfy-table" +version = "7.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958c5d6ecf1f214b4c2bbbbf6ab9523a864bd136dcf71a7e8904799acfe1ad47" +dependencies = [ + "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.17", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "csv" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde_core", +] + +[[package]] +name = "csv-core" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782" +dependencies = [ + "memchr", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", + "serde_core", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flatbuffers" +version = "25.12.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35f6839d7b3b98adde531effaf34f0c2badc6f4735d26fe74709d8e513a96ef3" +dependencies = [ + "bitflags", + "rustc_version", +] + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "gcloud-auth" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b43924e3df02cb3b846ca66a7ee58e8c13eb2556d0308c71f6154083f6980365" +dependencies = [ + "async-trait", + "base64", + "gcloud-metadata", + "home", + "jsonwebtoken", + "reqwest", + "serde", + "serde_json", + "thiserror 2.0.18", + "time", + "token-source", + "tokio", + "tracing", + "urlencoding", +] + +[[package]] +name = "gcloud-bigquery" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5608493741763c0a874f00672110f040a24487ba1564e1a4e5af6f78a0b4c42b" +dependencies = [ + "anyhow", + "arrow 56.2.0", + "async-stream", + "async-trait", + "backon", + "base64", + "bigdecimal", + "gcloud-auth", + "gcloud-gax", + "gcloud-googleapis", + "num-bigint", + "prost-types", + "reqwest", + "reqwest-middleware", + "serde", + "serde_json", + "thiserror 2.0.18", + "time", + "token-source", + "tokio", + "tracing", +] + +[[package]] +name = "gcloud-gax" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558634081d1cf458d1bc0166f69475a80f445b5b991f162028b293a38307059d" +dependencies = [ + "http", + "thiserror 2.0.18", + "token-source", + "tokio", + "tokio-retry2", + "tonic", + "tower", + "tracing", +] + +[[package]] +name = "gcloud-googleapis" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d79fc4ec36213a21b734a2ce204176eb39c439fa528f9a388c9a1349ca344b0d" +dependencies = [ + "prost", + "prost-types", + "tonic", + "tonic-prost", +] + +[[package]] +name = "gcloud-metadata" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd3152612316be627be52fe9ca72331eb48425059b3a6a700e7adde223e061d5" +dependencies = [ + "reqwest", + "thiserror 2.0.18", + "tokio", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "h2" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2 0.6.3", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.0", +] + +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + +[[package]] +name = "iri-string" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e659a4bb38e810ebc252e53b5814ff908a8c58c2a9ce2fae1bbec24cbf4e20" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys 0.3.1", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca" +dependencies = [ + "cfg-if", + "futures-util", + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "jsonwebtoken" +version = "10.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0529410abe238729a60b108898784df8984c87f6054c9c4fcacc47e4803c1ce1" +dependencies = [ + "aws-lc-rs", + "base64", + "getrandom 0.2.17", + "js-sys", + "pem", + "serde", + "serde_json", + "signature", + "simple_asn1", +] + +[[package]] +name = "lexical-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d8d125a277f807e55a77304455eb7b1cb52f2b18c143b60e766c120bd64a594" +dependencies = [ + "lexical-parse-float", + "lexical-parse-integer", + "lexical-util", + "lexical-write-float", + "lexical-write-integer", +] + +[[package]] +name = "lexical-parse-float" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a9f232fbd6f550bc0137dcb5f99ab674071ac2d690ac69704593cb4abbea56" +dependencies = [ + "lexical-parse-integer", + "lexical-util", +] + +[[package]] +name = "lexical-parse-integer" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a7a039f8fb9c19c996cd7b2fcce303c1b2874fe1aca544edc85c4a5f8489b34" +dependencies = [ + "lexical-util", +] + +[[package]] +name = "lexical-util" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2604dd126bb14f13fb5d1bd6a66155079cb9fa655b37f875b3a742c705dbed17" + +[[package]] +name = "lexical-write-float" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c438c87c013188d415fbabbb1dceb44249ab81664efbd31b14ae55dabb6361" +dependencies = [ + "lexical-util", + "lexical-write-integer", +] + +[[package]] +name = "lexical-write-integer" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "409851a618475d2d5796377cad353802345cba92c867d9fbcde9cf4eac4e14df" +dependencies = [ + "lexical-util", +] + +[[package]] +name = "libc" +version = "0.2.184" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "matrixmultiply" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08" +dependencies = [ + "autocfg", + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "ndarray" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520080814a7a6b4a6e9070823bb24b4531daac8c4627e08ba5de8c5ef2f2752d" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "portable-atomic", + "portable-atomic-util", + "rawpointer", +] + +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "numpy" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778da78c64ddc928ebf5ad9df5edf0789410ff3bdbf3619aed51cd789a6af1e2" +dependencies = [ + "half", + "libc", + "ndarray", + "num-complex", + "num-integer", + "num-traits", + "pyo3", + "pyo3-build-config", + "rustc-hash", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64", + "serde_core", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "phf" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_shared" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "091397be61a01d4be58e7841595bd4bfedb15f1cd54977d79b8271e94ed799a3" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8991c4cbdb8bc5b11f0b074ffe286c30e523de90fee5ba8132f1399f23cb3dd7" +dependencies = [ + "prost", +] + +[[package]] +name = "pyo3" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12" +dependencies = [ + "chrono", + "chrono-tz", + "indexmap", + "libc", + "once_cell", + "portable-atomic", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", +] + +[[package]] +name = "pyo3-arrow" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0360400036dda3db3d69102ef7e9646e4cd946c75a2d1d41fb8fd39879312636" +dependencies = [ + "arrow-array 58.1.0", + "arrow-buffer 58.1.0", + "arrow-cast 58.1.0", + "arrow-data 58.1.0", + "arrow-schema 58.1.0", + "arrow-select 58.1.0", + "chrono", + "chrono-tz", + "half", + "indexmap", + "numpy", + "pyo3", + "thiserror 1.0.69", +] + +[[package]] +name = "pyo3-build-config" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e" +dependencies = [ + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb" +dependencies = [ + "heck", + "proc-macro2", + "pyo3-build-config", + "quote", + "syn", +] + +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2 0.6.3", + "thiserror 2.0.18", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.18", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2 0.6.3", + "tracing", + "windows-sys 0.60.2", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ec095654a25171c2124e9e3393a930bddbffdc939556c914957a4c3e0a87166" +dependencies = [ + "rand_chacha", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "redis" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e902a69d09078829137b4a5d9d082e0490393537badd7c91a3d69d14639e115f" +dependencies = [ + "arc-swap", + "async-trait", + "bytes", + "combine", + "futures-util", + "itoa", + "num-bigint", + "percent-encoding", + "pin-project-lite", + "ryu", + "sha1_smol", + "socket2 0.5.10", + "tokio", + "tokio-util", + "url", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "reqwest" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3f43e3283ab1488b624b44b0e988d0acea0b3214e694730a055cb6b2efa801" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-util", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", +] + +[[package]] +name = "reqwest-middleware" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "199dda04a536b532d0cc04d7979e39b1c763ea749bf91507017069c00b96056f" +dependencies = [ + "anyhow", + "async-trait", + "http", + "reqwest", + "serde", + "thiserror 2.0.18", + "tower-service", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted 0.9.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustls" +version = "0.23.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d99feebc72bae7ab76ba994bb5e121b8d83d910ca40b36e0921f53becc41784" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + +[[package]] +name = "rustls-webpki" +version = "0.103.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20a6af516fea4b20eccceaf166e8aa666ac996208e8a644ce3ef5aa783bc7cd4" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted 0.9.0", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1_smol" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "simd-adler32" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "simple_asn1" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d585997b0ac10be3c5ee635f1bab02d512760d14b7c468801ac8a01d9ae5f1d" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror 2.0.18", + "time", +] + +[[package]] +name = "siphasher" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "target-lexicon" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "token-source" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75746ae15bef509f21039a652383104424208fdae172a964a8930858b9a78412" +dependencies = [ + "async-trait", +] + +[[package]] +name = "tokio" +version = "1.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f66bf9585cda4b724d3e78ab34b73fb2bbaba9011b9bfdf69dc836382ea13b8c" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.6.3", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-retry2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05e40fd65880de11383bbc693d3c636045ed1b5010ef1265a1d2b41d73334a1" +dependencies = [ + "pin-project", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fec7c61a0695dc1887c1b53952990f3ad2e3a31453e1f49f10e75424943a93ec" +dependencies = [ + "async-trait", + "base64", + "bytes", + "flate2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", + "webpki-roots", +] + +[[package]] +name = "tonic-prost" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55376a0bbaa4975a3f10d009ad763d8f4108f067c7c2e74f3001fb49778d309" +dependencies = [ + "bytes", + "prost", + "tonic", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project-lite", + "slab", + "sync_wrapper", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-segmentation" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f371d383f2fb139252e0bfac3b81b265689bf45b6874af544ffa4c975ac1ebf8" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-streams" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2dfbb17949fa2088e5d39408c48368947b86f7834484e87b73de55bc14d97d" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-root-certs" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804f18a4ac2676ffb4e8b5b5fa9ae38af06df08162314f96a68d2a363e21a8ca" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "webpki-roots" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" + +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "yoke" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e20c12a --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "bqredis" +version = "0.1.0" +edition = "2021" + +[lib] +name = "_bqredis" +crate-type = ["cdylib"] + +[dependencies] +# Python bindings +pyo3 = { version = "0.28", features = ["extension-module"] } +pyo3-arrow = "0.17" + +# Async runtime +tokio = { version = "1", features = ["full"] } +futures = "0.3" + +# Redis +redis = { version = "0.26", features = ["tokio-comp"] } + +# BigQuery +google-cloud-bigquery = { package = "gcloud-bigquery", version = "1.6" } +google-cloud-googleapis = { package = "gcloud-googleapis", version = "1.3", features = ["bigquery"] } +google-cloud-gax = { package = "gcloud-gax", version = "1.4" } +google-cloud-auth = { package = "gcloud-auth", version = "1.3" } + +# Arrow +arrow = { version = "58", features = ["ipc"] } + +# Utilities +sha2 = "0.10" +hex = "0.4" +chrono = { version = "0.4", features = ["serde"] } +thiserror = "1" +tracing = "0.1" diff --git a/bqredis/__init__.py b/bqredis/__init__.py index dae0092..0b848ee 100644 --- a/bqredis/__init__.py +++ b/bqredis/__init__.py @@ -1,350 +1,13 @@ -"""Implementation of a Redis BigQuery cache.""" +"""Redis-backed BigQuery query cache, implemented in Rust. -import concurrent.futures -import datetime -import hashlib -import io -import logging -import threading -import typing +All BigQuery I/O and threading runs in Rust without holding the Python GIL. +Results are returned as ``pyarrow.Table`` objects. -import pyarrow.ipc -import redis -from google.cloud import bigquery -from google.cloud import bigquery_storage_v1 as bq_storage +Authentication uses Application Default Credentials (ADC). Run: + gcloud auth application-default login +or set GOOGLE_APPLICATION_CREDENTIALS before instantiating BQRedis. +""" -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) +from bqredis._bqredis import BQRedis - -class _QueryResult: - key: str - query_time: datetime.datetime - serialized_schema: bytes - serialized_data: io.BytesIO - records: typing.Any - - def __init__( - self, - key: str, - query_time: datetime.datetime, - serialized_schema: bytes, - serialized_data: io.BytesIO, - ): - self.key = key - self.query_time = query_time - self.serialized_schema = serialized_schema - self.serialized_data = serialized_data - self.records = None - - -def _read_pyarrow_table( - serialized_schema: bytes, serialized_data: bytes | io.BytesIO | None -) -> pyarrow.Table: - # TODO: Stop copying data! - schema = pyarrow.ipc.read_schema( - pyarrow.BufferReader(serialized_schema).read_buffer() - ) - if serialized_data is None: - return pyarrow.Table.from_pylist([], schema) - if isinstance(serialized_data, bytes) and len(serialized_data) == 0: - return pyarrow.Table.from_pylist([], schema) - if ( - isinstance(serialized_data, io.BytesIO) - and serialized_data.getbuffer().nbytes == 0 - ): - return pyarrow.Table.from_pylist([], schema) - all_data = io.BytesIO() - all_data.write(serialized_schema) - if isinstance(serialized_data, io.BytesIO): - all_data.write(serialized_data.getbuffer()) - else: - all_data.write(serialized_data) - - with pyarrow.ipc.open_stream( - pyarrow.BufferReader(all_data.getbuffer()).read_buffer() - ) as reader: - return reader.read_all() - - -class BQRedis: - """A class to cache BigQuery results in Redis. - - This should be instantiated as a singleton, as it maintains a - ThreadPoolExecutor. This allows concurrent query execution and caching - across multiple instances which share a redis connection. Additionally, - each instance maintains at most one inflight connection per query to - BigQuery. - """ - - def __init__( - self, - redis_client: redis.Redis, - executor: concurrent.futures.ThreadPoolExecutor | None = None, - bigquery_client: bigquery.Client | None = None, - bigquery_storage_client: bq_storage.BigQueryReadClient | None = None, - redis_key_prefix: str = "bigquery_cache:", - redis_cache_ttl_sec: int = 3600, # 1 hour - redis_background_refresh_ttl_sec: int = 300, # 5 minutes - max_stream_count: int | None = None, - ): - self.bigquery_client = bigquery_client or bigquery.Client() - self.bigquery_storage_client = ( - bigquery_storage_client or bq_storage.BigQueryReadClient() - ) - self.redis_client = redis_client - # This executor is used for bigquery, where a lot of actual processing happens. - self.executor = executor or concurrent.futures.ThreadPoolExecutor() - # This executor is used to make it convenient to generate an async interface. - # It will have much cheaper processing. - max_workers: int | None = getattr(self.executor, "_max_workers") - if max_workers is not None: - max_workers *= 2 - self.frontend_executor = concurrent.futures.ThreadPoolExecutor( - max_workers=max_workers - ) - self.redis_key_prefix = redis_key_prefix - self.redis_cache_ttl = redis_cache_ttl_sec - self.redis_background_refresh_ttl = redis_background_refresh_ttl_sec - self.max_stream_count = max_stream_count - self.inflight_requests: dict[str, concurrent.futures.Future[_QueryResult]] = {} - # This lock exists so we can avoid launching multiple inflight requests for the same - # query while another parallel request is actively queuing. Because this is a weakref - # dictionary, the lock does not help protect against deletions, so accessing values - # from the inflight_requests dict need to be atomic (e.g. a direct get, or a try/except) - # instead of first checking for existence and then accessing. - self.inflight_requests_lock = threading.Lock() - - def convert_arrow_to_output_format(self, records: pyarrow.Table) -> typing.Any: - """Convert the pyarrow RecordBatch to the desired output format.""" - # This method should be overridden in subclasses to convert - # the RecordBatch to the desired output format. - # The base implementation just returns the RecordBatch itself. - return records - - def _submit_query( - self, query: str, key: str - ) -> concurrent.futures.Future[_QueryResult]: - """Only have one instance of a specific query inflight at a time.""" - with self.inflight_requests_lock: - inflight_request = self.inflight_requests.get(key) - if inflight_request is not None: - logger.debug("Re-used inflight request for key: %s", key) - return inflight_request - logger.debug("Dispatching new inflight request for key: %s", key) - new_request = self.executor.submit(self._execute_query, query, key) - self.inflight_requests[key] = new_request - new_request.add_done_callback(self._cache_put_callback) - return new_request - - def _cache_put_callback( - self, query_result_future: concurrent.futures.Future[_QueryResult] - ) -> None: - """Store the serialized schema and data in Redis.""" - try: - query_result = query_result_future.result() - except Exception as exc: - logger.error("Query failed, not caching result: %s", exc) - return - self._cache_put(query_result) - - def _cache_put(self, query_result: _QueryResult) -> None: - pipeline = self.redis_client.pipeline() - pipeline.set( - query_result.key + ":schema", - query_result.serialized_schema, - ex=self.redis_cache_ttl, - ) - pipeline.set( - query_result.key + ":data", - query_result.serialized_data.getvalue(), - ex=self.redis_cache_ttl, - ) - pipeline.set( - query_result.key + ":query_time", - query_result.query_time.isoformat(), - ex=self.redis_cache_ttl, - ) - pipeline.execute() - logger.debug("Cached query result for key: %s", query_result.key) - - def _mark_inflight_completed(self, key: str): - with self.inflight_requests_lock: - self.inflight_requests.pop(key) - - def _execute_query( - self, query: str, key: str, background: bool = False - ) -> _QueryResult: - try: - result = self._read_bigquery_bytes(query, key, background) - finally: - if not background: - self._mark_inflight_completed(key) - records = _read_pyarrow_table(result.serialized_schema, result.serialized_data) - result.records = self.convert_arrow_to_output_format(records) - return result - - # All of the external IO to GCP happens here in one function. - # This makes it easier to mock out in unit tests. - def _read_bigquery_bytes( - self, query: str, key: str, background: bool - ) -> _QueryResult: - query_time = datetime.datetime.now(datetime.timezone.utc) - query_config = ( - self.bigquery_client.default_query_job_config or bigquery.QueryJobConfig() - ) - if background: - query_config.priority = bigquery.QueryPriority.BATCH - query_job: bigquery.QueryJob = self.bigquery_client.query( - query, job_config=query_config - ) - while not query_job.done(reload=False): - query_job.reload() - if exc := query_job.exception(): - deleted_count = 0 - try: - deleted_count = self.redis_client.delete(key + ":background_refresh") # type: ignore - finally: - if deleted_count: - logger.info( - "Cleared background refresh marker on failure for key: %s", key - ) - logger.error("BigQuery job failed for key: %s, error: %s", key, exc) - raise exc - if query_job.destination is None: - raise RuntimeError("BigQuery job has no destination table.") - read_request = bq_storage.types.ReadSession( - table=query_job.destination.to_bqstorage(), - data_format=bq_storage.types.DataFormat.ARROW, - ) - read_request.read_options.arrow_serialization_options.buffer_compression = ( - bq_storage.types.ArrowSerializationOptions.CompressionCodec.ZSTD # type: ignore - ) - session = self.bigquery_storage_client.create_read_session( - parent=f"projects/{query_job.destination.project}", - read_session=read_request, - max_stream_count=self.max_stream_count or 0, - ) - result = _QueryResult( - key=key, - query_time=query_time, - serialized_schema=session.arrow_schema.serialized_schema, - serialized_data=io.BytesIO(), - ) - page_count = 0 - for stream in session.streams: - reader = self.bigquery_storage_client.read_rows(stream.name) - for page in reader: - page_count += 1 - result.serialized_data.write( - page.arrow_record_batch.serialized_record_batch - ) - logger.debug( - "Query for key %s returned %d pages in %d streams with a total of %d bytes", - key, - page_count, - len(session.streams), - result.serialized_data.getbuffer().nbytes, - ) - return result - - def _background_refresh_cache(self, query: str, key: str) -> None: - if self.redis_client.get(key + ":background_refresh"): - logger.info("Background refresh already in progress for query key %s", key) - return - logger.debug("Background refreshing cache for query key %s", key) - self.redis_client.set( - key + ":background_refresh", "1", ex=self.redis_background_refresh_ttl - ) - try: - result = self._execute_query(query, key, background=True) - except Exception as exc: - logger.error("Background refresh for query key %s failed: %s", key, exc) - else: - self._cache_put(result) - finally: - self.redis_client.delete(key + ":background_refresh") - - def submit_background_refresh(self, query: str) -> concurrent.futures.Future[None]: - """Submit a background task to refresh the cache for a given query.""" - query_hash = hashlib.sha256(query.encode()).hexdigest() - key = self.redis_key_prefix + query_hash - return self.executor.submit(self._background_refresh_cache, query, key) - - def _check_redis_cache( - self, query: str, key: str, max_age: int | None - ) -> tuple[pyarrow.Table | None, datetime.datetime | None]: - pipeline = self.redis_client.pipeline() - pipeline.get(key + ":data") - pipeline.get(key + ":schema") - pipeline.get(key + ":query_time") - cached_data: bytes | None - cached_schema: bytes | None - cached_query_time_str: bytes | None - cached_data, cached_schema, cached_query_time_str = pipeline.execute() - if ( - cached_schema is None - or cached_schema is None - or cached_query_time_str is None - ): - return None, None - cached_query_time = datetime.datetime.fromisoformat( - cached_query_time_str.decode("utf-8") - ) - result_age = ( - datetime.datetime.now(datetime.timezone.utc) - cached_query_time - ).total_seconds() - if max_age is not None and result_age > max_age: - return None, None - if max_age == 0: - return None, None - if result_age > self.redis_background_refresh_ttl: - self.executor.submit(self._background_refresh_cache, query, key) - logger.debug("Using cached result for query key: %s", key) - return _read_pyarrow_table(cached_schema, cached_data), cached_query_time - - def query_sync_with_time( - self, query: str, max_age: int | None = None - ) -> tuple[pyarrow.Table, datetime.datetime]: - """Execute a bigquery allowing cached results and getting the query time.""" - query_hash = hashlib.sha256(query.encode()).hexdigest() - key = self.redis_key_prefix + query_hash - cached_records, cached_query_time = self._check_redis_cache(query, key, max_age) - if cached_records is not None and cached_query_time is not None: - return self.convert_arrow_to_output_format( - cached_records - ), cached_query_time - logger.debug("Requesting new execution for query key %s", key) - result = self._submit_query(query, key).result() - return result.records, result.query_time - - def query_sync(self, query: str, max_age: int | None = None) -> pyarrow.Table: - """Execute a bigquery allowing cached results.""" - return self.query_sync_with_time(query, max_age)[0] - - def query( - self, query: str, max_age: int | None = None - ) -> concurrent.futures.Future[pyarrow.Table]: - """Execute a bigquery allowing cached results as a future.""" - return self.frontend_executor.submit(self.query_sync, query, max_age) - - def query_with_time( - self, query: str, max_age: int | None = None - ) -> concurrent.futures.Future[tuple[pyarrow.Table, datetime.datetime]]: - """Execute a bigquery allowing cached results as a future.""" - return self.frontend_executor.submit(self.query_sync_with_time, query, max_age) - - def clear_cache_sync(self) -> None: - """Clear the cache synchronously.""" - with self.inflight_requests_lock: - self.inflight_requests.clear() - logger.debug("Beginning cache clear") - key_count = 0 - for key in self.redis_client.scan_iter(self.redis_key_prefix + "*"): - self.redis_client.delete(key) - key_count += 1 - logger.info("Cleared %d keys from Redis cache", key_count) - - def clear_cache(self) -> concurrent.futures.Future[None]: - """Clear the cache in the background.""" - return self.frontend_executor.submit(self.clear_cache_sync) +__all__ = ["BQRedis"] diff --git a/pyproject.toml b/pyproject.toml index bff90c4..ef81739 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,22 +1,15 @@ [build-system] -requires = ["hatchling", "hatch-vcs"] -build-backend = "hatchling.build" +requires = ["maturin>=1.0,<2.0"] +build-backend = "maturin" -[tool.hatch.build] -include = ["bqredis/*"] - -[tool.hatch.version] -source = "vcs" - -[tool.hatch.version.raw-options] -local_scheme = "no-local-version" - -[tool.hatch.metadata.hooks.vcs.urls] -source_archive = "https://github.com/DelfinaCare/bqredis/archive/{commit_hash}.zip" +[tool.maturin] +python-source = "." +module-name = "bqredis._bqredis" +features = ["pyo3/extension-module"] [project] name = "bqredis" -dynamic = ["version"] +version = "0.1.0" authors = [ { name="Ali.Ebrahim", email="ali@delfina.com" }, ] @@ -31,16 +24,12 @@ classifiers = [ ] dependencies = [ - "redis >= 5.2.1", "pyarrow >= 18.1.0", - "google-cloud-bigquery >= 3.35.1", - "google-cloud-bigquery-storage >= 2.32.0", ] [project.optional-dependencies] dev = [ "mypy >=1.11.2", - "fakeredis >= 2.30.3", "pyarrow-stubs >=20.0.0.20250716", "pytest >= 8.4.1" ] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..20e4364 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,824 @@ +use std::collections::HashMap; +use std::io::Cursor; +use std::sync::{Arc, Mutex}; +use std::time::Duration; + +use arrow::ipc::reader::StreamReader; +use arrow::ipc::writer::StreamWriter; +use chrono::{DateTime, Utc}; +use futures::future::{BoxFuture, FutureExt, Shared}; +use google_cloud_auth::token::DefaultTokenSourceProvider; +use google_cloud_bigquery::client::{Client, ClientConfig}; +use google_cloud_bigquery::grpc::apiv1::bigquery_client::StreamingReadClient; +use google_cloud_bigquery::http::job::get::GetJobRequest; +use google_cloud_bigquery::http::job::query::QueryRequest; +use google_cloud_bigquery::http::job::{JobState, JobType}; +use google_cloud_gax::conn::{ConnectionManager, ConnectionOptions, Environment}; +use google_cloud_googleapis::cloud::bigquery::storage::v1::big_query_read_client::BigQueryReadClient; +use google_cloud_googleapis::cloud::bigquery::storage::v1::read_rows_response::Rows; +use google_cloud_googleapis::cloud::bigquery::storage::v1::read_session::{ + table_read_options::OutputFormatSerializationOptions, Schema as SessionSchema, TableReadOptions, +}; +use google_cloud_googleapis::cloud::bigquery::storage::v1::{ + ArrowSerializationOptions, CreateReadSessionRequest, DataFormat, ReadRowsRequest, ReadSession, +}; +use pyo3::exceptions::PyRuntimeError; +use pyo3::prelude::*; +use pyo3_arrow::PyTable; +use redis::AsyncCommands; +use sha2::{Digest, Sha256}; +use tokio::runtime::Runtime; + +// ── Error type ──────────────────────────────────────────────────────────────── + +#[derive(Debug, Clone, thiserror::Error)] +enum BQRedisError { + #[error("BigQuery error: {0}")] + BigQuery(String), + #[error("Redis error: {0}")] + Redis(String), + #[error("Arrow error: {0}")] + Arrow(String), + #[error("{0}")] + Other(String), +} + +impl From for PyErr { + fn from(e: BQRedisError) -> Self { + PyRuntimeError::new_err(e.to_string()) + } +} + +// Results shared across concurrent waiters must be Clone. +type SharedResult = Result>; +type SharedFuture = Shared>>>; + +// ── Cached query result ──────────────────────────────────────────────────────── + +#[derive(Clone)] +struct QueryResult { + query_time: DateTime, + serialized_schema: Vec, + serialized_data: Vec, +} + +impl QueryResult { + /// Decode the IPC bytes and return a `pyarrow.Table`. + /// + /// `serialized_data` is always a complete Arrow IPC stream (schema + batches + EOS). + /// For empty tables it contains only the schema message followed by EOS. + fn to_pyarrow(&self, py: Python) -> PyResult> { + let reader = StreamReader::try_new(Cursor::new(&self.serialized_data), None) + .map_err(|e| PyRuntimeError::new_err(e.to_string()))?; + let schema = reader.schema(); + let batches: Result, _> = reader.collect(); + let batches = batches.map_err(|e| PyRuntimeError::new_err(e.to_string()))?; + + PyTable::try_new(batches, schema) + .map_err(|e| PyRuntimeError::new_err(e.to_string()))? + .into_pyarrow(py) + .map(|b| b.unbind()) + } +} + +// ── Configuration ───────────────────────────────────────────────────────────── + +struct BQRedisConfig { + redis_key_prefix: String, + cache_ttl_sec: u64, + background_refresh_ttl_sec: u64, + max_stream_count: i32, +} + +// ── Core state (shared across Python threads via Arc) ───────────────────────── + +struct BQRedisInner { + project_id: String, + bq_client: Client, + conn_manager: Arc, + redis: redis::Client, + config: BQRedisConfig, + /// One in-flight future per query key. Concurrent callers for the same key + /// each get a clone of the same Shared future and all receive the result + /// once the single underlying task completes. + inflight: Mutex>, +} + +impl BQRedisInner { + /// Create a fresh StreamingReadClient from the shared connection pool. + fn streaming_client(&self) -> StreamingReadClient { + StreamingReadClient::new(BigQueryReadClient::new(self.conn_manager.conn())) + } + + fn query_key(&self, query: &str) -> String { + let hash = Sha256::digest(query.as_bytes()); + format!("{}{}", self.config.redis_key_prefix, hex::encode(hash)) + } + + /// Return an existing in-flight future for `key`, or create and register a + /// new one that drives `run_query` to completion. + fn get_or_submit(self: Arc, query: String, key: String) -> SharedFuture { + let inflight = self.inflight.lock().unwrap(); + if let Some(fut) = inflight.get(&key) { + tracing::debug!("Re-used inflight request for key: {key}"); + return fut.clone(); + } + tracing::debug!("Dispatching new inflight request for key: {key}"); + + let inner = Arc::clone(&self); + let key_for_cleanup = key.clone(); + let fut: SharedFuture = async move { + let result = inner + .clone() + .run_query_and_cache(query, key.clone()) + .await; + // Remove from inflight map once the result is ready. + if let Ok(mut inflight) = inner.inflight.lock() { + inflight.remove(&key); + } + result + } + .boxed() + .shared(); + + self.inflight + .lock() + .unwrap() + .insert(key_for_cleanup, fut.clone()); + fut + } + + /// Execute the BigQuery job, read via Storage API, cache in Redis, return result. + async fn run_query_and_cache( + self: Arc, + query: String, + key: String, + ) -> SharedResult> { + let result = self + .read_bigquery_bytes(&query) + .await + .map_err(Arc::new)?; + self.cache_put(&key, &result).await.map_err(Arc::new)?; + tracing::debug!("Cached query result for key: {key}"); + Ok(Arc::new(result)) + } + + /// Submit a BigQuery query job, wait for completion, stream Arrow IPC bytes + /// via the BigQuery Storage Read API, and return the raw bytes. + async fn read_bigquery_bytes(&self, query: &str) -> Result { + let query_time = Utc::now(); + + // ── Submit job ──────────────────────────────────────────────────────── + let query_req = QueryRequest { + query: query.to_string(), + timeout_ms: Some(0), // return immediately with a job reference + use_legacy_sql: false, + ..Default::default() + }; + let query_resp = self + .bq_client + .job() + .query(&self.project_id, &query_req) + .await + .map_err(|e| BQRedisError::BigQuery(e.to_string()))?; + + let job_ref = query_resp.job_reference; + + // ── Poll until done ──────────────────────────────────────────────────── + let completed_job = loop { + let job = self + .bq_client + .job() + .get( + &job_ref.project_id, + &job_ref.job_id, + &GetJobRequest { + location: job_ref.location.clone(), + }, + ) + .await + .map_err(|e| BQRedisError::BigQuery(e.to_string()))?; + + if matches!(job.status.state, JobState::Done) { + break job; + } + tokio::time::sleep(Duration::from_secs(1)).await; + }; + + // ── Check for job-level errors ──────────────────────────────────────── + if let Some(err) = completed_job.status.error_result.as_ref() { + return Err(BQRedisError::BigQuery(format!( + "{}: {}", + err.reason.as_deref().unwrap_or("unknown"), + err.message.as_deref().unwrap_or("") + ))); + } + + // ── Get destination table ───────────────────────────────────────────── + let destination = match &completed_job.configuration.job { + JobType::Query(q) => q + .destination_table + .as_ref() + .ok_or_else(|| BQRedisError::BigQuery("Job has no destination table".into()))?, + _ => return Err(BQRedisError::BigQuery("Expected a query job".into())), + }; + + let table_path = format!( + "projects/{}/datasets/{}/tables/{}", + destination.project_id, destination.dataset_id, destination.table_id, + ); + + // ── Create BigQuery Storage read session ────────────────────────────── + let mut streaming_client = self.streaming_client(); + + let read_options = Some(TableReadOptions { + output_format_serialization_options: Some( + OutputFormatSerializationOptions::ArrowSerializationOptions( + ArrowSerializationOptions { + buffer_compression: 2, // ZSTD = 2 + }, + ), + ), + ..Default::default() + }); + + let session = streaming_client + .create_read_session( + CreateReadSessionRequest { + parent: format!("projects/{}", self.project_id), + read_session: Some(ReadSession { + table: table_path, + data_format: DataFormat::Arrow.into(), + read_options, + ..Default::default() + }), + max_stream_count: self.config.max_stream_count, + ..Default::default() + }, + None, + ) + .await + .map_err(|e| BQRedisError::BigQuery(e.to_string()))? + .into_inner(); + + // ── Extract Arrow schema ─────────────────────────────────────────────── + let raw_schema_bytes = match &session.schema { + Some(SessionSchema::ArrowSchema(s)) => s.serialized_schema.to_vec(), + _ => { + return Err(BQRedisError::Arrow( + "BigQuery Storage session did not return an Arrow schema".into(), + )) + } + }; + + // Parse the Arrow schema from BigQuery's raw schema message. + // StreamReader reads only the schema header, so it works whether or + // not there is a trailing EOS marker in raw_schema_bytes. + let arrow_schema = StreamReader::try_new(Cursor::new(&raw_schema_bytes), None) + .map_err(|e| BQRedisError::Arrow(format!("Failed to parse BQ schema: {e}")))? + .schema(); + + // Build a clean schema-only IPC stream (schema message + EOS). + let mut serialized_schema = Vec::new(); + { + let mut w = StreamWriter::try_new(&mut serialized_schema, &arrow_schema) + .map_err(|e| BQRedisError::Arrow(e.to_string()))?; + w.finish().map_err(|e| BQRedisError::Arrow(e.to_string()))?; + } + + // Prepare schema-without-EOS bytes for building per-batch mini-streams. + const EOS_MARKER: &[u8] = &[0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00]; + let schema_no_eos: &[u8] = if raw_schema_bytes.ends_with(EOS_MARKER) { + &raw_schema_bytes[..raw_schema_bytes.len() - 8] + } else { + &raw_schema_bytes[..] + }; + + // ── Stream record batches ───────────────────────────────────────────── + let mut all_batch_bytes: Vec> = Vec::new(); + let mut page_count = 0usize; + + for stream in &session.streams { + let mut row_stream = streaming_client + .read_rows( + ReadRowsRequest { + read_stream: stream.name.clone(), + offset: 0, + }, + None, + ) + .await + .map_err(|e| BQRedisError::BigQuery(e.to_string()))? + .into_inner(); + + while let Some(response) = row_stream + .message() + .await + .map_err(|e| BQRedisError::BigQuery(e.to_string()))? + { + if let Some(Rows::ArrowRecordBatch(batch)) = response.rows { + all_batch_bytes.push(batch.serialized_record_batch.to_vec()); + page_count += 1; + } + } + } + + tracing::debug!( + "Query returned {page_count} pages in {} streams", + session.streams.len(), + ); + + // ── Build complete Arrow IPC stream ─────────────────────────────────── + // serialized_data is always a complete IPC stream (schema + batches + EOS) + // so that cache_get / to_pyarrow can parse it directly without concatenation. + let mut serialized_data = Vec::new(); + { + let mut writer = StreamWriter::try_new(&mut serialized_data, &arrow_schema) + .map_err(|e| BQRedisError::Arrow(e.to_string()))?; + + for batch_bytes in &all_batch_bytes { + // Each BigQuery serialized_record_batch is a raw IPC record batch + // message without a schema header. Wrap it in a mini-stream + // (schema_no_eos + batch + EOS) so StreamReader can parse it. + let mut mini = Vec::with_capacity(schema_no_eos.len() + batch_bytes.len() + 8); + mini.extend_from_slice(schema_no_eos); + mini.extend_from_slice(batch_bytes); + mini.extend_from_slice(EOS_MARKER); + + let mut mini_reader = StreamReader::try_new(Cursor::new(mini), None) + .map_err(|e| BQRedisError::Arrow(format!("Failed to parse BQ batch: {e}")))?; + if let Some(batch) = mini_reader.next() { + let batch = batch.map_err(|e| BQRedisError::Arrow(e.to_string()))?; + writer + .write(&batch) + .map_err(|e| BQRedisError::Arrow(e.to_string()))?; + } + } + + writer + .finish() + .map_err(|e| BQRedisError::Arrow(e.to_string()))?; + } + + Ok(QueryResult { + query_time, + serialized_schema, + serialized_data, + }) + } + + // ── Redis helpers ───────────────────────────────────────────────────────── + + async fn redis_conn(&self) -> Result { + self.redis + .get_multiplexed_async_connection() + .await + .map_err(|e| BQRedisError::Redis(e.to_string())) + } + + async fn cache_put(&self, key: &str, result: &QueryResult) -> Result<(), BQRedisError> { + let mut conn = self.redis_conn().await?; + let ttl = self.config.cache_ttl_sec; + redis::pipe() + .set_ex( + format!("{key}:schema"), + result.serialized_schema.as_slice(), + ttl, + ) + .set_ex( + format!("{key}:data"), + result.serialized_data.as_slice(), + ttl, + ) + .set_ex( + format!("{key}:query_time"), + result.query_time.to_rfc3339().as_str(), + ttl, + ) + .query_async::<()>(&mut conn) + .await + .map_err(|e| BQRedisError::Redis(e.to_string())) + } + + /// Returns `(result, query_time, needs_background_refresh)` or `None` if + /// there is no usable cached value. + async fn cache_get( + &self, + key: &str, + max_age: Option, + ) -> Result, bool)>, BQRedisError> { + let mut conn = self.redis_conn().await?; + let (data, schema, query_time_str): ( + Option>, + Option>, + Option, + ) = redis::pipe() + .get(format!("{key}:data")) + .get(format!("{key}:schema")) + .get(format!("{key}:query_time")) + .query_async(&mut conn) + .await + .map_err(|e| BQRedisError::Redis(e.to_string()))?; + + let (Some(data), Some(query_time_str)) = (data, query_time_str) else { + return Ok(None); + }; + + let cached_query_time = query_time_str + .parse::>() + .map_err(|e| BQRedisError::Other(e.to_string()))?; + + let age_sec = (Utc::now() - cached_query_time).num_seconds(); + + if max_age == Some(0) || max_age.is_some_and(|ma| age_sec > ma) { + return Ok(None); + } + + let needs_refresh = age_sec > self.config.background_refresh_ttl_sec as i64; + + Ok(Some(( + QueryResult { + query_time: cached_query_time, + serialized_schema: schema.unwrap_or_default(), + serialized_data: data, + }, + cached_query_time, + needs_refresh, + ))) + } + + async fn background_refresh(&self, query: String, key: String) { + let bg_key = format!("{key}:background_refresh"); + let mut conn = match self.redis_conn().await { + Ok(c) => c, + Err(e) => { + tracing::error!("Background refresh: Redis connect failed: {e}"); + return; + } + }; + let already: bool = conn + .exists(&bg_key) + .await + .unwrap_or(false); + if already { + tracing::info!("Background refresh already in progress for key: {key}"); + return; + } + let _: Result<(), _> = conn + .set_ex(&bg_key, 1u8, self.config.background_refresh_ttl_sec) + .await; + + tracing::debug!("Background refreshing cache for key: {key}"); + match self.read_bigquery_bytes(&query).await { + Ok(result) => { + if let Err(e) = self.cache_put(&key, &result).await { + tracing::error!("Background refresh: cache_put failed: {e}"); + } + } + Err(e) => { + tracing::error!("Background refresh for key {key} failed: {e}"); + let _: Result<(), _> = conn.del(&bg_key).await; + return; + } + } + let _: Result<(), _> = conn.del(&bg_key).await; + } + + // ── Top-level query logic ───────────────────────────────────────────────── + + async fn query_inner( + self: Arc, + query: String, + max_age: Option, + ) -> Result<(QueryResult, DateTime), BQRedisError> { + let key = self.query_key(&query); + if let Some((cached, time, needs_refresh)) = self.cache_get(&key, max_age).await? { + tracing::debug!("Using cached result for key: {key}"); + if needs_refresh { + let inner = Arc::clone(&self); + let q = query.clone(); + let k = key.clone(); + tokio::spawn(async move { inner.background_refresh(q, k).await }); + } + return Ok((cached, time)); + } + tracing::debug!("Requesting new execution for key: {key}"); + let result = self + .clone() + .get_or_submit(query, key) + .await + .map_err(|e| (*e).clone())?; + Ok(((*result).clone(), result.query_time)) + } + + async fn clear_cache_inner(&self) -> Result<(), BQRedisError> { + tracing::debug!("Beginning cache clear"); + let mut conn = self.redis_conn().await?; + let keys: Vec = conn + .keys(format!("{}*", self.config.redis_key_prefix)) + .await + .map_err(|e| BQRedisError::Redis(e.to_string()))?; + let count = keys.len(); + if !keys.is_empty() { + conn.del::, ()>(keys) + .await + .map_err(|e| BQRedisError::Redis(e.to_string()))?; + } + // Also clear in-flight requests. + if let Ok(mut inflight) = self.inflight.lock() { + inflight.clear(); + } + tracing::info!("Cleared {count} keys from Redis cache"); + Ok(()) + } + +} + +// ── Python class ───────────────────────────────────────────────────────────── + +/// A Redis-backed cache for BigQuery queries. +/// +/// All I/O (BigQuery and Redis) runs on an owned Tokio runtime without holding +/// the Python GIL. Results are returned as `pyarrow.Table` objects. +/// +/// Authentication uses Application Default Credentials (ADC). Run +/// `gcloud auth application-default login` or set +/// `GOOGLE_APPLICATION_CREDENTIALS` before instantiating. +#[pyclass(module = "bqredis")] +pub struct BQRedis { + rt: Runtime, + inner: Arc, +} + +#[pymethods] +impl BQRedis { + #[new] + #[pyo3(signature = ( + redis_url, + *, + redis_key_prefix = "bigquery_cache:", + redis_cache_ttl_sec = 3600, + redis_background_refresh_ttl_sec = 300, + max_stream_count = None, + ))] + fn new( + redis_url: &str, + redis_key_prefix: &str, + redis_cache_ttl_sec: u64, + redis_background_refresh_ttl_sec: u64, + max_stream_count: Option, + ) -> PyResult { + let rt = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .map_err(|e| PyRuntimeError::new_err(e.to_string()))?; + + let (bq_client, project_id, conn_manager) = rt + .block_on(async { + // Use ADC for the high-level HTTP + gRPC BigQuery client. + let (config, project_id) = ClientConfig::new_with_auth() + .await + .map_err(|e| BQRedisError::BigQuery(e.to_string()))?; + let project_id = project_id.unwrap_or_default(); + let bq_client = Client::new(config) + .await + .map_err(|e| BQRedisError::BigQuery(e.to_string()))?; + + // Build a separate authenticated gRPC connection pool for the + // BigQuery Storage Read API. + let tsp = DefaultTokenSourceProvider::new( + google_cloud_auth::project::Config::default() + .with_audience("https://bigquerystorage.googleapis.com/") + .with_scopes(&[ + "https://www.googleapis.com/auth/bigquery", + "https://www.googleapis.com/auth/cloud-platform", + ]), + ) + .await + .map_err(|e| BQRedisError::BigQuery(e.to_string()))?; + + let conn_manager = ConnectionManager::new( + 1, + "bigquerystorage.googleapis.com", + "https://bigquerystorage.googleapis.com/", + &Environment::GoogleCloud(Box::new(tsp)), + &ConnectionOptions::default(), + ) + .await + .map_err(|e| BQRedisError::BigQuery(format!("gRPC connection error: {e:?}")))?; + + Ok::<_, BQRedisError>((bq_client, project_id, conn_manager)) + }) + .map_err(|e: BQRedisError| PyErr::from(e))?; + + let redis_client = + redis::Client::open(redis_url).map_err(|e| PyRuntimeError::new_err(e.to_string()))?; + + let inner = Arc::new(BQRedisInner { + project_id, + bq_client, + conn_manager: Arc::new(conn_manager), + redis: redis_client, + config: BQRedisConfig { + redis_key_prefix: redis_key_prefix.to_string(), + cache_ttl_sec: redis_cache_ttl_sec, + background_refresh_ttl_sec: redis_background_refresh_ttl_sec, + max_stream_count: max_stream_count.unwrap_or(0), + }, + inflight: Mutex::new(HashMap::new()), + }); + + Ok(BQRedis { rt, inner }) + } + + /// Execute a query, returning a pyarrow.Table (cached result allowed). + #[pyo3(signature = (query, max_age = None))] + fn query_sync( + &self, + py: Python, + query: String, + max_age: Option, + ) -> PyResult> { + let (result, _time) = self.block_on_query(py, query, max_age)?; + result.to_pyarrow(py) + } + + /// Like `query_sync` but also returns the timestamp of when the data was queried. + #[pyo3(signature = (query, max_age = None))] + fn query_sync_with_time( + &self, + py: Python, + query: String, + max_age: Option, + ) -> PyResult<(Py, Py)> { + let (result, time) = self.block_on_query(py, query, max_age)?; + let table = result.to_pyarrow(py)?; + let py_time = Self::datetime_to_python(py, time)?; + Ok((table, py_time)) + } + + /// Return a `concurrent.futures.Future` that resolves to a `pyarrow.Table`. + #[pyo3(signature = (query, max_age = None))] + fn query<'py>( + &self, + py: Python<'py>, + query: String, + max_age: Option, + ) -> PyResult> { + let (fut, fut_ref) = Self::make_python_future(py)?; + let inner = Arc::clone(&self.inner); + self.rt.spawn(async move { + let result = inner.query_inner(query, max_age).await; + Python::attach(|py| { + match result { + Ok((qr, _)) => match qr.to_pyarrow(py) { + Ok(tbl) => { + let _ = fut_ref.call_method1(py, "set_result", (tbl,)); + } + Err(e) => { + let _ = fut_ref.call_method1(py, "set_exception", (e,)); + } + }, + Err(e) => { + let exc = PyRuntimeError::new_err(e.to_string()); + let _ = fut_ref.call_method1(py, "set_exception", (exc,)); + } + } + }); + }); + Ok(fut) + } + + /// Return a `concurrent.futures.Future` that resolves to `(pyarrow.Table, datetime)`. + #[pyo3(signature = (query, max_age = None))] + fn query_with_time<'py>( + &self, + py: Python<'py>, + query: String, + max_age: Option, + ) -> PyResult> { + let (fut, fut_ref) = Self::make_python_future(py)?; + let inner = Arc::clone(&self.inner); + self.rt.spawn(async move { + let result = inner.query_inner(query, max_age).await; + Python::attach(|py| { + match result { + Ok((qr, time)) => { + let tbl = qr.to_pyarrow(py); + let ts = Self::datetime_to_python(py, time); + match (tbl, ts) { + (Ok(t), Ok(ts)) => { + let _ = fut_ref.call_method1(py, "set_result", ((t, ts),)); + } + (Err(e), _) | (_, Err(e)) => { + let _ = fut_ref.call_method1(py, "set_exception", (e,)); + } + } + } + Err(e) => { + let exc = PyRuntimeError::new_err(e.to_string()); + let _ = fut_ref.call_method1(py, "set_exception", (exc,)); + } + } + }); + }); + Ok(fut) + } + + /// Submit a background task that refreshes the cache for `query`. + /// Returns a `concurrent.futures.Future[None]`. + fn submit_background_refresh<'py>( + &self, + py: Python<'py>, + query: String, + ) -> PyResult> { + let (fut, fut_ref) = Self::make_python_future(py)?; + let inner = Arc::clone(&self.inner); + self.rt.spawn(async move { + let key = inner.query_key(&query); + inner.background_refresh(query, key).await; + Python::attach(|py| { + let _ = fut_ref.call_method1(py, "set_result", (py.None(),)); + }); + }); + Ok(fut) + } + + /// Clear the Redis cache synchronously. + fn clear_cache_sync(&self, py: Python) -> PyResult<()> { + py.detach(|| self.rt.block_on(self.inner.clear_cache_inner())) + .map_err(PyErr::from) + } + + /// Clear the Redis cache asynchronously; returns a `concurrent.futures.Future[None]`. + fn clear_cache<'py>(&self, py: Python<'py>) -> PyResult> { + let (fut, fut_ref) = Self::make_python_future(py)?; + let inner = Arc::clone(&self.inner); + self.rt.spawn(async move { + let result = inner.clear_cache_inner().await; + Python::attach(|py| match result { + Ok(()) => { + let _ = fut_ref.call_method1(py, "set_result", (py.None(),)); + } + Err(e) => { + let exc = PyRuntimeError::new_err(e.to_string()); + let _ = fut_ref.call_method1(py, "set_exception", (exc,)); + } + }); + }); + Ok(fut) + } +} + +// ── Private helpers ─────────────────────────────────────────────────────────── + +impl BQRedis { + /// Run `query_inner` synchronously, releasing the GIL while waiting. + fn block_on_query( + &self, + py: Python, + query: String, + max_age: Option, + ) -> PyResult<(QueryResult, DateTime)> { + let inner = Arc::clone(&self.inner); + py.detach(move || { + self.rt + .block_on(inner.query_inner(query, max_age)) + .map_err(PyErr::from) + }) + } + + /// Allocate a `concurrent.futures.Future` and return both the bound Python + /// object and an owned `Py` for use from Rust background tasks. + fn make_python_future<'py>(py: Python<'py>) -> PyResult<(Bound<'py, PyAny>, Py)> { + let fut = py + .import("concurrent.futures")? + .getattr("Future")? + .call0()?; + let owned: Py = fut.clone().unbind(); + Ok((fut, owned)) + } + + /// Convert a `chrono::DateTime` to a Python `datetime.datetime`. + fn datetime_to_python(py: Python, dt: DateTime) -> PyResult> { + let datetime_mod = py.import("datetime")?; + let timezone = datetime_mod.getattr("timezone")?; + let utc = timezone.getattr("utc")?; + let datetime_cls = datetime_mod.getattr("datetime")?; + Ok(datetime_cls + .call_method1( + "fromisoformat", + (dt.to_rfc3339_opts(chrono::SecondsFormat::Micros, true),), + )? + .call_method1("astimezone", (utc,))? + .into()) + } +} + +// ── Module registration ─────────────────────────────────────────────────────── + +#[pymodule] +fn _bqredis(m: &Bound<'_, PyModule>) -> PyResult<()> { + m.add_class::()?; + Ok(()) +} diff --git a/test/bqredis_integration_test.py b/test/bqredis_integration_test.py index a70c7bd..70f4aa0 100644 --- a/test/bqredis_integration_test.py +++ b/test/bqredis_integration_test.py @@ -1,3 +1,10 @@ +"""Integration tests for bqredis. + +Not hermetic - requires: + - Application Default Credentials (gcloud auth application-default login) + - A running Redis server at redis://localhost:6379 +""" + import hashlib import unittest @@ -6,112 +13,113 @@ import bqredis +REDIS_URL = "redis://localhost:6379" + +QUERY = ( + "SELECT alpha_2_code" + " FROM \`bigquery-public-data.country_codes.country_codes\`" + " ORDER BY alpha_3_code DESC LIMIT 3" +) + class TestBQRedisIntegration(unittest.TestCase): - """This test is not hermetic and requires being authenticated with GCP.""" + """End-to-end tests that hit BigQuery and Redis.""" def setUp(self): super().setUp() - self.redis = redis.Redis.from_url("redis://localhost:6379") - self.cache = bqredis.BQRedis(self.redis) - self.query_str = "SELECT alpha_2_code FROM `bigquery-public-data.country_codes.country_codes` ORDER BY alpha_3_code DESC LIMIT 3" - self.expected_record_batch = pa.RecordBatch.from_arrays( - [pa.array(["ZW", "ZM", "ZA"])], names=["alpha_2_code"] - ) - self.expected_table = pa.Table.from_batches([self.expected_record_batch]) - self.expected_bin_schema = self.expected_table.schema.serialize().to_pybytes() - # The data could be compressed in different ways, so we will not actually - # compare binary data directly. We will just ensure that something gets - # stored in redis, and that the data deserialized correctly. - # self.expected_bin_data = pa.compress(self.expected_result.serialize(), "zstd").to_pybytes() + self.redis = redis.Redis.from_url(REDIS_URL) + self.cache = bqredis.BQRedis(REDIS_URL) + self.query_str = QUERY self.query_hash = hashlib.sha256(self.query_str.encode()).hexdigest() + self.expected_table = pa.table({"alpha_2_code": ["ZW", "ZM", "ZA"]}) def tearDown(self): - self.assertEqual(len(self.cache.inflight_requests), 0) self.cache.clear_cache_sync() return super().tearDown() - def assert_not_in_cache(self, key): - self.assertIsNone(self.redis.get(self.cache.redis_key_prefix + key + ":data")) - self.assertIsNone(self.redis.get(self.cache.redis_key_prefix + key + ":schema")) - - def assert_in_cache(self, key): - data: bytes = self.redis.get(self.cache.redis_key_prefix + key + ":data") # type: ignore - schema = self.redis.get(self.cache.redis_key_prefix + key + ":schema") - self.assertIsNotNone(data) - self.assertEqual(schema, self.expected_bin_schema) - schema = pa.ipc.read_schema(pa.BufferReader(schema).read_buffer()) - self.assertEqual( - pa.ipc.read_record_batch(data, schema), self.expected_record_batch - ) + def _key(self, query_hash=None): + h = query_hash or self.query_hash + return "bigquery_cache:" + h + + def assert_not_in_cache(self, query_hash=None): + k = self._key(query_hash) + self.assertIsNone(self.redis.get(k + ":data")) + self.assertIsNone(self.redis.get(k + ":schema")) + + def assert_in_cache(self, query_hash=None): + k = self._key(query_hash) + self.assertIsNotNone(self.redis.get(k + ":data")) + self.assertIsNotNone(self.redis.get(k + ":schema")) def test_execution_end_to_end(self): - self.assert_not_in_cache(self.query_hash) + self.assert_not_in_cache() first_result = self.cache.query_sync(self.query_str) self.assertEqual(len(first_result), 3) self.assertEqual(first_result, self.expected_table) - self.assert_in_cache(self.query_hash) + self.assert_in_cache() second_result = self.cache.query_sync(self.query_str) self.assertEqual(len(second_result), 3) self.assertEqual(second_result, self.expected_table) - self.assert_in_cache(self.query_hash) + self.assert_in_cache() def test_execution_end_to_end_empty_result(self): - query_str = "SELECT alpha_2_code FROM `bigquery-public-data.country_codes.country_codes` WHERE alpha_2_code = 'ZZ'" + query_str = ( + "SELECT alpha_2_code" + " FROM \`bigquery-public-data.country_codes.country_codes\`" + " WHERE alpha_2_code = 'ZZ'" + ) query_hash = hashlib.sha256(query_str.encode()).hexdigest() self.assert_not_in_cache(query_hash) first_result = self.cache.query_sync(query_str) self.assertEqual(len(first_result), 0) - schema = self.redis.get(self.cache.redis_key_prefix + query_hash + ":schema") - self.assertEqual(schema, self.expected_bin_schema) second_result = self.cache.query_sync(query_str) self.assertEqual(len(second_result), 0) - schema = self.redis.get(self.cache.redis_key_prefix + query_hash + ":schema") - self.assertEqual(schema, self.expected_bin_schema) - def test_background_execution(self): - self.assert_not_in_cache(self.query_hash) + def test_background_refresh(self): + self.assert_not_in_cache() self.cache.submit_background_refresh(self.query_str).result() - self.assert_in_cache(self.query_hash) - second_result = self.cache.query_sync(self.query_str) - self.assertEqual(len(second_result), 3) - self.assertEqual(second_result, self.expected_table) - self.assert_in_cache(self.query_hash) + self.assert_in_cache() + result = self.cache.query_sync(self.query_str) + self.assertEqual(len(result), 3) + self.assertEqual(result, self.expected_table) def test_with_failing_query(self): - failing_query = "SELECT nonexistent_col FROM `bigquery-public-data.country_codes.country_codes`" - query_hash = hashlib.sha256(failing_query.encode()).hexdigest() - failing_result = self.cache.query(failing_query) + failing_query = ( + "SELECT nonexistent_col" + " FROM \`bigquery-public-data.country_codes.country_codes\`" + ) + failing_hash = hashlib.sha256(failing_query.encode()).hexdigest() with self.assertRaises(Exception): - failing_result.result() - self.assert_not_in_cache(query_hash) + self.cache.query(failing_query).result() + self.assert_not_in_cache(failing_hash) def test_stream_count_consistency(self): - """Results from no max_streams, 1 stream, and 2 streams should be the same (order may vary).""" - query_str = "SELECT alpha_2_code FROM `bigquery-public-data.country_codes.country_codes`" - - def sorted_column(table: pa.Table) -> list: - return sorted(table.column("alpha_2_code").to_pylist()) - - result_default = bqredis.BQRedis(self.redis).query_sync(query_str) - result_1_stream = bqredis.BQRedis(self.redis, max_stream_count=1).query_sync( - query_str - ) - result_2_streams = bqredis.BQRedis(self.redis, max_stream_count=2).query_sync( - query_str + query_str = ( + "SELECT alpha_2_code" + " FROM \`bigquery-public-data.country_codes.country_codes\`" ) - self.assertEqual(sorted_column(result_default), sorted_column(result_1_stream)) - self.assertEqual(sorted_column(result_default), sorted_column(result_2_streams)) + def sorted_col(t): + return sorted(t.column("alpha_2_code").to_pylist()) + + r0 = bqredis.BQRedis(REDIS_URL).query_sync(query_str) + r1 = bqredis.BQRedis(REDIS_URL, max_stream_count=1).query_sync(query_str) + r2 = bqredis.BQRedis(REDIS_URL, max_stream_count=2).query_sync(query_str) + self.assertEqual(sorted_col(r0), sorted_col(r1)) + self.assertEqual(sorted_col(r0), sorted_col(r2)) def test_multiple_queries(self): - query_str_2 = "SELECT alpha_2_code FROM `bigquery-public-data.country_codes.country_codes` ORDER BY alpha_3_code ASC LIMIT 3" - result1 = self.cache.query(self.query_str) - result2 = self.cache.query(query_str_2) - self.assertEqual(len(result1.result()), 3) - self.assertEqual(result1.result(), self.expected_table) - self.assertEqual(len(result2.result()), 3) - self.assertNotEqual(result2.result(), self.expected_table) + query2 = ( + "SELECT alpha_2_code" + " FROM \`bigquery-public-data.country_codes.country_codes\`" + " ORDER BY alpha_3_code ASC LIMIT 3" + ) + f1 = self.cache.query(self.query_str) + f2 = self.cache.query(query2) + self.assertEqual(len(f1.result()), 3) + self.assertEqual(f1.result(), self.expected_table) + self.assertEqual(len(f2.result()), 3) + self.assertNotEqual(f2.result(), self.expected_table) if __name__ == "__main__": diff --git a/test/bqredis_unit_test.py b/test/bqredis_unit_test.py index f37a6b2..9bf8354 100644 --- a/test/bqredis_unit_test.py +++ b/test/bqredis_unit_test.py @@ -1,241 +1,110 @@ -import concurrent.futures +"""Unit tests for bqredis. + +These tests verify that BQRedis can be imported and that pre-populated Redis +cache data is returned correctly without contacting BigQuery. + +Constructing a BQRedis instance requires Application Default Credentials +(ADC) and a running Redis server. Tests in this file that need a real +BQRedis instance are skipped when credentials or Redis are unavailable. +""" + import datetime import hashlib -import io -import threading -import unittest.mock +import unittest -import fakeredis import pyarrow as pa +import pyarrow.ipc import bqredis +REDIS_URL = "redis://localhost:6379" + -def _query_result(key: str, *result: pa.RecordBatch) -> bqredis._QueryResult: - data = b"".join(r.serialize().to_pybytes() for r in result) - return bqredis._QueryResult( - key=key, - query_time=datetime.datetime.now(datetime.timezone.utc), - serialized_schema=result[0].schema.serialize().to_pybytes(), - serialized_data=io.BytesIO(data), - ) +def _make_ipc_bytes(table: pa.Table) -> tuple[bytes, bytes]: + """Serialize *table* to Arrow IPC stream bytes (schema, data).""" + sink = pa.BufferOutputStream() + writer = pa.ipc.new_stream(sink, table.schema) + for batch in table.to_batches(): + writer.write_batch(batch) + writer.close() + stream_bytes = sink.getvalue().to_pybytes() + # Schema-only IPC (no batches) for the :schema key + schema_sink = pa.BufferOutputStream() + schema_writer = pa.ipc.new_stream(schema_sink, table.schema) + schema_writer.close() + return schema_sink.getvalue().to_pybytes(), stream_bytes -class MockException(Exception): - pass +def _try_make_cache(redis_url=REDIS_URL): + try: + return bqredis.BQRedis(redis_url) + except Exception: + return None -class FakeBigqueryClient: - default_query_job_config = None +class TestBQRedisImport(unittest.TestCase): + """Tests that do not require GCP or Redis.""" - def __init__(self, testcase: unittest.TestCase): - self.test = testcase + def test_module_exports_bqredis(self): + self.assertTrue(hasattr(bqredis, "BQRedis")) - def query(self, *args, **kwargs): - self.test.fail("Failed to mock call to bigquery") + def test_class_is_callable(self): + self.assertTrue(callable(bqredis.BQRedis)) + def test_invalid_redis_url_raises(self): + with self.assertRaises(Exception): + bqredis.BQRedis("not-a-redis-url") + + +class TestBQRedisCaching(unittest.TestCase): + """Tests that exercise the Redis-caching path without calling BigQuery. + + Skipped when a BQRedis instance cannot be constructed (no ADC / no Redis). + """ -class TestBQRedis(unittest.TestCase): def setUp(self): super().setUp() - self.executor = concurrent.futures.ThreadPoolExecutor() - self.redis = fakeredis.FakeStrictRedis() - self.cache = bqredis.BQRedis( - self.redis, - bigquery_client=FakeBigqueryClient(self), # type: ignore - bigquery_storage_client=object(), # type: ignore - executor=self.executor, - ) - self.query_str = "SELECT foo FROM bar;" + self.cache = _try_make_cache() + if self.cache is None: + self.skipTest("Could not construct BQRedis (no ADC or no Redis)") + self.query_str = "SELECT alpha_2_code FROM mock_table" self.query_hash = hashlib.sha256(self.query_str.encode()).hexdigest() + self.key = "bigquery_cache:" + self.query_hash + import redis as _redis + + self.redis = _redis.Redis.from_url(REDIS_URL) def tearDown(self): - self.assertEqual(len(self.cache.inflight_requests), 0) - self.executor.shutdown(wait=False, cancel_futures=True) + self.cache.clear_cache_sync() return super().tearDown() - def mock_execute_query_to_bytes(self) -> unittest.mock.MagicMock: - return unittest.mock.patch.object( # type: ignore - self.cache, "_read_bigquery_bytes" - ) - - def test_check_cache(self): - key = self.cache.redis_key_prefix + self.query_hash - records = pa.RecordBatch.from_arrays( - [pa.array(["ZW", "ZM", "ZA"])], names=["alpha_2_code"] - ) - mock_result = _query_result(key, records) - # With no value set, should not find anything - with unittest.mock.patch.object(self.cache.executor, "submit") as mock_submit: - self.assertEqual( - self.cache._check_redis_cache(self.query_str, key, None), (None, None) - ) - self.assertEqual(mock_submit.call_count, 0) - self.assertEqual( - self.cache._check_redis_cache(self.query_str, key, 10), (None, None) - ) - self.assertEqual(mock_submit.call_count, 0) - self.assertEqual( - self.cache._check_redis_cache(self.query_str, key, 0), (None, None) - ) - self.assertEqual(mock_submit.call_count, 0) - ft = concurrent.futures.Future() - ft.set_result(mock_result) - self.cache._cache_put_callback(ft) - with unittest.mock.patch.object(self.cache.executor, "submit") as mock_submit: - # A fresh result should get returned, with no cache refresh - self.assertEqual( - self.cache._check_redis_cache(self.query_str, key, None), - (pa.Table.from_batches([records]), mock_result.query_time), - ) - self.assertEqual(mock_submit.call_count, 0) - self.assertEqual( - self.cache._check_redis_cache(self.query_str, key, 1), - (pa.Table.from_batches([records]), mock_result.query_time), - ) - self.assertEqual(mock_submit.call_count, 0) - - # Data is close to expiring - only 10 seconds left. Its age is now mocked as 3600 - 10 - about_to_expire = datetime.datetime.now( - datetime.timezone.utc - ) - datetime.timedelta(seconds=3590) - self.cache.redis_client.set( - key + ":query_time", about_to_expire.isoformat() - ) - self.assertEqual( - self.cache._check_redis_cache(self.query_str, key, None), - (pa.Table.from_batches([records]), about_to_expire), - ) - self.assertEqual(mock_submit.call_count, 1) - # Requesting a fresh result does not find anything, and does not schedule a background - # refresh because the main execution will be used to fill the cache. - self.assertEqual( - self.cache._check_redis_cache(self.query_str, key, 1), (None, None) - ) - self.assertEqual(mock_submit.call_count, 1) - self.assertEqual( - self.cache._check_redis_cache(self.query_str, key, 0), (None, None) - ) - self.assertEqual(mock_submit.call_count, 1) - - def test_multiple_streams(self): - key = self.cache.redis_key_prefix + self.query_hash - records = pa.RecordBatch.from_arrays( - [pa.array(["ZW", "ZM", "ZA"])], names=["alpha_2_code"] - ) - mock_result = _query_result(key, records, records) - with unittest.mock.patch.object( - self.cache, "_read_bigquery_bytes", return_value=mock_result - ) as execution_mock: - self.assertEqual(execution_mock.call_count, 0) - result = self.cache.query_sync(self.query_str) - self.assertEqual(execution_mock.call_count, 1) - self.assertEqual(len(result), 6) - second_result = self.cache.query_sync(self.query_str) - self.assertEqual(execution_mock.call_count, 1) - self.assertEqual(len(second_result), 6) - - def test_execution_called_only_once_with_cache(self): - key = self.cache.redis_key_prefix + self.query_hash - expected_result = pa.RecordBatch.from_arrays( - [pa.array(["ZW", "ZM", "ZA"])], names=["alpha_2_code"] - ) - with self.mock_execute_query_to_bytes() as execution_mock: - execution_mock.return_value = _query_result(key, expected_result) - self.assertEqual(execution_mock.call_count, 0) - result = self.cache.query_sync_with_time(self.query_str) - self.assertEqual(len(result), 2) - self.assertEqual(result[0], pa.Table.from_batches([expected_result])) - self.assertEqual(result[1], execution_mock.return_value.query_time) - execution_mock.assert_called_once_with(self.query_str, key, False) - self.assertEqual(execution_mock.call_count, 1) - second_result = self.cache.query_sync(self.query_str) - self.assertEqual(second_result, pa.Table.from_batches([expected_result])) - self.assertEqual(execution_mock.call_count, 1) - - def test_execution_called_only_once_with_cache_empty_result(self): - key = self.cache.redis_key_prefix + self.query_hash - returned_bytes = _query_result( - key, pa.RecordBatch.from_arrays([pa.array([])], names=["alpha_2_code"]) - ) - # Sometimes, we actually just end up with an empty set of bytes. - returned_bytes.serialized_data = io.BytesIO(b"") - with unittest.mock.patch.object( - self.cache, "_read_bigquery_bytes", return_value=returned_bytes - ) as execution_mock: - self.assertEqual(execution_mock.call_count, 0) - result = self.cache.query_sync(self.query_str) - self.assertEqual(len(result), 0) - execution_mock.assert_called_once_with(self.query_str, key, False) - self.assertEqual(execution_mock.call_count, 1) - second_result = self.cache.query_sync(self.query_str) - self.assertEqual(len(second_result), 0) - self.assertEqual(execution_mock.call_count, 1) - - def test_execution_failure(self): - key = self.cache.redis_key_prefix + self.query_hash - with self.mock_execute_query_to_bytes() as execution_mock: - execution_mock.side_effect = MockException("BigQuery error") - self.assertEqual(execution_mock.call_count, 0) - with self.assertRaises(MockException): - self.cache.query(self.query_str).result(timeout=1) - execution_mock.assert_called_once_with(self.query_str, key, False) - self.assertEqual(execution_mock.call_count, 1) - with self.assertRaises(MockException): - self.cache.query(self.query_str).result(timeout=1) - self.assertEqual(execution_mock.call_count, 2) - - def test_max_stream_count_default(self): - """Test that max_stream_count defaults to None and passes 0 to create_read_session.""" - self.assertIsNone(self.cache.max_stream_count) - - def test_max_stream_count_custom(self): - """Test that a custom max_stream_count is stored and used.""" - cache = bqredis.BQRedis( - self.redis, - bigquery_client=FakeBigqueryClient(self), # type: ignore - bigquery_storage_client=object(), # type: ignore - executor=self.executor, - max_stream_count=4, - ) - self.assertEqual(cache.max_stream_count, 4) - - def test_executor_exhaustion(self): - self.executor.shutdown(wait=False) - self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) - self.cache.executor = self.executor - query_strs = [f"SELECT foo{i} FROM bar;" for i in range(100)] - keys = { - self.cache.redis_key_prefix + hashlib.sha256(query.encode()).hexdigest() - for query in query_strs - } - - expected_result = pa.RecordBatch.from_arrays( - [pa.array(["ZW", "ZM", "ZA"])], names=["alpha_2_code"] - ) - block = threading.Lock() - - def _mock_query_executor( - query: str, key: str, background: bool - ) -> bqredis._QueryResult: - nonlocal block - with block: - if key in keys: - return _query_result(key, expected_result) - raise KeyError(key) - - with self.mock_execute_query_to_bytes() as execution_mock: - block.acquire(timeout=1) - execution_mock.side_effect = _mock_query_executor - self.assertEqual(execution_mock.call_count, 0) - queries = [self.cache.query(query_str) for query_str in query_strs] - # Allow the functions to proceed without enough threads in the threadpool - block.release() - for i, query in enumerate(queries): - self.assertEqual( - query.result(timeout=1), pa.Table.from_batches([expected_result]) - ) - self.assertEqual(execution_mock.call_count, len(query_strs)) + def _populate_cache(self, table: pa.Table): + schema_bytes, stream_bytes = _make_ipc_bytes(table) + now = datetime.datetime.now(datetime.timezone.utc) + self.redis.set(self.key + ":schema", schema_bytes) + self.redis.set(self.key + ":data", stream_bytes) + self.redis.set(self.key + ":query_time", now.isoformat()) + + def test_returns_cached_table(self): + table = pa.table({"alpha_2_code": ["ZW", "ZM", "ZA"]}) + self._populate_cache(table) + result = self.cache.query_sync(self.query_str) + self.assertEqual(result.num_rows, 3) + self.assertEqual(result.column("alpha_2_code").to_pylist(), ["ZW", "ZM", "ZA"]) + + def test_returns_cached_table_with_time(self): + table = pa.table({"alpha_2_code": ["ZW", "ZM", "ZA"]}) + self._populate_cache(table) + result, ts = self.cache.query_sync_with_time(self.query_str) + self.assertEqual(result.num_rows, 3) + self.assertIsInstance(ts, datetime.datetime) + + def test_clear_cache_removes_entries(self): + table = pa.table({"x": [1, 2, 3]}) + self._populate_cache(table) + self.assertIsNotNone(self.redis.get(self.key + ":schema")) + self.cache.clear_cache_sync() + self.assertIsNone(self.redis.get(self.key + ":schema")) if __name__ == "__main__":