This is an automated email from the ASF dual-hosted git repository. tisonkun pushed a commit to branch feature-flag in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
commit 46df9753864eb3c001cb4bf54dada3c54533297f Author: tison <[email protected]> AuthorDate: Sat May 9 14:15:29 2026 +0800 refactor: gate sketches with feature flags Signed-off-by: tison <[email protected]> --- datasketches/Cargo.toml | 10 ++++++++++ datasketches/src/lib.rs | 14 ++++++++++++++ datasketches/tests/bloom_serialization_test.rs | 2 ++ datasketches/tests/countmin_test.rs | 2 ++ datasketches/tests/cpc_serialization_test.rs | 2 ++ datasketches/tests/cpc_union_test.rs | 2 ++ datasketches/tests/cpc_update_test.rs | 2 ++ datasketches/tests/cpc_wrapper_test.rs | 2 ++ datasketches/tests/frequencies_serialization_test.rs | 2 ++ datasketches/tests/frequencies_update_test.rs | 2 ++ datasketches/tests/hll_serialization_test.rs | 2 ++ datasketches/tests/hll_union_test.rs | 2 ++ datasketches/tests/hll_update_test.rs | 2 ++ datasketches/tests/tdigest_serialization_test.rs | 2 ++ datasketches/tests/tdigest_test.rs | 2 ++ datasketches/tests/theta_intersection_test.rs | 2 ++ datasketches/tests/theta_serialization_test.rs | 2 ++ datasketches/tests/theta_sketch_test.rs | 2 ++ 18 files changed, 56 insertions(+) diff --git a/datasketches/Cargo.toml b/datasketches/Cargo.toml index 214288e..ba79372 100644 --- a/datasketches/Cargo.toml +++ b/datasketches/Cargo.toml @@ -34,6 +34,16 @@ keywords = ["sketch", "hyperloglog", "probabilistic"] all-features = true rustdoc-args = ["--cfg", "docsrs"] +[features] +default = [] +bloom = [] +countmin = [] +cpc = [] +frequencies = [] +hll = [] +tdigest = [] +theta = [] + [dev-dependencies] googletest = { workspace = true } insta = { workspace = true } diff --git a/datasketches/src/lib.rs b/datasketches/src/lib.rs index 33ea2f8..0bd9d1f 100644 --- a/datasketches/src/lib.rs +++ b/datasketches/src/lib.rs @@ -30,16 +30,30 @@ #[cfg(target_endian = "big")] compile_error!("datasketches does not support big-endian targets"); +#[cfg(feature = "bloom")] +#[cfg_attr(docsrs, doc(cfg(feature = "bloom")))] pub mod bloom; pub mod codec; pub mod common; +#[cfg(feature = "countmin")] +#[cfg_attr(docsrs, doc(cfg(feature = "countmin")))] pub mod countmin; +#[cfg(feature = "cpc")] +#[cfg_attr(docsrs, doc(cfg(feature = "cpc")))] pub mod cpc; pub mod error; +#[cfg(feature = "frequencies")] +#[cfg_attr(docsrs, doc(cfg(feature = "frequencies")))] pub mod frequencies; pub mod hash_value; +#[cfg(feature = "hll")] +#[cfg_attr(docsrs, doc(cfg(feature = "hll")))] pub mod hll; +#[cfg(feature = "tdigest")] +#[cfg_attr(docsrs, doc(cfg(feature = "tdigest")))] pub mod tdigest; +#[cfg(feature = "theta")] +#[cfg_attr(docsrs, doc(cfg(feature = "theta")))] pub mod theta; mod hash; diff --git a/datasketches/tests/bloom_serialization_test.rs b/datasketches/tests/bloom_serialization_test.rs index 15daba2..f096679 100644 --- a/datasketches/tests/bloom_serialization_test.rs +++ b/datasketches/tests/bloom_serialization_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "bloom")] + mod common; use std::fs; diff --git a/datasketches/tests/countmin_test.rs b/datasketches/tests/countmin_test.rs index dddc72c..a8681e4 100644 --- a/datasketches/tests/countmin_test.rs +++ b/datasketches/tests/countmin_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "countmin")] + use datasketches::countmin::CountMinSketch; #[test] diff --git a/datasketches/tests/cpc_serialization_test.rs b/datasketches/tests/cpc_serialization_test.rs index bbcb56e..85b749a 100644 --- a/datasketches/tests/cpc_serialization_test.rs +++ b/datasketches/tests/cpc_serialization_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "cpc")] + mod common; use std::fs; diff --git a/datasketches/tests/cpc_union_test.rs b/datasketches/tests/cpc_union_test.rs index 36badbd..5bc3b18 100644 --- a/datasketches/tests/cpc_union_test.rs +++ b/datasketches/tests/cpc_union_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "cpc")] + use datasketches::cpc::CpcSketch; use datasketches::cpc::CpcUnion; use googletest::assert_that; diff --git a/datasketches/tests/cpc_update_test.rs b/datasketches/tests/cpc_update_test.rs index 7b814f7..8e78995 100644 --- a/datasketches/tests/cpc_update_test.rs +++ b/datasketches/tests/cpc_update_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "cpc")] + use datasketches::common::NumStdDev; use datasketches::cpc::CpcSketch; use googletest::assert_that; diff --git a/datasketches/tests/cpc_wrapper_test.rs b/datasketches/tests/cpc_wrapper_test.rs index 6355ed0..4545e20 100644 --- a/datasketches/tests/cpc_wrapper_test.rs +++ b/datasketches/tests/cpc_wrapper_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "cpc")] + use datasketches::common::NumStdDev; use datasketches::cpc::CpcSketch; use datasketches::cpc::CpcUnion; diff --git a/datasketches/tests/frequencies_serialization_test.rs b/datasketches/tests/frequencies_serialization_test.rs index f8d95bc..fd82761 100644 --- a/datasketches/tests/frequencies_serialization_test.rs +++ b/datasketches/tests/frequencies_serialization_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "frequencies")] + mod common; use std::fs; diff --git a/datasketches/tests/frequencies_update_test.rs b/datasketches/tests/frequencies_update_test.rs index a5a98e1..f15f219 100644 --- a/datasketches/tests/frequencies_update_test.rs +++ b/datasketches/tests/frequencies_update_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "frequencies")] + use datasketches::frequencies::ErrorType; use datasketches::frequencies::FrequentItemsSketch; diff --git a/datasketches/tests/hll_serialization_test.rs b/datasketches/tests/hll_serialization_test.rs index 4f7291b..c3f9d97 100644 --- a/datasketches/tests/hll_serialization_test.rs +++ b/datasketches/tests/hll_serialization_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "hll")] + mod common; use std::fs; diff --git a/datasketches/tests/hll_union_test.rs b/datasketches/tests/hll_union_test.rs index 91080bf..5bc3bb8 100644 --- a/datasketches/tests/hll_union_test.rs +++ b/datasketches/tests/hll_union_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "hll")] + //! HyperLogLog Union Integration Tests //! //! These tests verify the public API behavior of HllUnion, focusing on: diff --git a/datasketches/tests/hll_update_test.rs b/datasketches/tests/hll_update_test.rs index e72c6fc..0b0d611 100644 --- a/datasketches/tests/hll_update_test.rs +++ b/datasketches/tests/hll_update_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "hll")] + use datasketches::common::NumStdDev; use datasketches::hll::HllSketch; use datasketches::hll::HllType; diff --git a/datasketches/tests/tdigest_serialization_test.rs b/datasketches/tests/tdigest_serialization_test.rs index 18f58ce..d52983e 100644 --- a/datasketches/tests/tdigest_serialization_test.rs +++ b/datasketches/tests/tdigest_serialization_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "tdigest")] + mod common; use std::fs; diff --git a/datasketches/tests/tdigest_test.rs b/datasketches/tests/tdigest_test.rs index b61d779..cce2130 100644 --- a/datasketches/tests/tdigest_test.rs +++ b/datasketches/tests/tdigest_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "tdigest")] + use datasketches::tdigest::TDigestMut; use googletest::assert_that; use googletest::prelude::eq; diff --git a/datasketches/tests/theta_intersection_test.rs b/datasketches/tests/theta_intersection_test.rs index 4959529..9b98062 100644 --- a/datasketches/tests/theta_intersection_test.rs +++ b/datasketches/tests/theta_intersection_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "theta")] + use datasketches::theta::CompactThetaSketch; use datasketches::theta::ThetaIntersection; use datasketches::theta::ThetaSketch; diff --git a/datasketches/tests/theta_serialization_test.rs b/datasketches/tests/theta_serialization_test.rs index fd07d51..48c1c12 100644 --- a/datasketches/tests/theta_serialization_test.rs +++ b/datasketches/tests/theta_serialization_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "theta")] + mod common; use std::fs; diff --git a/datasketches/tests/theta_sketch_test.rs b/datasketches/tests/theta_sketch_test.rs index 28448c2..55664ef 100644 --- a/datasketches/tests/theta_sketch_test.rs +++ b/datasketches/tests/theta_sketch_test.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![cfg(feature = "theta")] + use datasketches::common::NumStdDev; use datasketches::hash_value; use datasketches::theta::ThetaSketch; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
