Complete the code to create a KStream from the topic 'input-topic'.
KStream<String, String> stream = builder.stream([1]);The stream() method expects the topic name as a string in quotes.
Complete the code to create a KTable from the topic 'users'.
KTable<String, String> table = builder.table([1]);The table() method requires the topic name as a string literal.
Fix the error in the code to convert a KStream to a KTable.
KTable<String, String> table = stream.[1]();toStream() which converts to a stream, not a table.toKTable() or asTable().The correct method to convert a KStream to a KTable is toTable().
Fill both blanks to filter a KStream for values greater than 100 and map keys to uppercase.
KStream<String, Integer> filtered = stream.filter((key, value) -> value [1] 100).mapKeys((key, value) -> key.[2]());
toLowerCase() instead of toUpperCase().We filter values greater than 100 using > and convert keys to uppercase with toUpperCase().
Fill all three blanks to create a KTable from a topic, filter entries with values not null, and map values to their length.
KTable<String, Integer> result = builder.table([1]).filter((key, value) -> value [2] null).mapValues(value -> value.[3]());
The topic name is a string "events". We filter values not equal to null using != and get the length of the value string with length().