zbuf

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2021 License: BSD-3-Clause Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ScannerBatchSize = 100

Functions

func CopyPuller

func CopyPuller(w zio.Writer, p Puller) error

func NamedScanner

func NamedScanner(s Scanner, name string) *namedScanner

func NewCompareFn

func NewCompareFn(layout order.Layout) expr.CompareFn

func PullerReader

func PullerReader(p Puller) zio.Reader

func ScannerNopCloser

func ScannerNopCloser(s Scanner) *nopCloser

func WriteBatch added in v0.32.0

func WriteBatch(zw zio.Writer, batch Batch) error

WriteBatch writes the values in batch to zw. If an error occurs, WriteBatch stops and returns the error.

Types

type Array

type Array []zed.Value

Array is a slice of of records that implements the Batch and the Reader interfaces.

func ReadAll

func ReadAll(r zio.Reader) (arr Array, err error)

func (*Array) Append

func (a *Array) Append(r *zed.Value)

func (Array) NewReader

func (a Array) NewReader() zio.Reader

func (*Array) Read

func (a *Array) Read() (*zed.Value, error)

Read returns removes the first element of the Array and returns it, or it returns nil if the Array is empty.

func (Array) Ref

func (a Array) Ref()

func (Array) Unref

func (a Array) Unref()

func (Array) Values added in v0.32.0

func (a Array) Values() []zed.Value

func (*Array) Write

func (a *Array) Write(r *zed.Value) error

type Batch

type Batch interface {
	Ref()
	Unref()
	Values() []zed.Value
}

Batch is an interface to a bundle of values. Reference counting allows efficient, safe reuse in concert with sharing across goroutines.

A newly obtained Batch always has a reference count of one. The Batch owns its values and their storage, and an implementation may reuse this memory when the reference count falls to zero, reducing load on the garbage collector.

To promote reuse, a goroutine should release a Batch reference when possible, but care must be taken to avoid race conditions that arise from releasing a reference too soon. Specifically, a goroutine obtaining a value from a Batch must retain its Batch reference for as long as it retains the value, and the goroutine must not use the value after releasing its reference.

Regardless of reference count or implementation, an unreachable Batch will eventually be reclaimed by the garbage collector.

type File

type File struct {
	zio.Reader
	// contains filtered or unexported fields
}

func NewFile

func NewFile(r zio.Reader, c io.Closer, name string) *File

func (*File) Close

func (r *File) Close() error

func (*File) String

func (r *File) String() string

type Filter

type Filter interface {
	AsFilter() (expr.Filter, error)
	AsBufferFilter() (*expr.BufferFilter, error)
}

type Merger

type Merger struct {
	// contains filtered or unexported fields
}

A Merger merges multiple upstream Pullers into one downstream Puller. If the input streams are ordered according to the configured comparison, the output of Merger will have the same order. Each parent puller is run in its own goroutine so that deadlock is avoided when the upstream pullers would otherwise block waiting for an adjacent puller to finish but the Merger is waiting on the upstream puller.

func NewMerger

func NewMerger(ctx context.Context, pullers []Puller, cmp expr.CompareFn) *Merger

func (*Merger) Cancel

func (m *Merger) Cancel()

func (*Merger) Len added in v0.32.0

func (m *Merger) Len() int

func (*Merger) Less added in v0.32.0

func (m *Merger) Less(i, j int) bool

func (*Merger) Pop added in v0.32.0

func (m *Merger) Pop() interface{}

func (*Merger) Pull

func (m *Merger) Pull() (Batch, error)

func (*Merger) Push added in v0.32.0

func (m *Merger) Push(x interface{})

func (*Merger) Read

func (m *Merger) Read() (*zed.Value, error)

func (*Merger) Swap added in v0.32.0

func (m *Merger) Swap(i, j int)

type MultiStats

type MultiStats []Scanner

func (MultiStats) Stats

func (m MultiStats) Stats() ScannerStats

type Puller

type Puller interface {
	Pull() (Batch, error)
}

A Puller produces Batches of records, signaling end-of-stream by returning a nil Batch and nil error.

func NewPuller

func NewPuller(zr zio.Reader, n int) Puller

NewPuller returns a Puller for zr that returns Batches of up to n records.

type PullerCloser

type PullerCloser interface {
	Puller
	io.Closer
}

type Scanner

type Scanner interface {
	Statser
	Puller
}

A Scanner is a Batch source that also provides statistics.

func NewScanner

func NewScanner(ctx context.Context, r zio.Reader, filterExpr Filter) (Scanner, error)

NewScanner returns a Scanner for r that filters records by filterExpr and s.

type ScannerAble

type ScannerAble interface {
	NewScanner(ctx context.Context, filterExpr Filter) (Scanner, error)
}

ScannerAble is implemented by Readers that provide an optimized implementation of the Scanner interface.

type ScannerCloser

type ScannerCloser interface {
	Scanner
	io.Closer
}

type ScannerStats

type ScannerStats struct {
	BytesRead      int64 `zed:"bytes_read" json:"bytes_read"`
	BytesMatched   int64 `zed:"bytes_matched" json:"bytes_matched"`
	RecordsRead    int64 `zed:"records_read" json:"records_read"`
	RecordsMatched int64 `zed:"records_matched" json:"records_matched"`
}

ScannerStats holds Scanner statistics.

func (*ScannerStats) Add

func (s *ScannerStats) Add(in ScannerStats)

Add updates its receiver by adding to it the values in ss.

func (*ScannerStats) Copy

func (s *ScannerStats) Copy() ScannerStats

type Statser

type Statser interface {
	Stats() ScannerStats
}

A Statser produces scanner statistics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL