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 transaction into batch and snapshot #2182

Merged
merged 4 commits into from
Oct 3, 2024
Merged

Conversation

weiihann
Copy link
Contributor

@weiihann weiihann commented Sep 26, 2024

Description

This PR removes the Transaction struct and added batch and snapshot which implements the Transaction interface. batch is used for read-write operations while snapshot is used for read-only operations.

Rationale

A transaction can only be a batch or a snapshot, not both at the same time. The following pattern may be unnecessary:

if t.batch != nil {
  ...do something with batch
} else if t.snapshot != nil {
  ...do something with snapshot 
}

It's clearer to just separate batch and snapshot into different structs and use them accordingly.

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 74.15730% with 23 lines in your changes missing coverage. Please review.

Project coverage is 78.52%. Comparing base (0c0700c) to head (339d747).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
db/pebble/snapshot.go 46.66% 11 Missing and 5 partials ⚠️
db/pebble/batch.go 86.95% 3 Missing and 3 partials ⚠️
db/pebble/common.go 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2182      +/-   ##
==========================================
+ Coverage   78.44%   78.52%   +0.07%     
==========================================
  Files         100      102       +2     
  Lines        9191     9205      +14     
==========================================
+ Hits         7210     7228      +18     
+ Misses       1348     1346       -2     
+ Partials      633      631       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

db/db.go Show resolved Hide resolved
db/pebble/db.go Outdated Show resolved Hide resolved
Copy link
Contributor

@IronGauntlets IronGauntlets left a comment

Choose a reason for hiding this comment

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

In general, it looks good to me. I have let some comments

@kirugan kirugan merged commit 262c51f into main Oct 3, 2024
10 checks passed
@kirugan kirugan deleted the weiihann/refactor-txn branch October 3, 2024 09:47
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.

3 participants