ExDataSketch.Backend.Rust (ExDataSketch v0.7.1)

Copy Markdown View Source

Rust NIF-accelerated backend for ExDataSketch.

Delegates batch and full-state traversal operations to Rust NIFs for performance, while falling back to ExDataSketch.Backend.Pure for lightweight operations like new, single update, and point queries.

Availability

This backend is only available when the Rust NIF has been compiled. Check with ExDataSketch.Backend.Rust.available?/0.

Dirty Scheduler Thresholds

Batch operations automatically use dirty CPU schedulers when the input size exceeds configurable thresholds. Defaults:

  • hll_update_many: 10,000 hashes
  • ull_update_many: 10,000 hashes
  • ull_merge: 50,000 registers (m = 2^p)
  • ull_estimate: 50,000 registers (m = 2^p)
  • cms_update_many: 10,000 pairs
  • theta_update_many: 10,000 hashes
  • cms_merge: 100,000 total counters
  • theta_compact: 50,000 entries
  • theta_merge: 50,000 combined entries
  • kll_update_many: 10,000 values
  • kll_merge: 50,000 combined items
  • ddsketch_update_many: 10,000 values
  • ddsketch_merge: 50,000 combined count
  • fi_update_many: 10,000 items
  • fi_merge: 50,000 combined entries
  • fi_nif_query: 256 (k threshold for fi_top_k/fi_estimate; below this, Pure is used)

Override globally via application config:

config :ex_data_sketch, :dirty_thresholds, %{
  hll_update_many: 5_000,
  cms_update_many: 20_000
}

Or per-call via the :dirty_threshold option.

Summary

Functions

available?()

@spec available?() :: boolean()

Returns true if the Rust NIF is loaded and available.

Examples

iex> is_boolean(ExDataSketch.Backend.Rust.available?())
true

cms_update_many_raw(state_bin, items, opts)

hll_update_many_raw(state_bin, items, opts)

theta_update_many_raw(state_bin, items, opts)

ull_update_many_raw(state_bin, items, opts)