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(state_table): Cow for get row, minor refactors #3241

Merged
merged 3 commits into from
Jun 15, 2022

Conversation

skyzh
Copy link
Contributor

@skyzh skyzh commented Jun 15, 2022

Signed-off-by: Alex Chi iskyzh@gmail.com

What's changed and what's your intention?

TopN test doesn't pass, guess there's something wrong with it. Will fix later.

Checklist

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

Refer to a related PR or issue link (optional)

Signed-off-by: Alex Chi <iskyzh@gmail.com>
@skyzh skyzh changed the title refactor(state_table): not pass prefix when using pk bounds refactor(state_table): Cow for get row, minor refactors Jun 15, 2022
@skyzh skyzh requested review from BugenZhao, wcy-fdu and BowenXiao1999 and removed request for BugenZhao and wcy-fdu June 15, 2022 08:24
@skyzh skyzh marked this pull request as ready for review June 15, 2022 08:24
@skyzh skyzh requested review from wcy-fdu and BugenZhao June 15, 2022 08:25
@codecov
Copy link

codecov bot commented Jun 15, 2022

Codecov Report

Merging #3241 (1c839de) into main (88c6bae) will increase coverage by 0.00%.
The diff coverage is 95.00%.

@@           Coverage Diff           @@
##             main    #3241   +/-   ##
=======================================
  Coverage   73.22%   73.22%           
=======================================
  Files         747      747           
  Lines      101882   101892   +10     
=======================================
+ Hits        74602    74610    +8     
- Misses      27280    27282    +2     
Flag Coverage Δ
rust 73.22% <95.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
src/storage/src/table/cell_based_table.rs 75.95% <ø> (ø)
src/storage/src/table/state_table.rs 93.46% <95.00%> (-0.25%) ⬇️
src/meta/src/model/barrier.rs 78.57% <0.00%> (-3.58%) ⬇️
src/meta/src/barrier/mod.rs 69.94% <0.00%> (-0.30%) ⬇️
src/common/src/types/ordered_float.rs 24.90% <0.00%> (+0.19%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

pub async fn get_row(&self, pk: &Row, epoch: u64) -> StorageResult<Option<Row>> {
/// Get a single row from state table. This function will return a Cow. If the value is from
/// memtable, it will be a [`Cow::Borrowed`]. If is from cell based table, it will be an owned
/// value. To convert `Option<Cow<Row>>` to `Option<Row>`, just call `to_owned`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// value. To convert `Option<Cow<Row>>` to `Option<Row>`, just call `to_owned`.
/// value. To convert `Option<Cow<Row>>` to `Option<Row>`, just call `into_owned`.

@@ -57,8 +57,7 @@ pub struct CellBasedTable<S: StateStore> {
column_descs: Vec<ColumnDesc>,

/// Mapping from column id to column index
/// TODO: all CellBasedTable users should have a pk serializer, we should remove this option.
pub pk_serializer: Option<OrderedRowSerializer>,
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the Option now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet

@@ -167,7 +188,7 @@ impl<S: StateStore> StateTable<S> {
self.iter_with_pk_bounds::<_, Row>(.., epoch).await
}

/// This function scans rows from the relational table with specific `pk_bounds`.
/// This function scans rows from the relational table with specific `pk_prefix`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// This function scans rows from the relational table with specific `pk_prefix`.
/// This function scans rows from the relational table with specific `pk_bounds`.

@@ -239,76 +260,71 @@ where
let cell_based_table_iter = self.cell_based_table_iter.peekable();
Copy link
Member

Choose a reason for hiding this comment

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

Also fuse this stream?

Suggested change
let cell_based_table_iter = self.cell_based_table_iter.peekable();
let cell_based_table_iter = self.cell_based_table_iter.fuse().peekable();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

@BowenXiao1999 BowenXiao1999 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@wcy-fdu wcy-fdu left a comment

Choose a reason for hiding this comment

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

LSTM

Signed-off-by: Alex Chi <iskyzh@gmail.com>
@skyzh skyzh enabled auto-merge (squash) June 15, 2022 09:18
@skyzh skyzh merged commit 4f0ef58 into main Jun 15, 2022
@skyzh skyzh deleted the skyzh/refactor-table branch June 15, 2022 09:29
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.

None yet

4 participants