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

chore: replace unfold with async-stream #763

Merged
merged 2 commits into from
Mar 27, 2023
Merged

chore: replace unfold with async-stream #763

merged 2 commits into from
Mar 27, 2023

Conversation

chunshao90
Copy link
Contributor

@chunshao90 chunshao90 commented Mar 24, 2023

Which issue does this PR close?

Closes #

Rationale for this change

Replace unfold with async-stream.

What changes are included in this PR?

Replace unfold with async-stream.

Are there any user-facing changes?

No.

How does this change test

Integration test.

@chunshao90 chunshao90 marked this pull request as draft March 24, 2023 09:06
@chunshao90 chunshao90 marked this pull request as ready for review March 24, 2023 09:12
@codecov-commenter
Copy link

Codecov Report

Merging #763 (6f34a3c) into main (a5cd313) will increase coverage by 0.14%.
The diff coverage is 94.24%.

❗ Current head 6f34a3c differs from pull request most recent head 4cbeedc. Consider uploading reports for the commit 4cbeedc to get more accurate results

@@            Coverage Diff             @@
##             main     #763      +/-   ##
==========================================
+ Coverage   68.18%   68.33%   +0.14%     
==========================================
  Files         296      296              
  Lines       46057    46313     +256     
==========================================
+ Hits        31405    31646     +241     
- Misses      14652    14667      +15     
Impacted Files Coverage Δ
analytic_engine/src/instance/mod.rs 83.33% <ø> (ø)
tools/src/bin/sst-convert.rs 1.20% <0.00%> (ø)
analytic_engine/src/instance/write.rs 89.24% <92.23%> (+2.29%) ⬆️
analytic_engine/src/instance/flush_compaction.rs 92.68% <95.00%> (+0.04%) ⬆️
common_types/src/row/mod.rs 77.61% <96.66%> (+2.01%) ⬆️
analytic_engine/src/instance/read.rs 77.93% <96.87%> (+2.93%) ⬆️
analytic_engine/src/compaction/scheduler.rs 74.41% <100.00%> (+0.22%) ⬆️
analytic_engine/src/instance/open.rs 80.74% <100.00%> (+0.80%) ⬆️
analytic_engine/src/lib.rs 98.80% <100.00%> (+0.02%) ⬆️
analytic_engine/src/row_iter/dedup.rs 94.32% <100.00%> (+0.04%) ⬆️
... and 6 more

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jiacai2050
Copy link
Contributor

{
    let (mut __yield_tx, __yield_rx) = unsafe { $crate::__private::yielder::pair() };
    $crate::__private::AsyncStream::new(__yield_rx, async move {
        while let Some(value) = state.fetch_next_batch().await {
            let record_batch = value
                .box_err()
                .context(ErrWithSource {
                    msg: "Read record batch",
                })
                .and_then(|batch_with_key| {
                    batch_with_key
                        .try_project(&state.projected_schema)
                        .box_err()
                        .context(ErrWithSource {
                            msg: "Project record batch",
                        })
                });
            __yield_tx
                .send(::core::result::Result::Ok(match record_batch {
                    ::core::result::Result::Ok(v) => v,
                    ::core::result::Result::Err(e) => {
                        __yield_tx.send(::core::result::Result::Err(e.into())).await;
                        return;
                    }
                }))
                .await;
        }
    })
}

This is what try_stream does, we need to check if it has some side-effect.

Copy link
Member

@ShiKaiWi ShiKaiWi left a comment

Choose a reason for hiding this comment

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

LGTM

@ShiKaiWi ShiKaiWi added this pull request to the merge queue Mar 27, 2023
Merged via the queue into apache:main with commit eb6b1b1 Mar 27, 2023
chunshao90 added a commit to chunshao90/ceresdb that referenced this pull request May 15, 2023
* chore: replace unfold with async-stream

* refactor code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants