Count fix and Type alias refactor in Streams Scala API#4966
Count fix and Type alias refactor in Streams Scala API#4966guozhangwang merged 1 commit intoapache:trunkfrom
Conversation
4a52f32 to
100309b
Compare
|
@guozhangwang @debasishg Any thoughts on this? |
There was a problem hiding this comment.
I think ByteArrayKeyValueStore is more succinct than KeyValueStore[Bytes, Array[Byte]]? cc @debasishg @seglo for a second thought.
There was a problem hiding this comment.
+1 @guozhangwang .. exactly for this reason the type synonym was introduced
There was a problem hiding this comment.
I'm good with the type alias ByteArrayKeyValueStore but then we should do it consistently for the other types like SessionStore[Bytes, Array[Byte]]. I will then modify the PR to add the others.
There was a problem hiding this comment.
I would go defensive with implicits on Materialized. First, this abstraction doesn't add much value since it returns the Java abstraction. Also if someone doesn't wish to pass a serde to a Materialized, and use Materialized.as they can be inadvertently passed if implicits are in scope. This will lead to errors that are difficult to debug.
|
I don't believe there's much purpose to abstract
|
|
Indeed this doesn't bring too much value so I removed the add of the Materialized helper and left only some refactorings |
43aa5bb to
41cac50
Compare
There was a problem hiding this comment.
I'm just curious why we can save the casting of Long2long now?
There was a problem hiding this comment.
Not sure why it's been done in the first place
There was a problem hiding this comment.
We need to double check if Scala 2.11 is compatible with java / scala Long (I'm not an expert in this case..)
If that is indeed the case, could the above count() overloaded function be updated as well?
There was a problem hiding this comment.
There shouldn't be any difference between 2.12 and 2.11 here. Both are just doing boxing and unboxing in Scala long.
I'll write a test to but that on clear tomorrow.
There was a problem hiding this comment.
Indeed this change is faulty. I reverted this and added a test to make sure we don't get in this in the future.
There was a problem hiding this comment.
Actually the other overload def count(): KTable[K, Long] doesn't compile without the mapValues. This tricked us into thinking that we need to do this for this overload as well. Possibly the type parameter Long in Materialized helps the compiler to infer the return type of Long and make the conversion. So we still need to do the conversion manually in the other overload of count.
guozhangwang
left a comment
There was a problem hiding this comment.
Other parts LGTM. Left two more minor comments.
There was a problem hiding this comment.
Should we revert the change here as well?
| * @see `org.apache.kafka.streams.kstream.KGroupedTable#count` | ||
| */ | ||
| def count(materialized: Materialized[K, Long, ByteArrayKeyValueStore]): KTable[K, Long] = | ||
| inner.count(materialized) |
There was a problem hiding this comment.
This one would have triggered a StackOverflow looping on itself.
| * @see `org.apache.kafka.streams.kstream.SessionWindowedKStream#count` | ||
| */ | ||
| def count(materialized: Materialized[K, Long, SessionStore[Bytes, Array[Byte]]]): KTable[Windowed[K], Long] = | ||
| inner.count(materialized) |
There was a problem hiding this comment.
This one would have triggered a StackOverflow looping on itself.
|
Thanks @joan38 ! Merged to trunk. |
|
Thanks @guozhangwang |
…#4966) Reviewers: Debasish Ghosh <dghosh@acm.org>, Guozhang Wang <guozhang@confluent.io>
Provide a tiny helper for creating Materialized with implicit Serdes.
Committer Checklist (excluded from commit message)