Not sure if I can follow.
If you want to have a single task per thread, than you can configure as
many thread as task are created. Can't you? Of course, you need to know
how many task you are going to get and that depends on the number of
partitions. I doubt, you can to a "trial run" and observe the logs --
the created tasks are logged and thus you can figure it out.
For IQ: you can of course use IQ to access just the local data, too.
-Matthias
> <
https://www.google.com/url?q=https%3A%2F%2Fwww.confluent.io%2Fblog%2Funifying-stream-processing-and-interactive-queries-in-apache-kafka%2F&sa=D&sntz=1&usg=AFQjCNHYyJALEPZWpfUEvU9j7g7xKLJB4g>
>
> Interactive queries is able to query across tasks and even across
> instances (on different machines).
>
> Thanks
> Eno
>
> On Friday, 16 December 2016 00:24:46 UTC, Tianxiang Xiong wrote:
>
> How do state stores interact with Kafka Stream tasks
> <
http://docs.confluent.io/3.0.1/streams/architecture.html#stream-partitions-and-tasks>?
>
> Here's a contrived example:
>
> Suppose I wanted to track the number of clicks per user. There
> is a /KStream/ whose records are of the form {user-id :
> num-clicks}, partitioned on user-id. We could use /countByKey/
> <
https://kafka.apache.org/0100/javadoc/org/apache/kafka/streams/kstream/KStream.html#countByKey(org.apache.kafka.common.serialization.Serde,%20java.lang.String)>,
> but for the sake of argument let's use /process/
> <
https://kafka.apache.org/0100/javadoc/org/apache/kafka/streams/kstream/KStream.html#process(org.apache.kafka.streams.processor.ProcessorSupplier,%20java.lang.String...)> instead,
> and update a state store in the processor.
>
> We create a state store provider and register it to a
> /KStreamBuilder/ with:
>
> |
> StateStoreSuppliercountStore =Stores.create("Counts")
> .withKeys(Serdes.String())
> .withValues(Serdes.Long())
> .persistent()
> .build();
>
> builder.addStateStore(countStore);
> |
>
> If there are /n/ stream tasks, does each task get an independent
> state store?
>
> If so, two questions via examples:
>
> Let's say there are 3 tasks, /t1, t2, t3 /to which user IDs are
> partitioned, e.g. users 11, 12 to /t1/, 21, 22 to /t2/, 31, 32
> to /t3/. Then /t1/ have the counts for 11, 12, but not 21, 22,
> 31, or 32. /t2 /would have the counts for 21, 22, etc.
>
> * Suppose we have some front-end that displays the clicks per
> user. We'd need to consume from all state stores for all
> tasks. What's the best way to do that?
> o Is there a code example?
> * What if, while counting clicks for user 11, we wanted to
> compare their clicks with those of user 21? Since their
> clicks are counted in different tasks, the state store for
> /t1/ won't have the right click counts for user 21.
> o In other words, is there a way we can share /global
> state/ across tasks, with the ability to update that
> state from any task in such a way that other tasks will
> see that updated state before processing their next records?
>
> --
> 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
> <mailto:
confluent-platf...@googlegroups.com>.
> <mailto:
confluent...@googlegroups.com>.
> <
https://groups.google.com/d/msgid/confluent-platform/20c5f253-e238-4469-a4d2-1d3316f6fee1%40googlegroups.com?utm_medium=email&utm_source=footer>.