Complete the code to create a persistent state store named "my-store".
StoreBuilder<KeyValueStore<String, String>> storeBuilder = Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore([1]), Serdes.String(), Serdes.String());The store name must be a unique string identifier. Here, "my-store" is the correct name.
Complete the code to add the state store to the topology.
topology.[1](storeBuilder);The method addStateStore adds a state store to the topology.
Fix the error in the code to retrieve the state store from the processor context.
KeyValueStore<String, String> store = (KeyValueStore<String, String>) context.[1]("my-store");
The correct method to get a state store from the context is getStateStore.
Fill both blanks to create a RocksDB persistent key-value store with string serializers.
StoreBuilder<KeyValueStore<String, String>> storeBuilder = Stores.keyValueStoreBuilder(Stores.[1]KeyValueStore("my-rocks-store"), [2], Serdes.String());
The method persistentKeyValueStore creates a RocksDB persistent store. The serializer for keys is Serdes.String().
Fill all three blanks to define a state store, add it to the topology, and retrieve it in a processor.
StoreBuilder<KeyValueStore<String, String>> storeBuilder = Stores.keyValueStoreBuilder(Stores.[1]KeyValueStore("store1"), Serdes.String(), [2]); topology.[3](storeBuilder);
Use persistentKeyValueStore to create a persistent store, Serdes.String() for value serializer, and addStateStore to add it to the topology.