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: optimize key comparator for indicates key sort #6555

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

guqing
Copy link
Member

@guqing guqing commented Aug 30, 2024

What type of PR is this?

/kind improvement
/area core
/milestone 2.19.x

What this PR does / why we need it:

重构 KeyComparator 并通过更多的测试用例来确保排序功能的正确性

同时修复了可能存在溢出导致比较结果不正确的问题,目前:

  1. 字符串长度比较:在 compareStrings 方法中,字符串的长度比较使用 Integer.compare,这部分代码不会产生整数溢出问题。
  2. 数字部分的比较:在 compareNumbers 方法中,数字的比较是基于字符比较的(即逐位比较每个数字字符),没有涉及到将数3. 字字符串转化为 int 或 long 类型的操作,所以不会存在整数溢出问题。
  3. 处理小数部分的比较:在 compareDecimalNumbers 方法中,类似地,比较操作也是基于字符的,不涉及到数值转换,因此也不存在整数溢出问题

Which issue(s) this PR fixes:

Fixes #6466

Does this PR introduce a user-facing change?

修复由于索引比较时可能出现整数溢出导致文章偶尔无法访问的问题

@f2c-ci-robot f2c-ci-robot bot added kind/improvement Categorizes issue or PR as related to a improvement. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Aug 30, 2024
@f2c-ci-robot f2c-ci-robot bot added this to the 2.19.x milestone Aug 30, 2024
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Aug 30, 2024
@f2c-ci-robot f2c-ci-robot bot requested review from JohnNiang and wan92hen August 30, 2024 06:02
Copy link

Copy link

codecov bot commented Aug 30, 2024

Codecov Report

Attention: Patch coverage is 75.29412% with 21 lines in your changes missing coverage. Please review.

Project coverage is 57.99%. Comparing base (6cd8dc8) to head (aa326a8).
Report is 42 commits behind head on main.

Files with missing lines Patch % Lines
...va/run/halo/app/extension/index/KeyComparator.java 75.29% 12 Missing and 9 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6555      +/-   ##
============================================
- Coverage     58.18%   57.99%   -0.19%     
- Complexity     3774     3912     +138     
============================================
  Files           651      670      +19     
  Lines         22125    22940     +815     
  Branches       1538     1572      +34     
============================================
+ Hits          12873    13305     +432     
- Misses         8641     9020     +379     
- Partials        611      615       +4     

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

Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

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

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Aug 30, 2024
Copy link
Member

@JohnNiang JohnNiang 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

f2c-ci-robot bot commented Aug 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 30, 2024
@f2c-ci-robot f2c-ci-robot bot merged commit ba49dca into halo-dev:main Aug 30, 2024
8 checks passed
@ruibaby ruibaby modified the milestones: 2.19.x, 2.19.0 Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

未知原因的文章 404
3 participants