Skip to content

refactor: replace more GAT-based async trait with RPITIT #12271

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

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Sep 13, 2023

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

What's changed and what's your intention?

Hide the whitespaces and you'll find few changes.

As return-position-impl-trait-in-trait is now complete, we can replace more GAT-based async trait with that.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

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.

@github-actions github-actions bot added the type/refactor Type: Refactoring. label Sep 13, 2023
Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

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

Cool!

@BugenZhao BugenZhao enabled auto-merge September 13, 2023 08:26
Copy link
Contributor

@wangrunji0408 wangrunji0408 left a comment

Choose a reason for hiding this comment

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

LGTM!

P.S. Today I learned "hide whitespace".

Comment on lines -97 to +92
type SnapshotStream<'a> = impl Stream<Item = StreamExecutorResult<Option<StreamChunk>>> + 'a;

fn snapshot_read(&self, args: SnapshotReadArgs) -> Self::SnapshotStream<'_> {
#[try_stream]
async move {
let primary_keys = self
.inner
.pk_indices()
.iter()
.map(|idx| {
let f = &self.inner.schema().fields[*idx];
f.name.clone()
})
.collect_vec();

tracing::debug!(
"snapshot_read primary keys: {:?}, current_pos: {:?}",
primary_keys,
args.current_pos
);

let row_stream = self.inner.table_reader().snapshot_read(
self.inner.schema_table_name(),
args.current_pos,
primary_keys,
);

pin_mut!(row_stream);

let mut builder =
DataChunkBuilder::new(self.inner.schema().data_types(), args.chunk_size);
let chunk_stream = iter_chunks(row_stream, &mut builder);
#[for_await]
for chunk in chunk_stream {
yield chunk?;
}
#[try_stream(ok = Option<StreamChunk>, error = StreamExecutorError)]
async fn snapshot_read(&self, args: SnapshotReadArgs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we can also use #[try_stream] in impl Executor to avoid the indirect execute_inner. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I believe it's true.

@BugenZhao BugenZhao added this pull request to the merge queue Sep 13, 2023
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #12271 (cc81f14) into main (cbbee64) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 59.34%.

@@           Coverage Diff           @@
##             main   #12271   +/-   ##
=======================================
  Coverage   69.72%   69.72%           
=======================================
  Files        1411     1411           
  Lines      236365   236326   -39     
=======================================
- Hits       164807   164782   -25     
+ Misses      71558    71544   -14     
Flag Coverage Δ
rust 69.72% <59.34%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/batch/src/execution/local_exchange.rs 57.14% <0.00%> (+1.22%) ⬆️
src/connector/src/source/external.rs 35.08% <15.00%> (-0.21%) ⬇️
src/connector/src/source/mock_external_table.rs 76.47% <55.55%> (ø)
src/batch/src/execution/grpc_exchange.rs 50.00% <58.33%> (-4.35%) ⬇️
...m/src/executor/backfill/upstream_table/snapshot.rs 86.04% <64.28%> (-1.19%) ⬇️
src/stream/src/executor/dispatch.rs 82.52% <71.81%> (+0.23%) ⬆️
src/batch/src/exchange_source.rs 61.53% <100.00%> (-5.13%) ⬇️
src/batch/src/executor/test_utils.rs 61.94% <100.00%> (-0.34%) ⬇️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Merged via the queue into main with commit 6f136bf Sep 13, 2023
@BugenZhao BugenZhao deleted the bz/more-rpitit branch September 13, 2023 09:00
Li0k pushed a commit that referenced this pull request Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/refactor Type: Refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants