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 GetNewCounts(buckets []sql.HistogramBucket) (rowCount uint64, distinctCount uint64, nullCount uint64)
- 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(b1, b2 []sql.HistogramBucket, types []sql.Type) ([]sql.HistogramBucket, error)
- 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 NewStatsIter(ctx *sql.Context, dStats ...sql.Statistic) (*statsIter, error)
- func ParseRow(rowStr string, types []sql.Type) (sql.Row, error)
- func ParseTypeStrings(typs []string) ([]sql.Type, error)
- func PrefixGt(buckets []sql.HistogramBucket, types []sql.Type, val interface{}) ([]sql.HistogramBucket, error)
- func PrefixGtHist(h []sql.HistogramBucket, target sql.Row, ...) (int, error)
- func PrefixGte(buckets []sql.HistogramBucket, types []sql.Type, val interface{}) ([]sql.HistogramBucket, error)
- func PrefixGteHist(h []sql.HistogramBucket, target sql.Row, ...) (int, error)
- func PrefixIsNotNull(buckets []sql.HistogramBucket) ([]sql.HistogramBucket, error)
- func PrefixIsNull(buckets []sql.HistogramBucket) ([]sql.HistogramBucket, error)
- func PrefixKey(buckets []sql.HistogramBucket, idxCols sql.ColSet, types []sql.Type, ...) ([]sql.HistogramBucket, *sql.FuncDepSet, error)
- func PrefixLt(buckets []sql.HistogramBucket, types []sql.Type, val interface{}) ([]sql.HistogramBucket, error)
- func PrefixLtHist(h []sql.HistogramBucket, target sql.Row, ...) (int, error)
- func PrefixLte(buckets []sql.HistogramBucket, types []sql.Type, val interface{}) ([]sql.HistogramBucket, error)
- func PrefixLteHist(h []sql.HistogramBucket, target sql.Row, ...) (int, error)
- func StringifyKey(r sql.Row, types []sql.Type) string
- func Union(b1, b2 []sql.HistogramBucket, types []sql.Type) ([]sql.HistogramBucket, error)
- 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
- type StatisticJSON
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 GetNewCounts ¶ added in v0.18.1
func GetNewCounts(buckets []sql.HistogramBucket) (rowCount uint64, distinctCount uint64, nullCount uint64)
func Intersect ¶
func Intersect(b1, b2 []sql.HistogramBucket, types []sql.Type) ([]sql.HistogramBucket, error)
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 NewStatsIter ¶ added in v0.18.1
func PrefixGt ¶
func PrefixGt(buckets []sql.HistogramBucket, types []sql.Type, val interface{}) ([]sql.HistogramBucket, error)
func PrefixGtHist ¶
func PrefixGte ¶
func PrefixGte(buckets []sql.HistogramBucket, types []sql.Type, val interface{}) ([]sql.HistogramBucket, error)
func PrefixGteHist ¶
func PrefixIsNotNull ¶
func PrefixIsNotNull(buckets []sql.HistogramBucket) ([]sql.HistogramBucket, error)
func PrefixIsNull ¶
func PrefixIsNull(buckets []sql.HistogramBucket) ([]sql.HistogramBucket, error)
func PrefixKey ¶
func PrefixKey(buckets []sql.HistogramBucket, idxCols sql.ColSet, types []sql.Type, oldFds *sql.FuncDepSet, key []interface{}, nullable []bool) ([]sql.HistogramBucket, *sql.FuncDepSet, error)
func PrefixLt ¶
func PrefixLt(buckets []sql.HistogramBucket, types []sql.Type, val interface{}) ([]sql.HistogramBucket, error)
func PrefixLtHist ¶
func PrefixLte ¶
func PrefixLte(buckets []sql.HistogramBucket, types []sql.Type, val interface{}) ([]sql.HistogramBucket, error)
func PrefixLteHist ¶
func Union ¶
func Union(b1, b2 []sql.HistogramBucket, types []sql.Type) ([]sql.HistogramBucket, error)
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 sql.Histogram `json:"buckets"` IdxClass uint8 `json:"index_class"` LowerBnd sql.Row `json:"lower_bound"` Fds *sql.FuncDepSet `json:"-"` Colset sql.ColSet `json:"-"` }
func NewStatistic ¶
func NewStatistic(rowCount, distinctCount, nullCount, avgSize uint64, createdAt time.Time, qualifier sql.StatQualifier, columns []string, types []sql.Type, histogram []sql.HistogramBucket, class sql.IndexClass, lowerBound sql.Row) *Statistic
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
func (*Statistic) WithHistogram ¶
type StatisticJSON ¶ added in v0.18.1
type StatisticJSON 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"` Fds *sql.FuncDepSet `json:"-"` Colset sql.ColSet `json:"-"` }
StatisticJSON is used as an intermediary to deserialize the memory stats object. Otherwise, the histogram would have to be deserialized separately.
func (*StatisticJSON) ToStatistic ¶ added in v0.18.1
func (j *StatisticJSON) ToStatistic() *Statistic