pixi

package module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

README

pixi

A Go package providing an interface to read, write, and manipulate Pixi image/array files.

Documentation

Index

Constants

View Source
const (
	PixiFileType string = "pixi" // Every file starts with these four bytes.
	PixiVersion  int64  = 1      // Every file has a version number as the second set of four bytes.
)

Variables

This section is empty.

Functions

func NewBuffer

func NewBuffer(initialSize int) *buffer

func NewBufferFrom added in v0.0.9

func NewBufferFrom(underlying []byte) *buffer

func ReadMetadata

func ReadMetadata(r io.Reader) (string, string, error)

func WriteFixedSummary added in v0.0.8

func WriteFixedSummary(w io.Writer, d Summary) error

func WriteMetadata

func WriteMetadata(w io.Writer, key string, val string) error

func WriteSummary

func WriteSummary(w io.Writer, s Summary) error

Types

type AppendDataset

type AppendDataset struct {
	Summary
	WritingTileIndex uint
	WritingTile      AppendTile
	ReadCache        map[uint]*AppendTile
	MaxInCache       uint
	Backing          io.ReadWriteSeeker
}

func NewAppendDataset

func NewAppendDataset(d Summary, backing io.ReadWriteSeeker, maxInCache uint) (*AppendDataset, error)

Creates a new append dataset. It initializes the internal data structures and sets up the backing store.

func ReadAppend

func ReadAppend(r io.ReadWriteSeeker, ds Summary, maxInCache uint) (AppendDataset, error)

func (*AppendDataset) Finalize added in v0.0.3

func (d *AppendDataset) Finalize() error

func (*AppendDataset) GetRawSample added in v0.0.11

func (d *AppendDataset) GetRawSample(dimIndices []uint) ([]byte, error)

func (*AppendDataset) GetSample

func (d *AppendDataset) GetSample(dimIndices []uint) ([]any, error)

func (*AppendDataset) GetSampleField

func (d *AppendDataset) GetSampleField(dimIndices []uint, fieldId uint) (any, error)

func (*AppendDataset) SetSample

func (d *AppendDataset) SetSample(dimIndices []uint, sample []any) error

func (*AppendDataset) SetSampleField

func (d *AppendDataset) SetSampleField(dimIndices []uint, fieldId uint, fieldVal any) error

type AppendTile

type AppendTile struct {
	Dirty bool
	Data  []byte
}

type CacheDataset

type CacheDataset struct {
	Summary
	TileCache  map[uint]*CacheTile
	MaxInCache uint
	Backing    io.ReadWriteSeeker
}

func NewCacheDataset

func NewCacheDataset(d Summary, backing io.ReadWriteSeeker, maxInCache uint) (*CacheDataset, error)

func ReadCached

func ReadCached(r io.ReadWriteSeeker, ds Summary, maxInCache uint) (*CacheDataset, error)

func (*CacheDataset) Finalize added in v0.0.9

func (d *CacheDataset) Finalize() error

func (*CacheDataset) GetSample

func (d *CacheDataset) GetSample(dimIndices []uint) ([]any, error)

func (*CacheDataset) GetSampleField

func (d *CacheDataset) GetSampleField(dimIndices []uint, fieldId uint) (any, error)

func (*CacheDataset) SetSample

func (d *CacheDataset) SetSample(dimIndices []uint, sample []any) error

func (*CacheDataset) SetSampleField

func (d *CacheDataset) SetSampleField(dimIndices []uint, fieldId uint, fieldVal any) error

type CacheTile

type CacheTile struct {
	Dirty bool
	Data  []byte
}

type Compression

type Compression uint32
const (
	CompressionNone  Compression = 0
	CompressionFlate Compression = 1
)

type Dimension

type Dimension struct {
	Size     int64
	TileSize int32
}

func (Dimension) Tiles

func (d Dimension) Tiles() int

Returns the number of tiles in this dimension. The number of tiles is calculated by dividing the size of the dimension by the tile size, and then rounding up to the nearest whole number if there are any remaining bytes that do not fit into a full tile.

type Dimension64Iterator

type Dimension64Iterator struct {
	Value []int64
	Dims  []Dimension
}

func NewDimensionsIterator

func NewDimensionsIterator(dims []Dimension) *Dimension64Iterator

func (*Dimension64Iterator) HasNext

func (i *Dimension64Iterator) HasNext() bool

func (*Dimension64Iterator) Next

func (i *Dimension64Iterator) Next()

type DimensionU32Iterator

type DimensionU32Iterator struct {
	Value []uint
	Dims  []Dimension
}

func NewTileIndexIterator

func NewTileIndexIterator(dims []Dimension) *DimensionU32Iterator

func (*DimensionU32Iterator) HasNext

func (i *DimensionU32Iterator) HasNext() bool

func (*DimensionU32Iterator) Next

func (i *DimensionU32Iterator) Next()

type DimensionsError

type DimensionsError struct {
	GivenDims  int
	ActualDims int
}

func (DimensionsError) Error

func (d DimensionsError) Error() string

type Field

type Field struct {
	Name string
	Type FieldType
}

func (Field) Read

func (f Field) Read(raw []byte) any

func (Field) Size

func (f Field) Size() int64

func (Field) Write

func (f Field) Write(raw []byte, val any)

type FieldType

type FieldType uint32
const (
	FieldUnknown FieldType = 0
	FieldInt8    FieldType = 1
	FieldUint8   FieldType = 2
	FieldInt16   FieldType = 3
	FieldUint16  FieldType = 4
	FieldInt32   FieldType = 5
	FieldUint32  FieldType = 6
	FieldInt64   FieldType = 7
	FieldUint64  FieldType = 8
	FieldFloat32 FieldType = 9
	FieldFloat64 FieldType = 10
)

func (FieldType) Read

func (f FieldType) Read(raw []byte) any

This function reads the value of a given FieldType from the provided raw byte slice. The read operation is type-dependent, with each field type having its own specific method for reading values. This ensures that the correct data is read and converted into the expected format.

func (FieldType) Size

func (f FieldType) Size() int64

This function returns the size of a field in bytes.

func (FieldType) Write

func (f FieldType) Write(raw []byte, val any)

This function writes a value of any type into bytes according to the specified FieldType. The written bytes are stored in the provided byte array. This function will panic if the FieldType is unknown or if an unsupported field type is encountered.

type FormatError

type FormatError string

func (FormatError) Error

func (e FormatError) Error() string

type InMemoryDataset

type InMemoryDataset struct {
	Summary
	TileSet [][]byte
}

func NewInMemoryDataset

func NewInMemoryDataset(d Summary) (*InMemoryDataset, error)

func ReadInMemory

func ReadInMemory(r io.ReadSeeker, ds Summary) (InMemoryDataset, error)

func (*InMemoryDataset) GetSample

func (d *InMemoryDataset) GetSample(dimIndices []uint) ([]any, error)

func (*InMemoryDataset) GetSampleField

func (d *InMemoryDataset) GetSampleField(dimIndices []uint, fieldId uint) (any, error)

func (*InMemoryDataset) SetSample

func (d *InMemoryDataset) SetSample(dimIndices []uint, sample []any) error

func (*InMemoryDataset) SetSampleField

func (d *InMemoryDataset) SetSampleField(dimIndices []uint, fieldId uint, fieldVal any) error

type RangeError

type RangeError struct {
	Specified int
	ValidMin  int
	ValidMax  int
}

func (RangeError) Error

func (e RangeError) Error() string

type Summary

type Summary struct {
	Metadata map[string]string
	// Indicates whether the fields of the dataset are stored separated or contiguously. If true,
	// values for each field are stored next to each other. If false, the default, values for each
	// index are stored next to each other, with values for different fields stored next to each
	// other at the same index.
	Separated   bool
	Compression Compression // The type of compression used on this dataset (e.g., Flate, lz4).
	// An array of Dimension structs representing the dimensions and tiling of this dataset.
	// No dimensions equals an empty dataset.
	Dimensions []Dimension
	Fields     []Field // An array of Field structs representing the fields in this dataset.
	TileBytes  []int64 // An array of int64 values representing (compressed) size of each tile in bytes for this dataset.
}

Information about how data is stored and organized for a particular data set inside a pixi file.

func ReadFixedSummary added in v0.0.8

func ReadFixedSummary(r io.Reader) (Summary, error)

func ReadSummary

func ReadSummary(r io.ReadSeeker) (Summary, error)

func (*Summary) DataSize added in v0.0.8

func (d *Summary) DataSize() int64

The on-disk size in bytes of the (potentially compressed) data set. Does not include the dataset header size.

func (*Summary) DiskDataStart added in v0.0.8

func (d *Summary) DiskDataStart() int64

func (*Summary) DiskHeaderSize added in v0.0.8

func (d *Summary) DiskHeaderSize() int64

func (*Summary) DiskMetadataSize added in v0.0.8

func (d *Summary) DiskMetadataSize() int64

func (*Summary) DiskTileOffset added in v0.0.10

func (d *Summary) DiskTileOffset(tileIndex int) int64

The offset from the start of the on-disk (potentially compressed) file in which the tile is stored. Relative to the start of the file, not the data set Offset.

func (*Summary) SampleSize added in v0.0.8

func (d *Summary) SampleSize() int64

The size in bytes of each sample in the data set. Each field has a fixed size, and a sample is made up of one element of each field, so the sample size is the sum of all field sizes.

func (*Summary) Samples added in v0.0.8

func (d *Summary) Samples() int64

The total number of samples in the data set. If the tile size of any dimension is not a multiple of the dimension size, the 'padding' samples are not included in the count.

func (*Summary) TileSamples added in v0.0.8

func (d *Summary) TileSamples() int64

The number of samples per tile in the data set. Each tile has the same number of samples, regardless of if the data is stored separated or continguous.

func (*Summary) TileSize added in v0.0.8

func (d *Summary) TileSize(tileIndex int) int64

The size of a single tile in bytes. For contiguous files, the size of each tile is always the same. However, for separated data sets, each field is tiled (so the number of on-disk tiles is actually fieldCount * Tiles()). Hence, the tile size changes depending on which field is being accessed.

func (*Summary) Tiles added in v0.0.8

func (d *Summary) Tiles() int

type UnsupportedError

type UnsupportedError string

func (UnsupportedError) Error

func (e UnsupportedError) Error() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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