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
lightning: implement duplicate detector #43460
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Skipping CI for Draft Pull Request. |
a488e1f
to
9d5b799
Compare
4ce7382
to
4a661d2
Compare
/test unit-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will review worker later
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestInternalKey(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it's a good case to try FuzzXxx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it seems FuzzXxx
will not run automatically. If you think we need some fuzz tests, I can add some random tests using rand
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really need, I just find a good place to try new technique.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest lgtm
return splitKey | ||
} | ||
|
||
c1, c2 := startKey[l], endKey[l] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will endKey equal to empty slice? so we will meet index out of range
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's guaranteed that endKey
is greater than startKey
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest lgtm
// KeyAdder is used to add keys to the Detector. | ||
type KeyAdder struct { | ||
w extsort.Writer | ||
buf []byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used in Add
function.
|
||
// Detect detects duplicate keys that have been added to the Detector. | ||
// It returns the number of duplicate keys detected and any error encountered. | ||
func (d *Detector) Detect(ctx context.Context, opts *DetectOptions) (numDups int64, _ error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move Detector
code up, close with it's definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in c2d6a17.
} | ||
opts.ensureDefaults() | ||
|
||
logTask := d.logger.Begin(zap.InfoLevel, "[dup-detector] sort keys") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a zapper field to indicate [dup-detector]
part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in c2d6a17.
/merge |
This pull request has been accepted and is ready to merge. Commit hash: c2d6a17
|
What problem does this PR solve?
Issue Number: ref #41629
Problem Summary:
What is changed and how it works?
Implement a duplicate detector to detect key duplicates.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.