-
Notifications
You must be signed in to change notification settings - Fork 10
perf: implement NextGEQ #345
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
Merged
+811
−5
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
6b42af1
fast lid representation for optimized comparison
cheb0 c4d671e
add tests
cheb0 ad98152
remove reverse flag from node_range.go, delete unneeded null checks
cheb0 6d5bbab
Merge branch 'refs/heads/main' into 0-fast-cmp-xor
cheb0 e9401ba
rebase onto fast cmp
cheb0 5288d49
Merge branch 'refs/heads/main' into 0-fast-cmp-xor
cheb0 c31cb85
Merge branch 'refs/heads/0-fast-cmp-xor' into 332-next-geq
cheb0 4a8237e
fixes
cheb0 e2e89f8
implement String
cheb0 7de3263
linter fixes
cheb0 1e942d0
fix
cheb0 368d6c4
const masks
cheb0 a207c89
Merge branch 'refs/heads/0-fast-cmp-xor' into 332-next-geq
cheb0 08efdb7
rename node.CmpLID => node.LID
cheb0 684371e
Merge branch 'refs/heads/0-fast-cmp-xor' into 332-next-geq
cheb0 f62e2ab
remove TODO
cheb0 6035a9c
rename node.CmpLID => node.LID
cheb0 75663bb
Merge branch 'refs/heads/0-fast-cmp-xor' into 332-next-geq
cheb0 f6ac1eb
rename node.CmpLID => node.LID
cheb0 8c12ab3
rename node.CmpLID => node.LID (filename)
cheb0 c42a519
Merge branch 'refs/heads/0-fast-cmp-xor' into 332-next-geq
cheb0 35219c8
rename node.CmpLID => node.LID (filename)
cheb0 68f1aa3
review fixes
cheb0 e3fee6c
Merge branch 'refs/heads/main' into 0-fast-cmp-xor
cheb0 3c722bb
Merge branch 'refs/heads/main' into 0-fast-cmp-xor
cheb0 eadd789
review fixes
cheb0 bcbf323
review fixes
cheb0 3678a3a
review fixes: make masks private
cheb0 5925841
Merge branch 'main' into 0-fast-cmp-xor
cheb0 1e602f6
rename
cheb0 45611fb
Merge remote-tracking branch 'origin/0-fast-cmp-xor' into 0-fast-cmp-xor
cheb0 48d45b5
Merge remote-tracking branch 'origin/0-fast-cmp-xor' into 332-next-geq
cheb0 42a2183
Merge branch 'main' into 332-next-geq
cheb0 8be3a21
fix build
cheb0 e31ba10
review fixes: retire gallop search, honest NextGEQ
cheb0 53e51d8
review fixes
cheb0 2bd2a94
review fixes: call Next()
cheb0 db23bd2
review fixes: add TODO
cheb0 045ae6a
review fix: delete gallop search
cheb0 7c7eb95
linter fixes
cheb0 3e12a0a
Merge branch 'main' into 332-next-geq
cheb0 0b0a5ba
PR review: add TODO comment
cheb0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package node | ||
|
|
||
| import ( | ||
| "math" | ||
| "math/rand/v2" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestNodeAnd_NextGeqAscending(t *testing.T) { | ||
| left := NewStatic([]uint32{1, 2, 7, 10, 20, 25, 26, 30, 50, 80, 90, 100}, false) | ||
| right := NewStatic([]uint32{1, 3, 4, 7, 9, 30, 40, 45, 60, 80, 110}, false) | ||
|
|
||
| node := NewAnd(left, right) | ||
|
|
||
| id := node.NextGeq(NewDescLID(7)) | ||
| assert.Equal(t, uint32(7), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewDescLID(50)) | ||
| assert.Equal(t, uint32(80), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewDescLID(50)) | ||
| assert.True(t, id.IsNull()) | ||
| } | ||
|
|
||
| // TestNodeAnd_NextGeqCompatibility tests that just calling NextGeq with 0 passed as argument is equivalent to | ||
| // calling Next | ||
| func TestNodeAnd_NextGeqCompatibility(t *testing.T) { | ||
| for _, asc := range []bool{true, false} { | ||
| left := []uint32{rand.Uint32N(10)} | ||
| right := []uint32{rand.Uint32N(10)} | ||
|
|
||
| for i := 1; i < 1000; i++ { | ||
| left = append(left, left[i-1]+rand.Uint32N(10)) | ||
| right = append(right, right[i-1]+rand.Uint32N(10)) | ||
| } | ||
|
|
||
| node := NewAnd(NewStatic(left, asc), NewStatic(right, asc)) | ||
| nodeGeq := NewAnd(NewStatic(left, asc), NewStatic(right, asc)) | ||
|
|
||
| var zero uint32 | ||
| if asc { | ||
| zero = math.MaxUint32 | ||
| } else { | ||
| zero = 0 | ||
| } | ||
|
|
||
| for { | ||
| lid := node.Next() | ||
| lidGeq := nodeGeq.NextGeq(NewLID(zero, asc)) | ||
|
|
||
| assert.Equal(t, lid, lidGeq) | ||
|
|
||
| if lid.IsNull() { | ||
| break | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package node | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestNodeNAnd_NextGeq(t *testing.T) { | ||
| neg := NewStatic([]uint32{1, 2, 7, 10, 20, 25, 26, 30, 50, 80, 90, 100}, false) | ||
| reg := NewStatic([]uint32{1, 3, 4, 7, 9, 30, 40, 45, 60, 80, 110}, false) | ||
|
|
||
| node := NewNAnd(neg, reg) | ||
|
|
||
| id := node.NextGeq(NewDescLID(7)) | ||
| assert.Equal(t, uint32(9), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewDescLID(50)) | ||
| assert.Equal(t, uint32(60), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewDescLID(100)) | ||
| assert.Equal(t, uint32(110), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewDescLID(100)) | ||
| assert.True(t, id.IsNull()) | ||
| } | ||
|
|
||
| func TestNodeNAnd_NextGeq_Reverse(t *testing.T) { | ||
| neg := NewStatic([]uint32{1, 2, 7, 10, 20, 25, 26, 30, 50, 80, 90, 100}, true) | ||
| reg := NewStatic([]uint32{1, 3, 4, 7, 9, 30, 40, 45, 60, 80, 110}, true) | ||
|
|
||
| node := NewNAnd(neg, reg) | ||
|
|
||
| id := node.NextGeq(NewAscLID(80)) | ||
| assert.Equal(t, uint32(60), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewAscLID(49)) | ||
| assert.Equal(t, uint32(45), id.Unpack()) | ||
|
|
||
| // call with same nextID, should just return next value | ||
| id = node.NextGeq(NewAscLID(49)) | ||
| assert.Equal(t, uint32(40), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewAscLID(49)) | ||
| assert.Equal(t, uint32(9), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewAscLID(4)) | ||
| assert.Equal(t, uint32(4), id.Unpack()) | ||
|
|
||
| id = node.NextGeq(NewAscLID(1)) | ||
| assert.True(t, id.IsNull()) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.