KTable aggregatedStream = aq.groupBy((key, value)->value).count();
aggregatedStream.toStream()
KTable aggregatedStream = aq.groupBy((key, value)-> new KeyValue(value, 1)).count();(since you're just counting, I put in a dummy "1" as the value.)
--
You received this message because you are subscribed to the Google Groups "Confluent Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to confluent-platf...@googlegroups.com.
To post to this group, send email to confluent...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/confluent-platform/b65d80cb-373b-4e9a-bea1-fff7000bd047%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
KTable aggregatedstream=aq.groupBy((key, value)-> new KeyValue(value, 1L), Serialized.with(Serdes.String(),Serdes.Long())).count();
Thanks a lot for the prompt response!
-Anuj
Hello Anuj,At first glance, I think it's because groupBy expects a KeyValueMapper that returns a KeyValue. So maybe what you needed was:KTable aggregatedStream = aq.groupBy((key, value)-> new KeyValue(value, 1)).count();(since you're just counting, I put in a dummy "1" as the value.)Does that work?-John
On Tue, Jul 3, 2018 at 2:20 PM Anuj Choudhury <anuj.cho...@gmail.com> wrote:
--I cannot resolve this error:I have a Kafka Streams app, where the KTable is of the form <String,String>.I want to group the Ktable by the values, which can only be of the form "s","p" or "f".Suppose the KTable is aq.I do something of this sort:-.to("streams-wordcount-output", Produced.with(Serdes.String(), Serdes.Long()));KTable aggregatedStream = aq.groupBy((key, value)->value).count();
aggregatedStream.toStream()What is the problem with this approach, and why is it not working? The error it is giving is that :-java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.kafka.streams.KeyValueI cant really understand it.
You received this message because you are subscribed to the Google Groups "Confluent Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to confluent-platform+unsub...@googlegroups.com.
<KR> KGroupedStream<KR, V> groupBy(final KeyValueMapper<? super K, ? super V, KR> selector);
<KR, VR> KGroupedTable<KR, VR> groupBy(final KeyValueMapper<? super K, ? super V, KeyValue<KR, VR>> selector);