Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/client/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/brimdata/super/pkg/nano"
"github.com/brimdata/super/runtime/exec"
"github.com/brimdata/super/sio/bsupio"
"github.com/brimdata/super/sup"
"github.com/segmentio/ksuid"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func (c *Connection) doAndUnmarshal(req *Request, v any, templates ...any) error
if err != nil || rec == nil {
return err
}
m := sup.NewBSUPUnmarshaler()
m := super.NewUnmarshaler()
m.Bind(templates...)
return m.Unmarshal(*rec, v)
}
Expand Down
11 changes: 8 additions & 3 deletions api/client/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import (
"fmt"
"io"

"github.com/brimdata/super"
"github.com/brimdata/super/api"
"github.com/brimdata/super/sup"
)

type EventsClient struct {
rc io.ReadCloser
unmarshaler *sup.UnmarshalContext
unmarshaler *super.Unmarshaler
}

func newEventsClient(resp *Response) *EventsClient {
unmarshaler := sup.NewUnmarshaler()
unmarshaler := super.NewUnmarshaler()
unmarshaler.Bind(
api.EventPool{},
api.EventBranch{},
Expand All @@ -32,8 +33,12 @@ func (l *EventsClient) Recv() (string, any, error) {
if err != nil {
return "", nil, err
}
val, err := sup.ParseValue(super.NewContext(), data)
if err != nil {
return "", nil, err
}
var v any
if err := l.unmarshaler.Unmarshal(data, &v); err != nil {
if err := l.unmarshaler.Unmarshal(val, &v); err != nil {
return "", nil, err
}
return kind, v, err
Expand Down
6 changes: 3 additions & 3 deletions api/client/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"net/http/httptrace"
"time"

"github.com/brimdata/super"
"github.com/brimdata/super/api"
"github.com/brimdata/super/sio"
"github.com/brimdata/super/sio/bsupio"
"github.com/brimdata/super/sup"
)

type Request struct {
Expand Down Expand Up @@ -93,8 +93,8 @@ func (r *Request) reader() (io.Reader, error) {
if b, ok := r.Body.(io.Reader); ok {
return b, nil
}
m := sup.NewBSUPMarshaler()
m.Decorate(sup.StylePackage)
m := super.NewMarshaler(super.NewContext())
m.Decorate(super.StylePackage)
val, err := m.Marshal(r.Body)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions api/queryio/bsup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import (
"bytes"
"io"

"github.com/brimdata/super"
"github.com/brimdata/super/bsup/rows"
"github.com/brimdata/super/sio"
"github.com/brimdata/super/sio/bsupio"
"github.com/brimdata/super/sio/supio"
"github.com/brimdata/super/sup"
)

type BSUPWriter struct {
*bsupio.RowWriter
marshaler *sup.MarshalBSUPContext
marshaler *super.Marshaler
}

func NewBSUPWriter(w io.Writer) *BSUPWriter {
m := sup.NewBSUPMarshaler()
m.Decorate(sup.StyleSimple)
m := super.NewMarshaler(super.NewContext())
m.Decorate(super.StyleSimple)
return &BSUPWriter{
RowWriter: bsupio.NewRowWriter(sio.NopCloser(w)),
marshaler: m,
Expand Down
6 changes: 3 additions & 3 deletions api/queryio/unmarshal.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package queryio

import (
"github.com/brimdata/super"
"github.com/brimdata/super/api"
"github.com/brimdata/super/sup"
)

var unmarshaler *sup.UnmarshalBSUPContext
var unmarshaler *super.Unmarshaler

func init() {
unmarshaler = sup.NewBSUPUnmarshaler()
unmarshaler = super.NewUnmarshaler()
unmarshaler.Bind(
api.QueryChannelSet{},
api.QueryChannelEnd{},
Expand Down
5 changes: 2 additions & 3 deletions bsup/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import (
"github.com/brimdata/super"
"github.com/brimdata/super/bsup/rows"
"github.com/brimdata/super/sbuf"
"github.com/brimdata/super/sup"
)

type Context struct {
mu sync.Mutex
local *super.Context // holds the types for the Metadata values
metas []Metadata // id to Metadata
values []super.Value // id to unmarshaled Metadata
uctx *sup.UnmarshalBSUPContext
uctx *super.Unmarshaler
// The typedefs table is a merge of all the fusion vector subtypes.
// Only the typedefs needed are recorded in this table and different vectors
// are merged into this shared table by mapping each vector's IDs to the
Expand Down Expand Up @@ -69,7 +68,7 @@ func (c *Context) Lookup(id ID) Metadata {

func (c *Context) unmarshal(id ID) error {
if c.uctx == nil {
c.uctx = sup.NewBSUPUnmarshaler()
c.uctx = super.NewUnmarshaler()
c.uctx.SetContext(c.local)
c.uctx.Bind(Template...)
}
Expand Down
3 changes: 1 addition & 2 deletions bsup/rows/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/brimdata/super"
"github.com/brimdata/super/sio"
"github.com/brimdata/super/sup"
"github.com/stretchr/testify/require"
)

Expand All @@ -26,7 +25,7 @@ func TestScannerContext(t *testing.T) {
for i := range count {
names = append(names, strconv.Itoa(i))
values = append(values, i)
rec, err := sup.NewBSUPMarshaler().MarshalCustom(names, values)
rec, err := super.NewMarshaler(super.NewContext()).MarshalCustom(names, values)
require.NoError(t, err)
var buf bytes.Buffer
w := NewWriter(sio.NopCloser(&buf))
Expand Down
5 changes: 2 additions & 3 deletions bsup/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/brimdata/super"
"github.com/brimdata/super/bsup/rows"
"github.com/brimdata/super/sio"
"github.com/brimdata/super/sup"
"github.com/brimdata/super/vector"
"github.com/brimdata/super/vector/vbuild"
"github.com/brimdata/super/vector/vio"
Expand Down Expand Up @@ -73,8 +72,8 @@ func (w *Serializer) finalizeObject() error {
zw := rows.NewWriter(sio.NopCloser(&metaBuf))
// First, we write the root segmap of the vector of integer type IDs.
cctx := enc.cctx
m := sup.NewBSUPMarshalerWithContext(cctx.local)
m.Decorate(sup.StyleSimple)
m := super.NewMarshaler(cctx.local)
m.Decorate(super.StyleSimple)
for id := range len(cctx.metas) {
val, err := m.Marshal(cctx.Lookup(ID(id)))
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions bsupbytes/deserializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import (

"github.com/brimdata/super"
"github.com/brimdata/super/sio/bsupio"
"github.com/brimdata/super/sup"
)

type Deserializer struct {
reader *bsupio.RowReader
unmarshaler *sup.UnmarshalBSUPContext
unmarshaler *super.Unmarshaler
}

func NewDeserializer(reader io.Reader, templates []any) *Deserializer {
return NewDeserializerWithContext(super.NewContext(), reader, templates)
}

func NewDeserializerWithContext(sctx *super.Context, reader io.Reader, templates []any) *Deserializer {
u := sup.NewBSUPUnmarshaler()
u := super.NewUnmarshaler()
u.Bind(templates...)
return &Deserializer{
reader: bsupio.NewRowReader(sctx, reader),
Expand Down
14 changes: 7 additions & 7 deletions bsupbytes/serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ package bsupbytes
import (
"bytes"

"github.com/brimdata/super"
"github.com/brimdata/super/sio"
"github.com/brimdata/super/sio/bsupio"
"github.com/brimdata/super/sup"
)

type Serializer struct {
marshaler *sup.MarshalBSUPContext
marshaler *super.Marshaler
buffer bytes.Buffer
writer *bsupio.RowWriter
}

func NewSerializer() *Serializer {
m := sup.NewBSUPMarshaler()
m.Decorate(sup.StyleSimple)
m := super.NewMarshaler(super.NewContext())
m.Decorate(super.StyleSimple)
s := &Serializer{
marshaler: m,
}
s.writer = bsupio.NewRowWriter(sio.NopCloser(&s.buffer))
return s
}

func (s *Serializer) Decorate(style sup.TypeStyle) {
func (s *Serializer) Decorate(style super.TypeStyle) {
s.marshaler.Decorate(style)
}

func (s *Serializer) Write(v any) error {
rec, err := s.marshaler.Marshal(v)
val, err := s.marshaler.Marshal(v)
if err != nil {
return err
}
return s.writer.Write(rec)
return s.writer.Write(val)
}

// Bytes returns a slice holding the serialized values. Close must be called
Expand Down
6 changes: 5 additions & 1 deletion cli/queryflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"

"github.com/brimdata/super"
"github.com/brimdata/super/compiler/srcfiles"
"github.com/brimdata/super/sup"
"github.com/brimdata/super/vector/vio"
Expand Down Expand Up @@ -35,9 +36,12 @@ func (f *Flags) SetFlags(fs *flag.FlagSet) {

func (f *Flags) PrintStats(stats vio.Progress) {
if f.Stats {
out, err := sup.Marshal(stats)
val, err := super.Marshal(super.NewContext(), stats)
var out string
if err != nil {
out = fmt.Sprintf("error marshaling stats: %s", err)
} else {
out = sup.FormatValue(val)
}
fmt.Fprintln(os.Stderr, out)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/super/compile/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/brimdata/super/runtime"
"github.com/brimdata/super/runtime/exec"
"github.com/brimdata/super/sbuf"
"github.com/brimdata/super/sup"
"github.com/brimdata/super/vector/vio"
)

Expand Down Expand Up @@ -115,15 +114,16 @@ func (s *Shared) Run(ctx context.Context, args []string, dbFlags *dbflags.Flags,
}

func (s *Shared) writeValue(ctx context.Context, v any) error {
val, err := sup.MarshalBSUP(v)
sctx := super.NewContext()
val, err := super.Marshal(sctx, v)
if err != nil {
return err
}
writer, err := s.OutputFlags.Open(ctx, storage.NewLocalEngine())
if err != nil {
return err
}
err = vio.Copy(writer, sbuf.ValToPuller(super.NewContext(), val))
err = vio.Copy(writer, sbuf.ValToPuller(sctx, val))
if closeErr := writer.Close(); err == nil {
err = closeErr
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/super/db/internal/dbmanage/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/brimdata/super/runtime/sam/expr/extent"
"github.com/brimdata/super/sbuf"
"github.com/brimdata/super/sio"
"github.com/brimdata/super/sup"
"github.com/segmentio/ksuid"
)

Expand Down Expand Up @@ -72,7 +71,7 @@ from %q@%q:objects
type objectIterator struct {
reader sio.Reader
puller sbuf.Puller
unmarshaler *sup.UnmarshalBSUPContext
unmarshaler *super.Unmarshaler
}

func newObjectIterator(ctx context.Context, db api.Interface, head *dbid.Committish) (*objectIterator, error) {
Expand All @@ -85,7 +84,7 @@ func newObjectIterator(ctx context.Context, db api.Interface, head *dbid.Committ
return &objectIterator{
reader: sbuf.PullerReader(puller),
puller: puller,
unmarshaler: sup.NewBSUPUnmarshaler(),
unmarshaler: super.NewUnmarshaler(),
}, nil
}

Expand Down
9 changes: 4 additions & 5 deletions cmd/super/dev/bsup/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/brimdata/super/pkg/charm"
"github.com/brimdata/super/pkg/storage"
"github.com/brimdata/super/sup"
)

var spec = &charm.Spec{
Expand Down Expand Up @@ -73,7 +72,7 @@ func (c *Command) Run(args []string) error {
}
var vals []super.Value
sctx := super.NewContext()
marshaler := sup.NewBSUPMarshalerWithContext(sctx)
marshaler := super.NewMarshaler(sctx)
for {
hdr, err := readHeader(r)
if err != nil {
Expand Down Expand Up @@ -134,7 +133,7 @@ func readHeader(r io.Reader) (bsup.Header, error) {
return hdr, err
}

func readObject(sctx *super.Context, marshaler *sup.MarshalBSUPContext, r io.Reader, vals []super.Value) ([]super.Value, error) {
func readObject(sctx *super.Context, marshaler *super.Marshaler, r io.Reader, vals []super.Value) ([]super.Value, error) {
var bytes [bsup.DataHeaderSize]byte
if _, err := io.ReadFull(r, bytes[:]); err != nil {
return vals, err
Expand Down Expand Up @@ -191,7 +190,7 @@ func readObject(sctx *super.Context, marshaler *sup.MarshalBSUPContext, r io.Rea
return vals, err
}

func readFooter(sctx *super.Context, marshaler *sup.MarshalBSUPContext, r io.Reader, vals []super.Value) ([]super.Value, error) {
func readFooter(sctx *super.Context, marshaler *super.Marshaler, r io.Reader, vals []super.Value) ([]super.Value, error) {
var bytes [bsup.FooterSize]byte
if _, err := io.ReadFull(r, bytes[:]); err != nil {
return vals, err
Expand Down Expand Up @@ -227,7 +226,7 @@ func readFooter(sctx *super.Context, marshaler *sup.MarshalBSUPContext, r io.Rea
return vals, nil
}

func marshalTypeDefs(marshaler *sup.MarshalBSUPContext, vals []super.Value, bytes []byte) ([]super.Value, error) {
func marshalTypeDefs(marshaler *super.Marshaler, vals []super.Value, bytes []byte) ([]super.Value, error) {
id := uint32(super.IDTypeComplex)
for len(bytes) > 0 {
var desc any
Expand Down
5 changes: 2 additions & 3 deletions cmd/super/dev/bsuprows/frames/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/brimdata/super/sbuf"
"github.com/brimdata/super/scode"
"github.com/brimdata/super/sio"
"github.com/brimdata/super/sup"
"github.com/brimdata/super/vector/vio"
)

Expand Down Expand Up @@ -80,15 +79,15 @@ func (c *Command) Run(args []string) error {

type metaReader struct {
reader *reader
marshaler *sup.MarshalBSUPContext
marshaler *super.Marshaler
}

var _ sio.Reader = (*metaReader)(nil)

func newMetaReader(sctx *super.Context, r io.Reader) *metaReader {
return &metaReader{
reader: &reader{reader: bufio.NewReader(r)},
marshaler: sup.NewBSUPMarshalerWithContext(sctx),
marshaler: super.NewMarshaler(sctx),
}
}

Expand Down
Loading
Loading