Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

support for ValueTransformerWithKey #72

Open
hashangayasri opened this issue Jun 21, 2018 · 3 comments
Open

support for ValueTransformerWithKey #72

hashangayasri opened this issue Jun 21, 2018 · 3 comments

Comments

@hashangayasri
Copy link

Currently, KStreamS#transformValues only has support for ValueTransformer.
ValueTransformerWithKey support is needed.

@hashangayasri
Copy link
Author

hashangayasri commented Jun 21, 2018

Wrote an extension to support it

  // Add ValueTransformerWithKeySupplier
  import com.lightbend.kafka.scala.streams.KStreamS
  implicit class KStreamSWithValueTransformerKey[K,V](inner: KStreamS[K,V]) extends KStreamS[K,V](inner.inner){
    def transformValuesWithKey[VR](valueTransformerSupplierWithKey: () => ValueTransformerWithKey[K, V, VR],
                                   stateStoreNames: String*): KStreamS[K, VR] = {

      val valueTransformerWithKeySupplierJ: ValueTransformerWithKeySupplier[K, V, VR] = () => valueTransformerSupplierWithKey()
      new KStreamS(inner.inner.transformValues[VR](valueTransformerWithKeySupplierJ, stateStoreNames: _*))
    }
  }

@hashangayasri
Copy link
Author

Not submitting a pull request since this only applies to Kafka 1.1.0 and the current branches are for Kafka 1.0.0.
Let me know if a branch for Kafka 1.1.0 is opened.

  def transformValuesWithKey[VR](valueTransformerWithKeySupplier: () => ValueTransformerWithKey[K, V, VR],
                                 stateStoreNames: String*): KStreamS[K, VR] = {

    val valueTransformerWithKeySupplierJ: ValueTransformerWithKeySupplier[K, V, VR] = () => valueTransformerWithKeySupplier()
    new KStreamS(inner.transformValues[VR](valueTransformerWithKeySupplierJ, stateStoreNames: _*))
  }

would do

@debasishg
Copy link
Contributor

Please submit a PR to apache/kafka. streams-scala is on master now .. https://github.com/apache/kafka/tree/trunk/streams/streams-scala .. and will be released with 2.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants