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

Faster filtering #8

Merged
merged 1 commit into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ import (
)

/*
BenchmarkCollection/insert-8 5545016 216.8 ns/op 18 B/op 0 allocs/op
BenchmarkCollection/fetch-8 27272726 43.61 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/scan-8 648 1844623 ns/op 147 B/op 0 allocs/op
BenchmarkCollection/count-8 1000000 1107 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/range-8 10000 102549 ns/op 9 B/op 0 allocs/op
BenchmarkCollection/update-at-8 4316584 280.7 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/update-all-8 826 1379693 ns/op 53068 B/op 0 allocs/op
BenchmarkCollection/delete-at-8 7059126 169.1 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/delete-all-8 196734 6294 ns/op 0 B/op 0 allocs/op
cpu: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
BenchmarkCollection/insert-8 5531546 215.9 ns/op 18 B/op 0 allocs/op
BenchmarkCollection/fetch-8 23749724 44.97 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/scan-8 784 1527506 ns/op 160 B/op 0 allocs/op
BenchmarkCollection/count-8 1000000 1081 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/range-8 10000 100833 ns/op 14 B/op 0 allocs/op
BenchmarkCollection/update-at-8 4225484 281.7 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/update-all-8 830 1388480 ns/op 105714 B/op 0 allocs/op
BenchmarkCollection/delete-at-8 6928646 171.9 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/delete-all-8 180884 6373 ns/op 1 B/op 0 allocs/op
*/
func BenchmarkCollection(b *testing.B) {
amount := 100000
Expand Down Expand Up @@ -156,7 +157,7 @@ func BenchmarkCollection(b *testing.B) {
// Test replication many times
func TestReplicate(t *testing.T) {
for x := 0; x < 20; x++ {
runReplication(t, 5000, 500)
runReplication(t, 5000, 50)
}
}

Expand Down
20 changes: 7 additions & 13 deletions column_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,24 @@ func (c *columnnumber) LoadUint64(idx uint32) (v uint64, ok bool) {

// FilterFloat64 filters down the values based on the specified predicate.
func (c *columnnumber) FilterFloat64(index *bitmap.Bitmap, predicate func(v float64) bool) {
index.Filter(func(idx uint32) (match bool) {
if idx < uint32(len(c.data)) && c.fill.Contains(idx) {
match = predicate(float64(c.data[idx]))
}
return
index.And(c.fill)
index.Filter(func(idx uint32) bool {
return idx < uint32(len(c.data)) && predicate(float64(c.data[idx]))
})
}

// FilterInt64 filters down the values based on the specified predicate.
func (c *columnnumber) FilterInt64(index *bitmap.Bitmap, predicate func(v int64) bool) {
index.And(c.fill)
index.Filter(func(idx uint32) (match bool) {
if idx < uint32(len(c.data)) && c.fill.Contains(idx) {
match = predicate(int64(c.data[idx]))
}
return
return idx < uint32(len(c.data)) && predicate(int64(c.data[idx]))
})
}

// FilterUint64 filters down the values based on the specified predicate.
func (c *columnnumber) FilterUint64(index *bitmap.Bitmap, predicate func(v uint64) bool) {
index.And(c.fill)
index.Filter(func(idx uint32) (match bool) {
if idx < uint32(len(c.data)) && c.fill.Contains(idx) {
match = predicate(uint64(c.data[idx]))
}
return
return idx < uint32(len(c.data)) && predicate(uint64(c.data[idx]))
})
}
Loading