From df490e380d3e60c5ce763b2711ec80221dd2d1eb Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Wed, 29 Sep 2021 16:22:32 -0400 Subject: [PATCH] remove zson.Context (#3127) zed.Context replaces it. --- api/queryio/client.go | 3 +- api/queryio/zjson_test.go | 2 +- api/queryio/zng.go | 2 +- builder_test.go | 4 +-- cli/adaptor.go | 6 ++-- cli/inputflags/flags.go | 4 +-- cmd/zed/index/convert/command.go | 4 +-- cmd/zed/index/create/command.go | 6 ++-- cmd/zed/index/lookup/command.go | 3 +- cmd/zed/index/section/command.go | 4 +-- cmd/zed/lake/find/command.go | 2 +- cmd/zed/lake/index/create.go | 3 +- cmd/zed/lake/load/command.go | 4 +-- cmd/zed/query/command.go | 4 +-- cmd/zed/zst/create/command.go | 4 +-- cmd/zed/zst/cut/command.go | 4 +-- cmd/zed/zst/inspect/command.go | 4 +-- cmd/zed/zst/read/command.go | 4 +-- compiler/kernel/expr.go | 44 ++++++++++++------------ compiler/kernel/filter.go | 7 ++-- compiler/kernel/groupby.go | 6 ++-- compiler/kernel/proc.go | 4 +-- compiler/reader.go | 6 ++-- context_test.go | 8 ++--- driver/driver.go | 17 +++++---- expr/agg/agg.go | 5 ++- expr/agg/any.go | 5 ++- expr/agg/avg.go | 5 ++- expr/agg/collect.go | 5 ++- expr/agg/count.go | 5 ++- expr/agg/countdistinct.go | 5 ++- expr/agg/fuse.go | 5 ++- expr/agg/logical.go | 9 +++-- expr/agg/math.go | 5 ++- expr/agg/schema.go | 7 ++-- expr/agg/union.go | 5 ++- expr/bufferfilter.go | 4 +-- expr/cutter.go | 5 ++- expr/dropper.go | 5 ++- expr/eval.go | 19 +++++----- expr/expr_test.go | 2 +- expr/filter_test.go | 3 +- expr/flattener.go | 5 ++- expr/function/fields.go | 5 ++- expr/function/function.go | 8 ++--- expr/function/parse.go | 2 +- expr/function/string.go | 5 ++- expr/generator.go | 5 ++- expr/shaper.go | 14 ++++---- expr/unflattener.go | 5 ++- expr/values.go | 17 +++++---- fielditer_test.go | 2 +- index/finder.go | 4 +-- index/findreader.go | 3 +- index/index_test.go | 10 +++--- index/mem.go | 5 ++- index/reader.go | 9 +++-- index/stat.go | 4 +-- index/trailer.go | 7 ++-- index/writer.go | 9 +++-- lake/api/local.go | 4 +-- lake/api/remote.go | 3 +- lake/branch.go | 3 +- lake/commits/reader.go | 2 +- lake/commits/store.go | 6 ++-- lake/data/reader.go | 4 +-- lake/data/writer_test.go | 6 ++-- lake/index/index_test.go | 12 +++---- lake/index/store.go | 3 +- lake/index/writer.go | 2 +- lake/index/writer_test.go | 2 +- lake/journal/queue.go | 4 +-- lake/journal/store.go | 3 +- lake/mock/mock.go | 6 ++-- lake/partition.go | 6 ++-- lake/pool.go | 4 +-- lake/root.go | 19 +++++----- lake/scheduler.go | 6 ++-- lake/seekindex/seekindex_test.go | 3 +- lake/seekindex/writer.go | 5 ++- lake/sorted.go | 3 +- pkg/stringsearch/fieldnamefinder.go | 3 +- pkg/stringsearch/fieldnamefinder_test.go | 4 +-- pkg/test/internal.go | 6 ++-- proc/explode/explode.go | 3 +- proc/fuse/fuser.go | 5 ++- proc/groupby/groupby.go | 5 ++- proc/groupby/groupby_test.go | 2 +- proc/merge/merge_test.go | 3 +- proc/proc.go | 12 +++---- proc/rename/renamer.go | 5 ++- proc/shape/shaper.go | 5 ++- proc/spill/file.go | 6 ++-- proc/spill/merge.go | 5 ++- proc/spill/peeker.go | 3 +- recordval_test.go | 4 +-- service/client_test.go | 3 +- service/handlers.go | 6 ++-- typetype_test.go | 8 ++--- zed_test.go | 6 ++-- zio/anyio/fifo_test.go | 4 +-- zio/anyio/file.go | 6 ++-- zio/anyio/lookup.go | 3 +- zio/anyio/reader.go | 19 +++++----- zio/counter_test.go | 4 +-- zio/csvio/reader.go | 2 +- zio/csvio/reader_test.go | 4 +-- zio/csvio/writer.go | 3 +- zio/emitter/dir_test.go | 3 +- zio/jsonio/reader.go | 4 +-- zio/mapper.go | 3 +- zio/ndjsonio/ndjson_test.go | 3 +- zio/parquetio/reader.go | 3 +- zio/parquetio/type.go | 7 ++-- zio/peeker_test.go | 3 +- zio/tableio/writer.go | 3 +- zio/textio/writer.go | 3 +- zio/tzngio/format_test.go | 3 +- zio/tzngio/reader.go | 5 ++- zio/tzngio/reader_test.go | 20 +++++------ zio/tzngio/typeparser.go | 5 ++- zio/tzngio/tzngio_test.go | 4 +-- zio/zeekio/parser.go | 9 +++-- zio/zeekio/parser_test.go | 3 +- zio/zeekio/reader.go | 3 +- zio/zeekio/reader_test.go | 4 +-- zio/zeekio/writer.go | 3 +- zio/zjsonio/reader.go | 4 +-- zio/zjsonio/stream.go | 5 ++- zio/zjsonio/types.go | 19 +++++----- zio/zjsonio/values.go | 12 +++---- zio/zng_test.go | 18 +++++----- zio/zngio/encoder.go | 5 ++- zio/zngio/reader.go | 13 ++++--- zio/zngio/scanner.go | 3 +- zio/zngio/scanner_test.go | 3 +- zio/zngio/writer_test.go | 3 +- zio/zstio/reader.go | 4 +-- zngbytes/deserializer.go | 5 +-- zson/analyzer.go | 40 ++++++++++----------- zson/context.go | 18 ---------- zson/marshal.go | 12 +++---- zson/marshal_test.go | 4 +-- zson/marshal_zng_test.go | 10 +++--- zson/reader.go | 4 +-- zson/reader_test.go | 2 +- zson/zson.go | 8 ++--- zson/zson_test.go | 6 ++-- zst/column/array.go | 3 +- zst/column/column.go | 3 +- zst/column/field.go | 3 +- zst/column/primitive.go | 2 +- zst/column/record.go | 3 +- zst/column/union.go | 3 +- zst/cutter.go | 9 +++-- zst/object.go | 8 ++--- zst/reader.go | 6 ++-- zst/trailer.go | 5 ++- zst/writer.go | 7 ++-- ztest/ztest.go | 12 +++---- 160 files changed, 453 insertions(+), 522 deletions(-) delete mode 100644 zson/context.go diff --git a/api/queryio/client.go b/api/queryio/client.go index e44f3f6609..46bc7853c0 100644 --- a/api/queryio/client.go +++ b/api/queryio/client.go @@ -11,7 +11,6 @@ import ( "github.com/brimdata/zed/driver" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" ) func RunClientResponse(ctx context.Context, d driver.Driver, res *client.Response) (zbuf.ScannerStats, error) { @@ -23,7 +22,7 @@ func RunClientResponse(ctx context.Context, d driver.Driver, res *client.Respons return zbuf.ScannerStats{}, fmt.Errorf("unsupported format: %s", format) } run := &runner{driver: d} - r := NewZNGReader(zngio.NewReader(res.Body, zson.NewContext())) + r := NewZNGReader(zngio.NewReader(res.Body, zed.NewContext())) for ctx.Err() == nil { rec, ctrl, err := r.ReadPayload() if err != nil { diff --git a/api/queryio/zjson_test.go b/api/queryio/zjson_test.go index 695d696c60..b246783cc3 100644 --- a/api/queryio/zjson_test.go +++ b/api/queryio/zjson_test.go @@ -15,7 +15,7 @@ import ( ) func mkRecord(t *testing.T, s string) *zed.Record { - r := zson.NewReader(strings.NewReader(s), zson.NewContext()) + r := zson.NewReader(strings.NewReader(s), zed.NewContext()) rec, err := r.Read() require.NoError(t, err) return rec diff --git a/api/queryio/zng.go b/api/queryio/zng.go index c4b1840ef9..3c1db16c55 100644 --- a/api/queryio/zng.go +++ b/api/queryio/zng.go @@ -57,7 +57,7 @@ func (r *ZNGReader) ReadPayload() (*zed.Record, interface{}, error) { if msg.Encoding != zed.AppEncodingZSON { return nil, nil, fmt.Errorf("unsupported app encoding: %v", msg.Encoding) } - value, err := zson.ParseValue(zson.NewContext(), string(msg.Bytes)) + value, err := zson.ParseValue(zed.NewContext(), string(msg.Bytes)) if err != nil { return nil, nil, err } diff --git a/builder_test.go b/builder_test.go index 25f7aaff95..6f370eb51d 100644 --- a/builder_test.go +++ b/builder_test.go @@ -19,7 +19,7 @@ func TestBuilder(t *testing.T) { {a:7,r:{x:3}} {a:7,r:null (0=({x:int64}))} ` - r := zson.NewReader(strings.NewReader(input), zson.NewContext()) + r := zson.NewReader(strings.NewReader(input), zed.NewContext()) r0, err := r.Read() require.NoError(t, err) r1, err := r.Read() @@ -29,7 +29,7 @@ func TestBuilder(t *testing.T) { r3, err := r.Read() require.NoError(t, err) - zctx := zson.NewContext() + zctx := zed.NewContext() t0, err := zctx.LookupTypeRecord([]zed.Column{ {"key", zed.TypeIP}, diff --git a/cli/adaptor.go b/cli/adaptor.go index 04eb2a9c10..f4f28776d1 100644 --- a/cli/adaptor.go +++ b/cli/adaptor.go @@ -6,6 +6,7 @@ import ( "fmt" "io" + "github.com/brimdata/zed" "github.com/brimdata/zed/compiler/ast/dag" "github.com/brimdata/zed/expr/extent" "github.com/brimdata/zed/order" @@ -13,7 +14,6 @@ import ( "github.com/brimdata/zed/proc" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio/anyio" - "github.com/brimdata/zed/zson" "github.com/segmentio/ksuid" ) @@ -41,11 +41,11 @@ func (*FileAdaptor) Layout(context.Context, dag.Source) order.Layout { return order.Nil } -func (*FileAdaptor) NewScheduler(context.Context, *zson.Context, dag.Source, extent.Span, zbuf.Filter) (proc.Scheduler, error) { +func (*FileAdaptor) NewScheduler(context.Context, *zed.Context, dag.Source, extent.Span, zbuf.Filter) (proc.Scheduler, error) { return nil, errors.New("pool scan not available when running on local file system") } -func (f *FileAdaptor) Open(ctx context.Context, zctx *zson.Context, path string, pushdown zbuf.Filter) (zbuf.PullerCloser, error) { +func (f *FileAdaptor) Open(ctx context.Context, zctx *zed.Context, path string, pushdown zbuf.Filter) (zbuf.PullerCloser, error) { if path == "-" { path = "stdio:stdin" } diff --git a/cli/inputflags/flags.go b/cli/inputflags/flags.go index 753ca356ba..980c56aa7e 100644 --- a/cli/inputflags/flags.go +++ b/cli/inputflags/flags.go @@ -7,12 +7,12 @@ import ( "fmt" "os" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/auto" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/anyio" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" ) type Flags struct { @@ -47,7 +47,7 @@ func (f *Flags) Init() error { return nil } -func (f *Flags) Open(ctx context.Context, zctx *zson.Context, engine storage.Engine, paths []string, stopOnErr bool) ([]zio.Reader, error) { +func (f *Flags) Open(ctx context.Context, zctx *zed.Context, engine storage.Engine, paths []string, stopOnErr bool) ([]zio.Reader, error) { var readers []zio.Reader for _, path := range paths { if path == "-" { diff --git a/cmd/zed/index/convert/command.go b/cmd/zed/index/convert/command.go index 41f364ab8e..eefa66f9ff 100644 --- a/cmd/zed/index/convert/command.go +++ b/cmd/zed/index/convert/command.go @@ -4,6 +4,7 @@ import ( "errors" "flag" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/inputflags" zedindex "github.com/brimdata/zed/cmd/zed/index" "github.com/brimdata/zed/field" @@ -13,7 +14,6 @@ import ( "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/anyio" - "github.com/brimdata/zed/zson" ) var Convert = &charm.Spec{ @@ -73,7 +73,7 @@ func (c *Command) Run(args []string) error { if path == "-" { path = "stdio:stdin" } - zctx := zson.NewContext() + zctx := zed.NewContext() local := storage.NewLocalEngine() file, err := anyio.Open(ctx, zctx, local, path, c.inputFlags.Options()) if err != nil { diff --git a/cmd/zed/index/create/command.go b/cmd/zed/index/create/command.go index 88c0782d4d..2b056b334c 100644 --- a/cmd/zed/index/create/command.go +++ b/cmd/zed/index/create/command.go @@ -4,6 +4,7 @@ import ( "errors" "flag" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/inputflags" zedindex "github.com/brimdata/zed/cmd/zed/index" "github.com/brimdata/zed/expr" @@ -13,7 +14,6 @@ import ( "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/anyio" - "github.com/brimdata/zed/zson" ) var Create = &charm.Spec{ @@ -73,7 +73,7 @@ func (c *Command) Run(args []string) error { if path == "-" { path = "stdio:stdin" } - zctx := zson.NewContext() + zctx := zed.NewContext() local := storage.NewLocalEngine() file, err := anyio.Open(ctx, zctx, local, path, c.inputFlags.Options()) if err != nil { @@ -100,7 +100,7 @@ func (c *Command) Run(args []string) error { return writer.Close() } -func (c *Command) buildTable(zctx *zson.Context, reader zio.Reader) (*index.MemTable, error) { +func (c *Command) buildTable(zctx *zed.Context, reader zio.Reader) (*index.MemTable, error) { readKey := expr.NewDotExpr(field.Dotted(c.keyField)) table := index.NewMemTable(zctx) for { diff --git a/cmd/zed/index/lookup/command.go b/cmd/zed/index/lookup/command.go index e33b43b217..16849249a6 100644 --- a/cmd/zed/index/lookup/command.go +++ b/cmd/zed/index/lookup/command.go @@ -11,7 +11,6 @@ import ( "github.com/brimdata/zed/index" "github.com/brimdata/zed/pkg/charm" "github.com/brimdata/zed/pkg/storage" - "github.com/brimdata/zed/zson" ) var Lookup = &charm.Spec{ @@ -67,7 +66,7 @@ func (c *LookupCommand) Run(args []string) error { return err } local := storage.NewLocalEngine() - finder, err := index.NewFinder(ctx, zson.NewContext(), local, uri) + finder, err := index.NewFinder(ctx, zed.NewContext(), local, uri) if err != nil { return err } diff --git a/cmd/zed/index/section/command.go b/cmd/zed/index/section/command.go index f16c1c11c9..1fbfc1d208 100644 --- a/cmd/zed/index/section/command.go +++ b/cmd/zed/index/section/command.go @@ -4,13 +4,13 @@ import ( "errors" "flag" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/outputflags" zedindex "github.com/brimdata/zed/cmd/zed/index" "github.com/brimdata/zed/index" "github.com/brimdata/zed/pkg/charm" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) var Section = &charm.Spec{ @@ -57,7 +57,7 @@ func (c *Command) Run(args []string) error { } path := args[0] local := storage.NewLocalEngine() - reader, err := index.NewReader(zson.NewContext(), local, path) + reader, err := index.NewReader(zed.NewContext(), local, path) if err != nil { return err } diff --git a/cmd/zed/lake/find/command.go b/cmd/zed/lake/find/command.go index 1a02b2d0d6..10b8748dc1 100644 --- a/cmd/zed/lake/find/command.go +++ b/cmd/zed/lake/find/command.go @@ -113,7 +113,7 @@ func (c *Command) Run(args []string) error { hits := make(chan *zed.Record) var searchErr error go func() { - searchErr = lake.Find(ctx, zson.NewContext(), lk, query, hits, findOptions...) + searchErr = lake.Find(ctx, zed.NewContext(), lk, query, hits, findOptions...) close(hits) }() for hit := range hits { diff --git a/cmd/zed/lake/index/create.go b/cmd/zed/lake/index/create.go index d8224df9c2..32721c8c21 100644 --- a/cmd/zed/lake/index/create.go +++ b/cmd/zed/lake/index/create.go @@ -6,6 +6,7 @@ import ( "flag" "fmt" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/outputflags" "github.com/brimdata/zed/cli/procflags" "github.com/brimdata/zed/driver" @@ -103,7 +104,7 @@ func parseRule(args []string, ruleName string) ([]string, index.Rule, error) { if len(args) < 2 { return nil, nil, errors.New("type index rule requires type argument") } - typ, err := zson.ParseType(zson.NewContext(), args[1]) + typ, err := zson.ParseType(zed.NewContext(), args[1]) if err != nil { return nil, nil, err } diff --git a/cmd/zed/lake/load/command.go b/cmd/zed/lake/load/command.go index c280694085..99e02554c2 100644 --- a/cmd/zed/lake/load/command.go +++ b/cmd/zed/lake/load/command.go @@ -5,6 +5,7 @@ import ( "flag" "fmt" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/inputflags" "github.com/brimdata/zed/cli/lakeflags" "github.com/brimdata/zed/cli/procflags" @@ -16,7 +17,6 @@ import ( "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/pkg/units" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) var Load = &charm.Spec{ @@ -76,7 +76,7 @@ func (c *Command) Run(args []string) error { } paths := args local := storage.NewLocalEngine() - readers, err := c.inputFlags.Open(ctx, zson.NewContext(), local, paths, false) + readers, err := c.inputFlags.Open(ctx, zed.NewContext(), local, paths, false) if err != nil { return err } diff --git a/cmd/zed/query/command.go b/cmd/zed/query/command.go index 53bf9c7caa..bdabe732dd 100644 --- a/cmd/zed/query/command.go +++ b/cmd/zed/query/command.go @@ -8,6 +8,7 @@ import ( "strings" "text/tabwriter" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli" "github.com/brimdata/zed/cli/inputflags" "github.com/brimdata/zed/cli/outputflags" @@ -21,7 +22,6 @@ import ( "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) var Cmd = &charm.Spec{ @@ -141,7 +141,7 @@ func (c *Command) Run(args []string) error { if _, err := rlimit.RaiseOpenFilesLimit(); err != nil { return err } - zctx := zson.NewContext() + zctx := zed.NewContext() local := storage.NewLocalEngine() readers, err := c.inputFlags.Open(ctx, zctx, local, paths, c.stopErr) if err != nil { diff --git a/cmd/zed/zst/create/command.go b/cmd/zed/zst/create/command.go index 60939252d3..dfe5b52f7e 100644 --- a/cmd/zed/zst/create/command.go +++ b/cmd/zed/zst/create/command.go @@ -4,13 +4,13 @@ import ( "errors" "flag" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/inputflags" "github.com/brimdata/zed/cli/outputflags" "github.com/brimdata/zed/cmd/zed/zst" "github.com/brimdata/zed/pkg/charm" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) var Create = &charm.Spec{ @@ -68,7 +68,7 @@ func (c *Command) Run(args []string) error { return errors.New("must specify one or more input files") } local := storage.NewLocalEngine() - readers, err := c.inputFlags.Open(ctx, zson.NewContext(), local, args, true) + readers, err := c.inputFlags.Open(ctx, zed.NewContext(), local, args, true) if err != nil { return err } diff --git a/cmd/zed/zst/cut/command.go b/cmd/zed/zst/cut/command.go index c12cdd5068..ebdb7b533a 100644 --- a/cmd/zed/zst/cut/command.go +++ b/cmd/zed/zst/cut/command.go @@ -5,12 +5,12 @@ import ( "flag" "strings" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/outputflags" zstcmd "github.com/brimdata/zed/cmd/zed/zst" "github.com/brimdata/zed/pkg/charm" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" "github.com/brimdata/zed/zst" ) @@ -66,7 +66,7 @@ func (c *Command) Run(args []string) error { fields := strings.Split(c.fieldExpr, ".") path := args[0] local := storage.NewLocalEngine() - cutter, err := zst.NewCutterFromPath(ctx, zson.NewContext(), local, path, fields) + cutter, err := zst.NewCutterFromPath(ctx, zed.NewContext(), local, path, fields) if err != nil { return err } diff --git a/cmd/zed/zst/inspect/command.go b/cmd/zed/zst/inspect/command.go index 4b43c1e671..685524b3ff 100644 --- a/cmd/zed/zst/inspect/command.go +++ b/cmd/zed/zst/inspect/command.go @@ -4,13 +4,13 @@ import ( "errors" "flag" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/outputflags" zedzst "github.com/brimdata/zed/cmd/zed/zst" zstcmd "github.com/brimdata/zed/cmd/zed/zst" "github.com/brimdata/zed/pkg/charm" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" "github.com/brimdata/zed/zst" ) @@ -60,7 +60,7 @@ func (c *Command) Run(args []string) error { } path := args[0] local := storage.NewLocalEngine() - reader, err := zst.NewReaderFromPath(ctx, zson.NewContext(), local, path) + reader, err := zst.NewReaderFromPath(ctx, zed.NewContext(), local, path) if err != nil { return err } diff --git a/cmd/zed/zst/read/command.go b/cmd/zed/zst/read/command.go index 2e498ae405..2deeda1d76 100644 --- a/cmd/zed/zst/read/command.go +++ b/cmd/zed/zst/read/command.go @@ -4,12 +4,12 @@ import ( "errors" "flag" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/outputflags" zstcmd "github.com/brimdata/zed/cmd/zed/zst" "github.com/brimdata/zed/pkg/charm" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" "github.com/brimdata/zed/zst" ) @@ -54,7 +54,7 @@ func (c *Command) Run(args []string) error { } path := args[0] local := storage.NewLocalEngine() - reader, err := zst.NewReaderFromPath(ctx, zson.NewContext(), local, path) + reader, err := zst.NewReaderFromPath(ctx, zed.NewContext(), local, path) if err != nil { return err } diff --git a/compiler/kernel/expr.go b/compiler/kernel/expr.go index db8c10f4e0..d602e1cdfe 100644 --- a/compiler/kernel/expr.go +++ b/compiler/kernel/expr.go @@ -44,7 +44,7 @@ import ( // TBD: string values and net.IP address do not need to be copied because they // are allocated by go libraries and temporary buffers are not used. This will // change down the road when we implement no-allocation string and IP conversion. -func compileExpr(zctx *zson.Context, scope *Scope, e dag.Expr) (expr.Evaluator, error) { +func compileExpr(zctx *zed.Context, scope *Scope, e dag.Expr) (expr.Evaluator, error) { if e == nil { return nil, errors.New("null expression not allowed") } @@ -105,14 +105,14 @@ func compileExpr(zctx *zson.Context, scope *Scope, e dag.Expr) (expr.Evaluator, } } -func compileExprWithEmpty(zctx *zson.Context, scope *Scope, e dag.Expr) (expr.Evaluator, error) { +func compileExprWithEmpty(zctx *zed.Context, scope *Scope, e dag.Expr) (expr.Evaluator, error) { if e == nil { return nil, nil } return compileExpr(zctx, scope, e) } -func CompileExprs(zctx *zson.Context, scope *Scope, nodes []dag.Expr) ([]expr.Evaluator, error) { +func CompileExprs(zctx *zed.Context, scope *Scope, nodes []dag.Expr) ([]expr.Evaluator, error) { var exprs []expr.Evaluator for k := range nodes { e, err := compileExpr(zctx, scope, nodes[k]) @@ -124,7 +124,7 @@ func CompileExprs(zctx *zson.Context, scope *Scope, nodes []dag.Expr) ([]expr.Ev return exprs, nil } -func compileBinary(zctx *zson.Context, scope *Scope, e *dag.BinaryExpr) (expr.Evaluator, error) { +func compileBinary(zctx *zed.Context, scope *Scope, e *dag.BinaryExpr) (expr.Evaluator, error) { if slice, ok := e.RHS.(*dag.BinaryExpr); ok && slice.Op == ":" { return compileSlice(zctx, scope, e.LHS, slice) } @@ -154,7 +154,7 @@ func compileBinary(zctx *zson.Context, scope *Scope, e *dag.BinaryExpr) (expr.Ev } } -func compileSlice(zctx *zson.Context, scope *Scope, container dag.Expr, slice *dag.BinaryExpr) (expr.Evaluator, error) { +func compileSlice(zctx *zed.Context, scope *Scope, container dag.Expr, slice *dag.BinaryExpr) (expr.Evaluator, error) { from, err := compileExprWithEmpty(zctx, scope, slice.LHS) if err != nil { return nil, err @@ -170,7 +170,7 @@ func compileSlice(zctx *zson.Context, scope *Scope, container dag.Expr, slice *d return expr.NewSlice(e, from, to), nil } -func compileSeqExpr(zctx *zson.Context, scope *Scope, seq *dag.SeqExpr) (expr.Evaluator, error) { +func compileSeqExpr(zctx *zed.Context, scope *Scope, seq *dag.SeqExpr) (expr.Evaluator, error) { selectors, err := compileExprs(zctx, scope, seq.Selectors) if err != nil { return nil, err @@ -190,7 +190,7 @@ func compileSeqExpr(zctx *zson.Context, scope *Scope, seq *dag.SeqExpr) (expr.Ev return expr.NewAggExpr(zctx, pattern, sequence), nil } -func compileMethod(zctx *zson.Context, scope *Scope, src expr.Generator, method dag.Method) (expr.Generator, error) { +func compileMethod(zctx *zed.Context, scope *Scope, src expr.Generator, method dag.Method) (expr.Generator, error) { switch method.Name { case "map": if len(method.Args) != 1 { @@ -226,7 +226,7 @@ func compileMethod(zctx *zson.Context, scope *Scope, src expr.Generator, method } } -func compileUnary(zctx *zson.Context, scope *Scope, unary dag.UnaryExpr) (expr.Evaluator, error) { +func compileUnary(zctx *zed.Context, scope *Scope, unary dag.UnaryExpr) (expr.Evaluator, error) { if unary.Op != "!" { return nil, fmt.Errorf("unknown unary operator %s\n", unary.Op) } @@ -248,7 +248,7 @@ func compileLogical(lhs, rhs expr.Evaluator, operator string) (expr.Evaluator, e } } -func compileConditional(zctx *zson.Context, scope *Scope, node dag.Conditional) (expr.Evaluator, error) { +func compileConditional(zctx *zed.Context, scope *Scope, node dag.Conditional) (expr.Evaluator, error) { predicate, err := compileExpr(zctx, scope, node.Cond) if err != nil { return nil, err @@ -264,7 +264,7 @@ func compileConditional(zctx *zson.Context, scope *Scope, node dag.Conditional) return expr.NewConditional(predicate, thenExpr, elseExpr), nil } -func compileDotExpr(zctx *zson.Context, scope *Scope, dot *dag.Dot) (expr.Evaluator, error) { +func compileDotExpr(zctx *zed.Context, scope *Scope, dot *dag.Dot) (expr.Evaluator, error) { record, err := compileExpr(zctx, scope, dot.LHS) if err != nil { return nil, err @@ -272,7 +272,7 @@ func compileDotExpr(zctx *zson.Context, scope *Scope, dot *dag.Dot) (expr.Evalua return expr.NewDotAccess(record, dot.RHS), nil } -func compileCast(zctx *zson.Context, scope *Scope, node dag.Cast) (expr.Evaluator, error) { +func compileCast(zctx *zed.Context, scope *Scope, node dag.Cast) (expr.Evaluator, error) { e, err := compileExpr(zctx, scope, node.Expr) if err != nil { return nil, err @@ -292,7 +292,7 @@ func compileLval(e dag.Expr) (field.Path, error) { return nil, errors.New("invalid expression on lhs of assignment") } -func CompileAssignment(zctx *zson.Context, scope *Scope, node *dag.Assignment) (expr.Assignment, error) { +func CompileAssignment(zctx *zed.Context, scope *Scope, node *dag.Assignment) (expr.Assignment, error) { lhs, err := compileLval(node.LHS) if err != nil { return expr.Assignment{}, err @@ -317,7 +317,7 @@ func CompileAssignments(dsts field.List, srcs field.List) (field.List, []expr.Ev return fields, resolvers } -func compileCutter(zctx *zson.Context, scope *Scope, node dag.Call) (*expr.Cutter, error) { +func compileCutter(zctx *zed.Context, scope *Scope, node dag.Call) (*expr.Cutter, error) { var lhs field.List var rhs []expr.Evaluator for _, expr := range node.Args { @@ -363,7 +363,7 @@ func isShaperFunc(name string) bool { return shaperOps(name) != 0 } -func compileShaper(zctx *zson.Context, scope *Scope, node dag.Call) (*expr.Shaper, error) { +func compileShaper(zctx *zed.Context, scope *Scope, node dag.Call) (*expr.Shaper, error) { args := node.Args if len(args) == 1 { args = append([]dag.Expr{dag.Root}, args...) @@ -388,7 +388,7 @@ func compileShaper(zctx *zson.Context, scope *Scope, node dag.Call) (*expr.Shape return expr.NewShaper(zctx, field, typExpr, shaperOps(node.Name)), nil } -func compileCall(zctx *zson.Context, scope *Scope, call dag.Call) (expr.Evaluator, error) { +func compileCall(zctx *zed.Context, scope *Scope, call dag.Call) (expr.Evaluator, error) { // For now, we special case stateful functions here. We should generalize this // as we will add many more stateful functions and also resolve this // the changes to create running aggegation functions from reducers. @@ -442,7 +442,7 @@ func compileCall(zctx *zson.Context, scope *Scope, call dag.Call) (expr.Evaluato return expr.NewCall(zctx, fn, exprs), nil } -func compileExprs(zctx *zson.Context, scope *Scope, in []dag.Expr) ([]expr.Evaluator, error) { +func compileExprs(zctx *zed.Context, scope *Scope, in []dag.Expr) ([]expr.Evaluator, error) { out := make([]expr.Evaluator, 0, len(in)) for _, e := range in { ev, err := compileExpr(zctx, scope, e) @@ -454,7 +454,7 @@ func compileExprs(zctx *zson.Context, scope *Scope, in []dag.Expr) ([]expr.Evalu return out, nil } -func compileTypeValue(zctx *zson.Context, scope *Scope, t *astzed.TypeValue) (expr.Evaluator, error) { +func compileTypeValue(zctx *zed.Context, scope *Scope, t *astzed.TypeValue) (expr.Evaluator, error) { if typ, ok := t.Value.(*astzed.TypeName); ok { // We currently support dynamic type names only for // top-level type names. By dynamic, we mean typedefs that @@ -472,7 +472,7 @@ func compileTypeValue(zctx *zson.Context, scope *Scope, t *astzed.TypeValue) (ex return expr.NewLiteral(zed.NewTypeValue(typ)), nil } -func compileRegexpMatch(zctx *zson.Context, scope *Scope, match *dag.RegexpMatch) (expr.Evaluator, error) { +func compileRegexpMatch(zctx *zed.Context, scope *Scope, match *dag.RegexpMatch) (expr.Evaluator, error) { e, err := compileExpr(zctx, scope, match.Expr) if err != nil { return nil, err @@ -484,7 +484,7 @@ func compileRegexpMatch(zctx *zson.Context, scope *Scope, match *dag.RegexpMatch return expr.NewRegexpMatch(re, e), nil } -func compileRecordExpr(zctx *zson.Context, scope *Scope, record *dag.RecordExpr) (expr.Evaluator, error) { +func compileRecordExpr(zctx *zed.Context, scope *Scope, record *dag.RecordExpr) (expr.Evaluator, error) { var names []string var exprs []expr.Evaluator for _, f := range record.Fields { @@ -498,7 +498,7 @@ func compileRecordExpr(zctx *zson.Context, scope *Scope, record *dag.RecordExpr) return expr.NewRecordExpr(zctx, names, exprs), nil } -func compileArrayExpr(zctx *zson.Context, scope *Scope, array *dag.ArrayExpr) (expr.Evaluator, error) { +func compileArrayExpr(zctx *zed.Context, scope *Scope, array *dag.ArrayExpr) (expr.Evaluator, error) { exprs, err := compileExprs(zctx, scope, array.Exprs) if err != nil { return nil, err @@ -506,7 +506,7 @@ func compileArrayExpr(zctx *zson.Context, scope *Scope, array *dag.ArrayExpr) (e return expr.NewArrayExpr(zctx, exprs), nil } -func compileSetExpr(zctx *zson.Context, scope *Scope, set *dag.SetExpr) (expr.Evaluator, error) { +func compileSetExpr(zctx *zed.Context, scope *Scope, set *dag.SetExpr) (expr.Evaluator, error) { exprs, err := compileExprs(zctx, scope, set.Exprs) if err != nil { return nil, err @@ -514,7 +514,7 @@ func compileSetExpr(zctx *zson.Context, scope *Scope, set *dag.SetExpr) (expr.Ev return expr.NewSetExpr(zctx, exprs), nil } -func compileMapExpr(zctx *zson.Context, scope *Scope, m *dag.MapExpr) (expr.Evaluator, error) { +func compileMapExpr(zctx *zed.Context, scope *Scope, m *dag.MapExpr) (expr.Evaluator, error) { var entries []expr.Entry for _, f := range m.Entries { key, err := compileExpr(zctx, scope, f.Key) diff --git a/compiler/kernel/filter.go b/compiler/kernel/filter.go index 11a30d28df..e027057469 100644 --- a/compiler/kernel/filter.go +++ b/compiler/kernel/filter.go @@ -9,7 +9,6 @@ import ( "github.com/brimdata/zed/expr" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" ) type Filter struct { @@ -33,7 +32,7 @@ func (f *Filter) AsBufferFilter() (*expr.BufferFilter, error) { return CompileBufferFilter(f.pushdown) } -func compileCompareField(zctx *zson.Context, scope *Scope, e *dag.BinaryExpr) (expr.Filter, error) { +func compileCompareField(zctx *zed.Context, scope *Scope, e *dag.BinaryExpr) (expr.Filter, error) { if e.Op == "in" { literal, ok := e.LHS.(*astzed.Primitive) if !ok { @@ -101,7 +100,7 @@ func compileSearch(node *dag.Search) (expr.Filter, error) { return expr.SearchRecordOther(node.Text, node.Value) } -func CompileFilter(zctx *zson.Context, scope *Scope, node dag.Expr) (expr.Filter, error) { +func CompileFilter(zctx *zed.Context, scope *Scope, node dag.Expr) (expr.Filter, error) { switch v := node.(type) { case *dag.RegexpMatch: e, err := compileExpr(zctx, scope, v.Expr) @@ -198,7 +197,7 @@ func CompileFilter(zctx *zson.Context, scope *Scope, node dag.Expr) (expr.Filter } } -func compileExprPredicate(zctx *zson.Context, scope *Scope, e dag.Expr) (expr.Filter, error) { +func compileExprPredicate(zctx *zed.Context, scope *Scope, e dag.Expr) (expr.Filter, error) { predicate, err := compileExpr(zctx, scope, e) if err != nil { return nil, err diff --git a/compiler/kernel/groupby.go b/compiler/kernel/groupby.go index 641e8c872c..854822215c 100644 --- a/compiler/kernel/groupby.go +++ b/compiler/kernel/groupby.go @@ -4,13 +4,13 @@ import ( "errors" "fmt" + "github.com/brimdata/zed" "github.com/brimdata/zed/compiler/ast/dag" "github.com/brimdata/zed/expr" "github.com/brimdata/zed/field" "github.com/brimdata/zed/order" "github.com/brimdata/zed/proc" "github.com/brimdata/zed/proc/groupby" - "github.com/brimdata/zed/zson" ) func compileGroupBy(pctx *proc.Context, scope *Scope, parent proc.Interface, summarize *dag.Summarize) (*groupby.Proc, error) { @@ -26,7 +26,7 @@ func compileGroupBy(pctx *proc.Context, scope *Scope, parent proc.Interface, sum return groupby.New(pctx, parent, keys, names, reducers, summarize.Limit, dir, summarize.PartialsIn, summarize.PartialsOut) } -func compileAggs(assignments []dag.Assignment, scope *Scope, zctx *zson.Context) (field.List, []*expr.Aggregator, error) { +func compileAggs(assignments []dag.Assignment, scope *Scope, zctx *zed.Context) (field.List, []*expr.Aggregator, error) { names := make(field.List, 0, len(assignments)) aggs := make([]*expr.Aggregator, 0, len(assignments)) for _, assignment := range assignments { @@ -40,7 +40,7 @@ func compileAggs(assignments []dag.Assignment, scope *Scope, zctx *zson.Context) return names, aggs, nil } -func compileAgg(zctx *zson.Context, scope *Scope, assignment dag.Assignment) (field.Path, *expr.Aggregator, error) { +func compileAgg(zctx *zed.Context, scope *Scope, assignment dag.Assignment) (field.Path, *expr.Aggregator, error) { aggAST, ok := assignment.RHS.(*dag.Agg) if !ok { return nil, nil, errors.New("aggregator is not an aggregation expression") diff --git a/compiler/kernel/proc.go b/compiler/kernel/proc.go index 393e31b1b5..5dbee249d3 100644 --- a/compiler/kernel/proc.go +++ b/compiler/kernel/proc.go @@ -246,7 +246,7 @@ type picker struct{ *expr.Cutter } func (_ *picker) String() string { return "pick" } -func compileAssignments(assignments []dag.Assignment, zctx *zson.Context, scope *Scope) ([]expr.Assignment, error) { +func compileAssignments(assignments []dag.Assignment, zctx *zed.Context, scope *Scope) ([]expr.Assignment, error) { keys := make([]expr.Assignment, 0, len(assignments)) for _, assignment := range assignments { a, err := CompileAssignment(zctx, scope, &assignment) @@ -640,7 +640,7 @@ func (b *Builder) LoadConsts(ops []dag.Op) error { return nil } -func evalAtCompileTime(zctx *zson.Context, scope *Scope, in dag.Expr) (zed.Value, error) { +func evalAtCompileTime(zctx *zed.Context, scope *Scope, in dag.Expr) (zed.Value, error) { if in == nil { return zed.Value{zed.TypeNull, nil}, nil } diff --git a/compiler/reader.go b/compiler/reader.go index 5405e04be0..9243bb459a 100644 --- a/compiler/reader.go +++ b/compiler/reader.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" + "github.com/brimdata/zed" "github.com/brimdata/zed/compiler/ast" "github.com/brimdata/zed/compiler/ast/dag" "github.com/brimdata/zed/expr/extent" @@ -12,7 +13,6 @@ import ( "github.com/brimdata/zed/proc" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" "github.com/segmentio/ksuid" ) @@ -49,10 +49,10 @@ func (*internalAdaptor) Layout(context.Context, dag.Source) order.Layout { return order.Nil } -func (*internalAdaptor) NewScheduler(context.Context, *zson.Context, dag.Source, extent.Span, zbuf.Filter) (proc.Scheduler, error) { +func (*internalAdaptor) NewScheduler(context.Context, *zed.Context, dag.Source, extent.Span, zbuf.Filter) (proc.Scheduler, error) { return nil, errors.New("invalid pool or file scan specified for internally streamed Zed query") } -func (*internalAdaptor) Open(context.Context, *zson.Context, string, zbuf.Filter) (zbuf.PullerCloser, error) { +func (*internalAdaptor) Open(context.Context, *zed.Context, string, zbuf.Filter) (zbuf.PullerCloser, error) { return nil, errors.New("invalid file or URL access for internally streamed Zed query") } diff --git a/context_test.go b/context_test.go index 6330f2d91e..8c18cdcb45 100644 --- a/context_test.go +++ b/context_test.go @@ -10,7 +10,7 @@ import ( ) func TestDuplicates(t *testing.T) { - ctx := zson.NewContext() + ctx := zed.NewContext() setType := ctx.LookupTypeSet(zed.TypeInt32) typ1, err := ctx.LookupTypeRecord([]zed.Column{ zed.NewColumn("a", zed.TypeString), @@ -27,8 +27,8 @@ func TestDuplicates(t *testing.T) { } func TestTranslateAlias(t *testing.T) { - c1 := zson.NewContext() - c2 := zson.NewContext() + c1 := zed.NewContext() + c2 := zed.NewContext() set1, err := zson.ParseType(c1, "|[int64]|") require.NoError(t, err) set2, err := zson.ParseType(c2, "|[int64]|") @@ -43,7 +43,7 @@ func TestTranslateAlias(t *testing.T) { } func TestCopyMutateColumns(t *testing.T) { - c := zson.NewContext() + c := zed.NewContext() cols := []zed.Column{{"foo", zed.TypeString}, {"bar", zed.TypeInt64}} typ, err := c.LookupTypeRecord(cols) require.NoError(t, err) diff --git a/driver/driver.go b/driver/driver.go index 598f32d8ca..15c7a0d784 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -19,7 +19,6 @@ import ( "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zqe" - "github.com/brimdata/zed/zson" "go.uber.org/zap" ) @@ -30,7 +29,7 @@ type Driver interface { Stats(api.ScannerStats) error } -func RunWithReader(ctx context.Context, d Driver, program ast.Proc, zctx *zson.Context, reader zio.Reader, logger *zap.Logger) error { +func RunWithReader(ctx context.Context, d Driver, program ast.Proc, zctx *zed.Context, reader zio.Reader, logger *zap.Logger) error { pctx := proc.NewContext(ctx, zctx, logger) runtime, err := compiler.CompileForInternal(pctx, program, reader) if err != nil { @@ -40,7 +39,7 @@ func RunWithReader(ctx context.Context, d Driver, program ast.Proc, zctx *zson.C return run(pctx, d, runtime, nil) } -func RunWithOrderedReader(ctx context.Context, d Driver, program ast.Proc, zctx *zson.Context, reader zio.Reader, layout order.Layout, logger *zap.Logger) error { +func RunWithOrderedReader(ctx context.Context, d Driver, program ast.Proc, zctx *zed.Context, reader zio.Reader, layout order.Layout, logger *zap.Logger) error { pctx := proc.NewContext(ctx, zctx, logger) runtime, err := compiler.CompileForInternalWithOrder(pctx, program, reader, layout) if err != nil { @@ -50,7 +49,7 @@ func RunWithOrderedReader(ctx context.Context, d Driver, program ast.Proc, zctx return run(pctx, d, runtime, nil) } -func RunWithFileSystem(ctx context.Context, d Driver, program ast.Proc, zctx *zson.Context, reader zio.Reader, adaptor proc.DataAdaptor) (zbuf.ScannerStats, error) { +func RunWithFileSystem(ctx context.Context, d Driver, program ast.Proc, zctx *zed.Context, reader zio.Reader, adaptor proc.DataAdaptor) (zbuf.ScannerStats, error) { pctx := proc.NewContext(ctx, zctx, nil) runtime, err := compiler.CompileForFileSystem(pctx, program, reader, adaptor) if err != nil { @@ -61,7 +60,7 @@ func RunWithFileSystem(ctx context.Context, d Driver, program ast.Proc, zctx *zs return runtime.Statser().Stats(), err } -func RunJoinWithFileSystem(ctx context.Context, d Driver, program ast.Proc, zctx *zson.Context, readers []zio.Reader, adaptor proc.DataAdaptor) (zbuf.ScannerStats, error) { +func RunJoinWithFileSystem(ctx context.Context, d Driver, program ast.Proc, zctx *zed.Context, readers []zio.Reader, adaptor proc.DataAdaptor) (zbuf.ScannerStats, error) { pctx := proc.NewContext(ctx, zctx, nil) runtime, err := compiler.CompileJoinForFileSystem(pctx, program, readers, adaptor) if err != nil { @@ -72,7 +71,7 @@ func RunJoinWithFileSystem(ctx context.Context, d Driver, program ast.Proc, zctx return runtime.Statser().Stats(), err } -func RunWithLake(ctx context.Context, d Driver, program ast.Proc, zctx *zson.Context, lake proc.DataAdaptor, head *lakeparse.Commitish) (zbuf.ScannerStats, error) { +func RunWithLake(ctx context.Context, d Driver, program ast.Proc, zctx *zed.Context, lake proc.DataAdaptor, head *lakeparse.Commitish) (zbuf.ScannerStats, error) { pctx := proc.NewContext(ctx, zctx, nil) runtime, err := compiler.CompileForLake(pctx, program, lake, 0, head) if err != nil { @@ -83,7 +82,7 @@ func RunWithLake(ctx context.Context, d Driver, program ast.Proc, zctx *zson.Con return runtime.Statser().Stats(), err } -func RunWithLakeAndStats(ctx context.Context, d Driver, program ast.Proc, zctx *zson.Context, lake proc.DataAdaptor, head *lakeparse.Commitish, ticker <-chan time.Time, logger *zap.Logger, parallelism int) error { +func RunWithLakeAndStats(ctx context.Context, d Driver, program ast.Proc, zctx *zed.Context, lake proc.DataAdaptor, head *lakeparse.Commitish, ticker <-chan time.Time, logger *zap.Logger, parallelism int) error { pctx := proc.NewContext(ctx, zctx, logger) runtime, err := compiler.CompileForLake(pctx, program, lake, parallelism, head) if err != nil { @@ -260,7 +259,7 @@ func (d *transformDriver) ChannelEnd(cid int) error { return nil } // Copy applies a proc to all records from a zio.Reader, writing to a // single zio.Writer. The proc must have a single tail. -func Copy(ctx context.Context, w zio.Writer, prog ast.Proc, zctx *zson.Context, r zio.Reader, logger *zap.Logger) error { +func Copy(ctx context.Context, w zio.Writer, prog ast.Proc, zctx *zed.Context, r zio.Reader, logger *zap.Logger) error { d := &transformDriver{w: w} return RunWithReader(ctx, d, prog, zctx, r, logger) } @@ -317,7 +316,7 @@ func (r *Reader) Close() error { return r.Closer.Close() } -func NewReader(ctx context.Context, program ast.Proc, zctx *zson.Context, reader zio.Reader) (*Reader, error) { +func NewReader(ctx context.Context, program ast.Proc, zctx *zed.Context, reader zio.Reader) (*Reader, error) { pctx := proc.NewContext(ctx, zctx, nil) runtime, err := compiler.CompileForInternal(pctx, program, reader) if err != nil { diff --git a/expr/agg/agg.go b/expr/agg/agg.go index 84611f88ee..9fd1a47d47 100644 --- a/expr/agg/agg.go +++ b/expr/agg/agg.go @@ -6,7 +6,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/anymath" - "github.com/brimdata/zed/zson" ) // A Pattern is a template for creating instances of aggregator functions. @@ -27,8 +26,8 @@ var ( type Function interface { Consume(zed.Value) error ConsumeAsPartial(zed.Value) error - Result(*zson.Context) (zed.Value, error) - ResultAsPartial(*zson.Context) (zed.Value, error) + Result(*zed.Context) (zed.Value, error) + ResultAsPartial(*zed.Context) (zed.Value, error) } func NewPattern(op string) (Pattern, error) { diff --git a/expr/agg/any.go b/expr/agg/any.go index d5ba7a93bd..0020fb0c77 100644 --- a/expr/agg/any.go +++ b/expr/agg/any.go @@ -2,7 +2,6 @@ package agg import ( "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" ) type Any zed.Value @@ -16,7 +15,7 @@ func (a *Any) Consume(v zed.Value) error { return nil } -func (a Any) Result(*zson.Context) (zed.Value, error) { +func (a Any) Result(*zed.Context) (zed.Value, error) { if a.Type == nil { return zed.Value{Type: zed.TypeNull}, nil } @@ -27,6 +26,6 @@ func (a *Any) ConsumeAsPartial(v zed.Value) error { return a.Consume(v) } -func (a Any) ResultAsPartial(*zson.Context) (zed.Value, error) { +func (a Any) ResultAsPartial(*zed.Context) (zed.Value, error) { return a.Result(nil) } diff --git a/expr/agg/avg.go b/expr/agg/avg.go index 24efc35c21..988a1d52dd 100644 --- a/expr/agg/avg.go +++ b/expr/agg/avg.go @@ -4,7 +4,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr/coerce" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type Avg struct { @@ -23,7 +22,7 @@ func (a *Avg) Consume(v zed.Value) error { return nil } -func (a *Avg) Result(*zson.Context) (zed.Value, error) { +func (a *Avg) Result(*zed.Context) (zed.Value, error) { if a.count > 0 { return zed.NewFloat64(a.sum / float64(a.count)), nil } @@ -62,7 +61,7 @@ func (a *Avg) ConsumeAsPartial(p zed.Value) error { return nil } -func (a *Avg) ResultAsPartial(zctx *zson.Context) (zed.Value, error) { +func (a *Avg) ResultAsPartial(zctx *zed.Context) (zed.Value, error) { var zv zcode.Bytes zv = zed.NewFloat64(a.sum).Encode(zv) zv = zed.NewUint64(a.count).Encode(zv) diff --git a/expr/agg/collect.go b/expr/agg/collect.go index aa96ad251a..21796268a8 100644 --- a/expr/agg/collect.go +++ b/expr/agg/collect.go @@ -5,7 +5,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type Collect struct { @@ -42,7 +41,7 @@ func (c *Collect) update(b zcode.Bytes) { } } -func (c *Collect) Result(zctx *zson.Context) (zed.Value, error) { +func (c *Collect) Result(zctx *zed.Context) (zed.Value, error) { if c.typ == nil { // no values found return zed.Value{Type: zed.TypeNull}, nil @@ -78,6 +77,6 @@ func (c *Collect) ConsumeAsPartial(zv zed.Value) error { return nil } -func (c *Collect) ResultAsPartial(tc *zson.Context) (zed.Value, error) { +func (c *Collect) ResultAsPartial(tc *zed.Context) (zed.Value, error) { return c.Result(tc) } diff --git a/expr/agg/count.go b/expr/agg/count.go index 8f21d7ba74..61096d882d 100644 --- a/expr/agg/count.go +++ b/expr/agg/count.go @@ -2,7 +2,6 @@ package agg import ( "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" ) type Count uint64 @@ -14,7 +13,7 @@ func (c *Count) Consume(v zed.Value) error { return nil } -func (c Count) Result(*zson.Context) (zed.Value, error) { +func (c Count) Result(*zed.Context) (zed.Value, error) { return zed.NewUint64(uint64(c)), nil } @@ -26,6 +25,6 @@ func (c *Count) ConsumeAsPartial(p zed.Value) error { return err } -func (c Count) ResultAsPartial(*zson.Context) (zed.Value, error) { +func (c Count) ResultAsPartial(*zed.Context) (zed.Value, error) { return c.Result(nil) } diff --git a/expr/agg/countdistinct.go b/expr/agg/countdistinct.go index f46772bad0..8eb5d440d4 100644 --- a/expr/agg/countdistinct.go +++ b/expr/agg/countdistinct.go @@ -5,7 +5,6 @@ import ( "github.com/axiomhq/hyperloglog" "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" ) // CountDistinct uses hyperloglog to approximate the count of unique values for @@ -25,7 +24,7 @@ func (c *CountDistinct) Consume(v zed.Value) error { return nil } -func (c *CountDistinct) Result(*zson.Context) (zed.Value, error) { +func (c *CountDistinct) Result(*zed.Context) (zed.Value, error) { return zed.NewUint64(c.sketch.Estimate()), nil } @@ -34,7 +33,7 @@ func (*CountDistinct) ConsumeAsPartial(v zed.Value) error { return errors.New("partials not yet implemented in countdistinct") } -func (*CountDistinct) ResultAsPartial(zctx *zson.Context) (zed.Value, error) { +func (*CountDistinct) ResultAsPartial(zctx *zed.Context) (zed.Value, error) { // XXX this is straightforward to do using c.sketch.Merge(). See #1892. return zed.Value{}, errors.New("partials not yet implemented in countdistinct") } diff --git a/expr/agg/fuse.go b/expr/agg/fuse.go index 939b81ea0f..a3de72c65c 100644 --- a/expr/agg/fuse.go +++ b/expr/agg/fuse.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" ) type fuse struct { @@ -28,7 +27,7 @@ func (f *fuse) Consume(v zed.Value) error { return nil } -func (f *fuse) Result(zctx *zson.Context) (zed.Value, error) { +func (f *fuse) Result(zctx *zed.Context) (zed.Value, error) { if len(f.shapes)+len(f.partials) == 0 { // empty input return zed.Value{zed.TypeNull, nil}, nil @@ -63,6 +62,6 @@ func (f *fuse) ConsumeAsPartial(p zed.Value) error { return nil } -func (f *fuse) ResultAsPartial(zctx *zson.Context) (zed.Value, error) { +func (f *fuse) ResultAsPartial(zctx *zed.Context) (zed.Value, error) { return f.Result(zctx) } diff --git a/expr/agg/logical.go b/expr/agg/logical.go index 657f57bb04..e57770cfcc 100644 --- a/expr/agg/logical.go +++ b/expr/agg/logical.go @@ -2,7 +2,6 @@ package agg import ( "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" ) type And struct { @@ -25,7 +24,7 @@ func (a *And) Consume(v zed.Value) error { return nil } -func (a *And) Result(*zson.Context) (zed.Value, error) { +func (a *And) Result(*zed.Context) (zed.Value, error) { if a.val == nil { return zed.Value{Type: zed.TypeBool}, nil } @@ -39,7 +38,7 @@ func (a *And) ConsumeAsPartial(v zed.Value) error { return a.Consume(v) } -func (a *And) ResultAsPartial(*zson.Context) (zed.Value, error) { +func (a *And) ResultAsPartial(*zed.Context) (zed.Value, error) { return a.Result(nil) } @@ -63,7 +62,7 @@ func (o *Or) Consume(v zed.Value) error { return nil } -func (o *Or) Result(*zson.Context) (zed.Value, error) { +func (o *Or) Result(*zed.Context) (zed.Value, error) { if o.val == nil { return zed.Value{Type: zed.TypeBool}, nil } @@ -77,6 +76,6 @@ func (o *Or) ConsumeAsPartial(v zed.Value) error { return o.Consume(v) } -func (o *Or) ResultAsPartial(*zson.Context) (zed.Value, error) { +func (o *Or) ResultAsPartial(*zed.Context) (zed.Value, error) { return o.Result(nil) } diff --git a/expr/agg/math.go b/expr/agg/math.go index 0f6baa784f..ecd6497800 100644 --- a/expr/agg/math.go +++ b/expr/agg/math.go @@ -5,7 +5,6 @@ import ( "github.com/brimdata/zed/anymath" "github.com/brimdata/zed/expr/coerce" "github.com/brimdata/zed/pkg/nano" - "github.com/brimdata/zed/zson" ) type consumer interface { @@ -23,7 +22,7 @@ func newMathReducer(f *anymath.Function) *mathReducer { return &mathReducer{function: f} } -func (m *mathReducer) Result(*zson.Context) (zed.Value, error) { +func (m *mathReducer) Result(*zed.Context) (zed.Value, error) { if m.math == nil { if m.typ == nil { return zed.Value{Type: zed.TypeNull, Bytes: nil}, nil @@ -74,7 +73,7 @@ func (m *mathReducer) consumeVal(val zed.Value) { } } -func (m *mathReducer) ResultAsPartial(*zson.Context) (zed.Value, error) { +func (m *mathReducer) ResultAsPartial(*zed.Context) (zed.Value, error) { return m.Result(nil) } diff --git a/expr/agg/schema.go b/expr/agg/schema.go index 20f062adb1..cf068d8fd2 100644 --- a/expr/agg/schema.go +++ b/expr/agg/schema.go @@ -2,19 +2,18 @@ package agg import ( "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" ) // Schema constructs a fused record type for the record types passed to Mixin. // Records of any mixed-in type can be shaped to the fused type without loss of // information. type Schema struct { - zctx *zson.Context + zctx *zed.Context cols []zed.Column } -func NewSchema(zctx *zson.Context) *Schema { +func NewSchema(zctx *zed.Context) *Schema { return &Schema{zctx: zctx} } @@ -70,7 +69,7 @@ func columnOfField(cols []zed.Column, name string) (int, bool) { return -1, false } -func unify(zctx *zson.Context, a, b zed.Type) zed.Type { +func unify(zctx *zed.Context, a, b zed.Type) zed.Type { if ua, ok := zed.AliasOf(a).(*zed.TypeUnion); ok { types := ua.Types if ub, ok := zed.AliasOf(b).(*zed.TypeUnion); ok { diff --git a/expr/agg/union.go b/expr/agg/union.go index 520269c013..8260dfac42 100644 --- a/expr/agg/union.go +++ b/expr/agg/union.go @@ -5,7 +5,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type Union struct { @@ -55,7 +54,7 @@ func (u *Union) deleteOne() { } } -func (u *Union) Result(zctx *zson.Context) (zed.Value, error) { +func (u *Union) Result(zctx *zed.Context) (zed.Value, error) { if u.typ == nil { return zed.Value{Type: zed.TypeNull}, nil } @@ -92,6 +91,6 @@ func (u *Union) ConsumeAsPartial(zv zed.Value) error { return nil } -func (u *Union) ResultAsPartial(zctx *zson.Context) (zed.Value, error) { +func (u *Union) ResultAsPartial(zctx *zed.Context) (zed.Value, error) { return u.Result(zctx) } diff --git a/expr/bufferfilter.go b/expr/bufferfilter.go index 3a31d1d5d7..124454e764 100644 --- a/expr/bufferfilter.go +++ b/expr/bufferfilter.go @@ -4,9 +4,9 @@ import ( "fmt" "unicode/utf8" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/byteconv" "github.com/brimdata/zed/pkg/stringsearch" - "github.com/brimdata/zed/zson" ) const ( @@ -66,7 +66,7 @@ func NewBufferFilterForStringCase(pattern string) *BufferFilter { } // Eval returns true if buf matches the receiver and false otherwise. -func (b *BufferFilter) Eval(zctx *zson.Context, buf []byte) bool { +func (b *BufferFilter) Eval(zctx *zed.Context, buf []byte) bool { switch b.op { case opAnd: return b.left.Eval(zctx, buf) && b.right.Eval(zctx, buf) diff --git a/expr/cutter.go b/expr/cutter.go index e003cfe74d..cfdb8e183d 100644 --- a/expr/cutter.go +++ b/expr/cutter.go @@ -8,11 +8,10 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/field" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type Cutter struct { - zctx *zson.Context + zctx *zed.Context builder *zed.ColumnBuilder fieldRefs field.List fieldExprs []Evaluator @@ -30,7 +29,7 @@ type Cutter struct { // the Cutter copies fields that are not in fieldnames. If complement // is false, the Cutter copies any fields in fieldnames, where targets // specifies the copied field names. -func NewCutter(zctx *zson.Context, fieldRefs field.List, fieldExprs []Evaluator) (*Cutter, error) { +func NewCutter(zctx *zed.Context, fieldRefs field.List, fieldExprs []Evaluator) (*Cutter, error) { if len(fieldRefs) > 1 { for _, f := range fieldRefs { if f.IsRoot() { diff --git a/expr/dropper.go b/expr/dropper.go index 9a1bc93153..c878240b32 100644 --- a/expr/dropper.go +++ b/expr/dropper.go @@ -3,7 +3,6 @@ package expr import ( "github.com/brimdata/zed" "github.com/brimdata/zed/field" - "github.com/brimdata/zed/zson" ) type dropper struct { @@ -33,13 +32,13 @@ func (d *dropper) drop(in *zed.Record) (*zed.Record, error) { } type Dropper struct { - zctx *zson.Context + zctx *zed.Context fields field.List resolvers []Evaluator droppers map[int]*dropper } -func NewDropper(zctx *zson.Context, fields field.List) *Dropper { +func NewDropper(zctx *zed.Context, fields field.List) *Dropper { return &Dropper{ zctx: zctx, fields: fields, diff --git a/expr/eval.go b/expr/eval.go index 7b4936dc82..a5de4e95ac 100644 --- a/expr/eval.go +++ b/expr/eval.go @@ -11,7 +11,6 @@ import ( "github.com/brimdata/zed/expr/function" "github.com/brimdata/zed/field" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) var ErrIncompatibleTypes = coerce.ErrIncompatibleTypes @@ -267,7 +266,7 @@ func (r *RegexpMatch) Eval(rec *zed.Record) (zed.Value, error) { } type numeric struct { - zctx *zson.Context + zctx *zed.Context lhs Evaluator rhs Evaluator vals coerce.Pair @@ -585,12 +584,12 @@ func lookupKey(mapBytes, target zcode.Bytes) (zcode.Bytes, bool) { // Index represents an index operator "container[index]" where container is // either an array (with index type integer) or a record (with index type string). type Index struct { - zctx *zson.Context + zctx *zed.Context container Evaluator index Evaluator } -func NewIndexExpr(zctx *zson.Context, container, index Evaluator) (Evaluator, error) { +func NewIndexExpr(zctx *zed.Context, container, index Evaluator) (Evaluator, error) { return &Index{zctx, container, index}, nil } @@ -691,14 +690,14 @@ func (c *Conditional) Eval(rec *zed.Record) (zed.Value, error) { } type Call struct { - zctx *zson.Context + zctx *zed.Context fn function.Interface exprs []Evaluator args []zed.Value AddRoot bool } -func NewCall(zctx *zson.Context, fn function.Interface, exprs []Evaluator) *Call { +func NewCall(zctx *zed.Context, fn function.Interface, exprs []Evaluator) *Call { return &Call{ zctx: zctx, fn: fn, @@ -722,11 +721,11 @@ func (c *Call) Eval(rec *zed.Record) (zed.Value, error) { // a Zed typedef). It returns MISSING if the name doesn't exist. type TypeFunc struct { name string - zctx *zson.Context + zctx *zed.Context zv zed.Value } -func NewTypeFunc(zctx *zson.Context, name string) *TypeFunc { +func NewTypeFunc(zctx *zed.Context, name string) *TypeFunc { return &TypeFunc{ name: name, zctx: zctx, @@ -745,11 +744,11 @@ func (t *TypeFunc) Eval(rec *zed.Record) (zed.Value, error) { } type Exists struct { - zctx *zson.Context + zctx *zed.Context exprs []Evaluator } -func NewExists(zctx *zson.Context, exprs []Evaluator) *Exists { +func NewExists(zctx *zed.Context, exprs []Evaluator) *Exists { return &Exists{ zctx: zctx, exprs: exprs, diff --git a/expr/expr_test.go b/expr/expr_test.go index 12ecb37dc3..8b8a4e907a 100644 --- a/expr/expr_test.go +++ b/expr/expr_test.go @@ -18,7 +18,7 @@ func testSuccessful(t *testing.T, e string, record string, expect zed.Value) { if record == "" { record = "{}" } - zctx := zson.NewContext() + zctx := zed.NewContext() typ, _ := zctx.LookupTypeRecord([]zed.Column{{"result", expect.Type}}) bytes := zcode.AppendPrimitive(nil, expect.Bytes) rec := zed.NewRecord(typ, bytes) diff --git a/expr/filter_test.go b/expr/filter_test.go index 430715792a..b686326ed5 100644 --- a/expr/filter_test.go +++ b/expr/filter_test.go @@ -5,6 +5,7 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/compiler" "github.com/brimdata/zed/compiler/ast/dag" "github.com/brimdata/zed/lake/mock" @@ -34,7 +35,7 @@ func runCasesExpectBufferFilterFalsePositives(t *testing.T, record string, cases func runCasesHelper(t *testing.T, record string, cases []testcase, expectBufferFilterFalsePositives bool) { t.Helper() - zctx := zson.NewContext() + zctx := zed.NewContext() batch, err := zbuf.NewPuller(zson.NewReader(strings.NewReader(record), zctx), 2).Pull() require.NoError(t, err, "record: %q", record) require.Exactly(t, 1, batch.Length(), "record: %q", record) diff --git a/expr/flattener.go b/expr/flattener.go index 7e0bd9973a..32f074e7d6 100644 --- a/expr/flattener.go +++ b/expr/flattener.go @@ -5,11 +5,10 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type Flattener struct { - zctx *zson.Context + zctx *zed.Context mapper *zed.Mapper } @@ -17,7 +16,7 @@ type Flattener struct { // records where the type context of the received records must match the // zctx parameter provided here. Any new type descriptors that are created // to flatten types also use zctx. -func NewFlattener(zctx *zson.Context) *Flattener { +func NewFlattener(zctx *zed.Context) *Flattener { return &Flattener{ zctx: zctx, // This mapper maps types back into the same context and gives diff --git a/expr/function/fields.go b/expr/function/fields.go index 1bd6f774f8..140d06dd27 100644 --- a/expr/function/fields.go +++ b/expr/function/fields.go @@ -3,11 +3,10 @@ package function import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type fields struct { - zctx *zson.Context + zctx *zed.Context typ zed.Type bytes zcode.Bytes } @@ -40,7 +39,7 @@ func (f *fields) Call(args []zed.Value) (zed.Value, error) { return zed.Value{f.typ, bytes}, nil } -func isRecordType(zv zed.Value, zctx *zson.Context) *zed.TypeRecord { +func isRecordType(zv zed.Value, zctx *zed.Context) *zed.TypeRecord { if typ, ok := zed.AliasOf(zv.Type).(*zed.TypeRecord); ok { return typ } diff --git a/expr/function/function.go b/expr/function/function.go index 9da6363da9..ee925c6b0f 100644 --- a/expr/function/function.go +++ b/expr/function/function.go @@ -21,7 +21,7 @@ type Interface interface { Call([]zed.Value) (zed.Value, error) } -func New(zctx *zson.Context, name string, narg int) (Interface, bool, error) { +func New(zctx *zed.Context, name string, narg int) (Interface, bool, error) { argmin := 1 argmax := 1 var root bool @@ -172,7 +172,7 @@ func (l *lenFn) Call(args []zed.Value) (zed.Value, error) { } type typeOf struct { - zctx *zson.Context + zctx *zed.Context } func (t *typeOf) Call(args []zed.Value) (zed.Value, error) { @@ -181,7 +181,7 @@ func (t *typeOf) Call(args []zed.Value) (zed.Value, error) { } type typeUnder struct { - zctx *zson.Context + zctx *zed.Context } func (t *typeUnder) Call(args []zed.Value) (zed.Value, error) { @@ -210,7 +210,7 @@ func (*isErr) Call(args []zed.Value) (zed.Value, error) { } type is struct { - zctx *zson.Context + zctx *zed.Context } func (i *is) Call(args []zed.Value) (zed.Value, error) { diff --git a/expr/function/parse.go b/expr/function/parse.go index a6f9007f6f..c708775273 100644 --- a/expr/function/parse.go +++ b/expr/function/parse.go @@ -79,7 +79,7 @@ func (p *parseURI) Call(args []zed.Value) (zed.Value, error) { } type parseZSON struct { - zctx *zson.Context + zctx *zed.Context } func (p *parseZSON) Call(args []zed.Value) (zed.Value, error) { diff --git a/expr/function/string.go b/expr/function/string.go index 57a1395dc4..06c2ef0814 100644 --- a/expr/function/string.go +++ b/expr/function/string.go @@ -9,7 +9,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr/result" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) // XXX these string format functions should be handlded by :string cast @@ -249,12 +248,12 @@ func (*trim) Call(args []zed.Value) (zed.Value, error) { } type split struct { - zctx *zson.Context + zctx *zed.Context typ zed.Type bytes zcode.Bytes } -func newSplit(zctx *zson.Context) *split { +func newSplit(zctx *zed.Context) *split { return &split{ typ: zctx.LookupTypeArray(zed.TypeString), } diff --git a/expr/generator.go b/expr/generator.go index 620816c36b..af0632f607 100644 --- a/expr/generator.go +++ b/expr/generator.go @@ -3,7 +3,6 @@ package expr import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr/agg" - "github.com/brimdata/zed/zson" ) type Generator interface { @@ -89,12 +88,12 @@ func (f *FilterMethod) Next() (zed.Value, error) { } type AggExpr struct { - zctx *zson.Context + zctx *zed.Context newAgg agg.Pattern src Generator } -func NewAggExpr(zctx *zson.Context, pattern agg.Pattern, src Generator) *AggExpr { +func NewAggExpr(zctx *zed.Context, pattern agg.Pattern, src Generator) *AggExpr { return &AggExpr{ zctx: zctx, newAgg: pattern, diff --git a/expr/shaper.go b/expr/shaper.go index b77361afd6..17a348fa4f 100644 --- a/expr/shaper.go +++ b/expr/shaper.go @@ -24,7 +24,7 @@ const ( ) type Shaper struct { - zctx *zson.Context + zctx *zed.Context typExpr Evaluator expr Evaluator shapers map[zed.Type]*ConstShaper @@ -33,7 +33,7 @@ type Shaper struct { // NewShaper returns a shaper that will shape the result of expr // to the type returned by typExpr. -func NewShaper(zctx *zson.Context, expr, typExpr Evaluator, tf ShaperTransform) *Shaper { +func NewShaper(zctx *zed.Context, expr, typExpr Evaluator, tf ShaperTransform) *Shaper { return &Shaper{ zctx: zctx, typExpr: typExpr, @@ -67,7 +67,7 @@ func (s *Shaper) Eval(rec *zed.Record) (zed.Value, error) { } type ConstShaper struct { - zctx *zson.Context + zctx *zed.Context b zcode.Builder expr Evaluator shapeTo zed.Type @@ -77,7 +77,7 @@ type ConstShaper struct { // NewConstShaper returns a shaper that will shape the result of expr // to the provided shapeTo type. -func NewConstShaper(zctx *zson.Context, expr Evaluator, shapeTo zed.Type, tf ShaperTransform) *ConstShaper { +func NewConstShaper(zctx *zed.Context, expr Evaluator, shapeTo zed.Type, tf ShaperTransform) *ConstShaper { return &ConstShaper{ zctx: zctx, expr: expr, @@ -134,7 +134,7 @@ type shaper struct { step step } -func createShaper(zctx *zson.Context, tf ShaperTransform, spec, in zed.Type) (*shaper, error) { +func createShaper(zctx *zed.Context, tf ShaperTransform, spec, in zed.Type) (*shaper, error) { typ, err := shaperType(zctx, tf, spec, in) if err != nil { return nil, err @@ -143,7 +143,7 @@ func createShaper(zctx *zson.Context, tf ShaperTransform, spec, in zed.Type) (*s return &shaper{typ, step}, err } -func shaperType(zctx *zson.Context, tf ShaperTransform, spec, in zed.Type) (zed.Type, error) { +func shaperType(zctx *zed.Context, tf ShaperTransform, spec, in zed.Type) (zed.Type, error) { inUnder, specUnder := zed.AliasOf(in), zed.AliasOf(spec) if tf&Cast > 0 { if inUnder == specUnder || inUnder == zed.TypeNull { @@ -202,7 +202,7 @@ func shaperType(zctx *zson.Context, tf ShaperTransform, spec, in zed.Type) (zed. return in, nil } -func shaperColumns(zctx *zson.Context, tf ShaperTransform, specRec, inRec *zed.TypeRecord) ([]zed.Column, error) { +func shaperColumns(zctx *zed.Context, tf ShaperTransform, specRec, inRec *zed.TypeRecord) ([]zed.Column, error) { crop, fill := tf&Crop > 0, tf&Fill > 0 if tf&Order == 0 { crop, fill = !fill, !crop diff --git a/expr/unflattener.go b/expr/unflattener.go index 20f3655275..52bd7b0a69 100644 --- a/expr/unflattener.go +++ b/expr/unflattener.go @@ -3,11 +3,10 @@ package expr import ( "github.com/brimdata/zed" "github.com/brimdata/zed/field" - "github.com/brimdata/zed/zson" ) type Unflattener struct { - zctx *zson.Context + zctx *zed.Context builders map[int]*zed.ColumnBuilder recordTypes map[int]*zed.TypeRecord fieldExpr Evaluator @@ -20,7 +19,7 @@ type Unflattener struct { // to arbitrary-depth dotted names, it is not applied to dotted names // that start at lower levels (for example {a:{"a.a":1}} is // unchanged). -func NewUnflattener(zctx *zson.Context) *Unflattener { +func NewUnflattener(zctx *zed.Context) *Unflattener { return &Unflattener{ zctx: zctx, builders: make(map[int]*zed.ColumnBuilder), diff --git a/expr/values.go b/expr/values.go index 052abae249..e91c2a2006 100644 --- a/expr/values.go +++ b/expr/values.go @@ -3,18 +3,17 @@ package expr import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type RecordExpr struct { - zctx *zson.Context + zctx *zed.Context typ *zed.TypeRecord builder *zcode.Builder columns []zed.Column exprs []Evaluator } -func NewRecordExpr(zctx *zson.Context, names []string, exprs []Evaluator) *RecordExpr { +func NewRecordExpr(zctx *zed.Context, names []string, exprs []Evaluator) *RecordExpr { columns := make([]zed.Column, 0, len(names)) for _, name := range names { columns = append(columns, zed.Column{Name: name}) @@ -57,13 +56,13 @@ func (r *RecordExpr) Eval(rec *zed.Record) (zed.Value, error) { } type ArrayExpr struct { - zctx *zson.Context + zctx *zed.Context typ *zed.TypeArray builder *zcode.Builder exprs []Evaluator } -func NewArrayExpr(zctx *zson.Context, exprs []Evaluator) *ArrayExpr { +func NewArrayExpr(zctx *zed.Context, exprs []Evaluator) *ArrayExpr { return &ArrayExpr{ zctx: zctx, typ: zctx.LookupTypeArray(zed.TypeNull), @@ -111,13 +110,13 @@ func (a *ArrayExpr) Eval(rec *zed.Record) (zed.Value, error) { } type SetExpr struct { - zctx *zson.Context + zctx *zed.Context typ *zed.TypeSet builder *zcode.Builder exprs []Evaluator } -func NewSetExpr(zctx *zson.Context, exprs []Evaluator) *SetExpr { +func NewSetExpr(zctx *zed.Context, exprs []Evaluator) *SetExpr { return &SetExpr{ zctx: zctx, typ: zctx.LookupTypeSet(zed.TypeNull), @@ -170,13 +169,13 @@ type Entry struct { } type MapExpr struct { - zctx *zson.Context + zctx *zed.Context typ *zed.TypeMap builder *zcode.Builder entries []Entry } -func NewMapExpr(zctx *zson.Context, entries []Entry) *MapExpr { +func NewMapExpr(zctx *zed.Context, entries []Entry) *MapExpr { return &MapExpr{ zctx: zctx, typ: zctx.LookupTypeMap(zed.TypeNull, zed.TypeNull), diff --git a/fielditer_test.go b/fielditer_test.go index ffd6903797..7a846eff60 100644 --- a/fielditer_test.go +++ b/fielditer_test.go @@ -15,7 +15,7 @@ func TestRecordIter(t *testing.T) { // field, record with another record as the last field, non-record // container types inside records... const input = `{r1:{r2:{s:"hello"},a:[1,2,3],r3:{i:1.2.3.4}}}` - rec, err := zson.NewReader(strings.NewReader(input), zson.NewContext()).Read() + rec, err := zson.NewReader(strings.NewReader(input), zed.NewContext()).Read() require.NoError(t, err) it := rec.FieldIter() diff --git a/index/finder.go b/index/finder.go index d6fbe0abb0..21e22d44b2 100644 --- a/index/finder.go +++ b/index/finder.go @@ -19,7 +19,7 @@ var ErrNotFound = errors.New("key not found") // Finder looks up values in a microindex using its embedded index. type Finder struct { *Reader - zctx *zson.Context + zctx *zed.Context uri *storage.URI } @@ -28,7 +28,7 @@ type Finder struct { // corrupt, doesn't exist, or has an invalid trailer. If the microindex exists // but is empty, zero values are returned for any lookups. If the microindex // does not exist, a wrapped zqe.NotFound error is returned. -func NewFinder(ctx context.Context, zctx *zson.Context, engine storage.Engine, uri *storage.URI) (*Finder, error) { +func NewFinder(ctx context.Context, zctx *zed.Context, engine storage.Engine, uri *storage.URI) (*Finder, error) { reader, err := NewReaderFromURI(ctx, zctx, engine, uri) if err != nil { return nil, err diff --git a/index/findreader.go b/index/findreader.go index ddc05ef8dd..e9edf2d8d7 100644 --- a/index/findreader.go +++ b/index/findreader.go @@ -7,7 +7,6 @@ import ( "github.com/brimdata/zed/expr" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) // FinderReader is zio.Reader version of Finder that streams back all records @@ -19,7 +18,7 @@ type FinderReader struct { reader zio.Reader } -func NewFinderReader(ctx context.Context, zctx *zson.Context, engine storage.Engine, uri *storage.URI, inputs ...string) (*FinderReader, error) { +func NewFinderReader(ctx context.Context, zctx *zed.Context, engine storage.Engine, uri *storage.URI, inputs ...string) (*FinderReader, error) { finder, err := NewFinder(ctx, zctx, engine, uri) if err != nil { return nil, err diff --git a/index/index_test.go b/index/index_test.go index d87503bf6e..02fda24514 100644 --- a/index/index_test.go +++ b/index/index_test.go @@ -45,7 +45,7 @@ func TestMicroIndex(t *testing.T) { path := filepath.Join(t.TempDir(), "test2.zng") stream, err := newReader(N) require.NoError(t, err) - zctx := zson.NewContext() + zctx := zed.NewContext() engine := storage.NewLocalEngine() writer, err := index.NewWriter(zctx, engine, path) require.NoError(t, err) @@ -129,7 +129,7 @@ func TestCompare(t *testing.T) { runtest(t, desc, "==", c.value, c.eql) } }) - r, err := driver.NewReader(context.Background(), compiler.MustParseProc("sort ts"), zson.NewContext(), reader(records)) + r, err := driver.NewReader(context.Background(), compiler.MustParseProc("sort ts"), zed.NewContext(), reader(records)) require.NoError(t, err) asc := buildAndOpen(t, engine, r, index.Keys("ts"), index.Order(order.Asc)) t.Run("Ascending", func(t *testing.T) { @@ -148,7 +148,7 @@ func buildAndOpen(t *testing.T, engine storage.Engine, r zio.Reader, opts ...ind func openFinder(t *testing.T, path string) *index.Finder { uri, err := storage.ParseURI(path) require.NoError(t, err) - zctx := zson.NewContext() + zctx := zed.NewContext() finder, err := index.NewFinder(context.Background(), zctx, storage.NewLocalEngine(), uri) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, finder.Close()) }) @@ -157,7 +157,7 @@ func openFinder(t *testing.T, path string) *index.Finder { func build(t *testing.T, engine storage.Engine, r zio.Reader, opts ...index.Option) string { path := filepath.Join(t.TempDir(), "test.zng") - writer, err := index.NewWriter(zson.NewContext(), engine, path, opts...) + writer, err := index.NewWriter(zed.NewContext(), engine, path, opts...) require.NoError(t, err) require.NoError(t, zio.Copy(writer, r)) require.NoError(t, writer.Close()) @@ -165,7 +165,7 @@ func build(t *testing.T, engine storage.Engine, r zio.Reader, opts ...index.Opti } func reader(logs string) zio.Reader { - return zson.NewReader(strings.NewReader(logs), zson.NewContext()) + return zson.NewReader(strings.NewReader(logs), zed.NewContext()) } func newReader(size int) (zio.Reader, error) { diff --git a/index/mem.go b/index/mem.go index 22481db73e..14b138d0d8 100644 --- a/index/mem.go +++ b/index/mem.go @@ -7,7 +7,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) // MemTable implements an in-memory table to build a microindex. @@ -18,13 +17,13 @@ type MemTable struct { table map[string]zcode.Bytes keys []zcode.Bytes offset int - zctx *zson.Context + zctx *zed.Context builder *zed.Builder keyType zed.Type valType zed.Type } -func NewMemTable(zctx *zson.Context) *MemTable { +func NewMemTable(zctx *zed.Context) *MemTable { return &MemTable{ table: make(map[string]zcode.Bytes), zctx: zctx, diff --git a/index/reader.go b/index/reader.go index 238704284e..43ba00b1f0 100644 --- a/index/reader.go +++ b/index/reader.go @@ -10,7 +10,6 @@ import ( "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" ) const ( @@ -23,7 +22,7 @@ const ( type Reader struct { reader storage.Reader uri *storage.URI - zctx *zson.Context + zctx *zed.Context size int64 trailer *Trailer trailerLen int @@ -36,7 +35,7 @@ var _ io.Closer = (*Reader)(nil) // Seek() may be called on this Reader. Any call to Seek() must be to // an offset that begins a new zng stream (e.g., beginning of file or // the data immediately following an end-of-stream code) -func NewReader(zctx *zson.Context, engine storage.Engine, path string) (*Reader, error) { +func NewReader(zctx *zed.Context, engine storage.Engine, path string) (*Reader, error) { uri, err := storage.ParseURI(path) if err != nil { return nil, err @@ -44,7 +43,7 @@ func NewReader(zctx *zson.Context, engine storage.Engine, path string) (*Reader, return NewReaderFromURI(context.Background(), zctx, engine, uri) } -func NewReaderWithContext(ctx context.Context, zctx *zson.Context, engine storage.Engine, path string) (*Reader, error) { +func NewReaderWithContext(ctx context.Context, zctx *zed.Context, engine storage.Engine, path string) (*Reader, error) { uri, err := storage.ParseURI(path) if err != nil { return nil, err @@ -52,7 +51,7 @@ func NewReaderWithContext(ctx context.Context, zctx *zson.Context, engine storag return NewReaderFromURI(ctx, zctx, engine, uri) } -func NewReaderFromURI(ctx context.Context, zctx *zson.Context, engine storage.Engine, uri *storage.URI) (*Reader, error) { +func NewReaderFromURI(ctx context.Context, zctx *zed.Context, engine storage.Engine, uri *storage.URI) (*Reader, error) { r, err := engine.Get(ctx, uri) if err != nil { return nil, err diff --git a/index/stat.go b/index/stat.go index cbe9cd55e1..0c98c59b96 100644 --- a/index/stat.go +++ b/index/stat.go @@ -3,8 +3,8 @@ package index import ( "context" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" - "github.com/brimdata/zed/zson" ) type InfoKey struct { @@ -23,7 +23,7 @@ func Stat(ctx context.Context, engine storage.Engine, uri *storage.URI) (*Info, if err != nil { return nil, err } - r, err := NewReaderFromURI(ctx, zson.NewContext(), engine, uri) + r, err := NewReaderFromURI(ctx, zed.NewContext(), engine, uri) if err != nil { return nil, err } diff --git a/index/trailer.go b/index/trailer.go index 8c7971ece6..20d6f8c37f 100644 --- a/index/trailer.go +++ b/index/trailer.go @@ -10,7 +10,6 @@ import ( "github.com/brimdata/zed/order" "github.com/brimdata/zed/zcode" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" ) const ( @@ -41,7 +40,7 @@ type Trailer struct { var ErrNotIndex = errors.New("not a zed index") -func newTrailerRecord(zctx *zson.Context, childField string, frameThresh int, sections []int64, keyType *zed.TypeRecord, o order.Which) (*zed.Record, error) { +func newTrailerRecord(zctx *zed.Context, childField string, frameThresh int, sections []int64, keyType *zed.TypeRecord, o order.Which) (*zed.Record, error) { sectionsType := zctx.LookupTypeArray(zed.TypeInt64) cols := []zed.Column{ {MagicField, zed.TypeString}, @@ -100,7 +99,7 @@ func readTrailer(r io.ReaderAt, size int64) (*Trailer, int, error) { continue } r := bytes.NewReader(buf[off:n]) - rec, _ := zngio.NewReader(r, zson.NewContext()).Read() + rec, _ := zngio.NewReader(r, zed.NewContext()).Read() if rec == nil { continue } @@ -198,7 +197,7 @@ func decodeSections(rec *zed.Record) ([]int64, error) { return sizes, nil } -func uniqChildField(zctx *zson.Context, keys *zed.Record) string { +func uniqChildField(zctx *zed.Context, keys *zed.Record) string { // This loop works around the corner case that the field reserved // for the child pointer is in use by another key... childField := ChildFieldVal diff --git a/index/writer.go b/index/writer.go index 0eb5a15e24..8b8260042a 100644 --- a/index/writer.go +++ b/index/writer.go @@ -14,7 +14,6 @@ import ( "github.com/brimdata/zed/pkg/bufwriter" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" ) // Writer implements the zio.Writer interface. A Writer creates a zed index, @@ -48,7 +47,7 @@ import ( type Writer struct { uri *storage.URI keyFields field.List - zctx *zson.Context + zctx *zed.Context engine storage.Engine writer *indexWriter cutter *expr.Cutter @@ -78,11 +77,11 @@ type indexWriter struct { // provide keys in increasing lexicographic order. Duplicate keys are not // allowed but will not be detected. Close() or Abort() must be called when // done writing. -func NewWriter(zctx *zson.Context, engine storage.Engine, path string, options ...Option) (*Writer, error) { +func NewWriter(zctx *zed.Context, engine storage.Engine, path string, options ...Option) (*Writer, error) { return NewWriterWithContext(context.Background(), zctx, engine, path, options...) } -func NewWriterWithContext(ctx context.Context, zctx *zson.Context, engine storage.Engine, path string, options ...Option) (*Writer, error) { +func NewWriterWithContext(ctx context.Context, zctx *zed.Context, engine storage.Engine, path string, options ...Option) (*Writer, error) { w := &Writer{ zctx: zctx, engine: engine, @@ -290,7 +289,7 @@ func (w *Writer) writeEmptyTrailer() error { return writeTrailer(zw, w.zctx, "", w.frameThresh, nil, typ, w.order) } -func writeTrailer(w *zngio.Writer, zctx *zson.Context, childField string, frameThresh int, sizes []int64, keyType *zed.TypeRecord, o order.Which) error { +func writeTrailer(w *zngio.Writer, zctx *zed.Context, childField string, frameThresh int, sizes []int64, keyType *zed.TypeRecord, o order.Which) error { // Finally, write the size records as the trailer of the index. rec, err := newTrailerRecord(zctx, childField, frameThresh, sizes, keyType, o) if err != nil { diff --git a/lake/api/local.go b/lake/api/local.go index 2a9462f90e..dd786569b1 100644 --- a/lake/api/local.go +++ b/lake/api/local.go @@ -4,6 +4,7 @@ import ( "context" "errors" + "github.com/brimdata/zed" "github.com/brimdata/zed/api" "github.com/brimdata/zed/compiler" "github.com/brimdata/zed/driver" @@ -15,7 +16,6 @@ import ( "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" "github.com/segmentio/ksuid" ) @@ -102,7 +102,7 @@ func (l *LocalSession) Query(ctx context.Context, d driver.Driver, head *lakepar if _, err := rlimit.RaiseOpenFilesLimit(); err != nil { return zbuf.ScannerStats{}, err } - return driver.RunWithLake(ctx, d, query, zson.NewContext(), l.root, head) + return driver.RunWithLake(ctx, d, query, zed.NewContext(), l.root, head) } func (l *LocalSession) PoolID(ctx context.Context, poolName string) (ksuid.KSUID, error) { diff --git a/lake/api/remote.go b/lake/api/remote.go index fdd92bf52a..57e2a533b6 100644 --- a/lake/api/remote.go +++ b/lake/api/remote.go @@ -7,6 +7,7 @@ import ( "io" "strings" + "github.com/brimdata/zed" "github.com/brimdata/zed/api" "github.com/brimdata/zed/api/client" "github.com/brimdata/zed/api/queryio" @@ -182,7 +183,7 @@ func unmarshal(res *client.Response, i interface{}) error { return err } //XXX should be ZNG - zr, err := anyio.NewReaderWithOpts(res.Body, zson.NewContext(), anyio.ReaderOpts{Format: format}) + zr, err := anyio.NewReaderWithOpts(res.Body, zed.NewContext(), anyio.ReaderOpts{Format: format}) if err != nil { return nil } diff --git a/lake/branch.go b/lake/branch.go index 454eeb484f..4734054440 100644 --- a/lake/branch.go +++ b/lake/branch.go @@ -17,7 +17,6 @@ import ( "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" "github.com/segmentio/ksuid" ) @@ -335,7 +334,7 @@ func (b *Branch) indexObject(ctx context.Context, rules []index.Rule, id ksuid.K if err != nil { return nil, err } - reader := zngio.NewReader(r, zson.NewContext()) + reader := zngio.NewReader(r, zed.NewContext()) w, err := index.NewCombiner(ctx, b.engine, b.pool.IndexPath, rules, id) if err != nil { r.Close() diff --git a/lake/commits/reader.go b/lake/commits/reader.go index 5da8377e35..1e85fbfa78 100644 --- a/lake/commits/reader.go +++ b/lake/commits/reader.go @@ -19,7 +19,7 @@ type LogReader struct { var _ zio.Reader = (*LogReader)(nil) -func newLogReader(ctx context.Context, zctx *zson.Context, store *Store, leaf, stop ksuid.KSUID) *LogReader { +func newLogReader(ctx context.Context, zctx *zed.Context, store *Store, leaf, stop ksuid.KSUID) *LogReader { m := zson.NewZNGMarshalerWithContext(zctx) m.Decorate(zson.StyleSimple) return &LogReader{ diff --git a/lake/commits/store.go b/lake/commits/store.go index a309a3da19..89613691ef 100644 --- a/lake/commits/store.go +++ b/lake/commits/store.go @@ -7,11 +7,11 @@ import ( "fmt" "io" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/zngio" "github.com/brimdata/zed/zngbytes" - "github.com/brimdata/zed/zson" "github.com/segmentio/ksuid" ) @@ -203,7 +203,7 @@ func (s *Store) Open(ctx context.Context, commit, stop ksuid.KSUID) (io.Reader, return bytes.NewReader(b), nil } -func (s *Store) OpenAsZNG(ctx context.Context, zctx *zson.Context, commit, stop ksuid.KSUID) (*zngio.Reader, error) { +func (s *Store) OpenAsZNG(ctx context.Context, zctx *zed.Context, commit, stop ksuid.KSUID) (*zngio.Reader, error) { r, err := s.Open(ctx, commit, stop) if err != nil { return nil, err @@ -211,7 +211,7 @@ func (s *Store) OpenAsZNG(ctx context.Context, zctx *zson.Context, commit, stop return zngio.NewReader(r, zctx), nil } -func (s *Store) OpenCommitLog(ctx context.Context, zctx *zson.Context, commit, stop ksuid.KSUID) zio.Reader { +func (s *Store) OpenCommitLog(ctx context.Context, zctx *zed.Context, commit, stop ksuid.KSUID) zio.Reader { return newLogReader(ctx, zctx, s, commit, stop) } diff --git a/lake/data/reader.go b/lake/data/reader.go index dcdb64650e..7cd6dff1c9 100644 --- a/lake/data/reader.go +++ b/lake/data/reader.go @@ -6,13 +6,13 @@ import ( "fmt" "io" + "github.com/brimdata/zed" "github.com/brimdata/zed/expr" "github.com/brimdata/zed/expr/extent" "github.com/brimdata/zed/lake/seekindex" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio/zngio" "github.com/brimdata/zed/zqe" - "github.com/brimdata/zed/zson" ) type Reader struct { @@ -57,7 +57,7 @@ func (o *Object) NewReader(ctx context.Context, engine storage.Engine, path *sto return nil, err } defer indexReader.Close() - rg, err := seekindex.Lookup(zngio.NewReader(indexReader, zson.NewContext()), scanRange.First(), scanRange.Last(), cmp) + rg, err := seekindex.Lookup(zngio.NewReader(indexReader, zed.NewContext()), scanRange.First(), scanRange.Last(), cmp) if err != nil { if zqe.IsNotFound(err) { return sr, nil diff --git a/lake/data/writer_test.go b/lake/data/writer_test.go index 08e0570b36..d9c31573f5 100644 --- a/lake/data/writer_test.go +++ b/lake/data/writer_test.go @@ -11,7 +11,7 @@ func TestWriterIndex(t *testing.T) { ` def := index.MustNewDefinition(index.NewTypeRule(zed.TypeInt64)) chunk := testWriteWithDef(t, data, def) - reader, err := index.Find(context.Background(), zson.NewContext(), chunk.ZarDir(), def.ID, "100") + reader, err := index.Find(context.Background(), zed.NewContext(), chunk.ZarDir(), def.ID, "100") require.NoError(t, err) recs, err := zbuf.ReadAll(reader) require.NoError(t, err) @@ -29,7 +29,7 @@ func TestWriterSkipsInputPath(t *testing.T) { sdef := index.MustNewDefinition(index.NewFieldRule("s")) inputdef := index.MustNewDefinition(index.NewTypeRule(zed.TypeInt64)) inputdef.Input = "input_path" - zctx := zson.NewContext() + zctx := zed.NewContext() chunk := testWriteWithDef(t, data, sdef, inputdef) //reader, err := index.Find(context.Background(), zctx, chunk.ZarDir(), sdef.ID, "test") //require.NoError(t, err) @@ -46,7 +46,7 @@ func testWriteWithDef(t *testing.T, input string, defs ...*index.Definition) *Re ref := New() w, err := ref.NewWriter(context.Background(), dir, WriterOpts{Order: zbuf.OrderDesc, Definitions: defs}) require.NoError(t, err) - require.NoError(t, zbuf.Copy(w, zson.NewReader(strings.NewReader(input), zson.NewContext()))) + require.NoError(t, zbuf.Copy(w, zson.NewReader(strings.NewReader(input), zed.NewContext()))) require.NoError(t, w.Close(context.Background())) return w.Segment() } diff --git a/lake/index/index_test.go b/lake/index/index_test.go index 4949904c0c..5bd29c405e 100644 --- a/lake/index/index_test.go +++ b/lake/index/index_test.go @@ -17,7 +17,7 @@ func boomerang(t *testing.T, r1 Rule) (r2 Rule) { t.Helper() b, err := serialize(r1) require.NoError(t, err) - reader := zngio.NewReader(bytes.NewReader(b), zson.NewContext()) + reader := zngio.NewReader(bytes.NewReader(b), zed.NewContext()) rec, err := reader.Read() require.NoError(t, err) u := zson.NewZNGUnmarshaler() @@ -44,7 +44,7 @@ func babbleReader(t *testing.T) zio.Reader { r, err := os.Open("../../testdata/babble-sorted.zson") require.NoError(t, err) t.Cleanup(func() { r.Close() }) - return zson.NewReader(r, zson.NewContext()) + return zson.NewReader(r, zed.NewContext()) } /* Not yet @@ -56,7 +56,7 @@ func TestWriteIndices(t *testing.T) { dir := iosrc.MustParseURI(t.TempDir()) ctx := context.Background() - r := zson.NewReader(strings.NewReader(data), zson.NewContext()) + r := zson.NewReader(strings.NewReader(data), zed.NewContext()) ip := MustNewDefinition(NewTypeRule(zed.TypeIP)) proto := MustNewDefinition(NewFieldRule("proto")) @@ -94,7 +94,7 @@ func TestWriteIndices(t *testing.T) { for _, test := range tests { t.Run(fmt.Sprintf("Find-%s-%t", test.def.Kind, test.has), func(t *testing.T) { - reader, err := Find(ctx, zson.NewContext(), dir, test.def.ID, test.pattern) + reader, err := Find(ctx, zed.NewContext(), dir, test.def.ID, test.pattern) require.NoError(t, err) recs, err := zbuf.ReadAll(reader) require.NoError(t, err) @@ -115,7 +115,7 @@ func TestFindTypeRule(t *testing.T) { err := zbuf.Copy(w, babbleReader(t)) require.NoError(t, err) require.NoError(t, w.Close()) - reader, err := FindFromPath(context.Background(), zson.NewContext(), w.URI, "456") + reader, err := FindFromPath(context.Background(), zed.NewContext(), w.URI, "456") require.NoError(t, err) recs, err := zbuf.ReadAll(reader) require.NoError(t, err) @@ -137,7 +137,7 @@ func TestZedRule(t *testing.T) { err = zbuf.Copy(w, babbleReader(t)) require.NoError(t, err) require.NoError(t, w.Close()) - reader, err := FindFromPath(context.Background(), zson.NewContext(), w.URI, "kartometer-trifocal") + reader, err := FindFromPath(context.Background(), zed.NewContext(), w.URI, "kartometer-trifocal") require.NoError(t, err) recs, err := zbuf.ReadAll(reader) require.NoError(t, err) diff --git a/lake/index/store.go b/lake/index/store.go index b941a7c720..83a416c4d4 100644 --- a/lake/index/store.go +++ b/lake/index/store.go @@ -8,6 +8,7 @@ import ( "sort" "time" + "github.com/brimdata/zed" "github.com/brimdata/zed/lake/journal" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zngbytes" @@ -64,7 +65,7 @@ func (s *Store) load(ctx context.Context) error { if head == s.at { return nil } - r, err := s.journal.OpenAsZNG(ctx, zson.NewContext(), head, 0) + r, err := s.journal.OpenAsZNG(ctx, zed.NewContext(), head, 0) if err != nil { return err } diff --git a/lake/index/writer.go b/lake/index/writer.go index 3f7cc16f18..5757da15da 100644 --- a/lake/index/writer.go +++ b/lake/index/writer.go @@ -116,7 +116,7 @@ func newIndexer(ctx context.Context, engine storage.Engine, path *storage.URI, o if err != nil { return nil, err } - zctx := zson.NewContext() + zctx := zed.NewContext() fgr, err := driver.NewReader(ctx, p, zctx, r) if err != nil { return nil, err diff --git a/lake/index/writer_test.go b/lake/index/writer_test.go index 831a29b925..edcbff5afb 100644 --- a/lake/index/writer_test.go +++ b/lake/index/writer_test.go @@ -40,7 +40,7 @@ func TestWriterError(t *testing.T) { const r2 = "{ts:1970-01-01T00:00:02Z,id:2}" o := Object{Rule: NewFieldRule("test", "id"), ID: ksuid.New()} w := testWriter(t, o) - zctx := zson.NewContext() + zctx := zed.NewContext() arr1, err := zbuf.ReadAll(zson.NewReader(strings.NewReader(r1), zctx)) require.NoError(t, err) arr2, err := zbuf.ReadAll(zson.NewReader(strings.NewReader(r2), zctx)) diff --git a/lake/journal/queue.go b/lake/journal/queue.go index 04fde3b29e..34fe83ab85 100644 --- a/lake/journal/queue.go +++ b/lake/journal/queue.go @@ -11,9 +11,9 @@ import ( "strings" "time" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" ) const ext = "zng" @@ -172,7 +172,7 @@ func (q *Queue) Open(ctx context.Context, head, tail ID) (io.Reader, error) { return q.NewReader(ctx, head, tail), nil } -func (q *Queue) OpenAsZNG(ctx context.Context, zctx *zson.Context, head, tail ID) (*zngio.Reader, error) { +func (q *Queue) OpenAsZNG(ctx context.Context, zctx *zed.Context, head, tail ID) (*zngio.Reader, error) { r, err := q.Open(ctx, head, tail) if err != nil { return nil, err diff --git a/lake/journal/store.go b/lake/journal/store.go index 55479066bd..9737317a1b 100644 --- a/lake/journal/store.go +++ b/lake/journal/store.go @@ -7,6 +7,7 @@ import ( "os" "time" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zngbytes" "github.com/brimdata/zed/zson" @@ -72,7 +73,7 @@ func (s *Store) load(ctx context.Context) error { if head == s.at { return nil } - r, err := s.journal.OpenAsZNG(ctx, zson.NewContext(), head, 0) + r, err := s.journal.OpenAsZNG(ctx, zed.NewContext(), head, 0) if err != nil { return err } diff --git a/lake/mock/mock.go b/lake/mock/mock.go index 6341c3d2c2..92af0210e9 100644 --- a/lake/mock/mock.go +++ b/lake/mock/mock.go @@ -5,12 +5,12 @@ import ( "fmt" "strings" + "github.com/brimdata/zed" "github.com/brimdata/zed/compiler/ast/dag" "github.com/brimdata/zed/expr/extent" "github.com/brimdata/zed/order" "github.com/brimdata/zed/proc" "github.com/brimdata/zed/zbuf" - "github.com/brimdata/zed/zson" "github.com/segmentio/ksuid" ) @@ -103,10 +103,10 @@ func (l *Lake) Layout(_ context.Context, src dag.Source) order.Layout { return order.Nil } -func (*Lake) NewScheduler(context.Context, *zson.Context, dag.Source, extent.Span, zbuf.Filter) (proc.Scheduler, error) { +func (*Lake) NewScheduler(context.Context, *zed.Context, dag.Source, extent.Span, zbuf.Filter) (proc.Scheduler, error) { return nil, fmt.Errorf("mock.Lake.NewScheduler() should not be called") } -func (*Lake) Open(_ context.Context, _ *zson.Context, _ string, _ zbuf.Filter) (zbuf.PullerCloser, error) { +func (*Lake) Open(_ context.Context, _ *zed.Context, _ string, _ zbuf.Filter) (zbuf.PullerCloser, error) { return nil, fmt.Errorf("mock.Lake.Open() should not be called") } diff --git a/lake/partition.go b/lake/partition.go index 3d77e1e6d4..9c6c2e2001 100644 --- a/lake/partition.go +++ b/lake/partition.go @@ -138,7 +138,7 @@ func sortObjects(o order.Which, objects []*data.Object) { } } -func partitionReader(ctx context.Context, zctx *zson.Context, snap commits.View, span extent.Span, order order.Which) (zio.Reader, error) { +func partitionReader(ctx context.Context, zctx *zed.Context, snap commits.View, span extent.Span, order order.Which) (zio.Reader, error) { ch := make(chan Partition) ctx, cancel := context.WithCancel(ctx) var scanErr error @@ -167,7 +167,7 @@ func partitionReader(ctx context.Context, zctx *zson.Context, snap commits.View, }), nil } -func objectReader(ctx context.Context, zctx *zson.Context, snap commits.View, span extent.Span, order order.Which) (zio.Reader, error) { +func objectReader(ctx context.Context, zctx *zed.Context, snap commits.View, span extent.Span, order order.Which) (zio.Reader, error) { ch := make(chan data.Object) ctx, cancel := context.WithCancel(ctx) var scanErr error @@ -196,7 +196,7 @@ func objectReader(ctx context.Context, zctx *zson.Context, snap commits.View, sp }), nil } -func indexObjectReader(ctx context.Context, zctx *zson.Context, snap commits.View, span extent.Span, order order.Which) (zio.Reader, error) { +func indexObjectReader(ctx context.Context, zctx *zed.Context, snap commits.View, span extent.Span, order order.Which) (zio.Reader, error) { ch := make(chan *index.Object) ctx, cancel := context.WithCancel(ctx) var scanErr error diff --git a/lake/pool.go b/lake/pool.go index 863068b6b6..248d3c5ece 100644 --- a/lake/pool.go +++ b/lake/pool.go @@ -104,7 +104,7 @@ func (p *Pool) removeBranch(ctx context.Context, name string) error { return p.branches.Remove(ctx, *config) } -func (p *Pool) newScheduler(ctx context.Context, zctx *zson.Context, commit ksuid.KSUID, span extent.Span, filter zbuf.Filter) (proc.Scheduler, error) { +func (p *Pool) newScheduler(ctx context.Context, zctx *zed.Context, commit ksuid.KSUID, span extent.Span, filter zbuf.Filter) (proc.Scheduler, error) { snap, err := p.commits.Snapshot(ctx, commit) if err != nil { return nil, err @@ -159,7 +159,7 @@ type BranchTip struct { Commit ksuid.KSUID } -func (p *Pool) batchifyBranchTips(ctx context.Context, zctx *zson.Context, f expr.Filter) (zbuf.Array, error) { +func (p *Pool) batchifyBranchTips(ctx context.Context, zctx *zed.Context, f expr.Filter) (zbuf.Array, error) { branches, err := p.ListBranches(ctx) if err != nil { return nil, err diff --git a/lake/root.go b/lake/root.go index d30839423a..bae4430482 100644 --- a/lake/root.go +++ b/lake/root.go @@ -7,6 +7,7 @@ import ( "fmt" "sort" + "github.com/brimdata/zed" "github.com/brimdata/zed/compiler/ast/dag" "github.com/brimdata/zed/expr" "github.com/brimdata/zed/expr/extent" @@ -168,7 +169,7 @@ func (r *Root) readLakeMagic(ctx context.Context) error { return nil } -func (r *Root) batchifyPools(ctx context.Context, zctx *zson.Context, f expr.Filter) (zbuf.Array, error) { +func (r *Root) batchifyPools(ctx context.Context, zctx *zed.Context, f expr.Filter) (zbuf.Array, error) { m := zson.NewZNGMarshalerWithContext(zctx) m.Decorate(zson.StylePackage) pools, err := r.ListPools(ctx) @@ -188,7 +189,7 @@ func (r *Root) batchifyPools(ctx context.Context, zctx *zson.Context, f expr.Fil return batch, nil } -func (r *Root) batchifyBranches(ctx context.Context, zctx *zson.Context, f expr.Filter) (zbuf.Array, error) { +func (r *Root) batchifyBranches(ctx context.Context, zctx *zed.Context, f expr.Filter) (zbuf.Array, error) { m := zson.NewZNGMarshalerWithContext(zctx) m.Decorate(zson.StylePackage) poolRefs, err := r.ListPools(ctx) @@ -403,7 +404,7 @@ func (r *Root) AllIndexRules(ctx context.Context) ([]index.Rule, error) { return r.indexRules.All(ctx) } -func (r *Root) batchifyIndexRules(ctx context.Context, zctx *zson.Context, f expr.Filter) (zbuf.Array, error) { +func (r *Root) batchifyIndexRules(ctx context.Context, zctx *zed.Context, f expr.Filter) (zbuf.Array, error) { m := zson.NewZNGMarshalerWithContext(zctx) m.Decorate(zson.StylePackage) names, err := r.indexRules.Names(ctx) @@ -435,7 +436,7 @@ func (r *Root) batchifyIndexRules(ctx context.Context, zctx *zson.Context, f exp return batch, nil } -func (r *Root) NewScheduler(ctx context.Context, zctx *zson.Context, src dag.Source, span extent.Span, filter zbuf.Filter) (proc.Scheduler, error) { +func (r *Root) NewScheduler(ctx context.Context, zctx *zed.Context, src dag.Source, span extent.Span, filter zbuf.Filter) (proc.Scheduler, error) { switch src := src.(type) { case *dag.Pool: return r.newPoolScheduler(ctx, zctx, src.ID, src.Commit, span, filter) @@ -450,7 +451,7 @@ func (r *Root) NewScheduler(ctx context.Context, zctx *zson.Context, src dag.Sou } } -func (r *Root) newLakeMetaScheduler(ctx context.Context, zctx *zson.Context, meta string, filter zbuf.Filter) (proc.Scheduler, error) { +func (r *Root) newLakeMetaScheduler(ctx context.Context, zctx *zed.Context, meta string, filter zbuf.Filter) (proc.Scheduler, error) { f, err := filter.AsFilter() if err != nil { return nil, err @@ -476,7 +477,7 @@ func (r *Root) newLakeMetaScheduler(ctx context.Context, zctx *zson.Context, met return newScannerScheduler(s), nil } -func (r *Root) newPoolMetaScheduler(ctx context.Context, zctx *zson.Context, poolID ksuid.KSUID, meta string, filter zbuf.Filter) (proc.Scheduler, error) { +func (r *Root) newPoolMetaScheduler(ctx context.Context, zctx *zed.Context, poolID ksuid.KSUID, meta string, filter zbuf.Filter) (proc.Scheduler, error) { f, err := filter.AsFilter() if err != nil { return nil, err @@ -501,7 +502,7 @@ func (r *Root) newPoolMetaScheduler(ctx context.Context, zctx *zson.Context, poo return newScannerScheduler(s), nil } -func (r *Root) newCommitMetaScheduler(ctx context.Context, zctx *zson.Context, poolID, commit ksuid.KSUID, meta string, span extent.Span, filter zbuf.Filter) (proc.Scheduler, error) { +func (r *Root) newCommitMetaScheduler(ctx context.Context, zctx *zed.Context, poolID, commit ksuid.KSUID, meta string, span extent.Span, filter zbuf.Filter) (proc.Scheduler, error) { p, err := r.OpenPool(ctx, poolID) if err != nil { return nil, err @@ -579,7 +580,7 @@ func (r *Root) newCommitMetaScheduler(ctx context.Context, zctx *zson.Context, p } } -func (r *Root) newPoolScheduler(ctx context.Context, zctx *zson.Context, poolID, commit ksuid.KSUID, span extent.Span, filter zbuf.Filter) (proc.Scheduler, error) { +func (r *Root) newPoolScheduler(ctx context.Context, zctx *zed.Context, poolID, commit ksuid.KSUID, span extent.Span, filter zbuf.Filter) (proc.Scheduler, error) { pool, err := r.OpenPool(ctx, poolID) if err != nil { return nil, err @@ -587,7 +588,7 @@ func (r *Root) newPoolScheduler(ctx context.Context, zctx *zson.Context, poolID, return pool.newScheduler(ctx, zctx, commit, span, filter) } -func (r *Root) Open(context.Context, *zson.Context, string, zbuf.Filter) (zbuf.PullerCloser, error) { +func (r *Root) Open(context.Context, *zed.Context, string, zbuf.Filter) (zbuf.PullerCloser, error) { return nil, errors.New("cannot use 'file' or 'http' source in a lake query") } diff --git a/lake/scheduler.go b/lake/scheduler.go index 0dc53d6cac..ac3571ec6a 100644 --- a/lake/scheduler.go +++ b/lake/scheduler.go @@ -4,6 +4,7 @@ import ( "context" "sync" + "github.com/brimdata/zed" "github.com/brimdata/zed/expr/extent" "github.com/brimdata/zed/lake/commits" "github.com/brimdata/zed/lake/data" @@ -11,12 +12,11 @@ import ( "github.com/brimdata/zed/order" "github.com/brimdata/zed/proc" "github.com/brimdata/zed/zbuf" - "github.com/brimdata/zed/zson" ) type Scheduler struct { ctx context.Context - zctx *zson.Context + zctx *zed.Context pool *Pool snap commits.View span extent.Span @@ -29,7 +29,7 @@ type Scheduler struct { var _ proc.Scheduler = (*Scheduler)(nil) -func NewSortedScheduler(ctx context.Context, zctx *zson.Context, pool *Pool, snap commits.View, span extent.Span, filter zbuf.Filter) *Scheduler { +func NewSortedScheduler(ctx context.Context, zctx *zed.Context, pool *Pool, snap commits.View, span extent.Span, filter zbuf.Filter) *Scheduler { return &Scheduler{ ctx: ctx, zctx: zctx, diff --git a/lake/seekindex/seekindex_test.go b/lake/seekindex/seekindex_test.go index aba6404160..addcba9305 100644 --- a/lake/seekindex/seekindex_test.go +++ b/lake/seekindex/seekindex_test.go @@ -11,7 +11,6 @@ import ( "github.com/brimdata/zed/pkg/nano" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -76,7 +75,7 @@ type testSeekIndex struct { } func (t *testSeekIndex) Lookup(s nano.Span, expected Range, o order.Which) { - r := zngio.NewReader(bytes.NewReader(t.buffer.Bytes()), zson.NewContext()) + r := zngio.NewReader(bytes.NewReader(t.buffer.Bytes()), zed.NewContext()) cmp := extent.CompareFunc(o) var first, last zed.Value if o == order.Asc { diff --git a/lake/seekindex/writer.go b/lake/seekindex/writer.go index ec514ac5b0..4ef8c6f4ee 100644 --- a/lake/seekindex/writer.go +++ b/lake/seekindex/writer.go @@ -4,11 +4,10 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) type Writer struct { - zctx *zson.Context + zctx *zed.Context builder *zcode.Builder writer zio.Writer typ zed.Type @@ -17,7 +16,7 @@ type Writer struct { func NewWriter(w zio.Writer) *Writer { return &Writer{ - zctx: zson.NewContext(), + zctx: zed.NewContext(), builder: zcode.NewBuilder(), writer: w, } diff --git a/lake/sorted.go b/lake/sorted.go index 86176150cb..5985daf259 100644 --- a/lake/sorted.go +++ b/lake/sorted.go @@ -10,7 +10,6 @@ import ( "github.com/brimdata/zed/order" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" "go.uber.org/multierr" ) @@ -50,7 +49,7 @@ func (s *statScanner) Pull() (zbuf.Batch, error) { return batch, err } -func newSortedScanner(ctx context.Context, pool *Pool, zctx *zson.Context, filter zbuf.Filter, scan Partition, sched *Scheduler) (*sortedPuller, error) { +func newSortedScanner(ctx context.Context, pool *Pool, zctx *zed.Context, filter zbuf.Filter, scan Partition, sched *Scheduler) (*sortedPuller, error) { closers := make(multiCloser, 0, len(scan.Objects)) pullers := make([]zbuf.Puller, 0, len(scan.Objects)) for _, object := range scan.Objects { diff --git a/pkg/stringsearch/fieldnamefinder.go b/pkg/stringsearch/fieldnamefinder.go index 1396845c7d..234af82c97 100644 --- a/pkg/stringsearch/fieldnamefinder.go +++ b/pkg/stringsearch/fieldnamefinder.go @@ -6,7 +6,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/byteconv" - "github.com/brimdata/zed/zson" ) type FieldNameFinder struct { @@ -22,7 +21,7 @@ func NewFieldNameFinder(pattern string) *FieldNameFinder { // Find returns true if buf, which holds a sequence of ZNG value messages, might // contain a record with a field whose fully-qualified name (e.g., a.b.c) // matches the pattern. find also returns true if it encounters an error. -func (f *FieldNameFinder) Find(zctx *zson.Context, buf []byte) bool { +func (f *FieldNameFinder) Find(zctx *zed.Context, buf []byte) bool { f.checkedIDs.SetInt64(0) for len(buf) > 0 { code := buf[0] diff --git a/pkg/stringsearch/fieldnamefinder_test.go b/pkg/stringsearch/fieldnamefinder_test.go index b8370f43e5..ca32a6d55b 100644 --- a/pkg/stringsearch/fieldnamefinder_test.go +++ b/pkg/stringsearch/fieldnamefinder_test.go @@ -10,7 +10,7 @@ import ( func TestFieldNameIter(t *testing.T) { const typeString = "{r1:{r2:{s:string,r3:{t:time}},a:[int64],r4:{i:ip}},empty:{}}" - typ, err := zson.ParseType(zson.NewContext(), typeString) + typ, err := zson.ParseType(zed.NewContext(), typeString) require.NoError(t, err) var f FieldNameIter f.Init(typ.(*zed.TypeRecord)) @@ -28,7 +28,7 @@ func TestFieldNameIter(t *testing.T) { } func TestFieldNameIterEmptyTopLevelRecord(t *testing.T) { - typ, err := zson.ParseType(zson.NewContext(), "{}") + typ, err := zson.ParseType(zed.NewContext(), "{}") require.NoError(t, err) var f FieldNameIter f.Init(typ.(*zed.TypeRecord)) diff --git a/pkg/test/internal.go b/pkg/test/internal.go index 499242cc92..87700f3373 100644 --- a/pkg/test/internal.go +++ b/pkg/test/internal.go @@ -6,12 +6,12 @@ import ( "io" "strings" + "github.com/brimdata/zed" "github.com/brimdata/zed/compiler" "github.com/brimdata/zed/driver" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/anyio" "github.com/brimdata/zed/zio/emitter" - "github.com/brimdata/zed/zson" ) type Internal struct { @@ -28,7 +28,7 @@ func Trim(s string) string { return strings.TrimSpace(s) + "\n" } -func stringReader(input string, ifmt string, zctx *zson.Context) (zio.Reader, error) { +func stringReader(input string, ifmt string, zctx *zed.Context) (zio.Reader, error) { opts := anyio.ReaderOpts{ Format: ifmt, } @@ -49,7 +49,7 @@ func (i *Internal) Run() (string, error) { if err != nil { return "", fmt.Errorf("parse error: %w (%s)", err, i.Query) } - zctx := zson.NewContext() + zctx := zed.NewContext() reader, err := stringReader(i.Input, i.InputFormat, zctx) if err != nil { return "", err diff --git a/proc/explode/explode.go b/proc/explode/explode.go index 087cc047ed..3442ed2db4 100644 --- a/proc/explode/explode.go +++ b/proc/explode/explode.go @@ -6,7 +6,6 @@ import ( "github.com/brimdata/zed/proc" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) // A an explode Proc is a proc that, given an input record and a @@ -21,7 +20,7 @@ type Proc struct { // New creates a exploder for type typ, where the // output records' single column is named name. -func New(zctx *zson.Context, parent proc.Interface, args []expr.Evaluator, typ zed.Type, name string) (proc.Interface, error) { +func New(zctx *zed.Context, parent proc.Interface, args []expr.Evaluator, typ zed.Type, name string) (proc.Interface, error) { cols := []zed.Column{{Name: name, Type: typ}} rectyp := zctx.MustLookupTypeRecord(cols) builder := zed.NewBuilder(rectyp) diff --git a/proc/fuse/fuser.go b/proc/fuse/fuser.go index 44b18b0661..43b6afc94a 100644 --- a/proc/fuse/fuser.go +++ b/proc/fuse/fuser.go @@ -5,14 +5,13 @@ import ( "github.com/brimdata/zed/expr" "github.com/brimdata/zed/expr/agg" "github.com/brimdata/zed/proc/spill" - "github.com/brimdata/zed/zson" ) // Fuser buffers records written to it, assembling from them a unified schema of // fields and types. Fuser then transforms those records to the unified schema // as they are read back from it. type Fuser struct { - zctx *zson.Context + zctx *zed.Context memMaxBytes int nbytes int @@ -27,7 +26,7 @@ type Fuser struct { // NewFuser returns a new Fuser. The Fuser buffers records in memory until // their cumulative size (measured in zcode.Bytes length) exceeds memMaxBytes, // at which point it buffers them in a temporary file. -func NewFuser(zctx *zson.Context, memMaxBytes int) *Fuser { +func NewFuser(zctx *zed.Context, memMaxBytes int) *Fuser { return &Fuser{ zctx: zctx, memMaxBytes: memMaxBytes, diff --git a/proc/groupby/groupby.go b/proc/groupby/groupby.go index bba640c63e..3083b71065 100644 --- a/proc/groupby/groupby.go +++ b/proc/groupby/groupby.go @@ -13,7 +13,6 @@ import ( "github.com/brimdata/zed/proc/spill" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) var DefaultLimit = 1000000 @@ -33,7 +32,7 @@ type Proc struct { // deterministic but undefined total order. type Aggregator struct { ctx context.Context - zctx *zson.Context + zctx *zed.Context // The keyTypes and outTypes tables map a vector of types resulting // from evaluating the key and reducer expressions to a small int, // such that the same vector of types maps to the same small int. @@ -69,7 +68,7 @@ type Row struct { reducers valRow } -func NewAggregator(ctx context.Context, zctx *zson.Context, keyRefs, keyExprs, aggRefs []expr.Evaluator, aggs []*expr.Aggregator, builder *zed.ColumnBuilder, limit int, inputDir order.Direction, partialsIn, partialsOut bool) (*Aggregator, error) { +func NewAggregator(ctx context.Context, zctx *zed.Context, keyRefs, keyExprs, aggRefs []expr.Evaluator, aggs []*expr.Aggregator, builder *zed.ColumnBuilder, limit int, inputDir order.Direction, partialsIn, partialsOut bool) (*Aggregator, error) { if limit == 0 { limit = DefaultLimit } diff --git a/proc/groupby/groupby_test.go b/proc/groupby/groupby_test.go index 7ddbea856f..12e47accdd 100644 --- a/proc/groupby/groupby_test.go +++ b/proc/groupby/groupby_test.go @@ -314,7 +314,7 @@ func TestGroupbyStreamingSpill(t *testing.T) { proc, err := compiler.ParseProc("every 1s count() by ip") assert.NoError(t, err) - zctx := zson.NewContext() + zctx := zed.NewContext() zr := zson.NewReader(strings.NewReader(strings.Join(data, "\n")), zctx) cr := &countReader{r: zr} var outbuf bytes.Buffer diff --git a/proc/merge/merge_test.go b/proc/merge/merge_test.go index ef4446a8e6..4df74a83b2 100644 --- a/proc/merge/merge_test.go +++ b/proc/merge/merge_test.go @@ -6,6 +6,7 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/field" "github.com/brimdata/zed/order" "github.com/brimdata/zed/pkg/test" @@ -96,7 +97,7 @@ func TestParallelOrder(t *testing.T) { for i, c := range cases { t.Run(strconv.Itoa(i), func(t *testing.T) { - zctx := zson.NewContext() + zctx := zed.NewContext() pctx := &proc.Context{Context: context.Background(), Zctx: zctx} var parents []proc.Interface for _, input := range c.inputs { diff --git a/proc/proc.go b/proc/proc.go index a63cc16081..b8fdeeb734 100644 --- a/proc/proc.go +++ b/proc/proc.go @@ -3,11 +3,11 @@ package proc import ( "context" + "github.com/brimdata/zed" "github.com/brimdata/zed/compiler/ast/dag" "github.com/brimdata/zed/expr/extent" "github.com/brimdata/zed/order" "github.com/brimdata/zed/zbuf" - "github.com/brimdata/zed/zson" "github.com/segmentio/ksuid" "go.uber.org/zap" ) @@ -34,8 +34,8 @@ type DataAdaptor interface { PoolID(context.Context, string) (ksuid.KSUID, error) CommitObject(context.Context, ksuid.KSUID, string) (ksuid.KSUID, error) Layout(context.Context, dag.Source) order.Layout - NewScheduler(context.Context, *zson.Context, dag.Source, extent.Span, zbuf.Filter) (Scheduler, error) - Open(context.Context, *zson.Context, string, zbuf.Filter) (zbuf.PullerCloser, error) + NewScheduler(context.Context, *zed.Context, dag.Source, extent.Span, zbuf.Filter) (Scheduler, error) + Open(context.Context, *zed.Context, string, zbuf.Filter) (zbuf.PullerCloser, error) } type Scheduler interface { @@ -56,11 +56,11 @@ type Context struct { context.Context Logger *zap.Logger Warnings chan string - Zctx *zson.Context + Zctx *zed.Context cancel context.CancelFunc } -func NewContext(ctx context.Context, zctx *zson.Context, logger *zap.Logger) *Context { +func NewContext(ctx context.Context, zctx *zed.Context, logger *zap.Logger) *Context { ctx, cancel := context.WithCancel(ctx) if logger == nil { logger = zap.NewNop() @@ -75,7 +75,7 @@ func NewContext(ctx context.Context, zctx *zson.Context, logger *zap.Logger) *Co } func DefaultContext() *Context { - return NewContext(context.Background(), zson.NewContext(), nil) + return NewContext(context.Background(), zed.NewContext(), nil) } func (c *Context) Cancel() { diff --git a/proc/rename/renamer.go b/proc/rename/renamer.go index 2fb5599794..b0399d8aa1 100644 --- a/proc/rename/renamer.go +++ b/proc/rename/renamer.go @@ -8,11 +8,10 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/field" "github.com/brimdata/zed/proc" - "github.com/brimdata/zed/zson" ) type Function struct { - zctx *zson.Context + zctx *zed.Context // For the dst field name, we just store the leaf name since the // src path and the dst path are the same and only differ in the leaf name. srcs field.List @@ -22,7 +21,7 @@ type Function struct { var _ proc.Function = (*Function)(nil) -func NewFunction(zctx *zson.Context, srcs, dsts field.List) *Function { +func NewFunction(zctx *zed.Context, srcs, dsts field.List) *Function { return &Function{zctx, srcs, dsts, make(map[int]*zed.TypeRecord)} } diff --git a/proc/shape/shaper.go b/proc/shape/shaper.go index 58f3feb78e..ea377aed57 100644 --- a/proc/shape/shaper.go +++ b/proc/shape/shaper.go @@ -7,11 +7,10 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/proc/spill" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type Shaper struct { - zctx *zson.Context + zctx *zed.Context memMaxBytes int nbytes int @@ -119,7 +118,7 @@ func (a *anchor) needRecode() []zed.Column { return nil } -func NewShaper(zctx *zson.Context, memMaxBytes int) *Shaper { +func NewShaper(zctx *zed.Context, memMaxBytes int) *Shaper { return &Shaper{ zctx: zctx, memMaxBytes: memMaxBytes, diff --git a/proc/spill/file.go b/proc/spill/file.go index f9625412df..d7215e7103 100644 --- a/proc/spill/file.go +++ b/proc/spill/file.go @@ -4,11 +4,11 @@ import ( "bufio" "os" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/bufwriter" "github.com/brimdata/zed/pkg/fs" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" ) // File provides a means to write a sequence of zng records to temporary @@ -40,7 +40,7 @@ func NewTempFile() (*File, error) { return NewFile(f), nil } -func NewFileWithPath(path string, zctx *zson.Context) (*File, error) { +func NewFileWithPath(path string, zctx *zed.Context) (*File, error) { f, err := fs.Create(path) if err != nil { return nil, err @@ -48,7 +48,7 @@ func NewFileWithPath(path string, zctx *zson.Context) (*File, error) { return NewFile(f), nil } -func (f *File) Rewind(zctx *zson.Context) error { +func (f *File) Rewind(zctx *zed.Context) error { // Close the writer to flush any pending output but since we // wrapped the file in a zio.NopCloser, the file will stay open. if err := f.Writer.Close(); err != nil { diff --git a/proc/spill/merge.go b/proc/spill/merge.go index 873e8eecab..3666cd180a 100644 --- a/proc/spill/merge.go +++ b/proc/spill/merge.go @@ -9,7 +9,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr" - "github.com/brimdata/zed/zson" ) // MergeSort manages "runs" (files of sorted zng records) that are spilled to @@ -21,7 +20,7 @@ type MergeSort struct { compareFn expr.CompareFn tempDir string spillSize int64 - zctx *zson.Context + zctx *zed.Context } const TempPrefix = "zed-spill-" @@ -45,7 +44,7 @@ func NewMergeSort(compareFn expr.CompareFn) (*MergeSort, error) { return &MergeSort{ compareFn: compareFn, tempDir: tempDir, - zctx: zson.NewContext(), + zctx: zed.NewContext(), }, nil } diff --git a/proc/spill/peeker.go b/proc/spill/peeker.go index db5aa34fbf..57c6878d07 100644 --- a/proc/spill/peeker.go +++ b/proc/spill/peeker.go @@ -6,7 +6,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) type peeker struct { @@ -15,7 +14,7 @@ type peeker struct { ordinal int } -func newPeeker(ctx context.Context, filename string, ordinal int, recs []*zed.Record, zctx *zson.Context) (*peeker, error) { +func newPeeker(ctx context.Context, filename string, ordinal int, recs []*zed.Record, zctx *zed.Context) (*peeker, error) { f, err := NewFileWithPath(filename, zctx) if err != nil { return nil, err diff --git a/recordval_test.go b/recordval_test.go index 80d71bfe37..5b2ef2b50e 100644 --- a/recordval_test.go +++ b/recordval_test.go @@ -76,7 +76,7 @@ func TestRecordTypeCheck(t *testing.T) { func TestRecordAccessAlias(t *testing.T) { const input = `{foo:"hello" (=zfile),bar:true (=zbool)} (=0)` - reader := zson.NewReader(strings.NewReader(input), zson.NewContext()) + reader := zson.NewReader(strings.NewReader(input), zed.NewContext()) rec, err := reader.Read() require.NoError(t, err) s, err := rec.AccessString("foo") @@ -98,7 +98,7 @@ func TestRecordTs(t *testing.T) { {"{ts:1}", nano.MinTs}, // Type of ts field is not TypeOfTime. } for _, c := range cases { - zr := zson.NewReader(strings.NewReader(c.input), zson.NewContext()) + zr := zson.NewReader(strings.NewReader(c.input), zed.NewContext()) rec, err := zr.Read() assert.NoError(t, err) require.NotNil(t, rec) diff --git a/service/client_test.go b/service/client_test.go index 8298758efd..6f09374841 100644 --- a/service/client_test.go +++ b/service/client_test.go @@ -6,6 +6,7 @@ import ( "io" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/api" "github.com/brimdata/zed/api/client" "github.com/brimdata/zed/lake" @@ -60,7 +61,7 @@ func (c *testClient) TestBranchGet(id ksuid.KSUID) (config lake.BranchMeta) { func (c *testClient) zioreader(r *client.Response) zio.Reader { format, err := api.MediaTypeToFormat(r.ContentType) require.NoError(c, err) - zr, err := anyio.NewReaderWithOpts(r.Body, zson.NewContext(), anyio.ReaderOpts{Format: format}) + zr, err := anyio.NewReaderWithOpts(r.Body, zed.NewContext(), anyio.ReaderOpts{Format: format}) require.NoError(c, err) return zr } diff --git a/service/handlers.go b/service/handlers.go index 98d97cd424..5b394b627a 100644 --- a/service/handlers.go +++ b/service/handlers.go @@ -4,6 +4,7 @@ import ( "errors" "net/http" + "github.com/brimdata/zed" "github.com/brimdata/zed/api" "github.com/brimdata/zed/api/queryio" "github.com/brimdata/zed/compiler" @@ -18,7 +19,6 @@ import ( "github.com/brimdata/zed/zio/anyio" "github.com/brimdata/zed/zio/jsonio" "github.com/brimdata/zed/zqe" - "github.com/brimdata/zed/zson" "go.uber.org/zap" ) @@ -49,7 +49,7 @@ func handleQuery(c *Core, w *ResponseWriter, r *Request) { w.Error(err) } defer d.Close() - err = driver.RunWithLakeAndStats(r.Context(), d, query, zson.NewContext(), c.root, &req.Head, nil, r.Logger, 0) + err = driver.RunWithLakeAndStats(r.Context(), d, query, zed.NewContext(), c.root, &req.Head, nil, r.Logger, 0) if err != nil && !errors.Is(err, journal.ErrEmpty) { d.Error(err) } @@ -361,7 +361,7 @@ func handleBranchLoad(c *Core, w *ResponseWriter, r *Request) { // Force validation of ZNG when initialing loading into the lake. var opts anyio.ReaderOpts opts.Zng.Validate = true - zr, err := anyio.NewReaderWithOpts(anyio.GzipReader(r.Body), zson.NewContext(), opts) + zr, err := anyio.NewReaderWithOpts(anyio.GzipReader(r.Body), zed.NewContext(), opts) if err != nil { w.Error(err) return diff --git a/typetype_test.go b/typetype_test.go index 233e7d6147..42e78bdaba 100644 --- a/typetype_test.go +++ b/typetype_test.go @@ -10,8 +10,8 @@ import ( func TestTypeValue(t *testing.T) { const s = "{A:{B:int64},C:int32}" - zctx := zson.NewContext() - typ, err := zson.ParseType(zson.NewContext(), s) + zctx := zed.NewContext() + typ, err := zson.ParseType(zed.NewContext(), s) require.NoError(t, err) tv := zctx.LookupTypeValue(typ) require.Exactly(t, s, zed.FormatTypeValue(tv.Bytes)) @@ -19,8 +19,8 @@ func TestTypeValue(t *testing.T) { func TestTypeValueCrossContext(t *testing.T) { const s = "{A:{B:int64},C:int32}" - typ, err := zson.ParseType(zson.NewContext(), s) + typ, err := zson.ParseType(zed.NewContext(), s) require.NoError(t, err) - tv := zson.NewContext().LookupTypeValue(typ) + tv := zed.NewContext().LookupTypeValue(typ) require.Exactly(t, s, zed.FormatTypeValue(tv.Bytes)) } diff --git a/zed_test.go b/zed_test.go index a38529a1d5..a05c31ca62 100644 --- a/zed_test.go +++ b/zed_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio/anyio" "github.com/brimdata/zed/zio/parquetio" - "github.com/brimdata/zed/zson" "github.com/brimdata/zed/ztest" "github.com/stretchr/testify/require" ) @@ -125,7 +125,7 @@ func expectFailure(b ztest.Bundle) bool { } func isValidForZson(input string) bool { - r, err := anyio.NewReader(strings.NewReader(input), zson.NewContext()) + r, err := anyio.NewReader(strings.NewReader(input), zed.NewContext()) if err != nil { return false } @@ -179,7 +179,7 @@ diff baseline.parquet boomerang.parquet } func isValidForParquet(input string) bool { - r, err := anyio.NewReader(strings.NewReader(input), zson.NewContext()) + r, err := anyio.NewReader(strings.NewReader(input), zed.NewContext()) if err != nil { return false } diff --git a/zio/anyio/fifo_test.go b/zio/anyio/fifo_test.go index 47a536fff6..ab153fb811 100644 --- a/zio/anyio/fifo_test.go +++ b/zio/anyio/fifo_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" - "github.com/brimdata/zed/zson" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -22,7 +22,7 @@ func TestOpenFifoCancelation(t *testing.T) { errCh := make(chan error) ctx, cancel := context.WithCancel(context.Background()) go func() { - _, err := Open(ctx, zson.NewContext(), storage.NewFileSystem(), path, ReaderOpts{}) + _, err := Open(ctx, zed.NewContext(), storage.NewFileSystem(), path, ReaderOpts{}) errCh <- err }() time.Sleep(10 * time.Millisecond) diff --git a/zio/anyio/file.go b/zio/anyio/file.go index e37a9c251d..7dd24a517d 100644 --- a/zio/anyio/file.go +++ b/zio/anyio/file.go @@ -4,15 +4,15 @@ import ( "context" "io" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zbuf" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) // Open uses engine to open path for reading. path is a local file path or a // URI whose scheme is understood by engine. -func Open(ctx context.Context, zctx *zson.Context, engine storage.Engine, path string, opts ReaderOpts) (*zbuf.File, error) { +func Open(ctx context.Context, zctx *zed.Context, engine storage.Engine, path string, opts ReaderOpts) (*zbuf.File, error) { uri, err := storage.ParseURI(path) if err != nil { return nil, err @@ -41,7 +41,7 @@ func Open(ctx context.Context, zctx *zson.Context, engine storage.Engine, path s } } -func NewFile(zctx *zson.Context, rc io.ReadCloser, path string, opts ReaderOpts) (*zbuf.File, error) { +func NewFile(zctx *zed.Context, rc io.ReadCloser, path string, opts ReaderOpts) (*zbuf.File, error) { var err error r := io.Reader(rc) if opts.Format != "parquet" && opts.Format != "zst" { diff --git a/zio/anyio/lookup.go b/zio/anyio/lookup.go index 77a8826f88..1eff193158 100644 --- a/zio/anyio/lookup.go +++ b/zio/anyio/lookup.go @@ -4,6 +4,7 @@ import ( "fmt" "io" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/csvio" "github.com/brimdata/zed/zio/jsonio" @@ -16,7 +17,7 @@ import ( "github.com/brimdata/zed/zson" ) -func lookupReader(r io.Reader, zctx *zson.Context, opts ReaderOpts) (zio.Reader, error) { +func lookupReader(r io.Reader, zctx *zed.Context, opts ReaderOpts) (zio.Reader, error) { switch opts.Format { case "csv": return csvio.NewReader(r, zctx), nil diff --git a/zio/anyio/reader.go b/zio/anyio/reader.go index d52f7569fa..b22d7f0b6a 100644 --- a/zio/anyio/reader.go +++ b/zio/anyio/reader.go @@ -6,6 +6,7 @@ import ( "io" "github.com/aws/aws-sdk-go/aws" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/jsonio" "github.com/brimdata/zed/zio/tzngio" @@ -22,20 +23,20 @@ type ReaderOpts struct { AwsCfg *aws.Config } -func NewReaderWithOpts(r io.Reader, zctx *zson.Context, opts ReaderOpts) (zio.Reader, error) { +func NewReaderWithOpts(r io.Reader, zctx *zed.Context, opts ReaderOpts) (zio.Reader, error) { if opts.Format != "" && opts.Format != "auto" { return lookupReader(r, zctx, opts) } recorder := NewRecorder(r) track := NewTrack(recorder) - tzngErr := match(tzngio.NewReader(track, zson.NewContext()), "tzng") + tzngErr := match(tzngio.NewReader(track, zed.NewContext()), "tzng") if tzngErr == nil { return tzngio.NewReader(recorder, zctx), nil } track.Reset() - zr, err := zeekio.NewReader(track, zson.NewContext()) + zr, err := zeekio.NewReader(track, zed.NewContext()) if err != nil { return nil, err } @@ -46,13 +47,13 @@ func NewReaderWithOpts(r io.Reader, zctx *zson.Context, opts ReaderOpts) (zio.Re track.Reset() // ZJSON must come before ZSON since ZJSON is a subset of ZSON - zjsonErr := match(zjsonio.NewReader(track, zson.NewContext()), "zjson") + zjsonErr := match(zjsonio.NewReader(track, zed.NewContext()), "zjson") if zjsonErr == nil { return zjsonio.NewReader(recorder, zctx), nil } track.Reset() - zsonErr := match(zson.NewReader(track, zson.NewContext()), "zson") + zsonErr := match(zson.NewReader(track, zed.NewContext()), "zson") if zsonErr == nil { return zson.NewReader(recorder, zctx), nil } @@ -61,7 +62,7 @@ func NewReaderWithOpts(r io.Reader, zctx *zson.Context, opts ReaderOpts) (zio.Re // JSON comes after ZSON because we want the ZSON reader to handle // top-level JSON objects and the JSON reader to handle top-level // JSON arrays. - jsonErr := match(jsonio.NewReader(track, zson.NewContext()), "json") + jsonErr := match(jsonio.NewReader(track, zed.NewContext()), "json") if jsonErr == nil { return jsonio.NewReader(recorder, zctx), nil } @@ -72,7 +73,7 @@ func NewReaderWithOpts(r io.Reader, zctx *zson.Context, opts ReaderOpts) (zio.Re // validation to the user setting in the actual reader returned. zngOpts := opts.Zng zngOpts.Validate = true - zngErr := match(zngio.NewReaderWithOpts(track, zson.NewContext(), zngOpts), "zng") + zngErr := match(zngio.NewReaderWithOpts(track, zed.NewContext(), zngOpts), "zng") if zngErr == nil { return zngio.NewReaderWithOpts(recorder, zctx, opts.Zng), nil } @@ -80,7 +81,7 @@ func NewReaderWithOpts(r io.Reader, zctx *zson.Context, opts ReaderOpts) (zio.Re // XXX This is a placeholder until we add a flag to the csv reader // for "strict" mode. See issue #2316. - //csvErr := match(csvio.NewReader(track, zson.NewContext()), "csv") + //csvErr := match(csvio.NewReader(track, zed.NewContext()), "csv") //if csvErr == nil { // return csvio.NewReader(recorder, Context), nil //} @@ -92,7 +93,7 @@ func NewReaderWithOpts(r io.Reader, zctx *zson.Context, opts ReaderOpts) (zio.Re return nil, joinErrs([]error{tzngErr, zeekErr, zjsonErr, zsonErr, zngErr, csvErr, jsonErr, parquetErr, zstErr}) } -func NewReader(r io.Reader, zctx *zson.Context) (zio.Reader, error) { +func NewReader(r io.Reader, zctx *zed.Context) (zio.Reader, error) { return NewReaderWithOpts(r, zctx, ReaderOpts{}) } diff --git a/zio/counter_test.go b/zio/counter_test.go index edd65669a5..d659a4432e 100644 --- a/zio/counter_test.go +++ b/zio/counter_test.go @@ -32,7 +32,7 @@ func TestCounter(t *testing.T) { wg.Add(2) go func() { for i := 0; i < 22; i++ { - stream := zson.NewReader(strings.NewReader(input), zson.NewContext()) + stream := zson.NewReader(strings.NewReader(input), zed.NewContext()) counter := NewCounter(stream, &count) require.NoError(t, Copy(&sink, counter)) } @@ -40,7 +40,7 @@ func TestCounter(t *testing.T) { }() go func() { for i := 0; i < 17; i++ { - stream := zson.NewReader(strings.NewReader(input), zson.NewContext()) + stream := zson.NewReader(strings.NewReader(input), zed.NewContext()) counter := NewCounter(stream, &count) require.NoError(t, Copy(&sink, counter)) } diff --git a/zio/csvio/reader.go b/zio/csvio/reader.go index 84245ce7f9..f304f40174 100644 --- a/zio/csvio/reader.go +++ b/zio/csvio/reader.go @@ -28,7 +28,7 @@ type Reader struct { // StringsOnly bool //} -func NewReader(r io.Reader, zctx *zson.Context) *Reader { +func NewReader(r io.Reader, zctx *zed.Context) *Reader { preprocess := newPreprocess(r) reader := csv.NewReader(preprocess) reader.ReuseRecord = true diff --git a/zio/csvio/reader_test.go b/zio/csvio/reader_test.go index adb0a29dfe..db8fe8ffbc 100644 --- a/zio/csvio/reader_test.go +++ b/zio/csvio/reader_test.go @@ -4,12 +4,12 @@ import ( "strings" "testing" - "github.com/brimdata/zed/zson" + "github.com/brimdata/zed" "github.com/stretchr/testify/require" ) func TestNewReaderUsesContextParameter(t *testing.T) { - zctx := zson.NewContext() + zctx := zed.NewContext() rec, err := NewReader(strings.NewReader("f\n1\n"), zctx).Read() require.NoError(t, err) typ, err := zctx.LookupType(rec.Type.ID()) diff --git a/zio/csvio/writer.go b/zio/csvio/writer.go index 40ed317aca..2e49cfc7e2 100644 --- a/zio/csvio/writer.go +++ b/zio/csvio/writer.go @@ -9,7 +9,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" ) var ErrNotDataFrame = errors.New("CSV output requires uniform records but multiple types encountered (consider 'fuse')") @@ -34,7 +33,7 @@ func NewWriter(w io.WriteCloser, opts WriterOpts) *Writer { return &Writer{ writer: w, encoder: csv.NewWriter(w), - flattener: expr.NewFlattener(zson.NewContext()), + flattener: expr.NewFlattener(zed.NewContext()), format: format, } } diff --git a/zio/emitter/dir_test.go b/zio/emitter/dir_test.go index bdb5663ea8..8b92bb80d8 100644 --- a/zio/emitter/dir_test.go +++ b/zio/emitter/dir_test.go @@ -7,6 +7,7 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" storagemock "github.com/brimdata/zed/pkg/storage/mock" "github.com/brimdata/zed/zio" @@ -33,7 +34,7 @@ func TestDirS3Source(t *testing.T) { engine.EXPECT().Put(context.Background(), uri.AppendPath("http.zson")). Return(&nopCloser{bytes.NewBuffer(nil)}, nil) - r := zson.NewReader(strings.NewReader(input), zson.NewContext()) + r := zson.NewReader(strings.NewReader(input), zed.NewContext()) require.NoError(t, err) w, err := NewDirWithEngine(context.Background(), engine, uri, "", os.Stderr, anyio.WriterOpts{Format: "zson"}) require.NoError(t, err) diff --git a/zio/jsonio/reader.go b/zio/jsonio/reader.go index a43ed293d4..8646b2b84c 100644 --- a/zio/jsonio/reader.go +++ b/zio/jsonio/reader.go @@ -10,11 +10,11 @@ import ( ) type Reader struct { - zctx *zson.Context + zctx *zed.Context decoder *json.Decoder } -func NewReader(r io.Reader, zctx *zson.Context) *Reader { +func NewReader(r io.Reader, zctx *zed.Context) *Reader { d := json.NewDecoder(r) // Prime d's buffer so we can check for an array. d.More() diff --git a/zio/mapper.go b/zio/mapper.go index 716c54960e..7f236d1bd5 100644 --- a/zio/mapper.go +++ b/zio/mapper.go @@ -2,7 +2,6 @@ package zio import ( "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" ) type Mapper struct { @@ -10,7 +9,7 @@ type Mapper struct { mapper *zed.Mapper } -func NewMapper(reader Reader, zctx *zson.Context) *Mapper { +func NewMapper(reader Reader, zctx *zed.Context) *Mapper { return &Mapper{ Reader: reader, mapper: zed.NewMapper(zctx), diff --git a/zio/ndjsonio/ndjson_test.go b/zio/ndjsonio/ndjson_test.go index f3487bfefb..85cd173d2a 100644 --- a/zio/ndjsonio/ndjson_test.go +++ b/zio/ndjsonio/ndjson_test.go @@ -7,6 +7,7 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zson" "github.com/stretchr/testify/require" @@ -57,7 +58,7 @@ func TestNDJSONWriter(t *testing.T) { t.Run(c.name, func(t *testing.T) { var out bytes.Buffer w := NewWriter(NopCloser(&out)) - r := zson.NewReader(strings.NewReader(c.input), zson.NewContext()) + r := zson.NewReader(strings.NewReader(c.input), zed.NewContext()) require.NoError(t, zio.Copy(w, r)) NDJSONEq(t, c.output, out.String()) }) diff --git a/zio/parquetio/reader.go b/zio/parquetio/reader.go index 99c76f8981..96a4fd270b 100644 --- a/zio/parquetio/reader.go +++ b/zio/parquetio/reader.go @@ -5,7 +5,6 @@ import ( "io" "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" goparquet "github.com/fraugster/parquet-go" ) @@ -16,7 +15,7 @@ type Reader struct { builder builder } -func NewReader(r io.Reader, zctx *zson.Context) (*Reader, error) { +func NewReader(r io.Reader, zctx *zed.Context) (*Reader, error) { rs, ok := r.(io.ReadSeeker) if !ok { return nil, errors.New("reader cannot seek") diff --git a/zio/parquetio/type.go b/zio/parquetio/type.go index 0114fa0160..2c4f79c606 100644 --- a/zio/parquetio/type.go +++ b/zio/parquetio/type.go @@ -5,12 +5,11 @@ import ( "fmt" "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" "github.com/fraugster/parquet-go/parquet" "github.com/fraugster/parquet-go/parquetschema" ) -func newRecordType(zctx *zson.Context, children []*parquetschema.ColumnDefinition) (*zed.TypeRecord, error) { +func newRecordType(zctx *zed.Context, children []*parquetschema.ColumnDefinition) (*zed.TypeRecord, error) { var cols []zed.Column for _, c := range children { typ, err := newType(zctx, c) @@ -25,7 +24,7 @@ func newRecordType(zctx *zson.Context, children []*parquetschema.ColumnDefinitio return zctx.LookupTypeRecord(cols) } -func newType(zctx *zson.Context, cd *parquetschema.ColumnDefinition) (zed.Type, error) { +func newType(zctx *zed.Context, cd *parquetschema.ColumnDefinition) (zed.Type, error) { se := cd.SchemaElement if se.Type != nil { return newPrimitiveType(zctx, se) @@ -55,7 +54,7 @@ func newType(zctx *zson.Context, cd *parquetschema.ColumnDefinition) (zed.Type, } -func newPrimitiveType(zctx *zson.Context, s *parquet.SchemaElement) (zed.Type, error) { +func newPrimitiveType(zctx *zed.Context, s *parquet.SchemaElement) (zed.Type, error) { if s.IsSetLogicalType() && s.LogicalType.IsSetDECIMAL() || s.GetConvertedType() == parquet.ConvertedType_DECIMAL { return nil, errors.New("DECIMAL type is unimplemented") diff --git a/zio/peeker_test.go b/zio/peeker_test.go index 84ad9e86a6..7e11e5f42b 100644 --- a/zio/peeker_test.go +++ b/zio/peeker_test.go @@ -5,6 +5,7 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/zson" ) @@ -17,7 +18,7 @@ func TestPeeker(t *testing.T) { {key:"key5",value:"value5"} {key:"key6",value:"value6"} ` - stream := zson.NewReader(strings.NewReader(input), zson.NewContext()) + stream := zson.NewReader(strings.NewReader(input), zed.NewContext()) peeker := NewPeeker(stream) rec1, err := peeker.Peek() if err != nil { diff --git a/zio/tableio/writer.go b/zio/tableio/writer.go index 0877c205e9..71c49f6174 100644 --- a/zio/tableio/writer.go +++ b/zio/tableio/writer.go @@ -10,7 +10,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" ) type Writer struct { @@ -31,7 +30,7 @@ func NewWriter(w io.WriteCloser, utf8 bool) *Writer { } return &Writer{ writer: w, - flattener: expr.NewFlattener(zson.NewContext()), + flattener: expr.NewFlattener(zed.NewContext()), table: table, limit: 1000, format: format, diff --git a/zio/textio/writer.go b/zio/textio/writer.go index 2a70eaf4bf..91174b3732 100644 --- a/zio/textio/writer.go +++ b/zio/textio/writer.go @@ -9,7 +9,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" ) type Writer struct { @@ -32,7 +31,7 @@ func NewWriter(w io.WriteCloser, utf8 bool, opts WriterOpts) *Writer { return &Writer{ WriterOpts: opts, writer: w, - flattener: expr.NewFlattener(zson.NewContext()), + flattener: expr.NewFlattener(zed.NewContext()), format: format, } } diff --git a/zio/tzngio/format_test.go b/zio/tzngio/format_test.go index eec7e21e47..6619b2a168 100644 --- a/zio/tzngio/format_test.go +++ b/zio/tzngio/format_test.go @@ -6,7 +6,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" "github.com/stretchr/testify/assert" ) @@ -19,7 +18,7 @@ func makeContainer(vals ...[]byte) zcode.Bytes { } func TestFormatting(t *testing.T) { - zctx := zson.NewContext() + zctx := zed.NewContext() bstringSetType := zctx.LookupTypeSet(zed.TypeBstring) bstringVecType := zctx.LookupTypeArray(zed.TypeBstring) setOfVectorsType := zctx.LookupTypeSet(bstringVecType) diff --git a/zio/tzngio/reader.go b/zio/tzngio/reader.go index 6c365b00c8..a584406fd9 100644 --- a/zio/tzngio/reader.go +++ b/zio/tzngio/reader.go @@ -10,7 +10,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/skim" - "github.com/brimdata/zed/zson" ) var ( @@ -43,13 +42,13 @@ type ReadStats struct { type Reader struct { scanner *skim.Scanner stats ReadStats - zctx *zson.Context + zctx *zed.Context mapper map[string]zed.Type parser *Parser types *TypeParser } -func NewReader(reader io.Reader, zctx *zson.Context) *Reader { +func NewReader(reader io.Reader, zctx *zed.Context) *Reader { buffer := make([]byte, ReadSize) scanner := skim.NewScanner(reader, buffer, MaxLineSize) return &Reader{ diff --git a/zio/tzngio/reader_test.go b/zio/tzngio/reader_test.go index f27bbc886f..5f17f32686 100644 --- a/zio/tzngio/reader_test.go +++ b/zio/tzngio/reader_test.go @@ -6,9 +6,9 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -25,7 +25,7 @@ func TestCtrl(t *testing.T) { // this tests reading of control via text zng, // then writing of raw control, and reading back the result in := []byte(strings.TrimSpace(ctrl) + "\n") - r := tzngio.NewReader(bytes.NewReader(in), zson.NewContext()) + r := tzngio.NewReader(bytes.NewReader(in), zed.NewContext()) _, body, err := r.ReadPayload() assert.NoError(t, err) @@ -61,7 +61,7 @@ func TestDescriptors(t *testing.T) { // Step 4 - Test that referencing an invalid descriptor is an error. src += "100:[something;somethingelse;]\n" - r := tzngio.NewReader(strings.NewReader(src), zson.NewContext()) + r := tzngio.NewReader(strings.NewReader(src), zed.NewContext()) // Check Step 1 record, err := r.Read() @@ -108,13 +108,13 @@ func TestDescriptors(t *testing.T) { } for _, z := range zngs { - r := tzngio.NewReader(strings.NewReader(z), zson.NewContext()) + r := tzngio.NewReader(strings.NewReader(z), zed.NewContext()) _, err = r.Read() assert.Error(t, err, "tzng parse error", "invalid tzng") } // Descriptor with an invalid type is rejected - r = tzngio.NewReader(strings.NewReader("#4:notatype\n"), zson.NewContext()) + r = tzngio.NewReader(strings.NewReader("#4:notatype\n"), zed.NewContext()) _, err = r.Read() assert.Error(t, err, "unknown type", "descriptor with invalid type") } @@ -123,21 +123,21 @@ func TestSyntax(t *testing.T) { const bad1 = ` #0:record[_path:string,ts:time,uid:string,resp_ip_bytes:count,tunnel_parents:set[string]] 0:[conn;1425565514.419939;CogZFI3py5JsFZGik;0;]` - r := tzngio.NewReader(strings.NewReader(bad1), zson.NewContext()) + r := tzngio.NewReader(strings.NewReader(bad1), zed.NewContext()) _, err := r.Read() require.Error(t, err, "bad1 must have error") const bad2 = ` #0:record[a:string,record[b:string]] 0:[foo;[bar;]]` - r = tzngio.NewReader(strings.NewReader(bad2), zson.NewContext()) + r = tzngio.NewReader(strings.NewReader(bad2), zed.NewContext()) _, err = r.Read() require.Error(t, err, "bad2 must have error") const bad3 = ` #0:record[_path:string,ts:time,uid:string,resp_ip_bytes:count,tunnel_parents:set[string]] 0:[conn;1425565514.419939;CogZFI3py5JsFZGik;0;0;[]]` - r = tzngio.NewReader(strings.NewReader(bad3), zson.NewContext()) + r = tzngio.NewReader(strings.NewReader(bad3), zed.NewContext()) _, err = r.Read() require.Error(t, err, "bad3 must have error") @@ -211,7 +211,7 @@ func (o *output) Close() error { return nil } func boomerangErr(t *testing.T, name, logs, errorMsg string, errorArgs ...interface{}) { t.Run(name, func(t *testing.T) { in := []byte(strings.TrimSpace(logs) + "\n") - zngSrc := tzngio.NewReader(bytes.NewReader(in), zson.NewContext()) + zngSrc := tzngio.NewReader(bytes.NewReader(in), zed.NewContext()) zngDst := tzngio.NewWriter(&output{}) err := zio.Copy(zngDst, zngSrc) assert.Errorf(t, err, errorMsg, errorArgs...) @@ -223,7 +223,7 @@ func boomerang(t *testing.T, name, logs string) { t.Run(name, func(t *testing.T) { var out output in := []byte(strings.TrimSpace(logs) + "\n") - zngSrc := tzngio.NewReader(bytes.NewReader(in), zson.NewContext()) + zngSrc := tzngio.NewReader(bytes.NewReader(in), zed.NewContext()) zngDst := tzngio.NewWriter(&out) err := zio.Copy(zngDst, zngSrc) require.NoError(t, err) diff --git a/zio/tzngio/typeparser.go b/zio/tzngio/typeparser.go index 6fea6876bc..4860d10477 100644 --- a/zio/tzngio/typeparser.go +++ b/zio/tzngio/typeparser.go @@ -6,16 +6,15 @@ import ( "strings" "github.com/brimdata/zed" - "github.com/brimdata/zed/zson" ) var ErrEmptyTypeList = errors.New("empty type list in set or union") type TypeParser struct { - zctx *zson.Context + zctx *zed.Context } -func NewTypeParser(zctx *zson.Context) *TypeParser { +func NewTypeParser(zctx *zed.Context) *TypeParser { return &TypeParser{ zctx: zctx, } diff --git a/zio/tzngio/tzngio_test.go b/zio/tzngio/tzngio_test.go index 958d5ee270..e2997a9057 100644 --- a/zio/tzngio/tzngio_test.go +++ b/zio/tzngio/tzngio_test.go @@ -5,9 +5,9 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" "github.com/stretchr/testify/assert" ) @@ -67,7 +67,7 @@ func identity(t *testing.T, logs string) { var out bytes.Buffer dst := tzngio.NewWriter(zio.NopCloser(&out)) in := strings.TrimSpace(logs) + "\n" - src := tzngio.NewReader(strings.NewReader(in), zson.NewContext()) + src := tzngio.NewReader(strings.NewReader(in), zed.NewContext()) err := zio.Copy(dst, src) if assert.NoError(t, err) { assert.Equal(t, in, out.String()) diff --git a/zio/zeekio/parser.go b/zio/zeekio/parser.go index 486425c068..c059f7bc22 100644 --- a/zio/zeekio/parser.go +++ b/zio/zeekio/parser.go @@ -7,7 +7,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" ) type header struct { @@ -23,7 +22,7 @@ type header struct { type Parser struct { header - zctx *zson.Context + zctx *zed.Context types *tzngio.TypeParser unknown int // Count of unknown directives needfields bool @@ -41,7 +40,7 @@ var ( ErrBadEscape = errors.New("bad escape sequence") //XXX ) -func NewParser(r *zson.Context) *Parser { +func NewParser(r *zed.Context) *Parser { return &Parser{ header: header{separator: " "}, zctx: r, @@ -170,7 +169,7 @@ func (p *Parser) ParseDirective(line []byte) error { // bool indicating if a _path column was added. // Note that according to the zng spec, all the fields for a nested // record must be adjacent which simplifies the logic here. -func Unflatten(zctx *zson.Context, columns []zed.Column, addPath bool) ([]zed.Column, bool, error) { +func Unflatten(zctx *zed.Context, columns []zed.Column, addPath bool) ([]zed.Column, bool, error) { hasPath := false for _, col := range columns { // XXX could validate field names here... @@ -192,7 +191,7 @@ func Unflatten(zctx *zson.Context, columns []zed.Column, addPath bool) ([]zed.Co return out, needpath, nil } -func unflattenRecord(zctx *zson.Context, cols []zed.Column) ([]zed.Column, error) { +func unflattenRecord(zctx *zed.Context, cols []zed.Column) ([]zed.Column, error) { // extract a []Column consisting of all the leading columns // from the input that belong to the same record, with the // common prefix removed from their name. diff --git a/zio/zeekio/parser_test.go b/zio/zeekio/parser_test.go index eb50fcdd92..d19fe94beb 100644 --- a/zio/zeekio/parser_test.go +++ b/zio/zeekio/parser_test.go @@ -7,7 +7,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/nano" - "github.com/brimdata/zed/zson" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -34,7 +33,7 @@ func makeHeader(name string, rest []string) string { // directives, expecting them to all be parsed successfully. // A parser object ready for further testing is returned. func startTest(t *testing.T, headers []string) *Parser { - p := NewParser(zson.NewContext()) + p := NewParser(zed.NewContext()) for _, h := range headers { require.NoError(t, p.ParseDirective([]byte(h))) } diff --git a/zio/zeekio/reader.go b/zio/zeekio/reader.go index 3939a80c98..2c4a07f274 100644 --- a/zio/zeekio/reader.go +++ b/zio/zeekio/reader.go @@ -7,7 +7,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/skim" - "github.com/brimdata/zed/zson" ) const ( @@ -20,7 +19,7 @@ type Reader struct { parser *Parser } -func NewReader(reader io.Reader, zctx *zson.Context) (*Reader, error) { +func NewReader(reader io.Reader, zctx *zed.Context) (*Reader, error) { _, err := zctx.LookupTypeAlias("zenum", zed.TypeString) if err != nil { return nil, err diff --git a/zio/zeekio/reader_test.go b/zio/zeekio/reader_test.go index 52573095a7..29f5cea96d 100644 --- a/zio/zeekio/reader_test.go +++ b/zio/zeekio/reader_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/nano" - "github.com/brimdata/zed/zson" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -23,7 +23,7 @@ func TestReaderCRLF(t *testing.T) { 10.000000 1 ` input = strings.ReplaceAll(input, "\n", "\r\n") - r, err := NewReader(strings.NewReader(input), zson.NewContext()) + r, err := NewReader(strings.NewReader(input), zed.NewContext()) require.NoError(t, err) rec, err := r.Read() require.NoError(t, err) diff --git a/zio/zeekio/writer.go b/zio/zeekio/writer.go index a906d558d9..c0ef2af92d 100644 --- a/zio/zeekio/writer.go +++ b/zio/zeekio/writer.go @@ -10,7 +10,6 @@ import ( "github.com/brimdata/zed/expr" "github.com/brimdata/zed/pkg/nano" "github.com/brimdata/zed/zio/tzngio" - "github.com/brimdata/zed/zson" ) var ErrDescriptorChanged = errors.New("descriptor changed") @@ -32,7 +31,7 @@ func NewWriter(w io.WriteCloser, utf8 bool) *Writer { } return &Writer{ writer: w, - flattener: expr.NewFlattener(zson.NewContext()), + flattener: expr.NewFlattener(zed.NewContext()), format: format, } } diff --git a/zio/zjsonio/reader.go b/zio/zjsonio/reader.go index 16e5b20797..1d804c741a 100644 --- a/zio/zjsonio/reader.go +++ b/zio/zjsonio/reader.go @@ -18,12 +18,12 @@ const ( type Reader struct { scanner *skim.Scanner - zctx *zson.Context + zctx *zed.Context decoder decoder builder *zcode.Builder } -func NewReader(reader io.Reader, zctx *zson.Context) *Reader { +func NewReader(reader io.Reader, zctx *zed.Context) *Reader { buffer := make([]byte, ReadSize) return &Reader{ scanner: skim.NewScanner(reader, buffer, MaxLineSize), diff --git a/zio/zjsonio/stream.go b/zio/zjsonio/stream.go index 5c464e51ec..e06217d82f 100644 --- a/zio/zjsonio/stream.go +++ b/zio/zjsonio/stream.go @@ -7,18 +7,17 @@ import ( "github.com/brimdata/zed" astzed "github.com/brimdata/zed/compiler/ast/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type Stream struct { - zctx *zson.Context + zctx *zed.Context encoder encoder typetype map[zed.Type]bool } func NewStream() *Stream { return &Stream{ - zctx: zson.NewContext(), + zctx: zed.NewContext(), encoder: make(encoder), typetype: make(map[zed.Type]bool), } diff --git a/zio/zjsonio/types.go b/zio/zjsonio/types.go index dfa7e02a0f..a513172a5b 100644 --- a/zio/zjsonio/types.go +++ b/zio/zjsonio/types.go @@ -6,12 +6,11 @@ import ( "github.com/brimdata/zed" astzed "github.com/brimdata/zed/compiler/ast/zed" - "github.com/brimdata/zed/zson" ) type encoder map[zed.Type]string -func (e encoder) encodeType(zctx *zson.Context, typ zed.Type) astzed.Type { +func (e encoder) encodeType(zctx *zed.Context, typ zed.Type) astzed.Type { if name, ok := e[typ]; ok { return &astzed.TypeName{ Kind: "typename", @@ -58,7 +57,7 @@ func (e encoder) encodeType(zctx *zson.Context, typ zed.Type) astzed.Type { } } -func (e encoder) encodeTypeRecord(zctx *zson.Context, typ *zed.TypeRecord) *astzed.TypeRecord { +func (e encoder) encodeTypeRecord(zctx *zed.Context, typ *zed.TypeRecord) *astzed.TypeRecord { var fields []astzed.TypeField for _, c := range typ.Columns { typ := e.encodeType(zctx, c.Type) @@ -70,11 +69,11 @@ func (e encoder) encodeTypeRecord(zctx *zson.Context, typ *zed.TypeRecord) *astz } } -func (e encoder) encodeTypeEnum(zctx *zson.Context, typ *zed.TypeEnum) *astzed.TypeEnum { +func (e encoder) encodeTypeEnum(zctx *zed.Context, typ *zed.TypeEnum) *astzed.TypeEnum { panic("issue 2508") } -func (e encoder) encodeTypeUnion(zctx *zson.Context, union *zed.TypeUnion) *astzed.TypeUnion { +func (e encoder) encodeTypeUnion(zctx *zed.Context, union *zed.TypeUnion) *astzed.TypeUnion { var types []astzed.Type for _, t := range union.Types { types = append(types, e.encodeType(zctx, t)) @@ -87,7 +86,7 @@ func (e encoder) encodeTypeUnion(zctx *zson.Context, union *zed.TypeUnion) *astz type decoder map[string]zed.Type -func (d decoder) decodeType(zctx *zson.Context, typ astzed.Type) (zed.Type, error) { +func (d decoder) decodeType(zctx *zed.Context, typ astzed.Type) (zed.Type, error) { switch typ := typ.(type) { case *astzed.TypeRecord: return d.decodeTypeRecord(zctx, typ) @@ -135,7 +134,7 @@ func (d decoder) decodeType(zctx *zson.Context, typ astzed.Type) (zed.Type, erro return nil, fmt.Errorf("ZJSON unknown type: %T", typ) } -func (d decoder) decodeTypeRecord(zctx *zson.Context, typ *astzed.TypeRecord) (*zed.TypeRecord, error) { +func (d decoder) decodeTypeRecord(zctx *zed.Context, typ *astzed.TypeRecord) (*zed.TypeRecord, error) { columns := make([]zed.Column, 0, len(typ.Fields)) for _, field := range typ.Fields { typ, err := d.decodeType(zctx, field.Type) @@ -151,7 +150,7 @@ func (d decoder) decodeTypeRecord(zctx *zson.Context, typ *astzed.TypeRecord) (* return zctx.LookupTypeRecord(columns) } -func (d decoder) decodeTypeUnion(zctx *zson.Context, union *astzed.TypeUnion) (*zed.TypeUnion, error) { +func (d decoder) decodeTypeUnion(zctx *zed.Context, union *astzed.TypeUnion) (*zed.TypeUnion, error) { var types []zed.Type for _, t := range union.Types { typ, err := d.decodeType(zctx, t) @@ -163,7 +162,7 @@ func (d decoder) decodeTypeUnion(zctx *zson.Context, union *astzed.TypeUnion) (* return zctx.LookupTypeUnion(types), nil } -func (d decoder) decodeTypeMap(zctx *zson.Context, m *astzed.TypeMap) (*zed.TypeMap, error) { +func (d decoder) decodeTypeMap(zctx *zed.Context, m *astzed.TypeMap) (*zed.TypeMap, error) { keyType, err := d.decodeType(zctx, m.KeyType) if err != nil { return nil, err @@ -175,6 +174,6 @@ func (d decoder) decodeTypeMap(zctx *zson.Context, m *astzed.TypeMap) (*zed.Type return zctx.LookupTypeMap(keyType, valType), nil } -func (d decoder) decodeTypeEnum(zctx *zson.Context, enum *astzed.TypeEnum) (*zed.TypeEnum, error) { +func (d decoder) decodeTypeEnum(zctx *zed.Context, enum *astzed.TypeEnum) (*zed.TypeEnum, error) { return nil, errors.New("TBD: issue #2508") } diff --git a/zio/zjsonio/values.go b/zio/zjsonio/values.go index 9d95ba634c..8fa2109674 100644 --- a/zio/zjsonio/values.go +++ b/zio/zjsonio/values.go @@ -10,7 +10,7 @@ import ( "github.com/brimdata/zed/zson" ) -func encodeUnion(zctx *zson.Context, union *zed.TypeUnion, bytes zcode.Bytes) (interface{}, error) { +func encodeUnion(zctx *zed.Context, union *zed.TypeUnion, bytes zcode.Bytes) (interface{}, error) { // encode nil val as JSON null since // zed.Escape() returns "" for nil if bytes == nil { @@ -27,7 +27,7 @@ func encodeUnion(zctx *zson.Context, union *zed.TypeUnion, bytes zcode.Bytes) (i return []interface{}{strconv.Itoa(int(selector)), val}, nil } -func encodeMap(zctx *zson.Context, typ *zed.TypeMap, v zcode.Bytes) (interface{}, error) { +func encodeMap(zctx *zed.Context, typ *zed.TypeMap, v zcode.Bytes) (interface{}, error) { // encode nil val as JSON null since // zed.Escape() returns "" for nil if v == nil { @@ -58,7 +58,7 @@ func encodeMap(zctx *zson.Context, typ *zed.TypeMap, v zcode.Bytes) (interface{} return out, nil } -func encodePrimitive(zctx *zson.Context, typ zed.Type, v zcode.Bytes) (interface{}, error) { +func encodePrimitive(zctx *zed.Context, typ zed.Type, v zcode.Bytes) (interface{}, error) { // encode nil val as JSON null since // zed.Escape() returns "" for nil var fld interface{} @@ -84,7 +84,7 @@ func encodePrimitive(zctx *zson.Context, typ zed.Type, v zcode.Bytes) (interface return typ.Format(v), nil } -func encodeValue(zctx *zson.Context, typ zed.Type, val zcode.Bytes) (interface{}, error) { +func encodeValue(zctx *zed.Context, typ zed.Type, val zcode.Bytes) (interface{}, error) { switch typ := typ.(type) { case *zed.TypeAlias: return encodeValue(zctx, typ.Type, val) @@ -105,7 +105,7 @@ func encodeValue(zctx *zson.Context, typ zed.Type, val zcode.Bytes) (interface{} } } -func encodeRecord(zctx *zson.Context, typ *zed.TypeRecord, val zcode.Bytes) (interface{}, error) { +func encodeRecord(zctx *zed.Context, typ *zed.TypeRecord, val zcode.Bytes) (interface{}, error) { if val == nil { return nil, nil } @@ -127,7 +127,7 @@ func encodeRecord(zctx *zson.Context, typ *zed.TypeRecord, val zcode.Bytes) (int return out, nil } -func encodeContainer(zctx *zson.Context, typ zed.Type, bytes zcode.Bytes) (interface{}, error) { +func encodeContainer(zctx *zed.Context, typ zed.Type, bytes zcode.Bytes) (interface{}, error) { if bytes == nil { return nil, nil } diff --git a/zio/zng_test.go b/zio/zng_test.go index 04788aae7a..45478506db 100644 --- a/zio/zng_test.go +++ b/zio/zng_test.go @@ -30,7 +30,7 @@ func (o *Output) Close() error { // Send logs to ZSON reader -> ZNG writer -> ZNG reader -> ZSON writer. func boomerang(t *testing.T, logs string, compress bool) { in := []byte(strings.TrimSpace(logs) + "\n") - zsonSrc := zson.NewReader(bytes.NewReader(in), zson.NewContext()) + zsonSrc := zson.NewReader(bytes.NewReader(in), zed.NewContext()) var rawzng Output var zngLZ4BlockSize int if compress { @@ -41,7 +41,7 @@ func boomerang(t *testing.T, logs string, compress bool) { require.NoError(t, rawDst.Close()) var out Output - rawSrc := zngio.NewReader(bytes.NewReader(rawzng.Bytes()), zson.NewContext()) + rawSrc := zngio.NewReader(bytes.NewReader(rawzng.Bytes()), zed.NewContext()) zsonDst := zsonio.NewWriter(&out, zsonio.WriterOpts{}) err := zio.Copy(zsonDst, rawSrc) if assert.NoError(t, err) { @@ -50,14 +50,14 @@ func boomerang(t *testing.T, logs string, compress bool) { } func boomerangZJSON(t *testing.T, logs string) { - zsonSrc := zson.NewReader(strings.NewReader(logs), zson.NewContext()) + zsonSrc := zson.NewReader(strings.NewReader(logs), zed.NewContext()) var zjsonOutput Output zjsonDst := zjsonio.NewWriter(&zjsonOutput) err := zio.Copy(zjsonDst, zsonSrc) require.NoError(t, err) var out Output - zjsonSrc := zjsonio.NewReader(bytes.NewReader(zjsonOutput.Bytes()), zson.NewContext()) + zjsonSrc := zjsonio.NewReader(bytes.NewReader(zjsonOutput.Bytes()), zed.NewContext()) zsonDst := zsonio.NewWriter(&out, zsonio.WriterOpts{}) err = zio.Copy(zsonDst, zjsonSrc) if assert.NoError(t, err) { @@ -182,7 +182,7 @@ func TestStreams(t *testing.T) { {key:1.160.203.191} {key:2.12.27.251} ` - r := zson.NewReader(strings.NewReader(in), zson.NewContext()) + r := zson.NewReader(strings.NewReader(in), zed.NewContext()) var out Output zw := zngio.NewWriter(&out, zngio.WriterOpts{ LZ4BlockSize: zngio.DefaultLZ4BlockSize, @@ -202,7 +202,7 @@ func TestStreams(t *testing.T) { } } - zr := zngio.NewReader(bytes.NewReader(out.Buffer.Bytes()), zson.NewContext()) + zr := zngio.NewReader(bytes.NewReader(out.Buffer.Bytes()), zed.NewContext()) rec, rec2Off, err := zr.SkipStream() require.NoError(t, err) @@ -216,19 +216,19 @@ func TestStreams(t *testing.T) { len := int64(len(b)) sr := io.NewSectionReader(bytes.NewReader(b), rec4Off, len-rec4Off) - reader := zngio.NewReader(sr, zson.NewContext()) + reader := zngio.NewReader(sr, zed.NewContext()) rec, err = reader.Read() require.NoError(t, err) assert.Equal(t, recs[4].Bytes, rec.Bytes) sr = io.NewSectionReader(bytes.NewReader(b), rec2Off, len-rec2Off) - reader = zngio.NewReader(sr, zson.NewContext()) + reader = zngio.NewReader(sr, zed.NewContext()) rec, err = reader.Read() require.NoError(t, err) assert.Equal(t, recs[2].Bytes, rec.Bytes) sr = io.NewSectionReader(bytes.NewReader(b), 0, len) - reader = zngio.NewReader(sr, zson.NewContext()) + reader = zngio.NewReader(sr, zed.NewContext()) rec, err = reader.Read() require.NoError(t, err) assert.Equal(t, recs[0].Bytes, rec.Bytes) diff --git a/zio/zngio/encoder.go b/zio/zngio/encoder.go index 3b69ee976b..de01ed0f2a 100644 --- a/zio/zngio/encoder.go +++ b/zio/zngio/encoder.go @@ -3,17 +3,16 @@ package zngio import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type Encoder struct { - zctx *zson.Context + zctx *zed.Context encoded map[zed.Type]zed.Type } func NewEncoder() *Encoder { return &Encoder{ - zctx: zson.NewContext(), + zctx: zed.NewContext(), encoded: make(map[zed.Type]zed.Type), } } diff --git a/zio/zngio/reader.go b/zio/zngio/reader.go index 21983cb7cf..c49b6101b1 100644 --- a/zio/zngio/reader.go +++ b/zio/zngio/reader.go @@ -9,7 +9,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/peeker" "github.com/brimdata/zed/zbuf" - "github.com/brimdata/zed/zson" "github.com/pierrec/lz4/v4" ) @@ -24,9 +23,9 @@ type Reader struct { peekerOffset int64 // never points inside a compressed value message block uncompressedBuf *buffer // shared/output context - sctx *zson.Context + sctx *zed.Context // internal context implied by zng file - zctx *zson.Context + zctx *zed.Context // mapper to map internal to shared type contexts mapper *zed.Mapper sos int64 @@ -48,11 +47,11 @@ type AppMessage struct { Bytes []byte } -func NewReader(reader io.Reader, sctx *zson.Context) *Reader { +func NewReader(reader io.Reader, sctx *zed.Context) *Reader { return NewReaderWithOpts(reader, sctx, ReaderOpts{}) } -func NewReaderWithOpts(reader io.Reader, sctx *zson.Context, opts ReaderOpts) *Reader { +func NewReaderWithOpts(reader io.Reader, sctx *zed.Context, opts ReaderOpts) *Reader { if opts.Size == 0 { opts.Size = ReadSize } @@ -65,7 +64,7 @@ func NewReaderWithOpts(reader io.Reader, sctx *zson.Context, opts ReaderOpts) *R return &Reader{ peeker: peeker.NewReader(reader, opts.Size, opts.Max), sctx: sctx, - zctx: zson.NewContext(), + zctx: zed.NewContext(), mapper: zed.NewMapper(sctx), validate: opts.Validate, } @@ -123,7 +122,7 @@ func (r *Reader) LastSOS() int64 { } func (r *Reader) reset() { - r.zctx = zson.NewContext() + r.zctx = zed.NewContext() r.mapper = zed.NewMapper(r.sctx) r.sos = r.peekerOffset } diff --git a/zio/zngio/scanner.go b/zio/zngio/scanner.go index 862b398de9..28c2764239 100644 --- a/zio/zngio/scanner.go +++ b/zio/zngio/scanner.go @@ -10,7 +10,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/expr" "github.com/brimdata/zed/zbuf" - "github.com/brimdata/zed/zson" "golang.org/x/sync/errgroup" ) @@ -189,7 +188,7 @@ func copyBytes(dst, src []byte) []byte { return dst } -func (w *worker) scanBatch(buf *buffer, mapper *zed.Mapper, streamZctx *zson.Context) (zbuf.Batch, error) { +func (w *worker) scanBatch(buf *buffer, mapper *zed.Mapper, streamZctx *zed.Context) (zbuf.Batch, error) { // If w.bufferFilter evaluates to false, we know buf cannot contain // records matching w.filter. if w.bufferFilter != nil && !w.bufferFilter.Eval(streamZctx, buf.Bytes()) { diff --git a/zio/zngio/scanner_test.go b/zio/zngio/scanner_test.go index b9c25107f1..72fc95b9cc 100644 --- a/zio/zngio/scanner_test.go +++ b/zio/zngio/scanner_test.go @@ -8,6 +8,7 @@ import ( "strconv" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zson" "github.com/stretchr/testify/require" @@ -44,7 +45,7 @@ func TestScannerContext(t *testing.T) { readers = append(readers, bytes.NewReader(bufs[j])) } } - r := NewReaderWithOpts(io.MultiReader(readers...), zson.NewContext(), ReaderOpts{ + r := NewReaderWithOpts(io.MultiReader(readers...), zed.NewContext(), ReaderOpts{ Validate: true, }) // Create a scanner and scan, validating each record. diff --git a/zio/zngio/writer_test.go b/zio/zngio/writer_test.go index 0c0be4ff71..4f2376eb01 100644 --- a/zio/zngio/writer_test.go +++ b/zio/zngio/writer_test.go @@ -7,6 +7,7 @@ import ( "strings" "testing" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio" "github.com/brimdata/zed/zson" "github.com/stretchr/testify/assert" @@ -66,7 +67,7 @@ ff expected, err := hex.DecodeString(expectedHex) require.NoError(t, err) - zr := zson.NewReader(strings.NewReader(input), zson.NewContext()) + zr := zson.NewReader(strings.NewReader(input), zed.NewContext()) var buf bytes.Buffer zw := NewWriter(zio.NopCloser(&buf), WriterOpts{}) require.NoError(t, zio.Copy(zw, zr)) diff --git a/zio/zstio/reader.go b/zio/zstio/reader.go index 7a22568edc..759631dc2e 100644 --- a/zio/zstio/reader.go +++ b/zio/zstio/reader.go @@ -4,12 +4,12 @@ import ( "errors" "io" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" - "github.com/brimdata/zed/zson" "github.com/brimdata/zed/zst" ) -func NewReader(r io.Reader, zctx *zson.Context) (*zst.Reader, error) { +func NewReader(r io.Reader, zctx *zed.Context) (*zst.Reader, error) { reader, ok := r.(storage.Reader) if !ok { return nil, errors.New("zst must be used with a seekable input") diff --git a/zngbytes/deserializer.go b/zngbytes/deserializer.go index 04d558e1d8..360ac170ea 100644 --- a/zngbytes/deserializer.go +++ b/zngbytes/deserializer.go @@ -3,6 +3,7 @@ package zngbytes import ( "io" + "github.com/brimdata/zed" "github.com/brimdata/zed/zio/zngio" "github.com/brimdata/zed/zson" ) @@ -13,10 +14,10 @@ type Deserializer struct { } func NewDeserializer(reader io.Reader, templates []interface{}) *Deserializer { - return NewDeserializerWithContext(zson.NewContext(), reader, templates) + return NewDeserializerWithContext(zed.NewContext(), reader, templates) } -func NewDeserializerWithContext(zctx *zson.Context, reader io.Reader, templates []interface{}) *Deserializer { +func NewDeserializerWithContext(zctx *zed.Context, reader io.Reader, templates []interface{}) *Deserializer { u := zson.NewZNGUnmarshaler() u.Bind(templates...) return &Deserializer{ diff --git a/zson/analyzer.go b/zson/analyzer.go index 729a4d3b90..877f352bba 100644 --- a/zson/analyzer.go +++ b/zson/analyzer.go @@ -92,11 +92,11 @@ func NewAnalyzer() Analyzer { return Analyzer(make(map[string]zed.Type)) } -func (a Analyzer) ConvertValue(zctx *Context, val astzed.Value) (Value, error) { +func (a Analyzer) ConvertValue(zctx *zed.Context, val astzed.Value) (Value, error) { return a.convertValue(zctx, val, nil) } -func (a Analyzer) convertValue(zctx *Context, val astzed.Value, parent zed.Type) (Value, error) { +func (a Analyzer) convertValue(zctx *zed.Context, val astzed.Value, parent zed.Type) (Value, error) { switch val := val.(type) { case *astzed.ImpliedValue: return a.convertAny(zctx, val.Of, parent) @@ -166,7 +166,7 @@ func (a Analyzer) typeCheck(cast, parent zed.Type) error { return fmt.Errorf("decorator conflict enclosing context %q and decorator cast %q", parent, cast) } -func (a Analyzer) enterTypeDef(zctx *Context, name string, typ zed.Type) (*zed.TypeAlias, error) { +func (a Analyzer) enterTypeDef(zctx *zed.Context, name string, typ zed.Type) (*zed.TypeAlias, error) { var alias *zed.TypeAlias if zed.IsTypeName(name) { var err error @@ -179,7 +179,7 @@ func (a Analyzer) enterTypeDef(zctx *Context, name string, typ zed.Type) (*zed.T return alias, nil } -func (a Analyzer) convertAny(zctx *Context, val astzed.Any, cast zed.Type) (Value, error) { +func (a Analyzer) convertAny(zctx *zed.Context, val astzed.Any, cast zed.Type) (Value, error) { // If we're casting something to a union, then the thing inside needs to // describe itself and we can convert the inner value to a union value when // we know its type (so we can code the selector). @@ -209,7 +209,7 @@ func (a Analyzer) convertAny(zctx *Context, val astzed.Any, cast zed.Type) (Valu return nil, fmt.Errorf("internal error: unknown ast type in Analyzer.convertAny(): %T", val) } -func (a Analyzer) convertPrimitive(zctx *Context, val *astzed.Primitive, cast zed.Type) (Value, error) { +func (a Analyzer) convertPrimitive(zctx *zed.Context, val *astzed.Primitive, cast zed.Type) (Value, error) { typ := zed.LookupPrimitive(val.Type) if typ == nil { return nil, fmt.Errorf("no such primitive type: %q", val.Type) @@ -257,7 +257,7 @@ func castType(typ, cast zed.Type) (zed.Type, error) { return nil, fmt.Errorf("type mismatch: %q cannot be used as %q", typ, cast) } -func (a Analyzer) convertRecord(zctx *Context, val *astzed.Record, cast zed.Type) (Value, error) { +func (a Analyzer) convertRecord(zctx *zed.Context, val *astzed.Record, cast zed.Type) (Value, error) { var fields []Value var err error if cast != nil { @@ -285,7 +285,7 @@ func (a Analyzer) convertRecord(zctx *Context, val *astzed.Record, cast zed.Type }, nil } -func (a Analyzer) convertFields(zctx *Context, in []astzed.Field, cols []zed.Column) ([]Value, error) { +func (a Analyzer) convertFields(zctx *zed.Context, in []astzed.Field, cols []zed.Column) ([]Value, error) { fields := make([]Value, 0, len(in)) for k, f := range in { var cast zed.Type @@ -301,7 +301,7 @@ func (a Analyzer) convertFields(zctx *Context, in []astzed.Field, cols []zed.Col return fields, nil } -func lookupRecordType(zctx *Context, fields []astzed.Field, vals []Value) (*zed.TypeRecord, error) { +func lookupRecordType(zctx *zed.Context, fields []astzed.Field, vals []Value) (*zed.TypeRecord, error) { columns := make([]zed.Column, 0, len(fields)) for k, f := range fields { columns = append(columns, zed.Column{f.Name, vals[k].TypeOf()}) @@ -320,7 +320,7 @@ func arrayElemCast(cast zed.Type) (zed.Type, error) { return nil, errors.New("array decorator not of type array") } -func (a Analyzer) convertArray(zctx *Context, array *astzed.Array, cast zed.Type) (Value, error) { +func (a Analyzer) convertArray(zctx *zed.Context, array *astzed.Array, cast zed.Type) (Value, error) { vals := make([]Value, 0, len(array.Elements)) typ, err := arrayElemCast(cast) if err != nil { @@ -374,7 +374,7 @@ func (a Analyzer) convertArray(zctx *Context, array *astzed.Array, cast zed.Type }, nil } -func (a Analyzer) mixedNullArray(zctx *Context, types []zed.Type, vals []Value) *Array { +func (a Analyzer) mixedNullArray(zctx *zed.Context, types []zed.Type, vals []Value) *Array { if len(types) != 2 { return nil } @@ -425,7 +425,7 @@ func differentTypes(vals []Value) []zed.Type { return out } -func (a Analyzer) convertSet(zctx *Context, set *astzed.Set, cast zed.Type) (Value, error) { +func (a Analyzer) convertSet(zctx *zed.Context, set *astzed.Set, cast zed.Type) (Value, error) { var elemType zed.Type if cast != nil { setType, ok := zed.AliasOf(cast).(*zed.TypeSet) @@ -459,7 +459,7 @@ func (a Analyzer) convertSet(zctx *Context, set *astzed.Set, cast zed.Type) (Val }, nil } -func (a Analyzer) convertUnion(zctx *Context, v Value, union *zed.TypeUnion, cast zed.Type) (Value, error) { +func (a Analyzer) convertUnion(zctx *zed.Context, v Value, union *zed.TypeUnion, cast zed.Type) (Value, error) { valType := v.TypeOf() if valType == zed.TypeNull { // Set selector to -1 to signal to the builder to encode a null. @@ -481,7 +481,7 @@ func (a Analyzer) convertUnion(zctx *Context, v Value, union *zed.TypeUnion, cas return nil, fmt.Errorf("type %q is not in union type %q", valType, union) } -func (a Analyzer) convertEnum(zctx *Context, val *astzed.Enum, cast zed.Type) (Value, error) { +func (a Analyzer) convertEnum(zctx *zed.Context, val *astzed.Enum, cast zed.Type) (Value, error) { if cast == nil { return nil, fmt.Errorf("identifier %q must be enum and requires decorator", val.Name) } @@ -500,7 +500,7 @@ func (a Analyzer) convertEnum(zctx *Context, val *astzed.Enum, cast zed.Type) (V return nil, fmt.Errorf("identifier %q not a member of enum type %q", val.Name, enum) } -func (a Analyzer) convertMap(zctx *Context, m *astzed.Map, cast zed.Type) (Value, error) { +func (a Analyzer) convertMap(zctx *zed.Context, m *astzed.Map, cast zed.Type) (Value, error) { var keyType, valType zed.Type if cast != nil { typ, ok := zed.AliasOf(cast).(*zed.TypeMap) @@ -541,7 +541,7 @@ func (a Analyzer) convertMap(zctx *Context, m *astzed.Map, cast zed.Type) (Value }, nil } -func (a Analyzer) convertTypeValue(zctx *Context, tv *astzed.TypeValue, cast zed.Type) (Value, error) { +func (a Analyzer) convertTypeValue(zctx *zed.Context, tv *astzed.TypeValue, cast zed.Type) (Value, error) { if cast != nil { if _, ok := zed.AliasOf(cast).(*zed.TypeOfType); !ok { return nil, fmt.Errorf("cannot apply decorator (%q) to a type value", cast) @@ -560,7 +560,7 @@ func (a Analyzer) convertTypeValue(zctx *Context, tv *astzed.TypeValue, cast zed }, nil } -func (a Analyzer) convertType(zctx *Context, typ astzed.Type) (zed.Type, error) { +func (a Analyzer) convertType(zctx *zed.Context, typ astzed.Type) (zed.Type, error) { switch t := typ.(type) { case *astzed.TypePrimitive: name := t.Name @@ -619,7 +619,7 @@ func (a Analyzer) convertType(zctx *Context, typ astzed.Type) (zed.Type, error) return nil, fmt.Errorf("unknown type in Analyzer.convertType: %T", typ) } -func (a Analyzer) convertTypeRecord(zctx *Context, typ *astzed.TypeRecord) (*zed.TypeRecord, error) { +func (a Analyzer) convertTypeRecord(zctx *zed.Context, typ *astzed.TypeRecord) (*zed.TypeRecord, error) { fields := typ.Fields columns := make([]zed.Column, 0, len(fields)) for _, f := range fields { @@ -632,7 +632,7 @@ func (a Analyzer) convertTypeRecord(zctx *Context, typ *astzed.TypeRecord) (*zed return zctx.LookupTypeRecord(columns) } -func (a Analyzer) convertTypeMap(zctx *Context, tmap *astzed.TypeMap) (*zed.TypeMap, error) { +func (a Analyzer) convertTypeMap(zctx *zed.Context, tmap *astzed.TypeMap) (*zed.TypeMap, error) { keyType, err := a.convertType(zctx, tmap.KeyType) if err != nil { return nil, err @@ -644,7 +644,7 @@ func (a Analyzer) convertTypeMap(zctx *Context, tmap *astzed.TypeMap) (*zed.Type return zctx.LookupTypeMap(keyType, valType), nil } -func (a Analyzer) convertTypeUnion(zctx *Context, union *astzed.TypeUnion) (*zed.TypeUnion, error) { +func (a Analyzer) convertTypeUnion(zctx *zed.Context, union *astzed.TypeUnion) (*zed.TypeUnion, error) { var types []zed.Type for _, typ := range union.Types { typ, err := a.convertType(zctx, typ) @@ -656,7 +656,7 @@ func (a Analyzer) convertTypeUnion(zctx *Context, union *astzed.TypeUnion) (*zed return zctx.LookupTypeUnion(types), nil } -func (a Analyzer) convertTypeEnum(zctx *Context, enum *astzed.TypeEnum) (*zed.TypeEnum, error) { +func (a Analyzer) convertTypeEnum(zctx *zed.Context, enum *astzed.TypeEnum) (*zed.TypeEnum, error) { if len(enum.Symbols) == 0 { return nil, errors.New("enum body is empty") } diff --git a/zson/context.go b/zson/context.go deleted file mode 100644 index b005b50305..0000000000 --- a/zson/context.go +++ /dev/null @@ -1,18 +0,0 @@ -package zson - -import ( - "errors" - - "github.com/brimdata/zed" -) - -var ( - ErrAliasExists = errors.New("alias exists with different type") -) - -// XXX Leaving this wrapper here for now. When we move package zng into -// the top-level zed package, we'll change all the references zson.Context -// to astzed.Context. See issue #2824 -type Context = zed.Context - -var NewContext = zed.NewContext diff --git a/zson/marshal.go b/zson/marshal.go index ddceb22c42..f8167814a9 100644 --- a/zson/marshal.go +++ b/zson/marshal.go @@ -38,7 +38,7 @@ func NewMarshalerIndent(indent int) *MarshalContext { } } -func NewMarshalerWithContext(zctx *Context) *MarshalContext { +func NewMarshalerWithContext(zctx *zed.Context) *MarshalContext { return &MarshalContext{ MarshalZNGContext: NewZNGMarshalerWithContext(zctx), } @@ -62,7 +62,7 @@ func (m *MarshalContext) MarshalCustom(names []string, fields []interface{}) (st type UnmarshalContext struct { *UnmarshalZNGContext - zctx *Context + zctx *zed.Context analyzer Analyzer builder *zcode.Builder } @@ -70,7 +70,7 @@ type UnmarshalContext struct { func NewUnmarshaler() *UnmarshalContext { return &UnmarshalContext{ UnmarshalZNGContext: NewZNGUnmarshaler(), - zctx: NewContext(), + zctx: zed.NewContext(), analyzer: NewAnalyzer(), builder: zcode.NewBuilder(), } @@ -109,17 +109,17 @@ func MarshalZNG(v interface{}) (zed.Value, error) { } type MarshalZNGContext struct { - *Context + *zed.Context zcode.Builder decorator func(string, string) string bindings map[string]string } func NewZNGMarshaler() *MarshalZNGContext { - return NewZNGMarshalerWithContext(NewContext()) + return NewZNGMarshalerWithContext(zed.NewContext()) } -func NewZNGMarshalerWithContext(zctx *Context) *MarshalZNGContext { +func NewZNGMarshalerWithContext(zctx *zed.Context) *MarshalZNGContext { return &MarshalZNGContext{ Context: zctx, } diff --git a/zson/marshal_test.go b/zson/marshal_test.go index 5058bad59a..d6433b6a3a 100644 --- a/zson/marshal_test.go +++ b/zson/marshal_test.go @@ -214,7 +214,7 @@ func TestBug2575(t *testing.T) { writer.Close() r := bytes.NewReader(buffer.Bytes()) - reader := zngio.NewReader(r, zson.NewContext()) + reader := zngio.NewReader(r, zed.NewContext()) recActual, err := reader.Read() exp, err := zson.FormatValue(recExpected.Value) require.NoError(t, err) @@ -261,7 +261,7 @@ func TestZNGValueField(t *testing.T) { assert.Equal(t, *zngValueField, out) // Include a Zed record inside a Go struct in a zed.Value field. z := `{s:"foo",a:[1,2,3]}` - zv2, err := zson.ParseValue(zson.NewContext(), z) + zv2, err := zson.ParseValue(zed.NewContext(), z) require.NoError(t, err) zngValueField2 := &ZNGValueField{ Name: "test2", diff --git a/zson/marshal_zng_test.go b/zson/marshal_zng_test.go index 047d04621a..3bbbdb2f16 100644 --- a/zson/marshal_zng_test.go +++ b/zson/marshal_zng_test.go @@ -31,7 +31,7 @@ func boomerang(t *testing.T, in interface{}, out interface{}) { zw := zngio.NewWriter(zio.NopCloser(&buf), zngio.WriterOpts{}) err = zw.Write(rec) require.NoError(t, err) - zctx := zson.NewContext() + zctx := zed.NewContext() zr := zngio.NewReader(&buf, zctx) rec, err = zr.Read() require.NoError(t, err) @@ -147,7 +147,7 @@ func TestIPType(t *testing.T) { addr := net.ParseIP("192.168.1.1").To4() require.NotNil(t, addr) s := TestIP{Addr: addr} - zctx := zson.NewContext() + zctx := zed.NewContext() m := zson.NewZNGMarshalerWithContext(zctx) rec, err := m.MarshalRecord(s) require.NoError(t, err) @@ -183,7 +183,7 @@ func TestUnmarshalRecord(t *testing.T) { const expected = `{top:{T2f1:{T3f1:1(int32),T3f2:1.},T2f2:"t2f2-string1"}}` require.Equal(t, expected, toZSON(t, rec)) - zctx := zson.NewContext() + zctx := zed.NewContext() rec, err = zson.NewReader(strings.NewReader(expected), zctx).Read() require.NoError(t, err) @@ -210,7 +210,7 @@ func TestUnmarshalSlice(t *testing.T) { v1 := T1{ T1f1: []bool{true, false, true}, } - zctx := zson.NewContext() + zctx := zed.NewContext() rec, err := zson.NewZNGMarshalerWithContext(zctx).MarshalRecord(v1) require.NoError(t, err) require.NotNil(t, rec) @@ -227,7 +227,7 @@ func TestUnmarshalSlice(t *testing.T) { v3 := T2{ Field1: []*int{intp(1), intp(2)}, } - zctx = zson.NewContext() + zctx = zed.NewContext() rec, err = zson.NewZNGMarshalerWithContext(zctx).MarshalRecord(v3) require.NoError(t, err) require.NotNil(t, rec) diff --git a/zson/reader.go b/zson/reader.go index 1979551eea..655fef8806 100644 --- a/zson/reader.go +++ b/zson/reader.go @@ -10,13 +10,13 @@ import ( type Reader struct { reader io.Reader - zctx *Context + zctx *zed.Context parser *Parser analyzer Analyzer builder *zcode.Builder } -func NewReader(r io.Reader, zctx *Context) *Reader { +func NewReader(r io.Reader, zctx *zed.Context) *Reader { return &Reader{ reader: r, zctx: zctx, diff --git a/zson/reader_test.go b/zson/reader_test.go index 63550dc362..37d081b64a 100644 --- a/zson/reader_test.go +++ b/zson/reader_test.go @@ -23,7 +23,7 @@ func TestReadOneLineNoEOF(t *testing.T) { // The test needs two records because with a single record the parser // will stall waiting to see if the record has a decorator. reader <- []byte(expected + "\n" + expected) - r := zson.NewReader(reader, zson.NewContext()) + r := zson.NewReader(reader, zed.NewContext()) rec, err := r.Read() done <- result{rec: rec, err: err} }() diff --git a/zson/zson.go b/zson/zson.go index d7b01c16a8..dceef7edac 100644 --- a/zson/zson.go +++ b/zson/zson.go @@ -57,7 +57,7 @@ func SelfDescribing(typ zed.Type) bool { return false } -func ParseType(zctx *Context, zson string) (zed.Type, error) { +func ParseType(zctx *zed.Context, zson string) (zed.Type, error) { zp, err := NewParser(strings.NewReader(zson)) if err != nil { return nil, err @@ -69,7 +69,7 @@ func ParseType(zctx *Context, zson string) (zed.Type, error) { return NewAnalyzer().convertType(zctx, ast) } -func ParseValue(zctx *Context, zson string) (zed.Value, error) { +func ParseValue(zctx *zed.Context, zson string) (zed.Value, error) { zp, err := NewParser(strings.NewReader(zson)) if err != nil { return zed.Value{}, err @@ -85,7 +85,7 @@ func ParseValue(zctx *Context, zson string) (zed.Value, error) { return Build(zcode.NewBuilder(), val) } -func ParseValueFromAST(zctx *Context, ast astzed.Value) (zed.Value, error) { +func ParseValueFromAST(zctx *zed.Context, ast astzed.Value) (zed.Value, error) { val, err := NewAnalyzer().ConvertValue(zctx, ast) if err != nil { return zed.Value{}, err @@ -93,6 +93,6 @@ func ParseValueFromAST(zctx *Context, ast astzed.Value) (zed.Value, error) { return Build(zcode.NewBuilder(), val) } -func TranslateType(zctx *Context, astType astzed.Type) (zed.Type, error) { +func TranslateType(zctx *zed.Context, astType astzed.Type) (zed.Type, error) { return NewAnalyzer().convertType(zctx, astType) } diff --git a/zson/zson_test.go b/zson/zson_test.go index c4d85e77b3..ced2e301b9 100644 --- a/zson/zson_test.go +++ b/zson/zson_test.go @@ -35,7 +35,7 @@ func TestZsonParser(t *testing.T) { assert.NotEqual(t, s, "") } -func analyze(zctx *zson.Context, path string) (zson.Value, error) { +func analyze(zctx *zed.Context, path string) (zson.Value, error) { val, err := parse(path) if err != nil { return nil, err @@ -45,14 +45,14 @@ func analyze(zctx *zson.Context, path string) (zson.Value, error) { } func TestZsonAnalyzer(t *testing.T) { - zctx := zson.NewContext() + zctx := zed.NewContext() val, err := analyze(zctx, testFile) require.NoError(t, err) assert.NotNil(t, val) } func TestZsonBuilder(t *testing.T) { - zctx := zson.NewContext() + zctx := zed.NewContext() val, err := analyze(zctx, testFile) require.NoError(t, err) b := zcode.NewBuilder() diff --git a/zst/column/array.go b/zst/column/array.go index cae0103fe5..10f2ee478f 100644 --- a/zst/column/array.go +++ b/zst/column/array.go @@ -6,7 +6,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type ArrayWriter struct { @@ -46,7 +45,7 @@ func (a *ArrayWriter) Flush(eof bool) error { return a.values.Flush(eof) } -func (a *ArrayWriter) MarshalZNG(zctx *zson.Context, b *zcode.Builder) (zed.Type, error) { +func (a *ArrayWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error) { b.BeginContainer() valType, err := a.values.MarshalZNG(zctx, b) if err != nil { diff --git a/zst/column/column.go b/zst/column/column.go index ed19acfe4e..5e65427631 100644 --- a/zst/column/column.go +++ b/zst/column/column.go @@ -36,7 +36,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) const MaxSegmentThresh = 20 * 1024 * 1024 @@ -51,7 +50,7 @@ type Writer interface { Flush(bool) error // MarshalZNG is called after all data is flushed to build the reassembly // record for this column. - MarshalZNG(*zson.Context, *zcode.Builder) (zed.Type, error) + MarshalZNG(*zed.Context, *zcode.Builder) (zed.Type, error) } func NewWriter(typ zed.Type, spiller *Spiller) Writer { diff --git a/zst/column/field.go b/zst/column/field.go index fd6073775b..d9539e70e4 100644 --- a/zst/column/field.go +++ b/zst/column/field.go @@ -6,7 +6,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type FieldWriter struct { @@ -28,7 +27,7 @@ func (f *FieldWriter) write(body zcode.Bytes) error { return f.column.Write(body) } -func (f *FieldWriter) MarshalZNG(zctx *zson.Context, b *zcode.Builder) (zed.Type, error) { +func (f *FieldWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error) { b.BeginContainer() var colType zed.Type if f.vcnt == 0 { diff --git a/zst/column/primitive.go b/zst/column/primitive.go index 1752ae944b..860acfd6c7 100644 --- a/zst/column/primitive.go +++ b/zst/column/primitive.go @@ -39,7 +39,7 @@ func (p *PrimitiveWriter) Flush(eof bool) error { return err } -func (p *PrimitiveWriter) MarshalZNG(zctx *zson.Context, b *zcode.Builder) (zed.Type, error) { +func (p *PrimitiveWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error) { b.BeginContainer() for _, segment := range p.segments { // Add a segmap record to the array for each segment. diff --git a/zst/column/record.go b/zst/column/record.go index 68bb615d17..0f4a3dcc42 100644 --- a/zst/column/record.go +++ b/zst/column/record.go @@ -6,7 +6,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) var ErrColumnMismatch = errors.New("zng record value doesn't match column writer") @@ -56,7 +55,7 @@ func (r RecordWriter) Flush(eof bool) error { return nil } -func (r RecordWriter) MarshalZNG(zctx *zson.Context, b *zcode.Builder) (zed.Type, error) { +func (r RecordWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error) { var columns []zed.Column b.BeginContainer() for _, f := range r { diff --git a/zst/column/union.go b/zst/column/union.go index 035ba35e00..97f2c08775 100644 --- a/zst/column/union.go +++ b/zst/column/union.go @@ -7,7 +7,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" ) type UnionWriter struct { @@ -54,7 +53,7 @@ func (u *UnionWriter) Flush(eof bool) error { return nil } -func (u *UnionWriter) MarshalZNG(zctx *zson.Context, b *zcode.Builder) (zed.Type, error) { +func (u *UnionWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error) { var cols []zed.Column b.BeginContainer() for k, value := range u.values { diff --git a/zst/cutter.go b/zst/cutter.go index 4f1861b214..6ceeac073e 100644 --- a/zst/cutter.go +++ b/zst/cutter.go @@ -8,7 +8,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zcode" - "github.com/brimdata/zed/zson" "github.com/brimdata/zed/zst/column" ) @@ -24,7 +23,7 @@ func NewCutter(object *Object, fields []string) (*Reader, error) { } -func NewCutterFromPath(ctx context.Context, zctx *zson.Context, engine storage.Engine, path string, fields []string) (*Reader, error) { +func NewCutterFromPath(ctx context.Context, zctx *zed.Context, engine storage.Engine, path string, fields []string) (*Reader, error) { object, err := NewObjectFromPath(ctx, zctx, engine, path) if err != nil { return nil, err @@ -38,7 +37,7 @@ func NewCutterFromPath(ctx context.Context, zctx *zson.Context, engine storage.E } type CutAssembler struct { - zctx *zson.Context + zctx *zed.Context root *column.Int schemas []zed.Type columns []column.Interface @@ -48,7 +47,7 @@ type CutAssembler struct { leaf string } -func NewCutAssembler(zctx *zson.Context, fields []string, object *Object) (*CutAssembler, error) { +func NewCutAssembler(zctx *zed.Context, fields []string, object *Object) (*CutAssembler, error) { a := object.assembly n := len(a.columns) ca := &CutAssembler{ @@ -91,7 +90,7 @@ func NewCutAssembler(zctx *zson.Context, fields []string, object *Object) (*CutA return ca, nil } -func cutType(zctx *zson.Context, typ *zed.TypeRecord, fields []string) (*zed.TypeRecord, int, error) { +func cutType(zctx *zed.Context, typ *zed.TypeRecord, fields []string) (*zed.TypeRecord, int, error) { if len(fields) == 0 { panic("zst.cutType cannot be called with an empty fields argument") } diff --git a/zst/object.go b/zst/object.go index b6ecc7d0a5..651e24410a 100644 --- a/zst/object.go +++ b/zst/object.go @@ -43,7 +43,7 @@ import ( type Object struct { seeker *storage.Seeker closer io.Closer - zctx *zson.Context + zctx *zed.Context assembly *Assembly trailer *Trailer size int64 @@ -51,7 +51,7 @@ type Object struct { err error } -func NewObject(zctx *zson.Context, s *storage.Seeker, size int64) (*Object, error) { +func NewObject(zctx *zed.Context, s *storage.Seeker, size int64) (*Object, error) { trailer, err := readTrailer(s, size) if err != nil { return nil, err @@ -72,7 +72,7 @@ func NewObject(zctx *zson.Context, s *storage.Seeker, size int64) (*Object, erro return o, err } -func NewObjectFromSeeker(zctx *zson.Context, s *storage.Seeker) (*Object, error) { +func NewObjectFromSeeker(zctx *zed.Context, s *storage.Seeker) (*Object, error) { size, err := storage.Size(s.Reader) if err != nil { return nil, err @@ -80,7 +80,7 @@ func NewObjectFromSeeker(zctx *zson.Context, s *storage.Seeker) (*Object, error) return NewObject(zctx, s, size) } -func NewObjectFromPath(ctx context.Context, zctx *zson.Context, engine storage.Engine, path string) (*Object, error) { +func NewObjectFromPath(ctx context.Context, zctx *zed.Context, engine storage.Engine, path string) (*Object, error) { uri, err := storage.ParseURI(path) if err != nil { return nil, err diff --git a/zst/reader.go b/zst/reader.go index b562a175d9..5f964d4cc4 100644 --- a/zst/reader.go +++ b/zst/reader.go @@ -3,9 +3,9 @@ package zst import ( "context" + "github.com/brimdata/zed" "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zio" - "github.com/brimdata/zed/zson" ) // Reader implements zio.Reader and io.Closer. It reads a columnar @@ -30,7 +30,7 @@ func NewReader(object *Object) (*Reader, error) { } -func NewReaderFromPath(ctx context.Context, zctx *zson.Context, engine storage.Engine, path string) (*Reader, error) { +func NewReaderFromPath(ctx context.Context, zctx *zed.Context, engine storage.Engine, path string) (*Reader, error) { object, err := NewObjectFromPath(ctx, zctx, engine, path) if err != nil { return nil, err @@ -43,7 +43,7 @@ func NewReaderFromPath(ctx context.Context, zctx *zson.Context, engine storage.E return reader, nil } -func NewReaderFromSeeker(zctx *zson.Context, seeker *storage.Seeker) (*Reader, error) { +func NewReaderFromSeeker(zctx *zed.Context, seeker *storage.Seeker) (*Reader, error) { object, err := NewObjectFromSeeker(zctx, seeker) if err != nil { return nil, err diff --git a/zst/trailer.go b/zst/trailer.go index 58267526f7..9a2bde2003 100644 --- a/zst/trailer.go +++ b/zst/trailer.go @@ -9,7 +9,6 @@ import ( "github.com/brimdata/zed" "github.com/brimdata/zed/zcode" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" ) const ( @@ -38,7 +37,7 @@ type Trailer struct { var ErrNotZst = errors.New("not a zst object") -func newTrailerRecord(zctx *zson.Context, skewThresh, segmentThresh int, sections []int64) (*zed.Record, error) { +func newTrailerRecord(zctx *zed.Context, skewThresh, segmentThresh int, sections []int64) (*zed.Record, error) { sectionsType := zctx.LookupTypeArray(zed.TypeInt64) cols := []zed.Column{ {MagicField, zed.TypeString}, @@ -97,7 +96,7 @@ func readTrailer(r io.ReadSeeker, n int64) (*Trailer, error) { continue } r := bytes.NewReader(buf[off:n]) - rec, _ := zngio.NewReader(r, zson.NewContext()).Read() + rec, _ := zngio.NewReader(r, zed.NewContext()).Read() if rec == nil { continue } diff --git a/zst/writer.go b/zst/writer.go index 94b98f2e6d..b506503ab6 100644 --- a/zst/writer.go +++ b/zst/writer.go @@ -10,7 +10,6 @@ import ( "github.com/brimdata/zed/pkg/storage" "github.com/brimdata/zed/zcode" "github.com/brimdata/zed/zio/zngio" - "github.com/brimdata/zed/zson" "github.com/brimdata/zed/zst/column" ) @@ -22,7 +21,7 @@ const ( // Writer implements the zio.Writer interface. A Writer creates a columnar // zst object from a stream of zed.Records. type Writer struct { - zctx *zson.Context + zctx *zed.Context writer io.WriteCloser spiller *column.Spiller schemaMap map[int]int @@ -48,7 +47,7 @@ func NewWriter(w io.WriteCloser, skewThresh, segThresh int) (*Writer, error) { } spiller := column.NewSpiller(w, segThresh) return &Writer{ - zctx: zson.NewContext(), + zctx: zed.NewContext(), spiller: spiller, writer: w, schemaMap: make(map[int]int), @@ -230,7 +229,7 @@ func (w *Writer) writeEmptyTrailer() error { return writeTrailer(zw, w.zctx, w.skewThresh, w.segThresh, nil) } -func writeTrailer(w *zngio.Writer, zctx *zson.Context, skewThresh, segThresh int, sizes []int64) error { +func writeTrailer(w *zngio.Writer, zctx *zed.Context, skewThresh, segThresh int, sizes []int64) error { rec, err := newTrailerRecord(zctx, skewThresh, segThresh, sizes) if err != nil { return err diff --git a/ztest/ztest.go b/ztest/ztest.go index af4fbeb0af..4d12e7dd23 100644 --- a/ztest/ztest.go +++ b/ztest/ztest.go @@ -131,13 +131,13 @@ import ( "testing" "unicode/utf8" + "github.com/brimdata/zed" "github.com/brimdata/zed/cli/inputflags" "github.com/brimdata/zed/cli/outputflags" "github.com/brimdata/zed/compiler" "github.com/brimdata/zed/driver" "github.com/brimdata/zed/zio/anyio" "github.com/brimdata/zed/zqe" - "github.com/brimdata/zed/zson" "github.com/pmezard/go-difflib/difflib" "gopkg.in/yaml.v3" ) @@ -480,13 +480,13 @@ func runsh(path, testDir, tempDir string, zt *ZTest) error { return nil } -// runzq runs the Zed program in zed over input and returns the output. input +// runzq runs zedProgram over input and returns the output. input // may be in any format recognized by "zq -i auto" and may be gzip-compressed. // outputFlags may contain any flags accepted by cli/outputflags.Flags. If path // is empty, the program runs in the current process. If path is not empty, it // specifies a command search path used to find a zq executable to run the // program. -func runzq(path, zed, input string, outputFlags []string, inputFlags []string) (string, string, error) { +func runzq(path, zedProgram, input string, outputFlags []string, inputFlags []string) (string, string, error) { var errbuf, outbuf bytes.Buffer if path != "" { zq, err := lookupzq(path) @@ -494,7 +494,7 @@ func runzq(path, zed, input string, outputFlags []string, inputFlags []string) ( return "", "", err } flags := append(outputFlags, inputFlags...) - cmd := exec.Command(zq, append(flags, zed, "-")...) + cmd := exec.Command(zq, append(flags, zedProgram, "-")...) cmd.Stdin = strings.NewReader(input) cmd.Stdout = &outbuf cmd.Stderr = &errbuf @@ -504,7 +504,7 @@ func runzq(path, zed, input string, outputFlags []string, inputFlags []string) ( // tests. return outbuf.String(), errbuf.String(), err } - proc, err := compiler.ParseProc(zed) + proc, err := compiler.ParseProc(zedProgram) if err != nil { return "", "", err } @@ -514,7 +514,7 @@ func runzq(path, zed, input string, outputFlags []string, inputFlags []string) ( if err := flags.Parse(inputFlags); err != nil { return "", "", err } - zctx := zson.NewContext() + zctx := zed.NewContext() zr, err := anyio.NewReaderWithOpts(anyio.GzipReader(strings.NewReader(input)), zctx, inflags.Options()) if err != nil { return "", err.Error(), err