Skip to content

Conversation

rkhachatryan
Copy link
Contributor

@rkhachatryan rkhachatryan commented Sep 30, 2025

Introduce OrderedMultiSetState and 3 implementations (map, value, adaptive) to be used in SInkUpsertMaterializerV2.

Test coverage is currently provided on the operator level (#27070).

I'm planning to add lower-level unit tests later to this PR.

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 30, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@rkhachatryan rkhachatryan marked this pull request as ready for review October 1, 2025 08:40
@rkhachatryan rkhachatryan requested a review from pnowojski October 1, 2025 08:40

/**
* Remove the given element. If there are multiple instances of the same element, remove the
* first one in insertion order.
Copy link
Contributor

Choose a reason for hiding this comment

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

I am curious : should we allow the user to choose LIFO or FIFO for the remove ?

* The most recently added element was removed. The result will contain the element added
* before it.
*/
REMOVED_LAST_ADDED,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see tests checking these removal result types.

* An element was removed, it was not the most recently added, there are more elements. The
* result will not contain any elements
*/
REMOVED_OTHER
Copy link
Contributor

Choose a reason for hiding this comment

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

I am curious why nothing is returned in this case, this seems inconsistent with REMOVED_LAST_ADDED which will return the element added before it.

SizeChangeInfo append(T element, long timestamp) throws Exception;

/** Get iterator over all remaining elements and their timestamps, in order of insertion. */
Iterator<Tuple2<T, Long>> iterator() throws Exception;
Copy link
Contributor

@davidradl davidradl Oct 2, 2025

Choose a reason for hiding this comment

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

if the multi set changes (i.e. there is a removal) under the iterator what will happen? AI unit test for this would be good. It would be useful to understand any locking that has been considered or is in place.

Copy link
Contributor

@pnowojski pnowojski left a comment

Choose a reason for hiding this comment

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

(partial review, I haven't yet reviewed linked variant and tests).

Comment on lines 50 to 51
@Internal
@Experimental
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 aren't those two mutually exclusive? Class can either be Internal and not intended to be used outside of the Flink's repo, or Experimental/PublicEvolving/Public depending on the stability of the said api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see why @Experimental implies not-internal but I'd be fine removing it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here you have stated that Experimental is intended to be used by users

https://nightlies.apache.org/flink/flink-docs-master/docs/ops/upgrading/#api-compatibility-guarantees

so it has to be dropped here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointer, dropped @Experimental.

@github-actions github-actions bot added the community-reviewed PR has been reviewed by the community. label Oct 3, 2025
* @see org.apache.flink.api.common.state.ValueState
*/
@Internal
public class LinkedMultiSetState implements OrderedMultiSetState<RowData> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should have test coverage for this quite complex class. Ditto for Value and Adaptive versions, so probably one test suite to be executed on different implementations with adaptive configured in a couple of different ways?

Plus some dedicated tests for switchover in Adaptive version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely, so far I was adding the tests at the operator level, but will add the tests in this PR as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the tests (and fixed the found bugs).

@rkhachatryan rkhachatryan requested a review from pnowojski October 8, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-reviewed PR has been reviewed by the community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants