Skip to content

Commit

Permalink
move contents of package zng to top level (#3125)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwt authored Sep 29, 2021
1 parent 6629609 commit cc83c8f
Show file tree
Hide file tree
Showing 239 changed files with 3,121 additions and 3,149 deletions.
2 changes: 1 addition & 1 deletion zng/alias.go → alias.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zng
package zed

import (
"fmt"
Expand Down
6 changes: 3 additions & 3 deletions api/queryio/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"errors"
"fmt"

"github.com/brimdata/zed"
"github.com/brimdata/zed/api"
"github.com/brimdata/zed/api/client"
"github.com/brimdata/zed/driver"
"github.com/brimdata/zed/zbuf"
"github.com/brimdata/zed/zio/zngio"
"github.com/brimdata/zed/zng"
"github.com/brimdata/zed/zson"
)

Expand Down Expand Up @@ -49,11 +49,11 @@ func RunClientResponse(ctx context.Context, d driver.Driver, res *client.Respons
type runner struct {
driver driver.Driver
cid int
recs []*zng.Record
recs []*zed.Record
stats zbuf.ScannerStats
}

func (r *runner) Write(rec *zng.Record) error {
func (r *runner) Write(rec *zed.Record) error {
return r.driver.Write(r.cid, &zbuf.Array{rec})
}

Expand Down
4 changes: 2 additions & 2 deletions api/queryio/zjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"io"
"reflect"

"github.com/brimdata/zed"
"github.com/brimdata/zed/zio/zjsonio"
"github.com/brimdata/zed/zng"
"github.com/brimdata/zed/zson"
)

Expand All @@ -28,7 +28,7 @@ func NewZJSONWriter(w io.Writer) *ZJSONWriter {
}
}

func (w *ZJSONWriter) Write(rec *zng.Record) error {
func (w *ZJSONWriter) Write(rec *zed.Record) error {
object, err := w.stream.Transform(rec)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions api/queryio/zjson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import (
"strings"
"testing"

"github.com/brimdata/zed"
"github.com/brimdata/zed/api"
"github.com/brimdata/zed/api/queryio"
"github.com/brimdata/zed/pkg/test"
"github.com/brimdata/zed/zng"
"github.com/brimdata/zed/zson"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func mkRecord(t *testing.T, s string) *zng.Record {
func mkRecord(t *testing.T, s string) *zed.Record {
r := zson.NewReader(strings.NewReader(s), zson.NewContext())
rec, err := r.Read()
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions api/queryio/zng.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"io"

"github.com/brimdata/zed"
"github.com/brimdata/zed/zio"
"github.com/brimdata/zed/zio/zngio"
"github.com/brimdata/zed/zio/zsonio"
"github.com/brimdata/zed/zng"
"github.com/brimdata/zed/zson"
)

Expand Down Expand Up @@ -38,7 +38,7 @@ func (w *ZNGWriter) WriteControl(v interface{}) error {
if err != nil {
return err
}
return w.Writer.WriteControl(buf.Bytes(), zng.AppEncodingZSON)
return w.Writer.WriteControl(buf.Bytes(), zed.AppEncodingZSON)
}

type ZNGReader struct {
Expand All @@ -51,10 +51,10 @@ func NewZNGReader(r *zngio.Reader) *ZNGReader {
}
}

func (r *ZNGReader) ReadPayload() (*zng.Record, interface{}, error) {
func (r *ZNGReader) ReadPayload() (*zed.Record, interface{}, error) {
rec, msg, err := r.reader.ReadPayload()
if msg != nil {
if msg.Encoding != zng.AppEncodingZSON {
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))
Expand Down
2 changes: 1 addition & 1 deletion zng/array.go → array.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zng
package zed

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion zng/bool.go → bool.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zng
package zed

import (
"github.com/brimdata/zed/zcode"
Expand Down
2 changes: 1 addition & 1 deletion zng/bstring.go → bstring.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zng
package zed

import (
"github.com/brimdata/zed/zcode"
Expand Down
4 changes: 2 additions & 2 deletions zng/builder.go → builder.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zng
package zed

import (
"errors"
Expand Down Expand Up @@ -29,7 +29,7 @@ func NewBuilder(typ *TypeRecord) *Builder {
// but when leaf values are inserted we should have another method to handle this,
// e.g., by encoding the dfs traversal of the record type with info about
// primitive vs container insertions. This could be the start of a whole package
// that provides different ways to build zng.Records via, e.g., a marshal API,
// that provides different ways to build Records via, e.g., a marshal API,
// auto-generated stubs, etc.
func (b *Builder) Build(zvs ...zcode.Bytes) *Record {
b.Reset()
Expand Down
38 changes: 19 additions & 19 deletions zng/builder_test.go → builder_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package zng_test
package zed_test

import (
"net"
"strings"
"testing"

"github.com/brimdata/zed"
"github.com/brimdata/zed/zcode"
"github.com/brimdata/zed/zng"
"github.com/brimdata/zed/zson"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -31,33 +31,33 @@ func TestBuilder(t *testing.T) {

zctx := zson.NewContext()

t0, err := zctx.LookupTypeRecord([]zng.Column{
{"key", zng.TypeIP},
t0, err := zctx.LookupTypeRecord([]zed.Column{
{"key", zed.TypeIP},
})
assert.NoError(t, err)
b0 := zng.NewBuilder(t0)
b0 := zed.NewBuilder(t0)
ip := net.ParseIP("1.2.3.4")
rec := b0.Build(zng.EncodeIP(ip))
rec := b0.Build(zed.EncodeIP(ip))
assert.Equal(t, r0.Bytes, rec.Bytes)

t1, err := zctx.LookupTypeRecord([]zng.Column{
{"a", zng.TypeInt64},
{"b", zng.TypeInt64},
{"c", zng.TypeInt64},
t1, err := zctx.LookupTypeRecord([]zed.Column{
{"a", zed.TypeInt64},
{"b", zed.TypeInt64},
{"c", zed.TypeInt64},
})
assert.NoError(t, err)
b1 := zng.NewBuilder(t1)
rec = b1.Build(zng.EncodeInt(1), zng.EncodeInt(2), zng.EncodeInt(3))
b1 := zed.NewBuilder(t1)
rec = b1.Build(zed.EncodeInt(1), zed.EncodeInt(2), zed.EncodeInt(3))
assert.Equal(t, r1.Bytes, rec.Bytes)

subrec, err := zctx.LookupTypeRecord([]zng.Column{{"x", zng.TypeInt64}})
subrec, err := zctx.LookupTypeRecord([]zed.Column{{"x", zed.TypeInt64}})
assert.NoError(t, err)
t2, err := zctx.LookupTypeRecord([]zng.Column{
{"a", zng.TypeInt64},
t2, err := zctx.LookupTypeRecord([]zed.Column{
{"a", zed.TypeInt64},
{"r", subrec},
})
assert.NoError(t, err)
b2 := zng.NewBuilder(t2)
b2 := zed.NewBuilder(t2)
// XXX this is where this package needs work
// the second column here is a container here and this is where it would
// be nice for the builder to know this structure and wrap appropriately,
Expand All @@ -67,16 +67,16 @@ func TestBuilder(t *testing.T) {
// of the record and want to build it up, it would be nice to have some
// easy way to do it all...
var rb zcode.Builder
rb.AppendPrimitive(zng.EncodeInt(3))
rec = b2.Build(zng.EncodeInt(7), rb.Bytes())
rb.AppendPrimitive(zed.EncodeInt(3))
rec = b2.Build(zed.EncodeInt(7), rb.Bytes())
assert.Equal(t, r2.Bytes, rec.Bytes)

//rec, err = b2.Parse("7", "3")
//assert.NoError(t, err)
//assert.Equal(t, r2.Bytes, rec.Bytes)

//rec, err = b2.Parse("7")
//assert.Equal(t, err, zng.ErrIncomplete)
//assert.Equal(t, err, zed.ErrIncomplete)
//assert.Equal(t, r3.Bytes, rec.Bytes)
_ = r3
}
2 changes: 1 addition & 1 deletion zng/bytes.go → bytes.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zng
package zed

import (
"encoding/hex"
Expand Down
6 changes: 3 additions & 3 deletions cmd/zed/index/lookup/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"flag"
"strings"

"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/zng"
"github.com/brimdata/zed/zson"
)

Expand Down Expand Up @@ -76,11 +76,11 @@ func (c *LookupCommand) Run(args []string) error {
if err != nil {
return err
}
hits := make(chan *zng.Record)
hits := make(chan *zed.Record)
var searchErr error
go func() {
if c.closest {
var rec *zng.Record
var rec *zed.Record
rec, searchErr = finder.ClosestLTE(keys)
if rec != nil {
hits <- rec
Expand Down
2 changes: 1 addition & 1 deletion cmd/zed/lake/find/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *Command) Run(args []string) error {
return err
}
defer writer.Close()
hits := make(chan *zng.Record)
hits := make(chan *zed.Record)
var searchErr error
go func() {
searchErr = lake.Find(ctx, zson.NewContext(), lk, query, hits, findOptions...)
Expand Down
2 changes: 1 addition & 1 deletion zng/column.go → column.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zng
package zed

// Column defines the field name and type of a column in a record type.
type Column struct {
Expand Down
18 changes: 8 additions & 10 deletions columnbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (

"github.com/brimdata/zed/field"
"github.com/brimdata/zed/zcode"
"github.com/brimdata/zed/zng"
"github.com/brimdata/zed/zson"
)

var ErrNonAdjacent = errors.New("non adjacent fields")
Expand Down Expand Up @@ -75,7 +73,7 @@ type fieldInfo struct {
type ColumnBuilder struct {
fields []fieldInfo
builder *zcode.Builder
zctx *zson.Context
zctx *Context
curField int
}

Expand All @@ -84,7 +82,7 @@ type ColumnBuilder struct {
// Append should be called to enter field values in the left to right order
// of the provided fields and Encode is called to retrieve the nested zcode.Bytes
// value. Reset should be called before encoding the next record.
func NewColumnBuilder(zctx *zson.Context, fields field.List) (*ColumnBuilder, error) {
func NewColumnBuilder(zctx *Context, fields field.List) (*ColumnBuilder, error) {
seenRecords := make(map[string]bool)
fieldInfos := make([]fieldInfo, 0, len(fields))
var currentRecord []string
Expand Down Expand Up @@ -219,13 +217,13 @@ func (c *ColumnBuilder) Encode() (zcode.Bytes, error) {

// A ColumnBuilder understands the shape of a sequence of FieldExprs
// (i.e., which columns are inside nested records) but not the types.
// TypedColumns takes an array of zng.Types for the individual fields
// and constructs an array of zng.Columns that reflects the fullly
// TypedColumns takes an array of Types for the individual fields
// and constructs an array of Columns that reflects the fullly
// typed structure. This is suitable for e.g. allocating a descriptor.
func (c *ColumnBuilder) TypedColumns(types []zng.Type) []zng.Column {
func (c *ColumnBuilder) TypedColumns(types []Type) []Column {
type rec struct {
name string
cols []zng.Column
cols []Column
}
current := &rec{"", nil}
stack := make([]*rec, 1)
Expand All @@ -237,14 +235,14 @@ func (c *ColumnBuilder) TypedColumns(types []zng.Type) []zng.Column {
stack = append(stack, current)
}

current.cols = append(current.cols, zng.NewColumn(fi.field.Leaf(), types[i]))
current.cols = append(current.cols, NewColumn(fi.field.Leaf(), types[i]))

for j := 0; j < fi.containerEnds; j++ {
recType := c.zctx.MustLookupTypeRecord(current.cols)
slen := len(stack)
stack = stack[:slen-1]
cur := stack[slen-2]
cur.cols = append(cur.cols, zng.NewColumn(current.name, recType))
cur.cols = append(cur.cols, NewColumn(current.name, recType))
current = cur
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/kernel/bufferfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func newBufferFilterForLiteral(l astzed.Primitive) (*expr.BufferFilter, error) {
// Could try to extract a pattern (e.g., "efg" from "(ab|cd)(efg)+[hi]").
return nil, nil
case "string":
// Match the behavior of zng.ParseLiteral.
// Match the behavior of zed.ParseLiteral.
l.Type = "bstring"
}
v, err := zson.ParsePrimitive(l.Type, l.Text)
Expand Down
8 changes: 4 additions & 4 deletions compiler/kernel/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"errors"
"fmt"

"github.com/brimdata/zed"
"github.com/brimdata/zed/compiler/ast/dag"
astzed "github.com/brimdata/zed/compiler/ast/zed"
"github.com/brimdata/zed/expr"
"github.com/brimdata/zed/expr/agg"
"github.com/brimdata/zed/expr/function"
"github.com/brimdata/zed/field"
"github.com/brimdata/zed/zng"
"github.com/brimdata/zed/zson"
)

Expand All @@ -33,13 +33,13 @@ import (
// each record type is like a schema and as we encounter them, we can compile
// optimized code for the now-static types within that record type.
//
// The Evaluator return by CompileExpr produces zng.Values that are stored
// The Evaluator return by CompileExpr produces zed.Values that are stored
// in temporary buffers and may be modified on subsequent calls to Eval.
// This is intended to minimize the garbage collection needs of the inner loop
// by not allocating memory on a per-Eval basis. For uses like filtering and
// aggregations, where the results are immediately used, this is desirable and
// efficient but for use cases like storing the results as groupby keys, the
// resulting zng.Value should be copied (e.g., via zng.Value.Copy()).
// resulting zed.Value should be copied (e.g., via zed.Value.Copy()).
//
// 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
Expand Down Expand Up @@ -469,7 +469,7 @@ func compileTypeValue(zctx *zson.Context, scope *Scope, t *astzed.TypeValue) (ex
if err != nil {
return nil, err
}
return expr.NewLiteral(zng.NewTypeValue(typ)), nil
return expr.NewLiteral(zed.NewTypeValue(typ)), nil
}

func compileRegexpMatch(zctx *zson.Context, scope *Scope, match *dag.RegexpMatch) (expr.Evaluator, error) {
Expand Down
Loading

0 comments on commit cc83c8f

Please sign in to comment.