MoonBit Binary Fuse filters with deterministic bounded construction
let filter = @fuse.BinaryFuseFilter::build([101, 202, 303]).unwrap()
assert_true(filter.contains(202))
assert_false(filter.contains(404)) // a miss is expected, but not guaranteedmoon check --deny-warn
moon test --deny-warn
moon run cmd/demopub struct BinaryFuseFilter {
key_count : Int
segment_length : Int
segment_count : Int
seed : Int
attempts : Int
fingerprint_bits : Int
fingerprints : Array[Int]
}fn BinaryFuseFilter::build_with_options(hashes : Array[Int], options : BuildOptions) -> Result[BinaryFuseFilter, FuseError]fn BinaryFuseFilter::classify(self : BinaryFuseFilter, hashes : Array[Int]) -> Array[MembershipResult]fn BinaryFuseFilter::evaluate(self : BinaryFuseFilter, source_hashes : Array[Int], probes : Array[Int]) -> Result[QualityReport, FuseError]pub(all) struct BuildOptions {
fingerprint_bits : Int
max_attempts : Int
initial_seed : Int
}pub(all) struct BuildStats {
key_count : Int
array_length : Int
segment_length : Int
segment_count : Int
seed : Int
attempts : Int
fingerprint_bits : Int
}pub(all) struct EpochMapStats {
epoch_count : Int
entry_count : Int
first_epoch : Int
last_epoch : Int
}fn EpochStaticIntMap::build(entries : Array[EpochFuseValue]) -> Result[EpochStaticIntMap, FuseError]pub(all) struct EpochStats {
epoch_count : Int
key_count : Int
first_epoch : Int
last_epoch : Int
}pub(all) struct FingerprintStats {
slot_count : Int
occupied_slots : Int
empty_slots : Int
maximum_fingerprint : Int
fingerprint_sum : Int
}pub(all) enum FuseError {
EmptyInput
NegativeHash(Int)
DuplicateHash(Int)
InvalidFingerprintBits(Int)
InvalidAttempts(Int)
InvalidShardCount(Int)
InvalidTag(Int)
ConflictingValue(Int)
DuplicateString(String)
ConstructionFailed(Int)
InvalidEncoding
UnsupportedVersion(Int)
}pub struct FuseOverlay {
base : VerifiedFuseFilter
additions : VerifiedFuseFilter?
removals : VerifiedFuseFilter?
}fn FuseOverlay::from_patch(base : VerifiedFuseFilter, patch : FusePatch) -> Result[FuseOverlay, FuseError]pub(all) struct MapMergeStats {
left_only_count : Int
right_only_count : Int
shared_count : Int
conflicting_count : Int
}pub(all) struct OverlayStats {
base_key_count : Int
addition_count : Int
removal_count : Int
}pub(all) struct QualityReport {
source_count : Int
probe_count : Int
false_negative_count : Int
false_positive_count : Int
negative_probe_count : Int
}pub(all) struct QuerySummary {
query_count : Int
positive_count : Int
negative_count : Int
}pub(all) struct ShardStats {
shard_count : Int
key_count : Int
populated_shards : Int
smallest_shard : Int
largest_shard : Int
}fn ShardedFuseFilter::build(hashes : Array[Int], shard_count : Int) -> Result[ShardedFuseFilter, FuseError]fn ShardedFuseFilter::build_with_options(hashes : Array[Int], shard_count : Int, options : BuildOptions) -> Result[ShardedFuseFilter, FuseError]fn SnapshotDiff::apply_to(self : SnapshotDiff, source : VerifiedFuseFilter) -> Result[VerifiedFuseFilter, FuseError]fn StaticIntMap::difference(self : StaticIntMap, other : StaticIntMap) -> Result[StaticIntMap, FuseError]fn StaticIntMap::entries_before(self : StaticIntMap, first_key : Int, limit : Int) -> Array[FuseValue]fn StaticIntMap::entries_from(self : StaticIntMap, first_key : Int, limit : Int) -> Array[FuseValue]fn StaticIntMap::entries_inclusive(self : StaticIntMap, first_key : Int, last_key : Int) -> Array[FuseValue]fn StaticIntMap::intersection(self : StaticIntMap, other : StaticIntMap, policy : MapMergePolicy) -> Result[StaticIntMap, FuseError]fn StaticIntMap::merge(self : StaticIntMap, other : StaticIntMap, policy : MapMergePolicy) -> Result[StaticIntMap, FuseError]fn StaticIntMap::with_updates(self : StaticIntMap, updates : Array[FuseValue]) -> Result[StaticIntMap, FuseError]fn StaticIntMap::without_keys(self : StaticIntMap, hashes : Array[Int]) -> Result[StaticIntMap, FuseError]fn StaticStringMap::entries_before(self : StaticStringMap, first_key : String, limit : Int) -> Array[StringFuseValue]fn StaticStringMap::entries_between(self : StaticStringMap, first_key : String, last_key : String) -> Array[StringFuseValue]fn StaticStringMap::entries_from(self : StaticStringMap, first_key : String, limit : Int) -> Array[StringFuseValue]fn StaticStringMap::with_updates(self : StaticStringMap, updates : Array[StringFuseValue]) -> Result[StaticStringMap, FuseError]fn StaticStringMap::without_keys(self : StaticStringMap, keys : Array[String]) -> Result[StaticStringMap, FuseError]pub(all) struct StringMapStats {
entry_count : Int
shortest_key_length : Int
longest_key_length : Int
}pub(all) struct TagStats {
tag_count : Int
key_count : Int
smallest_tag : Int
largest_tag : Int
}fn VerifiedFuseFilter::apply_patch(self : VerifiedFuseFilter, patch : FusePatch) -> Result[VerifiedFuseFilter, FuseError]fn VerifiedFuseFilter::classify_exact(self : VerifiedFuseFilter, hashes : Array[Int]) -> Array[ExactMembershipResult]fn VerifiedFuseFilter::difference(self : VerifiedFuseFilter, other : VerifiedFuseFilter) -> Result[VerifiedFuseFilter, FuseError]fn VerifiedFuseFilter::intersection(self : VerifiedFuseFilter, other : VerifiedFuseFilter) -> Result[VerifiedFuseFilter, FuseError]fn VerifiedFuseFilter::symmetric_difference(self : VerifiedFuseFilter, other : VerifiedFuseFilter) -> Result[VerifiedFuseFilter, FuseError]fn VerifiedFuseFilter::union(self : VerifiedFuseFilter, other : VerifiedFuseFilter) -> Result[VerifiedFuseFilter, FuseError]Install
Download zipMoonBit Binary Fuse filters with deterministic bounded construction