View Source hyper_register behaviour (hyper v1.0.1)
Link to this section Summary
Functions
Size in bytes used to represent the registers in memory.
Compact is always called before any attempt at reading (sum, zero count, etc) or merging. It is intended to give backends that buffer the writes a chance to flush the buffer before the registers are needed.
Encode and decode are called to convert the in-memory representation of the backend to the serialized format. Must return one binary where each register is encoded as an 8-bit integer.
Merge any number of registers, used to calculate the union. For two register values at the same index, the max value must be in the resulting register.
Same as max_merge/1 but used when we know only two filters are merged.
Creates a new instance of the backend. The return value of this function will be passed to all functions in this module.
Reduce the precision of the registers. Used for mixed-precision union by first reducing the precision to the lowest of all filters.
A map with key the values possible for the register and values the number of register with that value.
Sum of 2^-R where R is the value in each register.
Set the register to the given value, *only* if the value already stored is lower than the new value. The backend needs to ensure the register value is only allowed to increase.
Count of registers set to 0.
Link to this section Types
-type t() :: module().
Link to this section Callbacks
-callback bytes(hyper:registers()) -> integer().
-callback compact(hyper:registers()) -> hyper:registers().
-callback decode_registers(binary(), hyper:precision()) -> hyper:registers().
-callback encode_registers(hyper:registers()) -> binary().
-callback max_merge([hyper:registers()]) -> hyper:registers().
-callback max_merge(hyper:registers(), hyper:registers()) -> hyper:registers().
-callback new(P :: hyper:precision()) -> hyper:registers().
-callback precision(hyper:registers()) -> integer().
-callback reduce_precision(hyper:precision(), hyper:registers()) -> hyper:registers().
-callback register_histogram(hyper:registers()) -> map().
-callback register_sum(hyper:registers()) -> float().
-callback set(Index :: integer(), Value :: integer(), hyper:registers()) -> hyper:registers().
-callback zero_count(hyper:registers()) -> integer().
Link to this section Functions
-spec bytes(t(), hyper:registers()) -> integer().
-spec compact(t(), hyper:registers()) -> hyper:registers().
-spec decode_registers(t(), binary(), hyper:precision()) -> hyper:registers().
-spec encode_registers(t(), hyper:registers()) -> binary().
-spec max_merge(t(), [hyper:registers()]) -> hyper:registers().
-spec max_merge(t(), hyper:registers(), hyper:registers()) -> hyper:registers().
-spec new(t(), P :: hyper:precision()) -> hyper:registers().
-spec precision(t(), hyper:registers()) -> integer().
-spec reduce_precision(t(), hyper:precision(), hyper:registers()) -> hyper:registers().
-spec register_histogram(t(), hyper:registers()) -> map().
-spec register_sum(t(), hyper:registers()) -> float().
-spec set(t(), Index :: integer(), Value :: integer(), hyper:registers()) -> hyper:registers().
-spec zero_count(t(), hyper:registers()) -> integer().