cbindex

package module
v0.0.0-...-2a0ae6d Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 9 Imported by: 0

README

Simple alphabetical file index

fileIndex, e := cbindex.NewFileIndex(cbindex.Config{
    DataCsvPath:           "rdd/data.csv", // path to csv file with key to search as first column
    IndexCsvPath:          "rdd/index.csv", // path to csv file with partial key (same as IndexKeyLength) and byte offset of the start in the file
    ConcurrentHandleLimit: 10000, // maximum open file hands, will return errors if exceeded
    WarmUpCount:           5000, // how many file handles to warm up if fileIndex.WarmUp() is called
    WarmUpDelay:           time.Millisecond, // how long to wait between warming each handle
    IndexKeyLength:        3, // character length of the indexes
})

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TooManyConcurrentHandlesError = errors.New("too many concurrent handles")
	InvalidHandleError            = errors.New("invalid handle")
	KeyTooShortForIndex           = errors.New("provided key too short for index")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	DataCsvPath           string
	IndexCsvPath          string
	ConcurrentHandleLimit int32
	WarmUpCount           int
	WarmUpDelay           time.Duration
	IndexKeyLength        int
}

type FileIndex

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

func NewFileIndex

func NewFileIndex(config Config) (*FileIndex, error)

func (*FileIndex) GetRow

func (f *FileIndex) GetRow(rowKey string) ([]string, error)

func (*FileIndex) GetRowsByPartialKey

func (f *FileIndex) GetRowsByPartialKey(rowKey string, limit int) ([][]string, error)

func (*FileIndex) WarmUp

func (f *FileIndex) WarmUp() error

Jump to

Keyboard shortcuts

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