Skip to content
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

refactor(common): move some over window utils to common #14204

Merged
merged 10 commits into from
Dec 27, 2023

Conversation

stdrc
Copy link
Member

@stdrc stdrc commented Dec 26, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

We had some handy utils and helper types in over_window module before, including KeyWithSentinel (renamed to Sentinelled), EstimatedBTreeMap and DeltaBTreeMap. This PR moves:

  • Sentinelled to common/types;
  • EstimatedBTreeMap to common/estimate_size;
  • DeltaBTreeMap to utils/delta_btree_map.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@xxchan
Copy link
Member

xxchan commented Dec 26, 2023

Where can they be reused?

@stdrc
Copy link
Member Author

stdrc commented Dec 26, 2023

Where can they be reused?

Idk, but

  • for KeyWithSentinel, I found it needed by another over_window submodule being implementing which indicates it's generality (at least some extent of);
  • for EstimatedBTreeMap, it's very common and has nothing related to over window, it's reasonable to move it to common following the convention of EstimatedHashMap and EstimatedVecDeque;
  • for DeltaBTreeMap, we have a similar but with different purpose struct in meta, BTreeMapTransaction, which focuses on insert/delete/get operations while DeltaBTreeMap focuses on get/iter operations. This indicates that this kind of helper types may be needed by other modules, so moving it to common can prevent potential re-invention.

@xxchan
Copy link
Member

xxchan commented Dec 26, 2023

It would be better to be put in a separate crate common/xxx or utils/xxx

@stdrc
Copy link
Member Author

stdrc commented Dec 26, 2023

It would be better to be put in a separate crate common/xxx or utils/xxx

Which one do you mean? This PR actually moves three different things to common: Sentinelled, EstimatedBTreeMap and DeltaBTreeMap. They logically belong to different common/xxx: Sentinelled is a type wrapper to help order things with smallest and largest which always rank first/last, so moved to common/types; EstimatedBTreeMap is a estimated-size version of BTreeMap, so moved to common/estimated_size; DeltaBTreeMap is a util to help iterate over a BTreeMap and some changes on it, so moved to common/utils.

Signed-off-by: Richard Chien <[email protected]>
@xxchan
Copy link
Member

xxchan commented Dec 26, 2023

I mean I don't want to the risingwave_common crate bloats. (Ideally) each utils should live in it's own crate. Especially for sth that can be widely used by other ppl without any context, (and doesn't depend on other stuff).

I think the common crate is for things that are widely used in our system (and it's specialized for our system, e.g., types, arrays, chunks).

How do you think?>

@xxchan
Copy link
Member

xxchan commented Dec 26, 2023

I'm emphasizing organizing code in "crates", not "modules" 🤪

@stdrc
Copy link
Member Author

stdrc commented Dec 26, 2023

I'm emphasizing organizing code in "crates", not "modules" 🤪

You're right. So we'd better separate many of the modules in common crate into different crates right? Will have a try tmr.

@xxchan
Copy link
Member

xxchan commented Dec 26, 2023

So we'd better separate many of the modules in common crate into different crates right?

Yes, that's what in my head. Although I don't think it makes much difference for the common crate NOW (Currently it takes only a few secs to compile), I view it as a mindset problem. We can do the right things at the beginning.. Other opinions are also welcomed. 🤪

@stdrc stdrc requested a review from a team as a code owner December 27, 2023 06:45
@stdrc stdrc requested a review from xxchan December 27, 2023 06:46
Signed-off-by: Richard Chien <[email protected]>
@stdrc stdrc enabled auto-merge December 27, 2023 06:57
@stdrc stdrc added this pull request to the merge queue Dec 27, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 27, 2023
Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

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

Rest LGTM.

@@ -0,0 +1,21 @@
[package]
name = "delta_btree_map"
Copy link
Contributor

Choose a reason for hiding this comment

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

As our convention, the name shall be risingwave_delta_btree_map.

src/utils/delta_btree_map/src/lib.rs Show resolved Hide resolved
@stdrc stdrc added this pull request to the merge queue Dec 27, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 27, 2023
@stdrc stdrc added this pull request to the merge queue Dec 27, 2023
Merged via the queue into main with commit d27d6c1 Dec 27, 2023
28 of 29 checks passed
@stdrc stdrc deleted the rc/move-over-window-utils-to-common branch December 27, 2023 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants