Skip to content

Commit

Permalink
Add runtime/vam.NewDematerializer (#5581)
Browse files Browse the repository at this point in the history
It returns a vector.Puller that wraps a zbuf.Puller.
  • Loading branch information
nwt authored Jan 17, 2025
1 parent 0355a75 commit ec4a26f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions runtime/vam/materialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,24 @@ func (m *Materializer) Pull(done bool) (zbuf.Batch, error) {
}
return zbuf.NewArray(vals), nil
}

type dematerializer struct {
parent zbuf.Puller
}

func NewDematerializer(p zbuf.Puller) vector.Puller {
return &dematerializer{p}
}

func (d *dematerializer) Pull(done bool) (vector.Any, error) {
batch, err := d.parent.Pull(done)
if batch == nil || err != nil {
return nil, err
}
defer batch.Unref()
builder := vector.NewDynamicBuilder()
for _, val := range batch.Values() {
builder.Write(val)
}
return builder.Build(), nil
}

0 comments on commit ec4a26f

Please sign in to comment.