Struct mz_compute_client::plan::top_k::MonotonicTop1Plan
source · pub struct MonotonicTop1Plan {
pub group_key: Vec<usize>,
pub order_key: Vec<ColumnOrder>,
pub must_consolidate: bool,
}
Expand description
A plan for monotonic TopKs with an offset of 0 and a limit of 1.
If the input to a TopK is monotonic (aka append-only aka no retractions) then we don’t have to worry about keeping every row we’ve seen around forever. Instead, the reduce can incrementally compute a new answer by looking at just the old TopK for a key and the incremental data.
This optimization generalizes to any TopK over a monotonic source, but we special case only TopK with offset=0 and limit=1 (aka Top1) for now. This is because (1) Top1 can merge in each incremental row in constant space and time while the generalized solution needs something like a priority queue and (2) we expect Top1 will be a common pattern used to turn a Kafka source’s “upsert” semantics into differential’s semantics. (2) is especially interesting because Kafka is monotonic with an ENVELOPE of NONE, which is the default for ENVELOPE in Materialize and commonly used by users.
Fields§
§group_key: Vec<usize>
The columns that form the key for each group.
order_key: Vec<ColumnOrder>
Ordering that is used within each group.
must_consolidate: bool
True if the input is logically but not physically monotonic, and the operator must first consolidate the inputs to remove potential negations.
Trait Implementations§
source§impl Arbitrary for MonotonicTop1Plan
impl Arbitrary for MonotonicTop1Plan
§type Parameters = (<Vec<usize, Global> as Arbitrary>::Parameters, <Vec<ColumnOrder, Global> as Arbitrary>::Parameters, <bool as Arbitrary>::Parameters)
type Parameters = (<Vec<usize, Global> as Arbitrary>::Parameters, <Vec<ColumnOrder, Global> as Arbitrary>::Parameters, <bool as Arbitrary>::Parameters)
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = Map<(<Vec<usize, Global> as Arbitrary>::Strategy, <Vec<ColumnOrder, Global> as Arbitrary>::Strategy, <bool as Arbitrary>::Strategy), fn(_: (Vec<usize, Global>, Vec<ColumnOrder, Global>, bool)) -> MonotonicTop1Plan>
type Strategy = Map<(<Vec<usize, Global> as Arbitrary>::Strategy, <Vec<ColumnOrder, Global> as Arbitrary>::Strategy, <bool as Arbitrary>::Strategy), fn(_: (Vec<usize, Global>, Vec<ColumnOrder, Global>, bool)) -> MonotonicTop1Plan>
Strategy
used to generate values of type Self
.source§fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy
source§impl Clone for MonotonicTop1Plan
impl Clone for MonotonicTop1Plan
source§fn clone(&self) -> MonotonicTop1Plan
fn clone(&self) -> MonotonicTop1Plan
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MonotonicTop1Plan
impl Debug for MonotonicTop1Plan
source§impl<'de> Deserialize<'de> for MonotonicTop1Plan
impl<'de> Deserialize<'de> for MonotonicTop1Plan
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl PartialEq<MonotonicTop1Plan> for MonotonicTop1Plan
impl PartialEq<MonotonicTop1Plan> for MonotonicTop1Plan
source§fn eq(&self, other: &MonotonicTop1Plan) -> bool
fn eq(&self, other: &MonotonicTop1Plan) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl RustType<ProtoMonotonicTop1Plan> for MonotonicTop1Plan
impl RustType<ProtoMonotonicTop1Plan> for MonotonicTop1Plan
source§fn into_proto(&self) -> ProtoMonotonicTop1Plan
fn into_proto(&self) -> ProtoMonotonicTop1Plan
Self
into a Proto
value.source§fn from_proto(proto: ProtoMonotonicTop1Plan) -> Result<Self, TryFromProtoError>
fn from_proto(proto: ProtoMonotonicTop1Plan) -> Result<Self, TryFromProtoError>
source§impl Serialize for MonotonicTop1Plan
impl Serialize for MonotonicTop1Plan
impl Eq for MonotonicTop1Plan
impl StructuralEq for MonotonicTop1Plan
impl StructuralPartialEq for MonotonicTop1Plan
Auto Trait Implementations§
impl RefUnwindSafe for MonotonicTop1Plan
impl Send for MonotonicTop1Plan
impl Sync for MonotonicTop1Plan
impl Unpin for MonotonicTop1Plan
impl UnwindSafe for MonotonicTop1Plan
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.