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 keyrange #939

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

lxl66566
Copy link
Collaborator

@lxl66566 lxl66566 commented Aug 7, 2024

close #743

Please briefly answer these questions:

  • what problem are you trying to solve? (or if there's no problem, what's the motivation for this change?)

    • Previously we always transformed between KeyRange and Interval<BytesAffine>, transform through &[u8]. This may make unnecessary Vec clone and memory allocation.
    • And the conflict check in KeyRange is too confusing and troubling due to Bounds.
  • what changes does this pull request make?

    • now KeyRange is refactored:
      pub enum KeyRange {
          OneKey(Vec<u8>),
          Range(Interval<BytesAffine>),
      }
      and it can convert between EtcdKeyRange and Interval<BytesAffine> without cloning.
    • The conflict check is also convenient by using Interval::overlap.
    • The reason spliting KeyRange to OneKey and Range is to distinguish prefix and onekey, which may has same form in [a, a+1).
    • refactored some KeyRange usage in crates/xline/src/storage/index.rs and crates/xline/src/storage/kv_store.rs. By using KeyRange directly instead of start: &[u8], end: &[u8] maybe better to construct from one key or all keys, and reduce the clone times.
  • are there any non-obvious implications of these changes? (does it break compatibility with previous versions, etc)

@mergify mergify bot requested a review from a team August 7, 2024 12:39
Copy link

mergify bot commented Aug 7, 2024

@lxl66566 Convert your pr to draft since CI failed

@mergify mergify bot marked this pull request as draft August 7, 2024 12:48
@mergify mergify bot added the CI:fail CI has failed label Aug 7, 2024
@lxl66566 lxl66566 force-pushed the refactor-keyrange branch 2 times, most recently from 3ee8802 to 60f7fee Compare August 9, 2024 01:51
@mergify mergify bot marked this pull request as ready for review August 9, 2024 02:01
@mergify mergify bot removed the CI:fail CI has failed label Aug 9, 2024
Copy link

codecov bot commented Aug 9, 2024

Codecov Report

Attention: Patch coverage is 77.82705% with 100 lines in your changes missing coverage. Please review.

Project coverage is 75.15%. Comparing base (e35b35a) to head (30c4a69).
Report is 304 commits behind head on master.

Files with missing lines Patch % Lines
crates/xlineapi/src/keyrange.rs 74.52% 70 Missing and 10 partials ⚠️
crates/xline/src/storage/index.rs 75.51% 12 Missing ⚠️
crates/xlineapi/src/lib.rs 63.63% 4 Missing ⚠️
crates/xline/src/storage/kv_store.rs 96.29% 1 Missing and 1 partial ⚠️
crates/xline/src/storage/auth_store/perms.rs 80.00% 1 Missing ⚠️
crates/xline/src/storage/lease_store/mod.rs 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #939      +/-   ##
==========================================
- Coverage   75.55%   75.15%   -0.41%     
==========================================
  Files         180      189       +9     
  Lines       26938    28541    +1603     
  Branches    26938    28541    +1603     
==========================================
+ Hits        20353    21449    +1096     
- Misses       5366     5794     +428     
- Partials     1219     1298      +79     

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

Copy link

mergify bot commented Aug 15, 2024

@lxl66566 Your PR is in conflict and cannot be merged.

Copy link

This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 14 days

@github-actions github-actions bot added Stale and removed Stale labels Sep 15, 2024
Signed-off-by: lxl66566 <lxl66566@gmail.com>

refactor(xlineapi): KeyRange refactor

Signed-off-by: lxl66566 <lxl66566@gmail.com>

refactor(xlineapi): refactor success, test pass

Signed-off-by: lxl66566 <lxl66566@gmail.com>

refactor(xlineapi): use KeyRange instead of directly pass &[u8] to avoid clone

Signed-off-by: lxl66566 <lxl66566@gmail.com>

refactor(xlineapi): simplify all keys judgement

Signed-off-by: lxl66566 <lxl66566@gmail.com>
Signed-off-by: lxl66566 <lxl66566@gmail.com>
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.

[Refactor]: Remove KeyRange
1 participant