ffmap

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlatFileMap

type FlatFileMap interface {
	// Size reports how many entries are stored in the map.
	Size() int
	// Get will set the value for the given key.  The returned bool indicates if the value was found and matches the
	// type, check the error for possible parsing or type errors.
	Get(key string, value interface{}) (bool, error)
	// ContainsKey will return true if the map has an associated value with the provided key
	ContainsKey(key string) bool
	// KeySet will return all the keys stored within the map.
	KeySet() []string
}

func OpenReadOnlyCSV

func OpenReadOnlyCSV(filename string) (FlatFileMap, error)

OpenReadOnlyCSV will read a CSV map file, providing a read only view of the data.

type KeyValueCSV

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

KeyValueCSV provides a primarily in-memory key value map, with the ability to load and commit the contents to disk.

func OpenCSV

func OpenCSV(filename string) (*KeyValueCSV, error)

OpenCSV will create or read an existing CSV map file.

func (*KeyValueCSV) Commit

func (kv *KeyValueCSV) Commit() error

func (*KeyValueCSV) ContainsKey

func (kv *KeyValueCSV) ContainsKey(key string) bool

func (*KeyValueCSV) Delete

func (kv *KeyValueCSV) Delete(key string)

func (*KeyValueCSV) Get

func (kv *KeyValueCSV) Get(key string, value interface{}) (bool, error)

func (*KeyValueCSV) KeySet

func (kv *KeyValueCSV) KeySet() []string

func (*KeyValueCSV) Set

func (kv *KeyValueCSV) Set(key string, value interface{}) error

func (*KeyValueCSV) Size

func (kv *KeyValueCSV) Size() int

type WritableFlatFileMap

type WritableFlatFileMap interface {
	FlatFileMap
	// Set will set the provided value into the map, when retrieved the same type must be used.  If a value already
	// exists, it will be replaced with the new value.
	Set(key string, value interface{}) error
	// Delete will remove the key from the map (if present).
	Delete(key string)
	// Commit will update the disk representation to match the in-memory state.  If this is not invoked the disk will
	// never be updated.  This must not be called concurrently, and may be slow as the file format is optimized.
	Commit() error
}

Jump to

Keyboard shortcuts

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