BloomFilterSerializer

class BloomFilterSerializer : KSerializer<BloomFilter>

Custom KSerializer for BloomFilter that chooses between two wire formats based on density, to keep delta messages O(k) instead of O(m):

  • Sparse (fmt = 0): when BloomFilter.nonZeroWordCountSPARSE_THRESHOLD. Encodes only the non-zero (wordIndex: Int, wordValue: Long) pairs as two parallel IntArray + LongArray. An add() delta spans at most k words — k=7 for a 1%-rate filter — so the wire payload is ~84 bytes vs ~12 KB dense for n=10 000.

  • Dense (fmt = 1): for fully-populated states (anti-entropy FullState). Encodes the full LongArray as before. Crossover point: once more than SPARSE_THRESHOLD words are non-zero the overhead of the index array exceeds the savings from omitting zeros.

Wire format (struct with fmt discriminator):

{ "fmt": 0, "bc": <bitCount>, "hc": <hashCount>,
"wi": <IntArray of word indices>, "wv": <LongArray of word values> } // sparse
{ "fmt": 1, "bc": <bitCount>, "hc": <hashCount>, "bits": <LongArray> } // dense

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): BloomFilter
Link copied to clipboard
open override fun serialize(encoder: Encoder, value: BloomFilter)