hep: go-hep.org/x/hep/rio Index | Files

package rio

import "go-hep.org/x/hep/rio"

Package rio is a record-oriented persistency mechanism.

Index

Package Files

block.go compressor.go doc.go file.go reader.go record.go rio.go scanner.go utils.go writer.go

Constants

const (

    // Name of the metadata record holding Metadata informations about the rio stream
    MetaRecord = ".rio.meta"
)

Variables

var (

    // Endian exposes the endianness of rio streams
    Endian = binary.LittleEndian
)

func RegisterCompressor Uses

func RegisterCompressor(kind CompressorKind, x Xpressor)

RegisterCompressor registers a compressor/decompressor. It silently replaces the compressor/decompressor if one was already registered.

type Block Uses

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

Block manages and desribes a block of data

func (*Block) Name Uses

func (blk *Block) Name() string

Name returns the name of this block

func (*Block) Read Uses

func (blk *Block) Read(data interface{}) error

Read reads data from the Reader, in the rio format

func (*Block) RioVersion Uses

func (blk *Block) RioVersion() Version

RioVersion returns the rio-binary version of the block

func (*Block) Write Uses

func (blk *Block) Write(data interface{}) error

Write writes data to the Writer, in the rio format

type BlockDesc Uses

type BlockDesc struct {
    Name string
    Type string
}

BlockDesc provides high-level informations about a Block

type Compressor Uses

type Compressor interface {
    io.WriteCloser

    // Reset clears the state of the Writer such that it is equivalent to its
    // initial state, but instead writing to w.
    Reset(w io.Writer) error

    // Flush flushes the Writer to its underlying io.Writer.
    Flush() error
}

A Compressor takes data written to it and writes the compressed form of that data to an underlying writer.

type CompressorKind Uses

type CompressorKind uint16

CompressorKind names the various compressors

const (
    CompressDefault CompressorKind = iota
    CompressNone
    CompressFlate
    CompressZlib
    CompressGzip
    CompressLZA
    CompressLZO
    CompressSnappy

    CompressUser CompressorKind = 0xffff // keep last
)

builtin compressor types

func (CompressorKind) NewCompressor Uses

func (ck CompressorKind) NewCompressor(w io.Writer, opts Options) (Compressor, error)

NewCompressor creates a Compressor writing to w, with compression level according to opts.

func (CompressorKind) NewDecompressor Uses

func (ck CompressorKind) NewDecompressor(r io.Reader) (Decompressor, error)

NewDecompressor creates a Decompressor reading from r.

func (CompressorKind) String Uses

func (ck CompressorKind) String() string

type Decompressor Uses

type Decompressor interface {
    io.ReadCloser

    // Reset clears the state of the Reader such that it is equivalent to its
    // initial state, but instead reading from r.
    Reset(r io.Reader) error
}

A Decompressor reads data from the underlying io.Reader and decompresses it.

type File Uses

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

File random-read-access to a rio stream

func Open Uses

func Open(r io.ReadSeeker) (*File, error)

Open creates a new read-only File.

func (*File) Close Uses

func (f *File) Close() error

Close closes access to the rio-file. It does not (and can not) close the underlying reader.

func (*File) Get Uses

func (f *File) Get(name string, ptr interface{}) error

Get reads the value `name` into `ptr`

func (*File) Has Uses

func (f *File) Has(name string) bool

Has returns whether a record `name` exists in this file.

func (*File) Keys Uses

func (f *File) Keys() []RecordDesc

Keys returns the list of record names.

type Marshaler Uses

type Marshaler interface {
    RioMarshal(w io.Writer) error
}

Marshaler is the interface implemented by an object that can marshal itself into a rio-binary form.

RioMarshal marshals the receiver into a rio-binary form, writes that binary form to the io.Writer and returns an error if any.

type Metadata Uses

type Metadata struct {
    Records []RecordDesc
    Offsets map[string][]Span
}

Metadata stores metadata about a rio stream

type Options Uses

type Options uint32

Options describes the various options attached to a rio stream such as: compression method, compression level, codec, ...

func NewOptions Uses

func NewOptions(compr CompressorKind, lvl int, codec int) Options

NewOptions returns a new Options value carefully crafted from the CompressorKind and compression level

func (Options) CompressorCodec Uses

func (o Options) CompressorCodec() int

CompressorCodec extracts the compression codec from the Options value

func (Options) CompressorKind Uses

func (o Options) CompressorKind() CompressorKind

CompressorKind extracts the CompressorKind from the Options value

func (Options) CompressorLevel Uses

func (o Options) CompressorLevel() int

CompressorLevel extracts the compression level from the Options value

type Reader Uses

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

Reader is a rio read-only stream

func NewReader Uses

func NewReader(r io.Reader) (*Reader, error)

NewReader returns a new read-only rio stream

func (*Reader) Close Uses

func (r *Reader) Close() error

Close finishes reading the rio read-only stream. It does not (and can not) close the underlying reader.

func (*Reader) Record Uses

func (r *Reader) Record(name string) *Record

Record adds a Record to the list of records to read or returns the Record with that name.

func (*Reader) Records Uses

func (r *Reader) Records() []*Record

Records returns the list of connected Records

type Record Uses

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

Record manages and describes blocks of data

func (*Record) Block Uses

func (rec *Record) Block(name string) *Block

Block returns the block named name for reading or writing Block returns nil if the block doesn't exist

func (*Record) Compress Uses

func (rec *Record) Compress() bool

Compress returns the compression flag

func (*Record) Connect Uses

func (rec *Record) Connect(name string, ptr interface{}) error

Connect connects a Block to this Record (for reading or writing)

func (*Record) Name Uses

func (rec *Record) Name() string

Name returns the name of this record

func (*Record) Options Uses

func (rec *Record) Options() Options

Options returns the options of this record.

func (*Record) Read Uses

func (rec *Record) Read() error

Read reads data from the Reader, in the rio format

func (*Record) SetUnpack Uses

func (rec *Record) SetUnpack(unpack bool)

SetUnpack sets whether to unpack incoming records

func (*Record) Unpack Uses

func (rec *Record) Unpack() bool

Unpack returns whether to unpack incoming records

func (*Record) Write Uses

func (rec *Record) Write() error

Write writes data to the Writer, in the rio format

type RecordDesc Uses

type RecordDesc struct {
    Name   string
    Blocks []BlockDesc
}

RecordDesc provides high-level informations about a Record

type Scanner Uses

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

Scanner provides a convenient interface for reading records of a rio-stream.

func NewScanner Uses

func NewScanner(r *Reader) *Scanner

NewScanner returns a new Scanner to read from r.

func (*Scanner) Err Uses

func (s *Scanner) Err() error

Err returns the first non-EOF error encountered by the reader.

func (*Scanner) Record Uses

func (s *Scanner) Record() *Record

Record returns the last Record read by the Scanner.

func (*Scanner) Scan Uses

func (s *Scanner) Scan() bool

Scan scans the next Record until io.EOF

func (*Scanner) Select Uses

func (s *Scanner) Select(selectors []Selector)

Select sets the records selection function.

type Selector Uses

type Selector struct {
    Name   string // Record name
    Unpack bool   // Whether to unpack the Record
}

Selector selects Records based on their name

type Span Uses

type Span struct {
    Pos int64
    Len int64
}

Span is a pair (position, length)

type Streamer Uses

type Streamer interface {
    Marshaler
    Unmarshaler
    RioVersion() Version
}

Streamer is the interface implemented by an object that can marshal/unmarshal a rio-binary representation of itself to/from an io.Writer/io.Reader.

type Unmarshaler Uses

type Unmarshaler interface {
    RioUnmarshal(r io.Reader) error
}

Unmarshalr is the interface implemented by an object that can unmarshal a rio-binary representation of itself.

RioUnmarshal must be able to unmarshal the form generated by RioMarshal.

type Version Uses

type Version uint32

Version describes a rio on-disk version of a serialized block.

type Writer Uses

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

Writer is a rio write-only stream

func NewWriter Uses

func NewWriter(w io.Writer) (*Writer, error)

NewWriter returns a new write-only rio stream

func (*Writer) Close Uses

func (w *Writer) Close() error

Close finishes writing the rio write-only stream. It does not (and can not) close the underlying writer.

func (*Writer) Record Uses

func (w *Writer) Record(name string) *Record

Record adds a Record to the list of records to write or returns the Record with that name.

func (*Writer) SetCompressor Uses

func (w *Writer) SetCompressor(compr CompressorKind, lvl int) error

SetCompressor enables compression and sets the compression method.

func (*Writer) WriteValue Uses

func (w *Writer) WriteValue(name string, value interface{}) error

WriteValue writes a value to the stream. The value is written to a record named `name` with one block `name`.

type Xpressor Uses

type Xpressor interface {
    Inflate(r io.Reader) (Decompressor, error)
    Deflate(w io.Writer, opts Options) (Compressor, error)
}

Xpressor provides compressor and decompressor functions

Package rio imports 12 packages (graph) and is imported by 7 packages. Updated 2018-11-24. Refresh now. Tools for package owners.