MCPcopy Index your code
hub / github.com/alecmocatta/streaming_algorithms

github.com/alecmocatta/streaming_algorithms @v0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.0 ↗ · + Follow
160 symbols 350 edges 9 files 22 documented · 14%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

streaming_algorithms

Crates.io MIT / Apache 2.0 licensed Build Status

📖 Docs | 💬 Chat

SIMD-accelerated implementations of various streaming algorithms.

This library is a work in progress. PRs are very welcome! Currently implemented algorithms include:

  • Count–min sketch
  • Top k (Count–min sketch plus a doubly linked hashmap to track heavy hitters / top k keys when ordered by aggregated value)
  • HyperLogLog
  • Reservoir sampling

A goal of this library is to enable composition of these algorithms; for example Top k + HyperLogLog to enable an approximate version of something akin to SELECT key FROM table GROUP BY key ORDER BY COUNT(DISTINCT value) DESC LIMIT k.

Run your application with RUSTFLAGS="-C target-cpu=native" and the nightly feature to benefit from the SIMD-acceleration like so:

RUSTFLAGS="-C target-cpu=native" cargo run --features "streaming_algorithms/nightly" --release

See this gist for a good list of further algorithms to be implemented. Other resources are Probabilistic data structures – Wikipedia, DataSketches – A similar Java library originating at Yahoo, and Algebird – A similar Java library originating at Twitter.

As these implementations are often in hot code paths, unsafe is used, albeit only when necessary to a) achieve the asymptotically optimal algorithm or b) mitigate an observed bottleneck.

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE.txt or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT.txt or http://opensource.org/licenses/MIT)

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Extension points exported contracts — how you extend this code

UnionAssign (Interface)
Union `Self` with `Rhs` in place. [9 implementers]
src/traits.rs
Intersect (Interface)
Intersect zero or more `&Self` to create `Option `. [8 implementers]
src/traits.rs
New (Interface)
New instances are instantiable given a specified input of ` ::Config`. [8 implementers]
src/traits.rs
IntersectPlusUnionIsPlus (Interface)
An optimisation for cases like putting a HyperLogLog inside a Count–min sketch, where intersecting, adding a val, and th [3 …
src/traits.rs

Core symbols most depended-on inside this repo

len
called by 26
src/distinct.rs
iter
called by 10
src/top.rs
assert
called by 10
src/linked_list.rs
capacity
called by 9
src/sample.rs
clone
called by 8
src/top.rs
usize_to_f64
called by 7
src/lib.rs
assert
called by 7
src/ordered_linked_list.rs
staticify
called by 6
src/ordered_linked_list.rs

Shape

Method 118
Function 20
Class 18
Interface 4

Languages

Rust100%

Modules by API surface

src/distinct.rs29 symbols
src/ordered_linked_list.rs27 symbols
src/linked_list.rs27 symbols
src/top.rs24 symbols
src/sample.rs21 symbols
src/count_min.rs18 symbols
src/traits.rs7 symbols
src/lib.rs4 symbols
src/distinct/consts.rs3 symbols

For agents

$ claude mcp add streaming_algorithms \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page