Skip to content

Step 4: Sketch Module #182

@thanos

Description

@thanos

Step 4: Sketch Module

Create lib/ex_data_sketch/ull.ex

Follow exact HLL pattern:

  • defstruct [:state, :opts, :backend]
  • new/1 with :p option (default 14, range 4..26 -- ULL supports higher p than HLL)
  • update/2 -- Hash.hash64/1 then backend.ull_update
  • update_many/2 -- map hashes, backend.ull_update_many
  • merge/2 -- validate same p, backend.ull_merge
  • estimate/1 -- backend.ull_estimate
  • serialize/1 -- Codec.encode(Codec.sketch_id_ull(), ...) with params <<p::unsigned-8>>
  • deserialize/1 -- Codec.decode pipeline with sketch ID 15 validation + state header "ULL1" validation
  • from_enumerable/2, merge_many/1, reducer/0, merger/1, size_bytes/1
  • count/1 -- alias for estimate/1 (matches HLL API)
  • Support optional :hash_fn parameter (same as HLL) for XXHash3 opt-in

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions