mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
a quicker empty check for group by
This commit is contained in:
parent
aa0d64047d
commit
216fd0964a
3 changed files with 30 additions and 1 deletions
|
|
@ -2854,7 +2854,7 @@ TOP:
|
|||
}
|
||||
gbi.rows[i].id = rowID
|
||||
|
||||
if gbi.rows[i].row.Count() == 0 {
|
||||
if gbi.rows[i].row.IsEmpty() {
|
||||
goto TOP // I wanted to just call nextAtIdx again, but if a bunch of
|
||||
// rows in a row were 0, I was worried we'd get into a stack
|
||||
// overflow situation
|
||||
|
|
|
|||
15
row.go
15
row.go
|
|
@ -16,6 +16,7 @@ package pilosa
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/pilosa/pilosa/roaring"
|
||||
|
|
@ -42,6 +43,20 @@ func NewRow(columns ...uint64) *Row {
|
|||
return r
|
||||
}
|
||||
|
||||
func (r *Row) IsEmpty() bool {
|
||||
fmt.Println("what", len(r.segments))
|
||||
if len(r.segments) == 0 {
|
||||
return true
|
||||
}
|
||||
for i := range r.segments {
|
||||
if r.segments[i].n > 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Merge merges data from other into r.
|
||||
func (r *Row) Merge(other *Row) {
|
||||
var segments []rowSegment
|
||||
|
|
|
|||
14
row_test.go
14
row_test.go
|
|
@ -111,3 +111,17 @@ func TestRow_Difference_Segment(t *testing.T) {
|
|||
t.Fatalf("Test 2 Difference Results %v != expected %v\n", res.Columns(), exp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRow_IsEmpty(t *testing.T) {
|
||||
r1 := pilosa.NewRow(1, ShardWidth)
|
||||
r2 := pilosa.NewRow(0, 2*ShardWidth)
|
||||
res := r2.Intersect(r1)
|
||||
|
||||
if r1.IsEmpty() {
|
||||
t.Fatal("r1 Should Not Be Empty\n")
|
||||
}
|
||||
if !res.IsEmpty() {
|
||||
t.Fatal("Result Should Be Empty\n")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue