From a1db1bc384742ed5439ff95bd5fd0cf22d6afee7 Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Thu, 16 Jan 2025 19:48:19 -0500 Subject: [PATCH] Add vector.Builder support for super.TypeEnum --- vector/builder.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vector/builder.go b/vector/builder.go index 7aecc9c4e5..9a45a810de 100644 --- a/vector/builder.go +++ b/vector/builder.go @@ -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) { @@ -270,6 +272,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