Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
Click to show internal directories.
Click to hide internal directories.