Documentation
¶
Overview ¶
Package sample reads small, bounded samples of rows. Every query is a plain SELECT with a LIMIT, ordered by the primary key where there is one, so the server reads only a few index pages per query.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QuoteIdent ¶
QuoteIdent quotes a table or column name for MySQL.
func Sampleable ¶
Sampleable reports whether the scanner reads a column's values. Binary, spatial and vector columns are skipped.
Types ¶
type Querier ¶
type Querier interface {
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}
Querier is the part of *sql.DB the package needs.
type Sample ¶
type Sample struct {
Columns []*model.Column
Rows [][]sql.NullString
Method string
}
Sample is the set of rows read from one table.
type Sampler ¶
type Sampler struct {
DB Querier
MaxValueLen int // longer text values are cut on the server
Timeout time.Duration // client-side limit per query
}
Sampler reads samples from one database.
func (*Sampler) KeyValues ¶
func (sm *Sampler) KeyValues(ctx context.Context, t *model.Table, keyCol, valueCol *model.Column, key string, limit int) ([]string, error)
KeyValues reads up to limit values of valueCol from rows where keyCol equals key. It is used to look at a known meta key directly when the window sample happened to miss it.