Skip to content

Commit

Permalink
Compute counts when creating View of Dict (#5518)
Browse files Browse the repository at this point in the history
Closes #5514
  • Loading branch information
mattnibs authored Dec 5, 2024
1 parent 200f373 commit 3284256
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vector/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,26 @@ func NewView(val Any, index []uint32) Any {
return NewConst(val.val, uint32(len(index)), NewBoolView(val.Nulls, index))
case *Dict:
index2 := make([]byte, len(index))
counts := make([]uint32, val.Any.Len())
var nulls *Bool
if val.Nulls != nil {
nulls = NewBoolEmpty(uint32(len(index)), nil)
for k, idx := range index {
if val.Nulls.Value(idx) {
nulls.Set(uint32(k))
}
index2[k] = val.Index[idx]
v := val.Index[idx]
index2[k] = v
counts[v]++
}
} else {
for k, idx := range index {
index2[k] = val.Index[idx]
v := val.Index[idx]
index2[k] = v
counts[v]++
}
}
return NewDict(val.Any, index2, nil, nulls)
return NewDict(val.Any, index2, counts, nulls)
case *Error:
return NewError(val.Typ, NewView(val.Vals, index), NewBoolView(val.Nulls, index))
case *Union:
Expand Down

0 comments on commit 3284256

Please sign in to comment.