hep: go-hep.org/x/hep/sio Index | Files | Directories

package sio

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

Package sio implements a record-oriented persistency mechanism.

Index

Package Files

block.go decoder.go defs.go doc.go encoder.go errors.go record.go sio.go stream.go

Variables

var (
    ErrStreamNoRecMarker   = errors.New("sio: no record marker found")
    ErrRecordNoBlockMarker = errors.New("sio: no block marker found")
    ErrBlockConnected      = errors.New("sio: block already connected")

    // ErrBlockShortRead means that the deserialization of a SIO block
    // read too few bytes with regard to what was written out in the
    // Block header length.
    ErrBlockShortRead = errors.New("sio: read too few bytes")
)

type Block Uses

type Block interface {
    Codec
    Versioner

    Name() string
}

Block is the interface implemented by an object that can be stored to (and loaded from) an SIO stream.

type Codec Uses

type Codec interface {
    Marshaler
    Unmarshaler
}

Code is the interface implemented by an object that can unmarshal and marshal itself from and to a binary, sio-compatible, form.

type Decoder Uses

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

Decoder decodes SIO streams. Decoder provides a nice API to deal with errors that may occur during decoding.

func NewDecoder Uses

func NewDecoder(r Reader) *Decoder

NewDecoder creates a new Decoder reading from the provided sio.Reader.

func (*Decoder) Decode Uses

func (dec *Decoder) Decode(ptr interface{})

Decode reads the next value from the input sio stream and stores it in the data, an empty interface value wrapping a pointer to a concrete value.

func (*Decoder) Err Uses

func (dec *Decoder) Err() error

Err returns the first encountered error while decoding, if any.

func (*Decoder) Pointer Uses

func (dec *Decoder) Pointer(ptr interface{})

Pointer marks a (pointer to a) pointer, assigning it a unique identifier, so links between values (inside a given SIO record) can be rebuilt.

func (*Decoder) Tag Uses

func (dec *Decoder) Tag(ptr interface{})

Tag tags a pointer, assigning it a unique identifier, so links between values (inside a given SIO record) can be rebuilt.

type Encoder Uses

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

Encoder encodes values into a SIO stream. Encoder provides a nice API to deal with errors that may occur during encoding.

func NewEncoder Uses

func NewEncoder(w Writer) *Encoder

NewEncoder creates a new Encoder writing to the provided sio.Writer.

func (*Encoder) Encode Uses

func (enc *Encoder) Encode(data interface{})

Encode writes the next value to the output sio stream.

func (*Encoder) Err Uses

func (dec *Encoder) Err() error

Err returns the first encountered error while decoding, if any.

func (*Encoder) Pointer Uses

func (enc *Encoder) Pointer(ptr interface{})

Pointer marks a (pointer to a) pointer, assigning it a unique identifier, so links between values (inside a given SIO record) can be stored.

func (*Encoder) Tag Uses

func (enc *Encoder) Tag(ptr interface{})

Tag tags a pointer, assigning it a unique identifier, so links between values (inside a given sio record) can be stored.

type Linker Uses

type Linker interface {
    LinkSio(v uint32) error
}

Linker is the interface implemented by an object that needs to recompute (internal) pointers, after the sio layer had performed pointer tagging/chasing relocation.

type Marshaler Uses

type Marshaler interface {
    MarshalSio(w Writer) error
}

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

type Operation Uses

type Operation int
const (
    OpRead Operation = iota
    OpWrite
)

type Reader Uses

type Reader interface {
    io.Reader

    Versioner
    Tag(ptr interface{}) error
    Pointer(ptr interface{}) error
}

Reader is the interface that wraps the basic io.Reader interface and adds SIO pointer tagging capabilities.

type Record Uses

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

Record manages blocks of data

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) Disconnect Uses

func (rec *Record) Disconnect()

Disconnect disconnects all blocks previously connected 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() uint32

Options returns the options of this record.

func (*Record) SetCompress Uses

func (rec *Record) SetCompress(compress bool)

SetCompress sets or resets the compression flag

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

type Stream Uses

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

Stream manages operations of a single RIO stream.

func Create Uses

func Create(fname string) (*Stream, error)

Create opens and connects a RIO stream to a file for writing

func Open Uses

func Open(fname string) (*Stream, error)

Open opens and connects a RIO stream to a file for reading

func (*Stream) Close Uses

func (stream *Stream) Close() error

Close closes a stream and the underlying file

func (*Stream) CurPos Uses

func (stream *Stream) CurPos() int64

CurPos returns the current position in the file

-1 if error

func (*Stream) DelRecord Uses

func (stream *Stream) DelRecord(n string)

DelRecord removes the Record with name n from this Stream. DelRecord is a no-op if such a Record was not known to the Stream.

func (*Stream) Fd Uses

func (stream *Stream) Fd() uintptr

Fd returns the integer Unix file descriptor referencing the underlying open file.

func (*Stream) FileName Uses

func (stream *Stream) FileName() string

FileName returns the name of the file connected to that stream

func (*Stream) HasRecord Uses

func (stream *Stream) HasRecord(n string) bool

HasRecord returns whether a Record with name n has been added to this Stream

func (*Stream) Mode Uses

func (stream *Stream) Mode() (os.FileMode, error)

Mode returns the stream mode (as os.FileMode)

func (*Stream) Name Uses

func (stream *Stream) Name() string

Name returns the stream name

func (*Stream) ReadRecord Uses

func (stream *Stream) ReadRecord() (*Record, error)

ReadRecord reads the next record

func (*Stream) Record Uses

func (stream *Stream) Record(name string) *Record

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

func (*Stream) Records Uses

func (stream *Stream) Records() []*Record

Records returns the list of Records currently attached to this Stream.

func (*Stream) Seek Uses

func (stream *Stream) Seek(offset int64, whence int) (int64, error)

Seek sets the offset for the next Read or Write on the stream to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

func (*Stream) SetCompressionLevel Uses

func (stream *Stream) SetCompressionLevel(lvl int)

SetCompressionLevel sets the (zlib) compression level

func (*Stream) Stat Uses

func (stream *Stream) Stat() (os.FileInfo, error)

Stat returns the FileInfo structure describing underlying file. If there is an error, it will be of type *os.PathError.

func (*Stream) Sync Uses

func (stream *Stream) Sync() error

Sync commits the current contents of the stream to stable storage.

func (*Stream) WriteRecord Uses

func (stream *Stream) WriteRecord(record *Record) error

type Unmarshaler Uses

type Unmarshaler interface {
    UnmarshalSio(r Reader) error
}

Unmarshaler is the interface implemented by an object that can unmarshal a binary, sio-compatible, representation of itself.

type Versioner Uses

type Versioner interface {
    VersionSio() uint32
}

Versioner is the interface implemented by an object that tells which version of SIO serialization/deserialization it supports.

type Writer Uses

type Writer interface {
    io.Writer

    Versioner
    Tag(ptr interface{}) error
    Pointer(ptr interface{}) error
}

Writer is the interface that wraps the basic io.Writer interface and adds SIO pointer tagging capabilities.

Directories

PathSynopsis
cmd/sio-ls-records

Package sio imports 11 packages (graph) and is imported by 2 packages. Updated 2019-02-21. Refresh now. Tools for package owners.