Interface GlobalKTable<K,V>
-
- Type Parameters:
K- Type of primary keysV- 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 forstream-table joins.In contrast to a
KTablethat is partitioned over allKafkaStreamsinstances, aGlobalKTableis fully replicated perKafkaStreamsinstance. Every partition of the underlying topic is consumed by eachGlobalKTable, such that the full set of data is available in everyKafkaStreamsinstance. This provides the ability to perform joins withKStreamwithout having to repartition the input stream. All joins with theGlobalKTablerequire that aKeyValueMapperis provided that can map from theKeyValueof the left hand sideKStreamto the key of the right hand sideGlobalKTable.A
GlobalKTableis created via aStreamsBuilder. For example:
allbuilder.globalTable("topic-name", "queryable-store-name");GlobalKTables are backed by aReadOnlyKeyValueStoreand are therefore queryable via the interactive queries API. For example:
Note that in contrast tofinal 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 presentKTableaGlobalKTable'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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringqueryableStoreName()Get the name of the local state store that can be used to query thisGlobalKTable.
-
-
-
Method Detail
-
queryableStoreName
String queryableStoreName()
Get the name of the local state store that can be used to query thisGlobalKTable.- Returns:
- the underlying state store name, or
nullif thisGlobalKTablecannot be queried.
-
-