mmarray

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 9 Imported by: 0

README

mmarray

Memory-mapped array types.

Example

a, _ := mmarray.NewTempByteArray(".")
a.SetCap(1024 * 1024 * 1024)
a.SetLen(a.Cap())
a.Map()
rand.Read(a.V)
a.Close()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array interface {
	Open(path string, mode int) error

	Closed() bool
	Mapped() bool
	Writable() bool

	Path() string

	Map()
	Unmap()

	Len() int64
	SetLen(int64)

	Cap() int64
	SetCap(int64) error

	Close()
	Delete()
	Sync()
	Append(interface{})
}

type BoolArray

type BoolArray struct {
	// V is a view on the mapped data as a slice of bools. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []bool
	// contains filtered or unexported fields
}

BoolArray is a wrapper around a memory mapped file, exposing the underlying data as a slice of bools. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using BoolArray's functions.

func NewBoolArray

func NewBoolArray() *BoolArray

func NewTempBoolArray

func NewTempBoolArray(parentDir string) (*BoolArray, error)

func OpenBoolArray

func OpenBoolArray(path string, flags int) (*BoolArray, error)

OpenBoolArray opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*BoolArray) Append

func (a *BoolArray) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *BoolArray or []bool.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*BoolArray) Cap

func (a *BoolArray) Cap() int64

Cap returns the capacity of the array.

func (*BoolArray) Close

func (a *BoolArray) Close()

Close closes the underlying file and resets the BoolArray to it's empty state. It will unmap the array if necessary.

func (*BoolArray) Closed

func (a *BoolArray) Closed() bool

Closed returns true if the BoolArray doesn't have an opened file. If Closed is true, then the BoolArray doesn't hold any open resources.

func (*BoolArray) Delete

func (a *BoolArray) Delete()

Delete closes the BoolArray and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*BoolArray) Len

func (a *BoolArray) Len() int64

func (*BoolArray) Map

func (a *BoolArray) Map()

func (*BoolArray) Mapped

func (a *BoolArray) Mapped() bool

Mapped returns true if the BoolArray's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*BoolArray) Open

func (a *BoolArray) Open(path string, flags int) error

Open has the same functionality as the OpenBoolArray function. If the BoolArray has an open file, it will be closed automatically.

func (*BoolArray) Path

func (a *BoolArray) Path() string

Path returns the path used to access the underlying file.

func (*BoolArray) SetCap

func (a *BoolArray) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*BoolArray) SetLen

func (a *BoolArray) SetLen(l int64)

func (*BoolArray) Sync

func (a *BoolArray) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*BoolArray) Unmap

func (a *BoolArray) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*BoolArray) Writable

func (a *BoolArray) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type ByteArray

type ByteArray struct {
	// V is a view on the mapped data as a slice of bytes. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []byte
	// contains filtered or unexported fields
}

ByteArray is a wrapper around a memory mapped file, exposing the underlying data as a slice of bytes. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using ByteArray's functions.

func NewByteArray

func NewByteArray() *ByteArray

func NewTempByteArray

func NewTempByteArray(parentDir string) (*ByteArray, error)

func OpenByteArray

func OpenByteArray(path string, flags int) (*ByteArray, error)

OpenByteArray opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*ByteArray) Append

func (a *ByteArray) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *ByteArray or []byte.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*ByteArray) Cap

func (a *ByteArray) Cap() int64

Cap returns the capacity of the array.

func (*ByteArray) Close

func (a *ByteArray) Close()

Close closes the underlying file and resets the ByteArray to it's empty state. It will unmap the array if necessary.

func (*ByteArray) Closed

func (a *ByteArray) Closed() bool

Closed returns true if the ByteArray doesn't have an opened file. If Closed is true, then the ByteArray doesn't hold any open resources.

func (*ByteArray) Delete

func (a *ByteArray) Delete()

Delete closes the ByteArray and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*ByteArray) Len

func (a *ByteArray) Len() int64

func (*ByteArray) Map

func (a *ByteArray) Map()

func (*ByteArray) Mapped

func (a *ByteArray) Mapped() bool

Mapped returns true if the ByteArray's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*ByteArray) Open

func (a *ByteArray) Open(path string, flags int) error

Open has the same functionality as the OpenByteArray function. If the ByteArray has an open file, it will be closed automatically.

func (*ByteArray) Path

func (a *ByteArray) Path() string

Path returns the path used to access the underlying file.

func (*ByteArray) SetCap

func (a *ByteArray) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*ByteArray) SetLen

func (a *ByteArray) SetLen(l int64)

func (*ByteArray) Sync

func (a *ByteArray) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*ByteArray) Unmap

func (a *ByteArray) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*ByteArray) Writable

func (a *ByteArray) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Float32Array

type Float32Array struct {
	// V is a view on the mapped data as a slice of float32s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []float32
	// contains filtered or unexported fields
}

Float32Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of float32s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Float32Array's functions.

func NewFloat32Array

func NewFloat32Array() *Float32Array

func NewTempFloat32Array

func NewTempFloat32Array(parentDir string) (*Float32Array, error)

func OpenFloat32Array

func OpenFloat32Array(path string, flags int) (*Float32Array, error)

OpenFloat32Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Float32Array) Append

func (a *Float32Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Float32Array or []float32.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Float32Array) Cap

func (a *Float32Array) Cap() int64

Cap returns the capacity of the array.

func (*Float32Array) Close

func (a *Float32Array) Close()

Close closes the underlying file and resets the Float32Array to it's empty state. It will unmap the array if necessary.

func (*Float32Array) Closed

func (a *Float32Array) Closed() bool

Closed returns true if the Float32Array doesn't have an opened file. If Closed is true, then the Float32Array doesn't hold any open resources.

func (*Float32Array) Delete

func (a *Float32Array) Delete()

Delete closes the Float32Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Float32Array) Len

func (a *Float32Array) Len() int64

func (*Float32Array) Map

func (a *Float32Array) Map()

func (*Float32Array) Mapped

func (a *Float32Array) Mapped() bool

Mapped returns true if the Float32Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Float32Array) Open

func (a *Float32Array) Open(path string, flags int) error

Open has the same functionality as the OpenFloat32Array function. If the Float32Array has an open file, it will be closed automatically.

func (*Float32Array) Path

func (a *Float32Array) Path() string

Path returns the path used to access the underlying file.

func (*Float32Array) SetCap

func (a *Float32Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Float32Array) SetLen

func (a *Float32Array) SetLen(l int64)

func (*Float32Array) Sync

func (a *Float32Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Float32Array) Unmap

func (a *Float32Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Float32Array) Writable

func (a *Float32Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Float64Array

type Float64Array struct {
	// V is a view on the mapped data as a slice of float64s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []float64
	// contains filtered or unexported fields
}

Float64Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of float64s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Float64Array's functions.

func NewFloat64Array

func NewFloat64Array() *Float64Array

func NewTempFloat64Array

func NewTempFloat64Array(parentDir string) (*Float64Array, error)

func OpenFloat64Array

func OpenFloat64Array(path string, flags int) (*Float64Array, error)

OpenFloat64Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Float64Array) Append

func (a *Float64Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Float64Array or []float64.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Float64Array) Cap

func (a *Float64Array) Cap() int64

Cap returns the capacity of the array.

func (*Float64Array) Close

func (a *Float64Array) Close()

Close closes the underlying file and resets the Float64Array to it's empty state. It will unmap the array if necessary.

func (*Float64Array) Closed

func (a *Float64Array) Closed() bool

Closed returns true if the Float64Array doesn't have an opened file. If Closed is true, then the Float64Array doesn't hold any open resources.

func (*Float64Array) Delete

func (a *Float64Array) Delete()

Delete closes the Float64Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Float64Array) Len

func (a *Float64Array) Len() int64

func (*Float64Array) Map

func (a *Float64Array) Map()

func (*Float64Array) Mapped

func (a *Float64Array) Mapped() bool

Mapped returns true if the Float64Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Float64Array) Open

func (a *Float64Array) Open(path string, flags int) error

Open has the same functionality as the OpenFloat64Array function. If the Float64Array has an open file, it will be closed automatically.

func (*Float64Array) Path

func (a *Float64Array) Path() string

Path returns the path used to access the underlying file.

func (*Float64Array) SetCap

func (a *Float64Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Float64Array) SetLen

func (a *Float64Array) SetLen(l int64)

func (*Float64Array) Sync

func (a *Float64Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Float64Array) Unmap

func (a *Float64Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Float64Array) Writable

func (a *Float64Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Int16Array

type Int16Array struct {
	// V is a view on the mapped data as a slice of int16s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []int16
	// contains filtered or unexported fields
}

Int16Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of int16s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Int16Array's functions.

func NewInt16Array

func NewInt16Array() *Int16Array

func NewTempInt16Array

func NewTempInt16Array(parentDir string) (*Int16Array, error)

func OpenInt16Array

func OpenInt16Array(path string, flags int) (*Int16Array, error)

OpenInt16Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Int16Array) Append

func (a *Int16Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Int16Array or []int16.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Int16Array) Cap

func (a *Int16Array) Cap() int64

Cap returns the capacity of the array.

func (*Int16Array) Close

func (a *Int16Array) Close()

Close closes the underlying file and resets the Int16Array to it's empty state. It will unmap the array if necessary.

func (*Int16Array) Closed

func (a *Int16Array) Closed() bool

Closed returns true if the Int16Array doesn't have an opened file. If Closed is true, then the Int16Array doesn't hold any open resources.

func (*Int16Array) Delete

func (a *Int16Array) Delete()

Delete closes the Int16Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Int16Array) Len

func (a *Int16Array) Len() int64

func (*Int16Array) Map

func (a *Int16Array) Map()

func (*Int16Array) Mapped

func (a *Int16Array) Mapped() bool

Mapped returns true if the Int16Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Int16Array) Open

func (a *Int16Array) Open(path string, flags int) error

Open has the same functionality as the OpenInt16Array function. If the Int16Array has an open file, it will be closed automatically.

func (*Int16Array) Path

func (a *Int16Array) Path() string

Path returns the path used to access the underlying file.

func (*Int16Array) SetCap

func (a *Int16Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Int16Array) SetLen

func (a *Int16Array) SetLen(l int64)

func (*Int16Array) Sync

func (a *Int16Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Int16Array) Unmap

func (a *Int16Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Int16Array) Writable

func (a *Int16Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Int32Array

type Int32Array struct {
	// V is a view on the mapped data as a slice of int32s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []int32
	// contains filtered or unexported fields
}

Int32Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of int32s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Int32Array's functions.

func NewInt32Array

func NewInt32Array() *Int32Array

func NewTempInt32Array

func NewTempInt32Array(parentDir string) (*Int32Array, error)

func OpenInt32Array

func OpenInt32Array(path string, flags int) (*Int32Array, error)

OpenInt32Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Int32Array) Append

func (a *Int32Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Int32Array or []int32.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Int32Array) Cap

func (a *Int32Array) Cap() int64

Cap returns the capacity of the array.

func (*Int32Array) Close

func (a *Int32Array) Close()

Close closes the underlying file and resets the Int32Array to it's empty state. It will unmap the array if necessary.

func (*Int32Array) Closed

func (a *Int32Array) Closed() bool

Closed returns true if the Int32Array doesn't have an opened file. If Closed is true, then the Int32Array doesn't hold any open resources.

func (*Int32Array) Delete

func (a *Int32Array) Delete()

Delete closes the Int32Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Int32Array) Len

func (a *Int32Array) Len() int64

func (*Int32Array) Map

func (a *Int32Array) Map()

func (*Int32Array) Mapped

func (a *Int32Array) Mapped() bool

Mapped returns true if the Int32Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Int32Array) Open

func (a *Int32Array) Open(path string, flags int) error

Open has the same functionality as the OpenInt32Array function. If the Int32Array has an open file, it will be closed automatically.

func (*Int32Array) Path

func (a *Int32Array) Path() string

Path returns the path used to access the underlying file.

func (*Int32Array) SetCap

func (a *Int32Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Int32Array) SetLen

func (a *Int32Array) SetLen(l int64)

func (*Int32Array) Sync

func (a *Int32Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Int32Array) Unmap

func (a *Int32Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Int32Array) Writable

func (a *Int32Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Int64Array

type Int64Array struct {
	// V is a view on the mapped data as a slice of int64s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []int64
	// contains filtered or unexported fields
}

Int64Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of int64s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Int64Array's functions.

func NewInt64Array

func NewInt64Array() *Int64Array

func NewTempInt64Array

func NewTempInt64Array(parentDir string) (*Int64Array, error)

func OpenInt64Array

func OpenInt64Array(path string, flags int) (*Int64Array, error)

OpenInt64Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Int64Array) Append

func (a *Int64Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Int64Array or []int64.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Int64Array) Cap

func (a *Int64Array) Cap() int64

Cap returns the capacity of the array.

func (*Int64Array) Close

func (a *Int64Array) Close()

Close closes the underlying file and resets the Int64Array to it's empty state. It will unmap the array if necessary.

func (*Int64Array) Closed

func (a *Int64Array) Closed() bool

Closed returns true if the Int64Array doesn't have an opened file. If Closed is true, then the Int64Array doesn't hold any open resources.

func (*Int64Array) Delete

func (a *Int64Array) Delete()

Delete closes the Int64Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Int64Array) Len

func (a *Int64Array) Len() int64

func (*Int64Array) Map

func (a *Int64Array) Map()

func (*Int64Array) Mapped

func (a *Int64Array) Mapped() bool

Mapped returns true if the Int64Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Int64Array) Open

func (a *Int64Array) Open(path string, flags int) error

Open has the same functionality as the OpenInt64Array function. If the Int64Array has an open file, it will be closed automatically.

func (*Int64Array) Path

func (a *Int64Array) Path() string

Path returns the path used to access the underlying file.

func (*Int64Array) SetCap

func (a *Int64Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Int64Array) SetLen

func (a *Int64Array) SetLen(l int64)

func (*Int64Array) Sync

func (a *Int64Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Int64Array) Unmap

func (a *Int64Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Int64Array) Writable

func (a *Int64Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Int8Array

type Int8Array struct {
	// V is a view on the mapped data as a slice of int8s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []int8
	// contains filtered or unexported fields
}

Int8Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of int8s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Int8Array's functions.

func NewInt8Array

func NewInt8Array() *Int8Array

func NewTempInt8Array

func NewTempInt8Array(parentDir string) (*Int8Array, error)

func OpenInt8Array

func OpenInt8Array(path string, flags int) (*Int8Array, error)

OpenInt8Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Int8Array) Append

func (a *Int8Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Int8Array or []int8.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Int8Array) Cap

func (a *Int8Array) Cap() int64

Cap returns the capacity of the array.

func (*Int8Array) Close

func (a *Int8Array) Close()

Close closes the underlying file and resets the Int8Array to it's empty state. It will unmap the array if necessary.

func (*Int8Array) Closed

func (a *Int8Array) Closed() bool

Closed returns true if the Int8Array doesn't have an opened file. If Closed is true, then the Int8Array doesn't hold any open resources.

func (*Int8Array) Delete

func (a *Int8Array) Delete()

Delete closes the Int8Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Int8Array) Len

func (a *Int8Array) Len() int64

func (*Int8Array) Map

func (a *Int8Array) Map()

func (*Int8Array) Mapped

func (a *Int8Array) Mapped() bool

Mapped returns true if the Int8Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Int8Array) Open

func (a *Int8Array) Open(path string, flags int) error

Open has the same functionality as the OpenInt8Array function. If the Int8Array has an open file, it will be closed automatically.

func (*Int8Array) Path

func (a *Int8Array) Path() string

Path returns the path used to access the underlying file.

func (*Int8Array) SetCap

func (a *Int8Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Int8Array) SetLen

func (a *Int8Array) SetLen(l int64)

func (*Int8Array) Sync

func (a *Int8Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Int8Array) Unmap

func (a *Int8Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Int8Array) Writable

func (a *Int8Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Uint16Array

type Uint16Array struct {
	// V is a view on the mapped data as a slice of uint16s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []uint16
	// contains filtered or unexported fields
}

Uint16Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of uint16s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Uint16Array's functions.

func NewTempUint16Array

func NewTempUint16Array(parentDir string) (*Uint16Array, error)

func NewUint16Array

func NewUint16Array() *Uint16Array

func OpenUint16Array

func OpenUint16Array(path string, flags int) (*Uint16Array, error)

OpenUint16Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Uint16Array) Append

func (a *Uint16Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Uint16Array or []uint16.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Uint16Array) Cap

func (a *Uint16Array) Cap() int64

Cap returns the capacity of the array.

func (*Uint16Array) Close

func (a *Uint16Array) Close()

Close closes the underlying file and resets the Uint16Array to it's empty state. It will unmap the array if necessary.

func (*Uint16Array) Closed

func (a *Uint16Array) Closed() bool

Closed returns true if the Uint16Array doesn't have an opened file. If Closed is true, then the Uint16Array doesn't hold any open resources.

func (*Uint16Array) Delete

func (a *Uint16Array) Delete()

Delete closes the Uint16Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Uint16Array) Len

func (a *Uint16Array) Len() int64

func (*Uint16Array) Map

func (a *Uint16Array) Map()

func (*Uint16Array) Mapped

func (a *Uint16Array) Mapped() bool

Mapped returns true if the Uint16Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Uint16Array) Open

func (a *Uint16Array) Open(path string, flags int) error

Open has the same functionality as the OpenUint16Array function. If the Uint16Array has an open file, it will be closed automatically.

func (*Uint16Array) Path

func (a *Uint16Array) Path() string

Path returns the path used to access the underlying file.

func (*Uint16Array) SetCap

func (a *Uint16Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Uint16Array) SetLen

func (a *Uint16Array) SetLen(l int64)

func (*Uint16Array) Sync

func (a *Uint16Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Uint16Array) Unmap

func (a *Uint16Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Uint16Array) Writable

func (a *Uint16Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Uint32Array

type Uint32Array struct {
	// V is a view on the mapped data as a slice of uint32s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []uint32
	// contains filtered or unexported fields
}

Uint32Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of uint32s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Uint32Array's functions.

func NewTempUint32Array

func NewTempUint32Array(parentDir string) (*Uint32Array, error)

func NewUint32Array

func NewUint32Array() *Uint32Array

func OpenUint32Array

func OpenUint32Array(path string, flags int) (*Uint32Array, error)

OpenUint32Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Uint32Array) Append

func (a *Uint32Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Uint32Array or []uint32.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Uint32Array) Cap

func (a *Uint32Array) Cap() int64

Cap returns the capacity of the array.

func (*Uint32Array) Close

func (a *Uint32Array) Close()

Close closes the underlying file and resets the Uint32Array to it's empty state. It will unmap the array if necessary.

func (*Uint32Array) Closed

func (a *Uint32Array) Closed() bool

Closed returns true if the Uint32Array doesn't have an opened file. If Closed is true, then the Uint32Array doesn't hold any open resources.

func (*Uint32Array) Delete

func (a *Uint32Array) Delete()

Delete closes the Uint32Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Uint32Array) Len

func (a *Uint32Array) Len() int64

func (*Uint32Array) Map

func (a *Uint32Array) Map()

func (*Uint32Array) Mapped

func (a *Uint32Array) Mapped() bool

Mapped returns true if the Uint32Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Uint32Array) Open

func (a *Uint32Array) Open(path string, flags int) error

Open has the same functionality as the OpenUint32Array function. If the Uint32Array has an open file, it will be closed automatically.

func (*Uint32Array) Path

func (a *Uint32Array) Path() string

Path returns the path used to access the underlying file.

func (*Uint32Array) SetCap

func (a *Uint32Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Uint32Array) SetLen

func (a *Uint32Array) SetLen(l int64)

func (*Uint32Array) Sync

func (a *Uint32Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Uint32Array) Unmap

func (a *Uint32Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Uint32Array) Writable

func (a *Uint32Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Uint64Array

type Uint64Array struct {
	// V is a view on the mapped data as a slice of uint64s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []uint64
	// contains filtered or unexported fields
}

Uint64Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of uint64s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Uint64Array's functions.

func NewTempUint64Array

func NewTempUint64Array(parentDir string) (*Uint64Array, error)

func NewUint64Array

func NewUint64Array() *Uint64Array

func OpenUint64Array

func OpenUint64Array(path string, flags int) (*Uint64Array, error)

OpenUint64Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Uint64Array) Append

func (a *Uint64Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Uint64Array or []uint64.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Uint64Array) Cap

func (a *Uint64Array) Cap() int64

Cap returns the capacity of the array.

func (*Uint64Array) Close

func (a *Uint64Array) Close()

Close closes the underlying file and resets the Uint64Array to it's empty state. It will unmap the array if necessary.

func (*Uint64Array) Closed

func (a *Uint64Array) Closed() bool

Closed returns true if the Uint64Array doesn't have an opened file. If Closed is true, then the Uint64Array doesn't hold any open resources.

func (*Uint64Array) Delete

func (a *Uint64Array) Delete()

Delete closes the Uint64Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Uint64Array) Len

func (a *Uint64Array) Len() int64

func (*Uint64Array) Map

func (a *Uint64Array) Map()

func (*Uint64Array) Mapped

func (a *Uint64Array) Mapped() bool

Mapped returns true if the Uint64Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Uint64Array) Open

func (a *Uint64Array) Open(path string, flags int) error

Open has the same functionality as the OpenUint64Array function. If the Uint64Array has an open file, it will be closed automatically.

func (*Uint64Array) Path

func (a *Uint64Array) Path() string

Path returns the path used to access the underlying file.

func (*Uint64Array) SetCap

func (a *Uint64Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Uint64Array) SetLen

func (a *Uint64Array) SetLen(l int64)

func (*Uint64Array) Sync

func (a *Uint64Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Uint64Array) Unmap

func (a *Uint64Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Uint64Array) Writable

func (a *Uint64Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

type Uint8Array

type Uint8Array struct {
	// V is a view on the mapped data as a slice of uint8s. The memory
	// backing V is not managed by the Go runtime, so be careful not use
	// references to the data in V after the array is unmapped. Note that the
	// memory must be unmapped when the capacity of the array is modified.
	V []uint8
	// contains filtered or unexported fields
}

Uint8Array is a wrapper around a memory mapped file, exposing the underlying data as a slice of uint8s. Because the memory isn't managed by the Go runtime, the user must manually manage the slice using Uint8Array's functions.

func NewTempUint8Array

func NewTempUint8Array(parentDir string) (*Uint8Array, error)

func NewUint8Array

func NewUint8Array() *Uint8Array

func OpenUint8Array

func OpenUint8Array(path string, flags int) (*Uint8Array, error)

OpenUint8Array opens the file at the given path. It takes the same flags as the os.OpenFile function. Before accessing the data, the Map function must be called.

func (*Uint8Array) Append

func (a *Uint8Array) Append(rhs interface{})

Append writes the the elements from rhs into the array. The concete type of rhs must be either *Uint8Array or []uint8.

Attempting to append to an unmapped array will panic.

Append will not increase the capacity of the underlying array. Attempting to append with insufficient capacity may panic or cause a segfault, or lead to undefined behavior.

func (*Uint8Array) Cap

func (a *Uint8Array) Cap() int64

Cap returns the capacity of the array.

func (*Uint8Array) Close

func (a *Uint8Array) Close()

Close closes the underlying file and resets the Uint8Array to it's empty state. It will unmap the array if necessary.

func (*Uint8Array) Closed

func (a *Uint8Array) Closed() bool

Closed returns true if the Uint8Array doesn't have an opened file. If Closed is true, then the Uint8Array doesn't hold any open resources.

func (*Uint8Array) Delete

func (a *Uint8Array) Delete()

Delete closes the Uint8Array and deletes the underlying file.

Attempting to delete a read-only file will panic.

func (*Uint8Array) Len

func (a *Uint8Array) Len() int64

func (*Uint8Array) Map

func (a *Uint8Array) Map()

func (*Uint8Array) Mapped

func (a *Uint8Array) Mapped() bool

Mapped returns true if the Uint8Array's file is mapped to memory. Mapped must be true in order to access or modify the data. This state is controlled by calls to Map and Unmap.

func (*Uint8Array) Open

func (a *Uint8Array) Open(path string, flags int) error

Open has the same functionality as the OpenUint8Array function. If the Uint8Array has an open file, it will be closed automatically.

func (*Uint8Array) Path

func (a *Uint8Array) Path() string

Path returns the path used to access the underlying file.

func (*Uint8Array) SetCap

func (a *Uint8Array) SetCap(numElem int64) error

SetCap is the only way to modify the capacity of the array. Capacity isn't automatically managed, so SetCap must be called when necessary to grow or shrink the array.

If the array is memory mapped when SetCap is called, it will be unmapped and re-mapped automatically. If the array isn't mapped, it will remain unmapped after SetCap is called.

Attempting to call SetCap on a read-only array will panic.

Attempting to set a capacity smaller than the length will panic.

func (*Uint8Array) SetLen

func (a *Uint8Array) SetLen(l int64)

func (*Uint8Array) Sync

func (a *Uint8Array) Sync()

Sync ensures changes to the mapped data are persisted to disk. Sync does nothing if the file isn't mapped, or isn't writable.

func (*Uint8Array) Unmap

func (a *Uint8Array) Unmap()

Unmap removes the memory map for the underlying file. Unmap does nothing if the array is already unmapped. Unmap will call Sync before unmapping.

func (*Uint8Array) Writable

func (a *Uint8Array) Writable() bool

Writable returns true if the underlying file was opened with the flag O_RDWR.

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

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