column

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: 6 Imported by: 0

Documentation

Overview

Package column implements the organization of columns on storage for a zst columnar storage object.

A zst object is created by allocating a RecordWriter for a top-level zng row type (i.e., "schema") via NewRecordWriter. The object to be written to is wrapped in a Spiller with a column threshold. Output is streamed to the underlying spiller in a single pass. (In the future, we may implement multiple passes to optimize the storage layout of column data or spread a given zst object across multiple

NewRecordWriter recursively decends the record type, allocating a column Writer for each node in the type tree. The top-level record body is written via a call to Write and all of the columns are called with their respetive values represented as a zcode.Bytes. The columns buffer data in memorry until they reach their byte threshold or until Flush is called.

After all of the zng data is written, a reassembly record may be formed for the RecordColumn by calling its MarshalZNG method, which builds the record value in place using zcode.Builder and returns the zed.TypeRecord (i.e., schema) of that record column.

Data is read from a zst file by scanning the reassembly records then unmarshaling a zed.Record body into an empty Record by calling Record.UnmarshalZNG, which recusirvely builds an assembly structure. An io.ReaderAt is passed to unmarshal so each column reader can access the underlying storage object and read its column data effciently in largish column chunks.

Once an assembly is built, the recontructed zng row data can be read from the assembly by calling the Read method on the top-level Record and passing in a zcode.Builder to reconstruct the record body in place. The assembly does not need any type information as the structure of values is entirely self describing in the zng data format.

Index

Constants

View Source
const MaxSegmentThresh = 20 * 1024 * 1024
View Source
const SegmapTypeString = "[{offset:int64,length:int32}]"

Variables

View Source
var ErrColumnMismatch = errors.New("zng record value doesn't match column writer")
View Source
var ErrCorruptSegment = errors.New("segmap value corrupt")
View Source
var ErrNonRecordAccess = errors.New("attempting to access a field in a non-record value")

Functions

func UnmarshalSegmap

func UnmarshalSegmap(in zed.Value, s *[]Segment) error

func UnmarshalSegment

func UnmarshalSegment(zv zcode.Bytes, s *Segment) error

Types

type Array

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

func (*Array) Read

func (a *Array) Read(b *zcode.Builder) error

func (*Array) UnmarshalZNG

func (a *Array) UnmarshalZNG(inner zed.Type, in zed.Value, r io.ReaderAt) error

type ArrayWriter

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

func NewArrayWriter

func NewArrayWriter(inner zed.Type, spiller *Spiller) *ArrayWriter

func (*ArrayWriter) Flush

func (a *ArrayWriter) Flush(eof bool) error

func (*ArrayWriter) MarshalZNG

func (a *ArrayWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error)

func (*ArrayWriter) Write

func (a *ArrayWriter) Write(body zcode.Bytes) error

type Field

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

func (*Field) Read

func (f *Field) Read(b *zcode.Builder) error

func (*Field) UnmarshalZNG

func (f *Field) UnmarshalZNG(typ zed.Type, in zed.Value, r io.ReaderAt) error

type FieldWriter

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

func (*FieldWriter) Flush

func (f *FieldWriter) Flush(eof bool) error

func (*FieldWriter) MarshalZNG

func (f *FieldWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error)

type Int

type Int struct {
	Primitive
}

func (*Int) Read

func (p *Int) Read() (int32, error)

type IntWriter

type IntWriter struct {
	PrimitiveWriter
}

func NewIntWriter

func NewIntWriter(spiller *Spiller) *IntWriter

func (*IntWriter) Write

func (p *IntWriter) Write(v int32) error

type Interface

type Interface interface {
	Read(*zcode.Builder) error
}

func Unmarshal

func Unmarshal(typ zed.Type, in zed.Value, r io.ReaderAt) (Interface, error)

type Presence

type Presence struct {
	Int
	// contains filtered or unexported fields
}

func NewPresence

func NewPresence() *Presence

func (*Presence) IsEmpty

func (p *Presence) IsEmpty() bool

func (*Presence) Read

func (p *Presence) Read() (bool, error)

type PresenceWriter

type PresenceWriter struct {
	IntWriter
	// contains filtered or unexported fields
}

func NewPresenceWriter

func NewPresenceWriter(spiller *Spiller) *PresenceWriter

func (*PresenceWriter) Finish

func (p *PresenceWriter) Finish()

func (*PresenceWriter) TouchUnset

func (p *PresenceWriter) TouchUnset()

func (*PresenceWriter) TouchValue

func (p *PresenceWriter) TouchValue()

type Primitive

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

func (*Primitive) Read

func (p *Primitive) Read(b *zcode.Builder) error

func (*Primitive) UnmarshalZNG

func (p *Primitive) UnmarshalZNG(in zed.Value, reader io.ReaderAt) error

type PrimitiveWriter

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

func NewPrimitiveWriter

func NewPrimitiveWriter(spiller *Spiller) *PrimitiveWriter

func (*PrimitiveWriter) Flush

func (p *PrimitiveWriter) Flush(eof bool) error

func (*PrimitiveWriter) MarshalZNG

func (p *PrimitiveWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error)

func (*PrimitiveWriter) Write

func (p *PrimitiveWriter) Write(body zcode.Bytes) error

type Record

type Record []*Field

func (Record) Lookup

func (r Record) Lookup(typ *zed.TypeRecord, fields []string) (zed.Type, Interface, error)

func (Record) Read

func (r Record) Read(b *zcode.Builder) error

func (*Record) UnmarshalZNG

func (r *Record) UnmarshalZNG(typ *zed.TypeRecord, in zed.Value, reader io.ReaderAt) error

type RecordWriter

type RecordWriter []*FieldWriter

func NewRecordWriter

func NewRecordWriter(typ *zed.TypeRecord, spiller *Spiller) RecordWriter

func (RecordWriter) Flush

func (r RecordWriter) Flush(eof bool) error

func (RecordWriter) MarshalZNG

func (r RecordWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error)

func (RecordWriter) Write

func (r RecordWriter) Write(body zcode.Bytes) error

type Segment

type Segment struct {
	Offset int64
	Length int64
}

func (Segment) NewSectionReader

func (s Segment) NewSectionReader(r io.ReaderAt) io.Reader

type Spiller

type Spiller struct {
	Thresh int
	// contains filtered or unexported fields
}

func NewSpiller

func NewSpiller(w io.Writer, thresh int) *Spiller

func (*Spiller) Position

func (s *Spiller) Position() int64

func (*Spiller) Write

func (s *Spiller) Write(segments []Segment, b zcode.Bytes) ([]Segment, error)

type Union

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

func (*Union) Read

func (u *Union) Read(b *zcode.Builder) error

func (*Union) UnmarshalZNG

func (u *Union) UnmarshalZNG(typ *zed.TypeUnion, in zed.Value, r io.ReaderAt) error

type UnionWriter

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

func NewUnionWriter

func NewUnionWriter(typ *zed.TypeUnion, spiller *Spiller) *UnionWriter

func (*UnionWriter) Flush

func (u *UnionWriter) Flush(eof bool) error

func (*UnionWriter) MarshalZNG

func (u *UnionWriter) MarshalZNG(zctx *zed.Context, b *zcode.Builder) (zed.Type, error)

func (*UnionWriter) Write

func (u *UnionWriter) Write(body zcode.Bytes) error

type Writer

type Writer interface {
	// Write encodes the given value into memory.  When the column exceeds
	// a threshold, it is automatically flushed.  Flush may also be called
	// explicitly to push columns to storage and thus avoid too much row skew
	// between columns.
	Write(zcode.Bytes) error
	// Push all in-memory column data to the storage layer.
	Flush(bool) error
	// MarshalZNG is called after all data is flushed to build the reassembly
	// record for this column.
	MarshalZNG(*zed.Context, *zcode.Builder) (zed.Type, error)
}

func NewWriter

func NewWriter(typ zed.Type, spiller *Spiller) Writer

Jump to

Keyboard shortcuts

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