Skip to content

MINOR: update the KStream#branch(split) doc and java doc and tests#11195

Merged
mjsax merged 1 commit intoapache:trunkfrom
showuon:updateBranchDoc
Aug 10, 2021
Merged

MINOR: update the KStream#branch(split) doc and java doc and tests#11195
mjsax merged 1 commit intoapache:trunkfrom
showuon:updateBranchDoc

Conversation

@showuon
Copy link
Copy Markdown
Member

@showuon showuon commented Aug 10, 2021

  1. update documentation to fix some wrong (out-dated) content
    After KAFKA-5488: Add type-safe split() operator #9107 (KIP-418), the returned content is not kstream[] anymore. Also, this description: If no predicate matches, the the record is dropped. is not right now. It'll be routed to the default branch, or dropped if no default branch is created. Fix them.

image

  1. update java doc
  2. add a test for Branched.withFunction() with non-null result test case.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@Override
public Branched<K, V> withName(final String name) {
Objects.requireNonNull(name, "name cannot be null");
return new Branched<>(name, chainFunction, chainConsumer);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a similar method: as that accept a name parameter to create a Branched instance here. We did a name null check there. We should also have a null check here for consistency.

public static <K, V> Branched<K, V> as(final String name) {
        Objects.requireNonNull(name, "name cannot be null");
        return new Branched<>(name, null, null);
    }

* .branch(predicate3, Branched.withFunction(ks->null)) // no entry: chain function returns null
* .branch(predicate4) // "foo-4": name defaults to the branch position
* .branch(predicate4, Branched.withFunction(ks->ks)) // "foo-4": chain function returns non-null value
* .branch(predicate5) // "foo-5": name defaults to the branch position
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add an example to explain the function return with non-null result case.

// "foo-4": chain function returns non-null value
.branch(isNegative, Branched.withFunction(ks -> ks))
// "foo-5": name defaults to the branch position
.branch(isMultipleOfSeven)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test case for function return with non-null result case.

@showuon
Copy link
Copy Markdown
Member Author

showuon commented Aug 10, 2021

@inponomarev @mjsax @vvcephei , please help review this PR. Thanks.

@mjsax mjsax added the streams label Aug 10, 2021
@mjsax mjsax merged commit 2bfd0ae into apache:trunk Aug 10, 2021
mjsax pushed a commit that referenced this pull request Aug 10, 2021
Reviewers: Ivan Ponomarev <iponomarev@mail.ru>, Matthias J. Sax <matthias@confluent.io>
mjsax pushed a commit that referenced this pull request Aug 10, 2021
Reviewers: Ivan Ponomarev <iponomarev@mail.ru>, Matthias J. Sax <matthias@confluent.io>
@mjsax
Copy link
Copy Markdown
Member

mjsax commented Aug 10, 2021

Thanks for the PR @showuon! Merged to trunk and cherry-picked to 3.0 and 2.8 branches.

xdgrulez pushed a commit to xdgrulez/kafka that referenced this pull request Dec 22, 2021
)

Reviewers: Ivan Ponomarev <iponomarev@mail.ru>, Matthias J. Sax <matthias@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants