|
35 | 35 | [actions-badge]: https://github.com/apache/datasketches-rust/actions/workflows/ci.yml/badge.svg |
36 | 36 | [actions-url]: https://github.com/apache/datasketches-rust/actions/workflows/ci.yml |
37 | 37 |
|
38 | | -This is the core Rust component of the DataSketches library. It contains a subset of the sketching algorithms and can be accessed directly from user applications. |
| 38 | +Apache DataSketches Rust provides stochastic streaming algorithms for answering queries over large data sets with compact, mergeable summaries. It is the core Rust component of Apache DataSketches and currently implements a subset of the algorithms available in the other language components. |
39 | 39 |
|
40 | | -Note that we have parallel core library components for Java, C++, Python, and Go implementations of many of the same sketch algorithms: |
| 40 | +## Getting started |
41 | 41 |
|
42 | | -- [datasketches-java](https://github.com/apache/datasketches-java) |
43 | | -- [datasketches-cpp](https://github.com/apache/datasketches-cpp) |
44 | | -- [datasketches-python](https://github.com/apache/datasketches-python) |
45 | | -- [datasketches-go](https://github.com/apache/datasketches-go) |
| 42 | +Sketch implementations are opt-in Cargo features; the crate enables none by default. For example, add the HyperLogLog implementation with: |
46 | 43 |
|
47 | | -Please visit the main [DataSketches website](https://datasketches.apache.org) for more information. |
| 44 | +```shell |
| 45 | +cargo add datasketches --features hll |
| 46 | +``` |
48 | 47 |
|
49 | | -If you are interested in making contributions to this site, please see our [Community](https://datasketches.apache.org/docs/Community/) page for how to contact us. |
| 48 | +Then build a sketch and query its distinct-count estimate: |
| 49 | + |
| 50 | +```rust |
| 51 | +use datasketches::hll::HllSketch; |
| 52 | +use datasketches::hll::HllType; |
| 53 | + |
| 54 | +let mut sketch = HllSketch::new(12, HllType::Hll8); |
| 55 | +for user in ["alice", "bob", "alice", "carol"] { |
| 56 | + sketch.update(user); |
| 57 | +} |
| 58 | + |
| 59 | +assert!(sketch.estimate() >= 3.0); |
| 60 | +``` |
| 61 | + |
| 62 | +Enable multiple algorithms by listing their features together, such as `features = ["hll", "theta"]` in `Cargo.toml`. |
| 63 | + |
| 64 | +## Available sketches |
| 65 | + |
| 66 | +| Feature | Main types | Use case | |
| 67 | +| --- | --- | --- | |
| 68 | +| `bloom` | `BloomFilter` | Space-efficient probabilistic set membership with a configurable false-positive rate. | |
| 69 | +| `countmin` | `CountMinSketch` | Approximate point-frequency queries over a stream. | |
| 70 | +| `cpc` | `CpcSketch`, `CpcUnion`, `CpcWrapper` | Highly compact distinct-count estimation and unions. | |
| 71 | +| `frequencies` | `FrequentItemsSketch` | Heavy-hitter discovery with upper and lower frequency bounds. | |
| 72 | +| `hll` | `HllSketch`, `HllUnion` | Fast distinct-count estimation and unions. | |
| 73 | +| `tdigest` | `TDigestMut`, `TDigest` | Quantile and rank estimation, with high accuracy near distribution tails. | |
| 74 | +| `theta` | `ThetaSketch` and set operations | Distinct counts, set expressions, and Jaccard similarity. | |
| 75 | +| `tuple` | `TupleSketch` and set operations | Theta-style keys with user-defined summaries attached to retained entries. | |
| 76 | + |
| 77 | +See the [API documentation](https://docs.rs/datasketches) for configuration, accuracy guarantees, serialization, and examples for each algorithm. |
| 78 | + |
| 79 | +## Compatibility |
| 80 | + |
| 81 | +The minimum supported Rust version is 1.86.0. The crate currently supports little-endian targets only. |
| 82 | + |
| 83 | +Supported serialization formats are tested with fixtures produced by Apache DataSketches Java, C++, and Go through the [DataSketches TCK](https://github.com/apache/datasketches-tck). When values must hash identically across language implementations, use the compatibility wrappers in `hash::value`. |
| 84 | + |
| 85 | +See the [changelog](CHANGELOG.md) for release notes and migration guidance. |
| 86 | + |
| 87 | +## Other language implementations |
| 88 | + |
| 89 | +Apache DataSketches also provides core library components for other languages: |
| 90 | + |
| 91 | +- [Java](https://github.com/apache/datasketches-java) |
| 92 | +- [C++](https://github.com/apache/datasketches-cpp) |
| 93 | +- [Python](https://github.com/apache/datasketches-python) |
| 94 | +- [Go](https://github.com/apache/datasketches-go) |
| 95 | + |
| 96 | +Visit the [Apache DataSketches website](https://datasketches.apache.org) for algorithm documentation, research background, and project-wide resources. |
| 97 | + |
| 98 | +## Community and contributing |
| 99 | + |
| 100 | +Questions, bug reports, and feature requests are welcome through [GitHub issues](https://github.com/apache/datasketches-rust/issues) and [GitHub discussions](https://github.com/apache/datasketches-rust/discussions). The [Apache DataSketches community page](https://datasketches.apache.org/docs/Community/) lists the public mailing lists and other ways to participate. |
| 101 | + |
| 102 | +See [CONTRIBUTING.md](CONTRIBUTING.md) to build, test, and contribute to the Rust component. All project participation is governed by the [Apache Software Foundation Code of Conduct](https://www.apache.org/foundation/policies/conduct.html). |
| 103 | + |
| 104 | +To report a security vulnerability, follow the [ASF security reporting process](https://www.apache.org/security/) instead of opening a public issue. |
| 105 | + |
| 106 | +## License |
| 107 | + |
| 108 | +Licensed under the [Apache License, Version 2.0](LICENSE). |
0 commit comments