mslice

package module
v0.0.0-...-4004381 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 5 Imported by: 0

README

mslice

Generic mmap'd slices

This package facilitates the creation of a mmap'd back slice of type T. It uses the unsafe package so those caveats apply.

Note: this will break if appending to the slice exceeds the initial capacity.

Disclaimer: not heavily tested so discretion is advised.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAppend = fmt.Errorf("append exceeds size")

ErrAppend is when we go past the mmap limit TODO: make it extendable

Functions

This section is empty.

Types

type Byter

type Byter interface {
	Size() int
	Flush() error
	Close() error
	Decode(int, Decoder) error
	Encode(int, Encoder) error
}

func NewByteFile

func NewByteFile(filename string, length int64) (Byter, error)

func OpenByteFile

func OpenByteFile(filename string, writable bool) (Byter, error)

type Decoder

type Decoder interface {
	Decode([]byte) error
	Size() int
}

type Encoder

type Encoder interface {
	Encode([]byte) error
	Size() int
}

type Flusher

type Flusher interface {
	Flush() error
	Close() error
}

type SliceFile

type SliceFile interface {
	Flusher
	Cap() int
	Len() int
	Append(...Encoder) error
	Set(int, Encoder) error
	Get(int, Decoder) error
}

func NewSlice

func NewSlice(filename string, length, cap int, slicePtr interface{}) (SliceFile, error)

NewSlice takes a pointer to an empty slice and converts it into a mmap'd slice of the requested capacity NOTE: the object must comprise only fixed size elements, i.e., numbers

func OpenSlice

func OpenSlice(filename string, writable bool, slicePtr interface{}) (SliceFile, error)

OpenAny takes a pointer to an empty slice and converts it into a mmap'd slice of the requested capacity

type Transcoder

type Transcoder interface {
	Encoder
	Decoder
}

Jump to

Keyboard shortcuts

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