index

package
v0.0.0-...-d1d5330 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Genplot

func Genplot(index *LearnedIndex, indexedCol []float64, plotfilepath string, roundedError bool)

Genplot takes an index and plots its keys, CDF, its approximation, and writes a plot.png file in assets/folder

Types

type LearnedIndex

type LearnedIndex struct {
	M                        estimate.Estimator
	ST                       *search.SortedTable
	Len                      int
	MinErrBound, MaxErrBound int
}

LearnedIndex is an index structure that use inference to locate keys

Example
keys := []float64{5, 3, 3, 3.14, 10, 2.5, 2.98}

index := New(keys)

for _, k := range keys {
	offset, err := index.Lookup(k)
	if err != nil {
		fmt.Printf("Error: %s\n", err)
	}
	fmt.Printf("The key %f is located %d\n", k, offset)
}
Output:

The key 2.500000 is located [5]
The key 2.980000 is located [6]
The key 3.000000 is located [1 2]
The key 3.000000 is located [1 2]
The key 3.140000 is located [3]
The key 5.000000 is located [0]
The key 10.000000 is located [4]

func New

func New(dataset []float64) *LearnedIndex

New return an LearnedIndex fitted over the dataset with a linear regression algorythm

func (*LearnedIndex) GuessIndex

func (idx *LearnedIndex) GuessIndex(key float64) (guess, lower, upper int)

GuessIndex return the predicted position of the key in the index and upper / lower positions' search interval. Guess, lower and upper always have values between 0 and len(keys)-1

func (*LearnedIndex) Lookup

func (idx *LearnedIndex) Lookup(key float64) (offsets []int, err error)

Lookup return the first offsets of the key or err if the key is not found in the index

Jump to

Keyboard shortcuts

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