tsar

package module
v0.0.0-...-0c81716 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 8 Imported by: 0

README

TSAR - Text Search All Rows

A library for specific search use case

tsar is a go library that creates a sorted reverse word index that uses binary search to look up. It also provides a small DSL for querying files directly

tsar works directly on text files and creates an index, this can be saved directly to a file and used for querying the text.

see example/simple.go

Documentation

Index

Constants

View Source
const CheckpointSize = 8 // bytes 0:4 unused (was row number), bytes 4:8 are entry offset
View Source
const MaxEntryPointers = math.MaxUint32
View Source
const MaxKeyLen = math.MaxUint8
View Source
const PartitionSize = 20
View Source
const PointerSize = 4

Variables

This section is empty.

Functions

func MarshalIndex

func MarshalIndex(i *Index) []byte

Types

type Entry

type Entry struct {
	Key      string
	Pointers []uint32
}

type EntryList

type EntryList map[string][]uint32

func NewEntryList

func NewEntryList() EntryList

func (EntryList) Append

func (l EntryList) Append(key string, ptr uint32) error

func (EntryList) Remove

func (l EntryList) Remove(key string)

func (EntryList) Set

func (l EntryList) Set(key string, pointers []uint32) error

func (EntryList) ToIndex

func (l EntryList) ToIndex() *Index

type Index

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

func UnmarshalIndex

func UnmarshalIndex(data []byte) (*Index, error)

func UnmarshalIndexLazy

func UnmarshalIndexLazy(data []byte) (*Index, error)

func UnmarshalIndexLazyReader

func UnmarshalIndexLazyReader(reader io.ReadSeeker) (*Index, error)

func (*Index) Find

func (i *Index) Find(needle string, match Matcher) ([]*Entry, error)

type Matcher

type Matcher func(candidate string, needle string) bool
var MatchEqual Matcher = func(a, b string) bool { return a == b }
var MatchPrefix Matcher = strings.HasPrefix

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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