internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2018 License: Apache-2.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 DoubleArrayBuilder

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

DoubleArrayBuilder represents the builder of the double array.

func NewDoubleArrayBuilder

func NewDoubleArrayBuilder(progress ProgressFunction) *DoubleArrayBuilder

NewDoubleArrayBuilder returns a builder of the double array with progress function. The parameter progress sets nil if no progress bar.

func (*DoubleArrayBuilder) Build

func (b *DoubleArrayBuilder) Build(keys []string, values []uint32) error

Build constructs a double array from given keys and values.

func (DoubleArrayBuilder) WriteTo

func (b DoubleArrayBuilder) WriteTo(w io.Writer) (int64, error)

WriteTo write to the serialize data of the double array.

type DoubleArrayUint32

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

DoubleArrayUint32 represents the TRIE data structure.

func BuildDoubleArray

func BuildDoubleArray(keys []string, values []uint32, progress ProgressFunction) (*DoubleArrayUint32, error)

BuildDoubleArray constructs a double array from given keywords and values. The parameter values sets nil if no values.

func Open

func Open(name string) (*DoubleArrayUint32, error)

Open opens the named file of the double array.

func (DoubleArrayUint32) CommonPrefixSearch

func (a DoubleArrayUint32) CommonPrefixSearch(key string, offset int) ([][2]int, error)

CommonPrefixSearch finds keywords sharing common prefix in an input and returns the array of pairs (id and it's length) if found.

func (DoubleArrayUint32) CommonPrefixSearchCallback

func (a DoubleArrayUint32) CommonPrefixSearchCallback(key string, offset int, callback func(id, size int)) error

CommonPrefixSearchCallback finds keywords sharing common prefix in an input and callback with id and it's length.

func (DoubleArrayUint32) ExactMatchSearch

func (a DoubleArrayUint32) ExactMatchSearch(key string) (id, size int, err error)

ExactMatchSearch searches TRIE by a given keyword and returns the id and it's length if found.

type ProgressFunction

type ProgressFunction interface {
	// SetMaximum sets the maximum of the progress bar.
	SetMaximum(int)
	// Increment with increase the current count on the progress bar.
	Increment()
}

ProgressFunction indicates progress bar of building double array.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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