zbuf

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: BSD-3-Clause Imports: 10 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

Types

type Array

type Array []*zed.Record

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.Record)

func (Array) Index

func (a Array) Index(k int) *zed.Record

XXX should change this to Record()

func (Array) Length

func (a Array) Length() int

func (Array) NewReader

func (a Array) NewReader() zio.Reader

func (*Array) Read

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

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

func (Array) Records

func (a Array) Records() []*zed.Record

func (Array) Ref

func (a Array) Ref()

func (Array) Unref

func (a Array) Unref()

func (*Array) Write

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

type Batch

type Batch interface {
	Ref()
	Unref()
	Index(int) *zed.Record
	Length() int
	Records() []*zed.Record
}

Batch is an interface to a bundle of records. 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 records 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 *zed.Record from a Batch must retain its Batch reference for as long as it retains the pointer, and the goroutine must not use the pointer 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 MergeByTs

func MergeByTs(ctx context.Context, pullers []Puller, o order.Which) *Merger

func NewMerger

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

func (*Merger) Cancel

func (m *Merger) Cancel()

func (*Merger) Pull

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

func (*Merger) Read

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

Read fulfills Reader so that we can use ReadBatch or use Merger as a Reader directly.

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
	BytesMatched   int64
	RecordsRead    int64
	RecordsMatched int64
}

ScannerStats holds Scanner statistics. It should be identical to api.ScannerStats.

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