monoid

package
v0.0.0-...-6425869 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package monoid defines the structural-monoid abstraction at the heart of Murmur.

A Monoid is the algebraic primitive Murmur uses to express "how aggregations combine": an associative Combine operation and an identity element. Monoids are *structural* — they carry a Kind that backend executors (Spark codegen, Valkey-native commands, DDB atomic adds) dispatch on to translate the abstract operation into a runtime-native implementation. Custom (user-defined) monoids carry KindCustom and only run on the Go execution backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStructural

func IsStructural(k Kind) bool

IsStructural reports whether the monoid kind is recognized by backend executors and can be translated to native operations on Spark, Valkey, and DynamoDB. Custom monoids return false and only run on Go execution backends.

Types

type Kind

type Kind string

Kind identifies a structural monoid for backend dispatch. Backends switch on Kind to emit native Spark plans, Valkey commands, DDB UpdateExpressions, etc. KindCustom marks an opaque user-defined monoid that only the Go executors can run.

const (
	KindSum    Kind = "sum"    // numeric addition; DDB ADD on int64 / float64
	KindCount  Kind = "count"  // event-counting flavor of Sum (always +1)
	KindMin    Kind = "min"    // running minimum; uses core.Bounded[V]
	KindMax    Kind = "max"    // running maximum; uses core.Bounded[V]
	KindFirst  Kind = "first"  // earliest-timestamp wins
	KindLast   Kind = "last"   // latest-timestamp wins
	KindSet    Kind = "set"    // map-set union
	KindHLL    Kind = "hll"    // HyperLogLog cardinality sketch
	KindTopK   Kind = "topk"   // Misra-Gries top-K heavy hitters
	KindBloom  Kind = "bloom"  // Bloom filter set membership
	KindMap    Kind = "map"    // per-key Combine via inner monoid
	KindTuple  Kind = "tuple"  // componentwise Combine via inner monoids
	KindCustom Kind = "custom" // user-defined opaque monoid; Go-only backends
)

Built-in Kind values. Backend executors switch on these to translate the abstract monoid into a runtime-native operation; admin servers use them to pick a typed decoder for the Query Console; users adding a new well-known monoid should add a new Kind constant here so that switch-statements elsewhere fail loudly during compile rather than silently fall through to KindCustom.

type Monoid

type Monoid[V any] interface {
	Identity() V
	Combine(a, b V) V
	Kind() Kind
}

Monoid is an associative binary operation Combine over values of type V with an Identity element. Implementations must satisfy:

Combine(Identity(), x) == x
Combine(x, Identity()) == x
Combine(Combine(x, y), z) == Combine(x, Combine(y, z))

Backend executors may rely on Kind() to translate Combine into a native operation (e.g., DynamoDB ADD, Spark sum aggregation, Valkey PFADD).

Directories

Path Synopsis
Package compose provides higher-order monoids that combine simpler monoids:
Package compose provides higher-order monoids that combine simpler monoids:
Package core provides the standard numeric and basic monoids: Sum, Count, Min, Max, First, Last, Set.
Package core provides the standard numeric and basic monoids: Sum, Count, Min, Max, First, Last, Set.
Package monoidlaws provides reusable test helpers that verify a monoid.Monoid[V] satisfies the algebraic laws (associativity and identity) required for safe use in Murmur pipelines.
Package monoidlaws provides reusable test helpers that verify a monoid.Monoid[V] satisfies the algebraic laws (associativity and identity) required for safe use in Murmur pipelines.
Package sketch defines probabilistic-aggregation monoids: HLL (cardinality), TopK (heavy hitters), and Bloom (set membership).
Package sketch defines probabilistic-aggregation monoids: HLL (cardinality), TopK (heavy hitters), and Bloom (set membership).
bloom
Package bloom is a Bloom filter implementation of monoid.Monoid[[]byte], suitable for approximate set-membership aggregations.
Package bloom is a Bloom filter implementation of monoid.Monoid[[]byte], suitable for approximate set-membership aggregations.
hll
Package hll is a HyperLogLog implementation of monoid.Monoid[[]byte], suitable for approximate-cardinality aggregations.
Package hll is a HyperLogLog implementation of monoid.Monoid[[]byte], suitable for approximate-cardinality aggregations.
topk
Package topk is a Misra-Gries top-K heavy-hitters implementation of monoid.Monoid[[]byte].
Package topk is a Misra-Gries top-K heavy-hitters implementation of monoid.Monoid[[]byte].
Package windowed expresses time-bucketed aggregations on top of any structural monoid.
Package windowed expresses time-bucketed aggregations on top of any structural monoid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL