- Type Parameters:
K- Type of primary keys
V- Type of value changes
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.
GlobalKTablecan only be used as right-hand side input for
In contrast to a
KTablethat is partitioned over all
GlobalKTableis fully replicated per
KafkaStreamsinstance. Every partition of the underlying topic is consumed by each
GlobalKTable, such that the full set of data is available in every
KafkaStreamsinstance. This provides the ability to perform joins with
KStreamwithout having to repartition the input stream. All joins with the
GlobalKTablerequire that a
KeyValueMapperis provided that can map from the
KeyValueof the left hand side
KStreamto the key of the right hand side
GlobalKTableis created via a
StreamsBuilder. 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.timestampedKeyValueStore()); 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.
String queryableStoreName()Get the name of the local state store that can be used to query this
- the underlying state store name, or
GlobalKTablecannot be queried.