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

Fix merge iterator duplicates issue #1157

Merged
merged 3 commits into from
Dec 18, 2019

Conversation

jarifibrahim
Copy link
Contributor

@jarifibrahim jarifibrahim commented Dec 12, 2019

Fixes: #1153

The tree-based merge iterator would not skip duplicate keys. This PR fixes it.
If merge iterator consists of 3 iterator

it1 = [1, 1, 1]
it2 = [1, 1, 1, 1, 2]
it3 = [1, 1, 1, 1, 2]

The result should be

[1, 2]

This change is Reviewable

@coveralls
Copy link

coveralls commented Dec 12, 2019

Coverage Status

Coverage decreased (-0.1%) to 69.921% when pulling 9a52493 on ibrahim/mergeiterator-duplicate into 7c5e6d7 on master.

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

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

:lgtm: please merge after tests pass.

Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ashish-goswami, @jarifibrahim, and @manishrjain)


table/merge_iterator.go, line 33 at r1 (raw file):

	small *node

	curKey  []byte

Please add a comment saying that this is used for remove duplicate keys across different iterators.

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ashish-goswami and @jarifibrahim)


table/merge_iterator.go, line 164 at r1 (raw file):

func (mi *MergeIterator) setCurrent() {
	if cap(mi.curKey) < len(mi.small.key) {
		mi.curKey = make([]byte, 2*len(mi.small.key))

mi.curKey = append(mi.curKey[:0], mi.small.key...)

@jarifibrahim
Copy link
Contributor Author

Windows build is not failing because of this PR. I'll fix the windows build in a separate PR.

@jarifibrahim jarifibrahim merged commit 779d9a0 into master Dec 18, 2019
@jarifibrahim jarifibrahim deleted the ibrahim/mergeiterator-duplicate branch December 18, 2019 13:14
jarifibrahim pushed a commit that referenced this pull request Mar 12, 2020
Fixes: #1153

The tree-based merge iterator would not skip duplicate keys.
This commit fixes it.
If merge iterator consists of 3 iterators
```
it1 = [1, 1, 1]
it2 = [1, 1, 1, 1, 2]
it3 = [1, 1, 1, 1, 2]
```
The result should be
```
[1, 2]
```

(cherry picked from commit 779d9a0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Behaviour difference between old and new merge iterator
4 participants