You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Paolo Patierno <pp...@live.com> on 2017/06/15 12:51:56 UTC

KStream and KTable different behaviour on filter() operation

Hi all,


I was asking why the different behaviour of filter() operation on a KStream and KTable.

On KStream, if the predicate is false, the message isn't passed to the next node (so for example if a sinknode, it doesn't arrive to the destination topic).

On KTable, if the predicate is true, a message with null value is passed.

With filter operation I want to avoid to receive messages for which the predicate is not valid.

Why this difference ?


Thanks,

Paolo


Paolo Patierno
Senior Software Engineer (IoT) @ Red Hat
Microsoft MVP on Windows Embedded & IoT
Microsoft Azure Advisor

Twitter : @ppatierno<http://twitter.com/ppatierno>
Linkedin : paolopatierno<http://it.linkedin.com/in/paolopatierno>
Blog : DevExperience<http://paolopatierno.wordpress.com/>

Re: KStream and KTable different behaviour on filter() operation

Posted by Eno Thereska <en...@gmail.com>.
Yeah the semantics are slightly different. For a KTable, a null value just means that the record is a tombstone, and will be anyways ignored by subsequent processing:
http://docs.confluent.io/current/streams/javadocs/org/apache/kafka/streams/kstream/KTable.html#filter-org.apache.kafka.streams.kstream.Predicate- <http://docs.confluent.io/current/streams/javadocs/org/apache/kafka/streams/kstream/KTable.html#filter-org.apache.kafka.streams.kstream.Predicate->

Eno


> On 15 Jun 2017, at 13:51, Paolo Patierno <pp...@live.com> wrote:
> 
> Hi all,
> 
> 
> I was asking why the different behaviour of filter() operation on a KStream and KTable.
> 
> On KStream, if the predicate is false, the message isn't passed to the next node (so for example if a sinknode, it doesn't arrive to the destination topic).
> 
> On KTable, if the predicate is true, a message with null value is passed.
> 
> With filter operation I want to avoid to receive messages for which the predicate is not valid.
> 
> Why this difference ?
> 
> 
> Thanks,
> 
> Paolo
> 
> 
> Paolo Patierno
> Senior Software Engineer (IoT) @ Red Hat
> Microsoft MVP on Windows Embedded & IoT
> Microsoft Azure Advisor
> 
> Twitter : @ppatierno<http://twitter.com/ppatierno>
> Linkedin : paolopatierno<http://it.linkedin.com/in/paolopatierno>
> Blog : DevExperience<http://paolopatierno.wordpress.com/>