-
Notifications
You must be signed in to change notification settings - Fork 14k
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
KAFKA-16339: [1/4 KStream#transform] Remove Deprecated "transformer" methods and classes #17198
KAFKA-16339: [1/4 KStream#transform] Remove Deprecated "transformer" methods and classes #17198
Conversation
I have missed removing the references to |
I have noticed that |
bafaa10
to
f28ac72
Compare
For now, I have removed the build with deduplicaiton topology test until we decide how to replace the |
I have replaced |
I have managed to fix the test! :D |
I have removed the references to |
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.
Thanks for the PR. Made a pass.
Btw: is there anything in docs/streams/...
that we need to update/remove, too (we can also do this as a single docs-only PR for the whole ticket, ie, all transformXxx()
method)
@@ -179,8 +178,7 @@ <KR> KStream<KR, V> selectKey(final KeyValueMapper<? super K, ? super V, ? exten | |||
* altered arbitrarily). | |||
* The provided {@link KeyValueMapper} is applied to each input record and computes a new output record. | |||
* Thus, an input record {@code <K,V>} can be transformed into an output record {@code <K':V'>}. | |||
* This is a stateless record-by-record operation (cf. {@link #transform(TransformerSupplier, String...)} for | |||
* stateful record transformation). | |||
* This is a stateless record-by-record operation. |
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.
Yes, it think we should link to #process(...)
here, instead of removing (same elsewhere where it make sense).
Btw: feel free to skip updating JavaDocs of other deprecated methods which will be remove in follow up PRs of this ticket.
streams/src/main/java/org/apache/kafka/streams/kstream/TransformerSupplier.java
Show resolved
Hide resolved
streams/src/main/java/org/apache/kafka/streams/kstream/ValueTransformerSupplier.java
Show resolved
Hide resolved
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImpl.java
Show resolved
Hide resolved
@@ -360,11 +368,9 @@ public KeyValue<Integer, Integer> transform(final Integer key, final Integer val | |||
throw new RuntimeException("Injected test error"); | |||
} | |||
|
|||
return KeyValue.pair(key, value); | |||
store.put(key, value); |
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.
We do we add a put here?
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.
Similar to the return null replacement with delete. Since we would return a pair with key and value, now I put it in store.
@ParameterizedTest | ||
@MethodSource("data") | ||
@SuppressWarnings("deprecation") | ||
public void shouldPunctuateWithTimestampPreservedInProcessorContext(final boolean stateUpdaterEnabled, final boolean processingThreadsEnabled) { |
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 think we need to keep this test, but rewrite using #process()
.
@@ -276,61 +274,6 @@ class TopologyTest { | |||
assertEquals(getTopologyScala, getTopologyJava) | |||
} | |||
|
|||
@nowarn | |||
@Test | |||
def shouldBuildIdenticalTopologyInJavaNScalaTransform(): Unit = { |
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.
Wondering if we have a test gap, as we don't have a similar test for process()
-- should we add a new test for #process()
like this one (or rewrite this test for #process()
)?
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 have rewritten this test with process
, but have missed to rewrite the test name. I will fix it.
@@ -222,42 +221,6 @@ class KStreamTest extends TestDriver { | |||
testDriver.close() | |||
} | |||
|
|||
@nowarn | |||
@Test | |||
def testTransformCorrectlyRecords(): Unit = { |
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.
Same question as above. Seems we are lacking a similar test for #process()
?
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.
Hm... I have replaced Transformer with ProcessorSupplier and transform with process. Have I missed something else?
@nowarn | ||
@Test | ||
def testSettingNameOnTransform(): Unit = { | ||
class TestTransformer extends Transformer[String, String, KeyValue[String, String]] { |
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.
Same
I will push some commits, one for each file from which I have removed the transform link, replacing it with process. |
35fd141
to
203f323
Compare
I have rebased my branch on trunk and this caused GitHub to close the PR. I am implementing the last review points again. |
This time, I have focused on removing the methods first and doing refactorings. After this, I will proceed with Javadoc updates. I have made the removing part. Now, I will do the refactoring part. |
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.
Thanks for updating the PR. LGTM.
Just triggered CI. Can merge after it finished and passed.
@fonsdant -- seems there is some compilation error:
Seem we need to rewrite this test to use the new |
Thanks, @mjsax, still need to refactor it. Meanwhile, do you prefer that I convert this PR to draft? Or should I keep it as it is? |
We can keep this PR as-is -- you can also to the refactoring as part of this PR if you want. |
@fonsdant Any update on this PR? -- We are approaching AK 4.0 release deadlines, and there is 3 more PRs for this ticket... |
@mjsax, sorry for the delay, I am still refactoring the tests, replacing transform with process. Given the coming deadline, I agree it would be adequate someone more experienced to resume it. |
I will push the work I done this passed week. |
As long as you have enough time to keep working, I think we are a good. Of course, if you are blocked, let us know. |
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
46a01a6
to
7a65aed
Compare
...-tests/src/test/java/org/apache/kafka/streams/integration/StandbyTaskEOSIntegrationTest.java
Outdated
Show resolved
Hide resolved
...-tests/src/test/java/org/apache/kafka/streams/integration/StandbyTaskEOSIntegrationTest.java
Outdated
Show resolved
Hide resolved
...-tests/src/test/java/org/apache/kafka/streams/integration/StandbyTaskEOSIntegrationTest.java
Outdated
Show resolved
Hide resolved
...-tests/src/test/java/org/apache/kafka/streams/integration/StandbyTaskEOSIntegrationTest.java
Outdated
Show resolved
Hide resolved
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamThreadTest.java
Outdated
Show resolved
Hide resolved
// | ||
// val transformNode = builder.build().describe().subtopologies().asScala.head.nodes().asScala.toList(1) | ||
// assertEquals("my-name", transformNode.name()) | ||
// } |
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.
Should we rewrite this to testSettingNameOnProcess
?
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.
Oh, sorry! I have missed it up. Of course, I will rewrite it!
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
@mjsax, I have removed the adding lines in buildTopologyWithDeduplication in StandbyTaskEOSIntegrationTest to match the previous implementation with transform (but still with process). Also, removed the comments of the KStreamTest scala test and rewritten it. Finally, removed var usage. |
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.
Thanks for the quick turn around. I think the Scala test can be simplified significantly. In the end, we only verify the name of he processor node in the Topology
.
@Test | ||
def testSettingNameOnTransform(): Unit = { | ||
val processorSupplier: ProcessorSupplier[String, String, String, String] = | ||
new api.ProcessorSupplier[String, String, String, String] { |
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.
Why do we need an explicit ProcessorSupplier
for this test? And we use process(() => new TestProcessor)
similar to the old code?
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.
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.
Not sure why IntelliJ shows an error... given that TestProcessor
is api.Processor
I would expect IntelliJ to figure out that the lambda is api.ProcessorSupplier
and resolve to the new process(...)
overload... In any case, the build did pass, so it seem ok. Also, the old process()
will be removed soon, too: #17190
def testSettingNameOnTransform(): Unit = { | ||
val processorSupplier: ProcessorSupplier[String, String, String, String] = | ||
new api.ProcessorSupplier[String, String, String, String] { | ||
private val storeName = "store-name" |
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.
Why do we add a store?
val processedKey = s"$key-processed" | ||
val processedValue = s"$value-processed" | ||
store.put(processedKey, processedValue) | ||
context.forward(new api.Record(processedKey, processedValue, record.timestamp())) |
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.
What the Processor
does is actually pretty meaningless for the test, so I think the while implementation could actually be empty? For this case, we don't even need init()
method, as we don't need access to the context
either.
Signed-off-by: Joao Pedro Fonseca Dantas <[email protected]>
Thanks, @mjsax! I have simplified the test and replaced the processorSupplier with a lambda. Should I replace it for for other methods too? And how about IntelliJ reporting it as problem? |
Merged to |
Uhuu! Here we go! I need to rebase the second one on this first now. Thanks, @mjsax! |
Hi, @mjsax! I have removed the
transform
methods from the main and test classes. However, I have asked myself whether the approach I have used forStandbyTaskEOSIntegrationTest
andStreamThreadTest
is correct. Should I replacetransform
withprocess
as suggested intransform
Javadoc or remove these tests? Thanks!