-
Notifications
You must be signed in to change notification settings - Fork 14.5k
MINOR: Extended Scala serdes implicit conversions with optional custom naming #6245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
mowczare
wants to merge
2
commits into
apache:trunk
from
mowczare:scala-implicit-conversions-extended
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,9 +35,9 @@ import org.apache.kafka.streams.scala.kstream._ | |
import scala.language.implicitConversions | ||
|
||
/** | ||
* Implicit conversions between the Scala wrapper objects and the underlying Java | ||
* objects. | ||
*/ | ||
* Implicit conversions between the Scala wrapper objects and the underlying Java | ||
* objects. | ||
*/ | ||
object ImplicitConversions { | ||
|
||
implicit def wrapKStream[K, V](inner: KStreamJ[K, V]): KStream[K, V] = | ||
|
@@ -60,24 +60,47 @@ object ImplicitConversions { | |
|
||
implicit def tuple2ToKeyValue[K, V](tuple: (K, V)): KeyValue[K, V] = new KeyValue(tuple._1, tuple._2) | ||
|
||
// we would also like to allow users implicit serdes | ||
// and these implicits will convert them to `Grouped`, `Produced` or `Consumed` | ||
// we would also like to allow users implicit serdes and optional repartition topic / state stores names | ||
// and these implicits will convert them to `Grouped`, `Produced`, `Consumed`, `Materialized` and `Joined` | ||
|
||
implicit def groupedFromNameAndSerde[K, V](repartitionTopicName: String) | ||
(implicit keySerde: Serde[K], valueSerde: Serde[V]): Grouped[K, V] = { | ||
Grouped.`with`[K, V](repartitionTopicName) | ||
} | ||
|
||
implicit def groupedFromSerde[K, V](implicit keySerde: Serde[K], valueSerde: Serde[V]): Grouped[K, V] = | ||
implicit def groupedFromSerde[K, V](implicit keySerde: Serde[K], valueSerde: Serde[V]): Grouped[K, V] = { | ||
Grouped.`with`[K, V] | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are redundant braces we don't need to add them.
|
||
|
||
implicit def consumedFromSerde[K, V](implicit keySerde: Serde[K], valueSerde: Serde[V]): Consumed[K, V] = | ||
implicit def consumedFromSerde[K, V](implicit keySerde: Serde[K], valueSerde: Serde[V]): Consumed[K, V] = { | ||
Consumed.`with`[K, V] | ||
} | ||
|
||
implicit def producedFromSerde[K, V](implicit keySerde: Serde[K], valueSerde: Serde[V]): Produced[K, V] = | ||
implicit def producedFromSerde[K, V](implicit keySerde: Serde[K], valueSerde: Serde[V]): Produced[K, V] = { | ||
Produced.`with`[K, V] | ||
} | ||
|
||
implicit def materializedFromNameAndSerde[K, V, S <: StateStore](stateStoreName: String) | ||
(implicit keySerde: Serde[K], | ||
valueSerde: Serde[V]): Materialized[K, V, S] = { | ||
Materialized.as[K, V, S](stateStoreName) | ||
} | ||
|
||
implicit def materializedFromSerde[K, V, S <: StateStore](implicit keySerde: Serde[K], | ||
valueSerde: Serde[V]): Materialized[K, V, S] = | ||
valueSerde: Serde[V]): Materialized[K, V, S] = { | ||
Materialized.`with`[K, V, S] | ||
} | ||
|
||
implicit def joinedFromNameAndKeyValueOtherSerde[K, V, VO](name: String) | ||
(implicit keySerde: Serde[K], | ||
valueSerde: Serde[V], | ||
otherValueSerde: Serde[VO]): Joined[K, V, VO] = { | ||
Joined.`with`[K, V, VO](name) | ||
} | ||
|
||
implicit def joinedFromKeyValueOtherSerde[K, V, VO](implicit keySerde: Serde[K], | ||
valueSerde: Serde[V], | ||
otherValueSerde: Serde[VO]): Joined[K, V, VO] = | ||
otherValueSerde: Serde[VO]): Joined[K, V, VO] = { | ||
Joined.`with`[K, V, VO] | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this still because it's the default in Scala but it seems that in this code base we adopted the Java style.
So for consistency I guess we should leave it to Java style or bigbang the whole codebase to Scala style.
You need to use
gradle spotlessApply
and commit the formatting change, then your Jenkins should pass.