Documentation
¶
Index ¶
- type FileArray
- func (fileArray *FileArray[T]) Append(item T) (serialization.Offset, error)
- func (fileArray *FileArray[T]) Close() error
- func (fileArray *FileArray[T]) Count() serialization.Length
- func (fileArray *FileArray[T]) Expand(items serialization.Length) error
- func (fileArray *FileArray[T]) GetFileName() string
- func (fileArray *FileArray[T]) GetItemFromIndex(index serialization.Offset) (T, error)
- func (fileArray *FileArray[T]) Prefetch()
- func (fileArray *FileArray[T]) Reopen(readOnly bool) error
- func (fileArray *FileArray[T]) SetItemAtIndex(item T, index serialization.Offset) error
- func (fileArray *FileArray[T]) ShrinkWrap() error
- func (fileArray *FileArray[T]) Unmap() error
- type Header
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileArray ¶
type FileArray[T serialization.Serializer[T]] struct { // contains filtered or unexported fields }
func NewFileArray ¶
func NewFileArray[T serialization.Serializer[T]](filename string, readOnly bool) (*FileArray[T], error)
NewFileArray initializes a new FileArray instance.
Parameters:
- serializer: The serializer used to serialize data.
- filename: The path to the backing file.
Returns:
- *FileArray: A pointer to the FileArray instance.
- error: An error if initialization fails.
func (*FileArray[T]) Append ¶
func (fileArray *FileArray[T]) Append(item T) (serialization.Offset, error)
Append appends an item of type T to a FileArray. It serializes the item and adds it to the end of the array.
Parameters:
- item: The item of type T to be appended.
Returns:
- An error if the operation fails, nil otherwise.
func (*FileArray[T]) Close ¶
Close unmaps the memory-mapped region and closes the backing file.
Returns:
- error: An error if unmap or file close operations fail.
func (*FileArray[T]) Count ¶
func (fileArray *FileArray[T]) Count() serialization.Length
Count returns the current count of elements stored in the FileArray instance.
func (*FileArray[T]) Expand ¶
func (fileArray *FileArray[T]) Expand(items serialization.Length) error
Expand increases the size of the memory-mapped region by the specified number of items.
func (*FileArray[T]) GetFileName ¶
GetFileName returns the name of the backing file.
func (*FileArray[T]) GetItemFromIndex ¶
func (fileArray *FileArray[T]) GetItemFromIndex(index serialization.Offset) (T, error)
GetItemFromIndex retrieves an item of type T from a FileArray at the specified index. It deserializes the item and returns it along with any potential errors.
Parameters:
- index: The index of the item to retrieve.
Returns:
- The item of type T at the specified index.
- An error if the operation fails, nil otherwise.
func (*FileArray[T]) SetItemAtIndex ¶
func (fileArray *FileArray[T]) SetItemAtIndex(item T, index serialization.Offset) error
SetItemAtIndex sets an item of type T at a specific index within a FileArray. It serializes the item and stores it at the given index.
Parameters:
- item: The item of type T to be set.
- index: The index where the item will be placed.
Returns:
- An error if the operation fails, nil otherwise.
func (*FileArray[T]) ShrinkWrap ¶
ShrinkWrap reduces the size of a FileArray to match the actual data size. It is used to optimize disk usage by resizing the array to fit its contents.
Returns:
- An error if the operation fails, nil otherwise.