pub struct KTable<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> { /* private fields */ }Expand description
A changelog-backed table handle.
store_name is the materialized store this table reads and writes. The DSL
uses it to derive changelog topics and to reuse the store in downstream
materialized ops. source_topic is the Kafka topic this table was sourced
from. It is set for builder.table_explicit() KTables and is None for
derived KTables. The join DSL reads it to declare copartition groups.
Implementations§
Source§impl<K, V, KS, VS> KTable<K, V, KS, VS>
impl<K, V, KS, VS> KTable<K, V, KS, VS>
pub fn with_key_serde<NewKS>(self, serde: NewKS) -> KTable<K, V, NewKS, VS>
pub fn with_value_serde<NewVS>(self, serde: NewVS) -> KTable<K, V, KS, NewVS>
Source§impl<K, V, KS, VS> KTable<K, V, KS, VS>
impl<K, V, KS, VS> KTable<K, V, KS, VS>
Sourcepub fn to_stream(&self) -> KStream<K, V, KS, VS>
pub fn to_stream(&self) -> KStream<K, V, KS, VS>
toStream: view the table’s change-stream as a KStream, forwarding
every record unchanged. Not key-changing.
Sourcepub fn map_values<V2, F>(
&self,
f: F,
) -> KTable<K, V2, KS, <V2 as DefaultSerde>::Serde>
pub fn map_values<V2, F>( &self, f: F, ) -> KTable<K, V2, KS, <V2 as DefaultSerde>::Serde>
mapValues: transform each value and forward the rewritten table view.
This op does not materialize a store. It matches the JVM’s
non-materialized mapValues. The key stays unchanged, and the op emits no
changelog topic. Use
map_values_materialized for the
store-backed form.
Sourcepub fn map_values_materialized<V2, NKS, NVS, F>(
&self,
f: F,
materialized: impl Into<Materialized<NKS, NVS>>,
) -> KTable<K, V2, NKS, NVS>
pub fn map_values_materialized<V2, NKS, NVS, F>( &self, f: F, materialized: impl Into<Materialized<NKS, NVS>>, ) -> KTable<K, V2, NKS, NVS>
mapValues: transform each value, materializing the rewritten table into
a new store. Key unchanged.
Sourcepub fn filter<NKS, NVS, P>(
&self,
predicate: P,
materialized: impl Into<Materialized<NKS, NVS>>,
) -> KTable<K, V, NKS, NVS>
pub fn filter<NKS, NVS, P>( &self, predicate: P, materialized: impl Into<Materialized<NKS, NVS>>, ) -> KTable<K, V, NKS, NVS>
filter: keep the rows that match predicate and materialize the view.
When a row that matched before stops matching, this op removes it from the
store and forwards it as a Change<V> tombstone, so downstream views drop
it. See the processor module doc.
Sourcepub fn group_by<KR, VR, M>(&self, mapper: M) -> KGroupedTable<KR, VR>where
KR: DefaultSerde + Any + Send + Sync + Clone + PartialEq,
VR: DefaultSerde + Any + Send + Sync + Clone,
<KR as DefaultSerde>::Serde: Serde<KR> + Clone,
<VR as DefaultSerde>::Serde: Serde<VR> + Clone,
M: Fn(&K, &V) -> (KR, VR) + Clone + Send + Sync + 'static,
K: Any + Send + Sync + Clone,
V: Any + Send + Clone,
pub fn group_by<KR, VR, M>(&self, mapper: M) -> KGroupedTable<KR, VR>where
KR: DefaultSerde + Any + Send + Sync + Clone + PartialEq,
VR: DefaultSerde + Any + Send + Sync + Clone,
<KR as DefaultSerde>::Serde: Serde<KR> + Clone,
<VR as DefaultSerde>::Serde: Serde<VR> + Clone,
M: Fn(&K, &V) -> (KR, VR) + Clone + Send + Sync + 'static,
K: Any + Send + Sync + Clone,
V: Any + Send + Clone,
groupBy: re-group the table by a new (KR, VR) derived from each entry.
After the re-group, aggregate with count, reduce, or aggregate. This
op always repartitions: the JVM KTable.groupBy inserts a repartition-map,
a sink, and a source.
Sourcepub fn group_by_explicit<KR, VR, GKS, GVS, M>(
&self,
mapper: M,
grouped: impl Into<Grouped<GKS, GVS>>,
) -> KGroupedTable<KR, VR>
pub fn group_by_explicit<KR, VR, GKS, GVS, M>( &self, mapper: M, grouped: impl Into<Grouped<GKS, GVS>>, ) -> KGroupedTable<KR, VR>
groupBy with explicit repartition serdes.
Sourcepub fn join<VB, VR, F, VBS>(
&self,
other: &KTable<K, VB, KS, VBS>,
joiner: F,
) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>
pub fn join<VB, VR, F, VBS>( &self, other: &KTable<K, VB, KS, VBS>, joiner: F, ) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>
join (inner KTable-KTable join): join rows that both tables hold.
For each key, the join row exists only when both tables hold a value.
On any change to either side, the join re-reads the other side’s current
value from its store and forwards a Change<VR>. It forwards a tombstone
when the row stops existing.
Both tables must be materialized, because the join reads each side’s store. The join declares the two source topics as a copartition group (KIP-1071).
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub fn left_join<VB, VR, F, VBS>(
&self,
other: &KTable<K, VB, KS, VBS>,
joiner: F,
) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>
pub fn left_join<VB, VR, F, VBS>( &self, other: &KTable<K, VB, KS, VBS>, joiner: F, ) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>
leftJoin (left KTable-KTable join): emit a row for every left row.
This join emits a row whenever the left (this) side is present. The
right side is optional, and the joiner receives None for it on a miss.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub fn outer_join<VB, VR, F, VBS>(
&self,
other: &KTable<K, VB, KS, VBS>,
joiner: F,
) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>
pub fn outer_join<VB, VR, F, VBS>( &self, other: &KTable<K, VB, KS, VBS>, joiner: F, ) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>
outerJoin (outer KTable-KTable join): emit a row for either side.
This join emits a row whenever either side is present. The joiner
receives an Option for each side.
Sourcepub fn join_on_foreign_key<KO, VB, VR, FKE, J, KOS, KosOther, VbsOther>(
&self,
other: &KTable<KO, VB, KosOther, VbsOther>,
fk_extractor: FKE,
joiner: J,
fk_serde: KOS,
) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>where
KO: Any + Send + Sync + Clone,
VB: Any + Send + Sync + Clone,
VR: DefaultSerde + Any + Send + Sync + Clone,
K: Send + Sync,
V: Send + Sync,
FKE: Fn(&V) -> KO + Clone + Send + Sync + 'static,
J: Fn(&V, &VB) -> VR + Clone + Send + Sync + 'static,
KOS: Serde<KO> + Clone + 'static,
KS: Serde<K> + Clone + 'static,
VS: Serde<V> + Clone + 'static,
KosOther: Clone,
VbsOther: Serde<VB> + Clone + 'static,
pub fn join_on_foreign_key<KO, VB, VR, FKE, J, KOS, KosOther, VbsOther>(
&self,
other: &KTable<KO, VB, KosOther, VbsOther>,
fk_extractor: FKE,
joiner: J,
fk_serde: KOS,
) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>where
KO: Any + Send + Sync + Clone,
VB: Any + Send + Sync + Clone,
VR: DefaultSerde + Any + Send + Sync + Clone,
K: Send + Sync,
V: Send + Sync,
FKE: Fn(&V) -> KO + Clone + Send + Sync + 'static,
J: Fn(&V, &VB) -> VR + Clone + Send + Sync + 'static,
KOS: Serde<KO> + Clone + 'static,
KS: Serde<K> + Clone + 'static,
VS: Serde<V> + Clone + 'static,
KosOther: Clone,
VbsOther: Serde<VB> + Clone + 'static,
join on a foreign key (KIP-213 inner FK join).
For each left record, the foreign key fk_extractor(&VA) selects a row in
other, which is a KTable<KO, VB>. joiner(&VA, &VB) produces the
result whenever both are present.
Both tables must be materialized source tables built with
builder.table, because the join reads sa and sb and needs their
serdes. The join lowers to the two-subtopology KIP-213 graph: the
subscription registration and response repartition topics, a subscription
state store, and the five FK-join processors. See the module
dsl::processors::fk for the per-processor semantics.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Sourcepub fn left_join_on_foreign_key<KO, VB, VR, FKE, J, KOS, KosOther, VbsOther>(
&self,
other: &KTable<KO, VB, KosOther, VbsOther>,
fk_extractor: FKE,
joiner: J,
fk_serde: KOS,
) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>where
KO: Any + Send + Sync + Clone,
VB: Any + Send + Sync + Clone,
VR: DefaultSerde + Any + Send + Sync + Clone,
K: Send + Sync,
V: Send + Sync,
FKE: Fn(&V) -> KO + Clone + Send + Sync + 'static,
J: Fn(&V, Option<&VB>) -> VR + Clone + Send + Sync + 'static,
KOS: Serde<KO> + Clone + 'static,
KS: Serde<K> + Clone + 'static,
VS: Serde<V> + Clone + 'static,
KosOther: Clone,
VbsOther: Serde<VB> + Clone + 'static,
pub fn left_join_on_foreign_key<KO, VB, VR, FKE, J, KOS, KosOther, VbsOther>(
&self,
other: &KTable<KO, VB, KosOther, VbsOther>,
fk_extractor: FKE,
joiner: J,
fk_serde: KOS,
) -> KTable<K, VR, KS, <VR as DefaultSerde>::Serde>where
KO: Any + Send + Sync + Clone,
VB: Any + Send + Sync + Clone,
VR: DefaultSerde + Any + Send + Sync + Clone,
K: Send + Sync,
V: Send + Sync,
FKE: Fn(&V) -> KO + Clone + Send + Sync + 'static,
J: Fn(&V, Option<&VB>) -> VR + Clone + Send + Sync + 'static,
KOS: Serde<KO> + Clone + 'static,
KS: Serde<K> + Clone + 'static,
VS: Serde<V> + Clone + 'static,
KosOther: Clone,
VbsOther: Serde<VB> + Clone + 'static,
leftJoin on a foreign key (KIP-213 left FK join).
This join emits a row for every left record. The joiner receives None
for the foreign value when the foreign key has no matching row.
Source§impl<K, V, KS, VS> KTable<K, V, KS, VS>
impl<K, V, KS, VS> KTable<K, V, KS, VS>
Sourcepub fn suppress(&self, suppressed: Suppressed<K>) -> KTable<K, V, KS, VS>
pub fn suppress(&self, suppressed: Suppressed<K>) -> KTable<K, V, KS, VS>
suppress(Suppressed): buffer updates and emit on a delay.
On a windowed table, until_window_closes emits each window’s final value
once the window closes. until_time_limit rate-limits any table to one
update per key per wait.
The buffer is a registered
SuppressBytesStore. It is durable, with
a changelog and restore, when logging is on. The serdes come from the
table-producing operation. A call to suppress on a table that changed its
value type through map_values panics, because no serde factory is
available.
§Panics
Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.
Auto Trait Implementations§
impl<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> !RefUnwindSafe for KTable<K, V, KS, VS>
impl<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> !Send for KTable<K, V, KS, VS>
impl<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> !Sync for KTable<K, V, KS, VS>
impl<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> !UnwindSafe for KTable<K, V, KS, VS>
impl<K, V, KS, VS> Freeze for KTable<K, V, KS, VS>
impl<K, V, KS, VS> Unpin for KTable<K, V, KS, VS>
impl<K, V, KS, VS> UnsafeUnpin for KTable<K, V, KS, VS>where
KS: UnsafeUnpin,
VS: UnsafeUnpin,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);