Documentation
¶
Overview ¶
Copyright 2023 Dolthub, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func AlignBuckets(h1, h2 sql.Histogram, lBound1, lBound2 sql.Row, s1Types, s2Types []sql.Type, ...) (sql.Histogram, sql.Histogram, error)
- func Empty(s sql.Statistic) bool
- func IndexFds(tableName string, sch sql.Schema, idx sql.Index) (*sql.FuncDepSet, sql.ColSet, error)
- func InterpolateNewCounts(from, to sql.Statistic) sql.Statistic
- func Intersect(s1, s2 sql.Statistic) sql.Statistic
- func Join(s1, s2 sql.Statistic, prefixCnt int, debug bool) (sql.Statistic, error)
- func McvPrefixGt(statistic sql.Statistic, i int, val interface{}) (sql.Statistic, error)
- func McvPrefixGte(statistic sql.Statistic, i int, val interface{}) (sql.Statistic, error)
- func McvPrefixIsNotNull(statistic sql.Statistic, i int, val interface{}) (sql.Statistic, error)
- func McvPrefixIsNull(statistic sql.Statistic, i int, val interface{}) (sql.Statistic, error)
- func McvPrefixLt(statistic sql.Statistic, i int, val interface{}) (sql.Statistic, error)
- func McvPrefixLte(statistic sql.Statistic, i int, val interface{}) (sql.Statistic, error)
- func NewExpDistIter(colCnt, rowCnt int, lambda float64) sql.RowIter
- func NewNormDistIter(colCnt, rowCnt int, mean, std float64) sql.RowIter
- func ParseTypeStrings(typs []string) ([]sql.Type, error)
- func PrefixGt(statistic sql.Statistic, val interface{}) (sql.Statistic, error)
- func PrefixGtHist(h sql.Histogram, target sql.Row, cmp func(sql.Row, sql.Row) (int, error)) (int, error)
- func PrefixGte(statistic sql.Statistic, val interface{}) (sql.Statistic, error)
- func PrefixGteHist(h sql.Histogram, target sql.Row, cmp func(sql.Row, sql.Row) (int, error)) (int, error)
- func PrefixIsNotNull(statistic sql.Statistic) (sql.Statistic, error)
- func PrefixIsNull(statistic sql.Statistic) (sql.Statistic, error)
- func PrefixKey(statistic sql.Statistic, key []interface{}, nullable []bool) (sql.Statistic, error)
- func PrefixLt(statistic sql.Statistic, val interface{}) (sql.Statistic, error)
- func PrefixLtHist(h sql.Histogram, target sql.Row, cmp func(sql.Row, sql.Row) (int, error)) (int, error)
- func PrefixLte(statistic sql.Statistic, val interface{}) (sql.Statistic, error)
- func PrefixLteHist(h sql.Histogram, target sql.Row, cmp func(sql.Row, sql.Row) (int, error)) (int, error)
- func Union(s1, s2 sql.Statistic) sql.Statistic
- func UpdateCounts(statistic sql.Statistic) sql.Statistic
- type Bucket
- type HeapRow
- type SqlHeap
- type Statistic
- func (s *Statistic) AvgSize() uint64
- func (s *Statistic) ColSet() sql.ColSet
- func (s *Statistic) Columns() []string
- func (s *Statistic) CreatedAt() time.Time
- func (s *Statistic) DistinctCount() uint64
- func (s *Statistic) FuncDeps() *sql.FuncDepSet
- func (s *Statistic) Histogram() sql.Histogram
- func (s *Statistic) IndexClass() sql.IndexClass
- func (s *Statistic) LowerBound() sql.Row
- func (s *Statistic) NullCount() uint64
- func (s *Statistic) Qualifier() sql.StatQualifier
- func (s *Statistic) RowCount() uint64
- func (s *Statistic) SetColumns(c []string)
- func (s *Statistic) SetQualifier(q sql.StatQualifier)
- func (s *Statistic) SetTypes(t []sql.Type)
- func (s *Statistic) ToInterface() interface{}
- func (s *Statistic) Types() []sql.Type
- func (s *Statistic) WithAvgSize(i uint64) sql.Statistic
- func (s *Statistic) WithColSet(cols sql.ColSet) sql.Statistic
- func (s *Statistic) WithDistinctCount(i uint64) sql.Statistic
- func (s *Statistic) WithFuncDeps(fds *sql.FuncDepSet) sql.Statistic
- func (s *Statistic) WithHistogram(h sql.Histogram) (sql.Statistic, error)
- func (s *Statistic) WithLowerBound(r sql.Row) sql.Statistic
- func (s *Statistic) WithNullCount(i uint64) sql.Statistic
- func (s *Statistic) WithRowCount(i uint64) sql.Statistic
Constants ¶
This section is empty.
Variables ¶
var ErrJoinStringStatistics = errors.New("joining string histograms is unsupported")
Functions ¶
func AlignBuckets ¶
func AlignBuckets(h1, h2 sql.Histogram, lBound1, lBound2 sql.Row, s1Types, s2Types []sql.Type, cmp func(sql.Row, sql.Row) (int, error)) (sql.Histogram, sql.Histogram, error)
AlignBuckets produces two histograms with the same number of buckets. Start by using upper bound keys to truncate histogram with a larger keyspace. Then for every misaligned pair of buckets, cut the one with the higher bound value on the smaller's key. We use a linear interpolation to divide keys when splitting.
func Join ¶
Join performs an alignment algorithm on two sets of statistics, and then pairwise estimates bucket cardinalities by joining most common values (mcvs) directly and assuming key uniformity otherwise. Only numeric types are supported.
func McvPrefixGt ¶
func McvPrefixGte ¶
func McvPrefixIsNotNull ¶
func McvPrefixIsNull ¶
func McvPrefixLt ¶
func McvPrefixLte ¶
func PrefixGtHist ¶
func PrefixGteHist ¶
func PrefixLtHist ¶
func PrefixLteHist ¶
Types ¶
type Bucket ¶
type Bucket struct {
RowCnt uint64 `json:"row_count"`
DistinctCnt uint64 `json:"distinct_count"`
NullCnt uint64 `json:"null_count"`
McvsCnt []uint64 `json:"mcv_counts"`
BoundCnt uint64 `json:"bound_count"`
BoundVal sql.Row `json:"upper_bound"`
McvVals []sql.Row `json:"mcvs"`
}
func NewHistogramBucket ¶
func (Bucket) BoundCount ¶
func (Bucket) DistinctCount ¶
func (Bucket) UpperBound ¶
type SqlHeap ¶
type SqlHeap struct {
// contains filtered or unexported fields
}
An SqlHeap is a min-heap of ints.
func NewSqlHeap ¶
type Statistic ¶
type Statistic struct {
RowCnt uint64 `json:"row_count"`
DistinctCnt uint64 `json:"distinct_count"`
NullCnt uint64 `json:"null_count"`
AvgRowSize uint64 `json:"avg_size"`
Created time.Time `json:"created_at"`
Qual sql.StatQualifier `json:"qualifier"`
Cols []string `json:"columns"`
Typs []sql.Type `json:"-"`
Hist []*Bucket `json:"buckets"`
IdxClass uint8 `json:"index_class"`
LowerBnd sql.Row `json:"lower_bound"`
// contains filtered or unexported fields
}
func NewStatistic ¶
func (*Statistic) DistinctCount ¶
func (*Statistic) FuncDeps ¶
func (s *Statistic) FuncDeps() *sql.FuncDepSet
func (*Statistic) IndexClass ¶
func (s *Statistic) IndexClass() sql.IndexClass
func (*Statistic) LowerBound ¶
func (*Statistic) Qualifier ¶
func (s *Statistic) Qualifier() sql.StatQualifier
func (*Statistic) SetColumns ¶
func (*Statistic) SetQualifier ¶
func (s *Statistic) SetQualifier(q sql.StatQualifier)
func (*Statistic) ToInterface ¶
func (s *Statistic) ToInterface() interface{}
func (*Statistic) WithFuncDeps ¶
func (s *Statistic) WithFuncDeps(fds *sql.FuncDepSet) sql.Statistic