datastructures

package
v0.0.0-...-3efd425 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvCache

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

CsvCache stores csv lines of equal length in an arbitrary StringDB implementation.

func NewCsvCache

func NewCsvCache(headers []string, useFileSystem bool) (*CsvCache, error)

NewCsvCache returns a CsvCache for the given headers using a memory or file-system mapped StringDB implementation.

func NewFileSystemCsvCache

func NewFileSystemCsvCache(headerCount int) (*CsvCache, error)

NewFileSystemCsvCache returns a CsvCache for the given headers using a file-system mapped StringDB implementation.

func NewMemoryCsvCache

func NewMemoryCsvCache(headerCount int) (*CsvCache, error)

NewMemoryCsvCache returns a CsvCache for the given headers using a memory mapped StringDB implementation.

func (*CsvCache) Add

func (cache *CsvCache) Add(values []string) error

Add adds an entry to the cache using the first array element as key. Returns an error if the key is already stored.

func (*CsvCache) Close

func (cache *CsvCache) Close()

Close disposes all resources of the cache.

func (*CsvCache) ContainsKey

func (cache *CsvCache) ContainsKey(key string) (bool, error)

ContainsKey returns true when the given key is stored in the cache, otherwise false.

func (*CsvCache) Get

func (cache *CsvCache) Get(key string) ([]string, error)

Get returns all columns of a cached line. Returns an error when the key is not stored in the cache.

func (*CsvCache) GetCount

func (cache *CsvCache) GetCount() int

GetCount returns the total number of cached lines.

type FileSystemStringDB

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

FileSystemStringDB is a StringDB implementation which stores the data on the local file system.

func (*FileSystemStringDB) Add

func (db *FileSystemStringDB) Add(key, str string) error

Add stores a value with the given key in the database. Returns an error if the key is already stored.

func (*FileSystemStringDB) Close

func (db *FileSystemStringDB) Close(delete bool) error

Close deletes all storage files from the local file-system.

func (*FileSystemStringDB) ContainsKey

func (db *FileSystemStringDB) ContainsKey(key string) (bool, error)

ContainsKey returns true if the given key is stored in the database, otherwise false.

func (*FileSystemStringDB) Get

func (db *FileSystemStringDB) Get(key string) (string, error)

Get returns the string stored in the database for the given key. Returns an error if the key is not stored in the database.

func (*FileSystemStringDB) GetCount

func (db *FileSystemStringDB) GetCount() int

GetCount returns the total number of entries in the database.

func (*FileSystemStringDB) GetDir

func (db *FileSystemStringDB) GetDir() string

GetDir returns the base directory of the file-system database.

type MemoryStringDB

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

MemoryStringDB is a StringDB implementation which stores all data in the memory.

func (*MemoryStringDB) Add

func (db *MemoryStringDB) Add(key, str string) error

Add stores a value with the given key in the database. Returns an error if the key is already stored.

func (*MemoryStringDB) Close

func (db *MemoryStringDB) Close(delete bool) error

Close disposes all storage resources of this database.

func (*MemoryStringDB) ContainsKey

func (db *MemoryStringDB) ContainsKey(key string) (bool, error)

ContainsKey returns true if the given key is stored in the database, otherwise false.

func (*MemoryStringDB) Get

func (db *MemoryStringDB) Get(key string) (string, error)

Get returns the string stored in the database for the given key. Returns an error if the key is not stored in the database.

func (*MemoryStringDB) GetCount

func (db *MemoryStringDB) GetCount() int

GetCount returns the total number of entries in the database.

type StringDB

type StringDB interface {
	GetCount() int
	Add(key, str string) error
	ContainsKey(key string) (bool, error)
	Get(key string) (string, error)
	Close(delete bool) error
}

StringDB is the abstract interface for storing keyed strings in a database.

func NewFileSystemStringDB

func NewFileSystemStringDB(dir string) (StringDB, error)

NewFileSystemStringDB returns a file-system mapped string database in the given directory.

func NewMemoryStringDB

func NewMemoryStringDB() (StringDB, error)

NewMemoryStringDB returns a memory mapped string database in the given directory.

Jump to

Keyboard shortcuts

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