K- Type of primary keys
V- Type of value changes
@InterfaceStability.Evolving public interface GlobalKTable<K,V>
GlobalKTableis an abstraction of a changelog stream from a primary-keyed table. Each record in this changelog stream is an update on the primary-keyed table with the record key as the primary key.
GlobalKTable can only be used as right-hand side input for
In contrast to a
KTable that is partitioned over all
KafkaStreams instances, a
is fully replicated per
Every partition of the underlying topic is consumed by each
GlobalKTable, such that the full set of data is
available in every
This provides the ability to perform joins with
KStream without having to repartition the input stream.
All joins with the
GlobalKTable require that a
KeyValueMapper is provided that can map from the
KeyValue of the left hand side
KStream to the key of the right hand side
GlobalKTable is created via a
KStreamBuilder. For example:
GlobalKTables are backed by a
ReadOnlyKeyValueStoreand are therefore queryable via the interactive queries API. For example:
Note that in contrast to
final GlobalKTable globalOne = builder.globalTable("g1", "g1-store"); final GlobalKTable globalTwo = builder.globalTable("g2", "g2-store"); ... final KafkaStreams streams = ...; streams.start() ... ReadOnlyKeyValueStore view = streams.store("g1-store", QueryableStoreTypes.keyValueStore()); view.get(key); // can be done on any key, as all keys are present
GlobalKTable's state holds a full copy of the underlying topic, thus all keys can be queried locally.
Records from the source topic that have null keys are dropped.