Skip to content

Commit

Permalink
Add vector.Builder support for super.TypeEnum (#5580)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwt authored Jan 17, 2025
1 parent 3eea13c commit 0355a75
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions vector/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func NewBuilder(typ super.Type) Builder {
b = newMapBuilder(typ)
case *super.TypeUnion:
b = newUnionBuilder(typ)
case *super.TypeEnum:
b = &enumBuilder{typ, nil}
default:
id := typ.ID()
if super.IsNumber(id) {
Expand Down Expand Up @@ -272,6 +274,19 @@ func (u *unionBuilder) Build() Any {
return NewUnion(u.typ, u.tags, vecs, nil)
}

type enumBuilder struct {
typ *super.TypeEnum
values []uint64
}

func (e *enumBuilder) Write(bytes zcode.Bytes) {
e.values = append(e.values, super.DecodeUint(bytes))
}

func (e *enumBuilder) Build() Any {
return NewEnum(e.typ, e.values, nil)
}

type intBuilder struct {
typ super.Type
values []int64
Expand Down

0 comments on commit 0355a75

Please sign in to comment.