query

package
v0.0.0-...-e01a1e4 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CassandraPool = sync.Pool{
	New: func() interface{} {
		return &Cassandra{
			HumanLabel:       []byte{},
			HumanDescription: []byte{},
			MeasurementName:  []byte{},
			FieldName:        []byte{},
			AggregationType:  []byte{},
			ForEveryN:        []byte{},
			WhereClause:      []byte{},
			OrderBy:          []byte{},
			TagSets:          [][]string{},
		}
	},
}

CassandraPool is a sync.Pool of Cassandra Query types

View Source
var ClickHousePool = sync.Pool{
	New: func() interface{} {
		return &ClickHouse{
			HumanLabel:       make([]byte, 0, 1024),
			HumanDescription: make([]byte, 0, 1024),
			Table:            make([]byte, 0, 1024),
			SqlQuery:         make([]byte, 0, 1024),
		}
	},
}

ClickHousePool is a sync.Pool of ClickHouse Query types

View Source
var CrateDBPool = sync.Pool{
	New: func() interface{} {
		return &CrateDB{
			HumanLabel:       make([]byte, 0, 1024),
			HumanDescription: make([]byte, 0, 1024),
			Table:            make([]byte, 0, 1024),
			SqlQuery:         make([]byte, 0, 1024),
		}
	},
}
View Source
var HTTPPool = sync.Pool{
	New: func() interface{} {
		return &HTTP{
			HumanLabel:       []byte{},
			HumanDescription: []byte{},
			Method:           []byte{},
			Path:             []byte{},
			Body:             []byte{},
			RawQuery:         []byte{},
			StartTimestamp:   0,
			EndTimestamp:     0,
		}
	},
}

HTTPPool is a sync.Pool of HTTP Query types

View Source
var MongoPool = sync.Pool{
	New: func() interface{} {
		return &Mongo{
			HumanLabel:       []byte{},
			HumanDescription: []byte{},
			CollectionName:   []byte{},
			BsonDoc:          []bson.M{},
		}
	},
}

MongoPool is a sync.Pool of Mongo Query types

View Source
var SiriDBPool = sync.Pool{
	New: func() interface{} {
		return &SiriDB{
			HumanLabel:       make([]byte, 0, 1024),
			HumanDescription: make([]byte, 0, 1024),
			SqlQuery:         make([]byte, 0, 1024),
		}
	},
}
View Source
var TimescaleDBPool = sync.Pool{
	New: func() interface{} {
		return &TimescaleDB{
			HumanLabel:       make([]byte, 0, 1024),
			HumanDescription: make([]byte, 0, 1024),
			Hypertable:       make([]byte, 0, 1024),
			SqlQuery:         make([]byte, 0, 1024),
		}
	},
}

TimescaleDBPool is a sync.Pool of TimescaleDB Query types

View Source
var TimestreamPool = sync.Pool{
	New: func() interface{} {
		return &Timestream{
			HumanLabel:       make([]byte, 0, 1024),
			HumanDescription: make([]byte, 0, 1024),
			Table:            make([]byte, 0, 50),
			SqlQuery:         make([]byte, 0, 1024),
		}
	},
}

TimestreamPool is a sync.Pool of Timestream Query types

Functions

This section is empty.

Types

type BenchmarkRunner

type BenchmarkRunner struct {
	BenchmarkRunnerConfig
	// contains filtered or unexported fields
}

BenchmarkRunner contains the common components for running a query benchmarking program against a database.

func NewBenchmarkRunner

func NewBenchmarkRunner(config BenchmarkRunnerConfig) *BenchmarkRunner

NewBenchmarkRunner creates a new instance of BenchmarkRunner which is common functionality to be used by query benchmarker programs

func (*BenchmarkRunner) DatabaseName

func (b *BenchmarkRunner) DatabaseName() string

DatabaseName returns the name of the database to run queries against

func (*BenchmarkRunner) DebugLevel

func (b *BenchmarkRunner) DebugLevel() int

DebugLevel returns the level of debug messages for this benchmark

func (*BenchmarkRunner) DoPrintResponses

func (b *BenchmarkRunner) DoPrintResponses() bool

DoPrintResponses indicates whether responses for queries should be printed

func (*BenchmarkRunner) GetBufferedReader

func (b *BenchmarkRunner) GetBufferedReader() *bufio.Reader

GetBufferedReader returns the buffered Reader that should be used by the loader

func (*BenchmarkRunner) Run

func (b *BenchmarkRunner) Run(queryPool *sync.Pool, processorCreateFn ProcessorCreate)

Run does the bulk of the benchmark execution. It launches a gorountine to track stats, creates workers to process queries, read in the input, execute the queries, and then does cleanup.

func (*BenchmarkRunner) SetLimit

func (b *BenchmarkRunner) SetLimit(limit uint64)

SetLimit changes the number of queries to run, with 0 being all of them

type BenchmarkRunnerConfig

type BenchmarkRunnerConfig struct {
	DBName           string `mapstructure:"db-name"`
	Limit            uint64 `mapstructure:"max-queries"`
	LimitRPS         uint64 `mapstructure:"max-rps"`
	MemProfile       string `mapstructure:"memprofile"`
	HDRLatenciesFile string `mapstructure:"hdr-latencies"`
	LatenciesFile    string `mapstructure:"latencies-file"`
	Workers          uint   `mapstructure:"workers"`
	PrintResponses   bool   `mapstructure:"print-responses"`
	Debug            int    `mapstructure:"debug"`
	FileName         string `mapstructure:"file"`
	BurnIn           uint64 `mapstructure:"burn-in"`
	PrintInterval    uint64 `mapstructure:"print-interval"`
	PrewarmQueries   bool   `mapstructure:"prewarm-queries"`
}

BenchmarkRunnerConfig is the configuration of the benchmark runner.

func (BenchmarkRunnerConfig) AddToFlagSet

func (c BenchmarkRunnerConfig) AddToFlagSet(fs *pflag.FlagSet)

AddToFlagSet adds command line flags needed by the BenchmarkRunnerConfig to the flag set.

type Cassandra

type Cassandra struct {
	HumanLabel       []byte
	HumanDescription []byte

	MeasurementName []byte // e.g. "cpu"
	FieldName       []byte // e.g. "usage_user"
	AggregationType []byte // e.g. "avg" or "sum". used literally in the cassandra query.
	TimeStart       time.Time
	TimeEnd         time.Time
	GroupByDuration time.Duration
	ForEveryN       []byte // e.g. "hostname,1"
	WhereClause     []byte // e.g. "usage_user,>,90.0"
	OrderBy         []byte // e.g. "timestamp_ns DESC"
	Limit           int
	TagSets         [][]string // semantically, each subgroup is OR'ed and they are all AND'ed together
	// contains filtered or unexported fields
}

Cassandra encodes a Cassandra request. This will be serialized for use by the tsbs_run_queries_cassandra program.

func NewCassandra

func NewCassandra() *Cassandra

NewCassandra returns a new Cassandra Query instance

func (*Cassandra) GetID

func (q *Cassandra) GetID() uint64

GetID returns the ID of this Query

func (*Cassandra) HumanDescriptionName

func (q *Cassandra) HumanDescriptionName() []byte

HumanDescriptionName returns the human readable description of this Query

func (*Cassandra) HumanLabelName

func (q *Cassandra) HumanLabelName() []byte

HumanLabelName returns the human readable name of this Query

func (*Cassandra) Release

func (q *Cassandra) Release()

Release resets and returns this Query to its pool

func (*Cassandra) SetID

func (q *Cassandra) SetID(n uint64)

SetID sets the ID for this Query

func (*Cassandra) String

func (q *Cassandra) String() string

String produces a debug-ready description of a Query.

type ClickHouse

type ClickHouse struct {
	HumanLabel       []byte
	HumanDescription []byte

	Table    []byte // e.g. "cpu"
	SqlQuery []byte
	// contains filtered or unexported fields
}

ClickHouse encodes a ClickHouse query. This will be serialized for use by the tsbs_run_queries_clickhouse program.

func NewClickHouse

func NewClickHouse() *ClickHouse

NewClickHouse returns a new ClickHouse Query instance

func (*ClickHouse) GetID

func (ch *ClickHouse) GetID() uint64

GetID returns the ID of this Query

func (*ClickHouse) HumanDescriptionName

func (ch *ClickHouse) HumanDescriptionName() []byte

HumanDescriptionName returns the human readable description of this Query

func (*ClickHouse) HumanLabelName

func (ch *ClickHouse) HumanLabelName() []byte

HumanLabelName returns the human readable name of this Query

func (*ClickHouse) Release

func (ch *ClickHouse) Release()

Release resets and returns this Query to its pool

func (*ClickHouse) SetID

func (ch *ClickHouse) SetID(n uint64)

SetID sets the ID for this Query

func (*ClickHouse) String

func (ch *ClickHouse) String() string

String produces a debug-ready description of a Query.

type CrateDB

type CrateDB struct {
	HumanLabel       []byte
	HumanDescription []byte

	Table    []byte // e.g. "cpu"
	SqlQuery []byte
	// contains filtered or unexported fields
}

CrateDB encodes a CrateDB request. This will be serialized for use by the tsbs_run_queries_cratedb program.

func NewCrateDB

func NewCrateDB() *CrateDB

func (*CrateDB) GetID

func (q *CrateDB) GetID() uint64

func (*CrateDB) HumanDescriptionName

func (q *CrateDB) HumanDescriptionName() []byte

func (*CrateDB) HumanLabelName

func (q *CrateDB) HumanLabelName() []byte

func (*CrateDB) Release

func (q *CrateDB) Release()

Release resets and returns this Query to its pool

func (*CrateDB) SetID

func (q *CrateDB) SetID(n uint64)

func (*CrateDB) String

func (q *CrateDB) String() string

String produces a debug-ready description of a Query.

type HTTP

type HTTP struct {
	HumanLabel       []byte
	HumanDescription []byte
	Method           []byte
	Path             []byte
	Body             []byte
	RawQuery         []byte
	StartTimestamp   int64
	EndTimestamp     int64
	// contains filtered or unexported fields
}

HTTP encodes an HTTP request. This will typically by serialized for use by the appropriate tsbs_run_queries program.

func NewHTTP

func NewHTTP() *HTTP

NewHTTP returns a new HTTP type Query

func (*HTTP) GetID

func (q *HTTP) GetID() uint64

GetID returns the ID of this Query

func (*HTTP) HumanDescriptionName

func (q *HTTP) HumanDescriptionName() []byte

HumanDescriptionName returns the human readable description of this Query

func (*HTTP) HumanLabelName

func (q *HTTP) HumanLabelName() []byte

HumanLabelName returns the human readable name of this Query

func (*HTTP) Release

func (q *HTTP) Release()

Release resets and returns this Query to its pool

func (*HTTP) SetID

func (q *HTTP) SetID(n uint64)

SetID sets the ID for this Query

func (*HTTP) String

func (q *HTTP) String() string

String produces a debug-ready description of a Query.

type Mongo

type Mongo struct {
	HumanLabel       []byte
	HumanDescription []byte
	CollectionName   []byte
	BsonDoc          []bson.M
	// contains filtered or unexported fields
}

Mongo encodes a Mongo request. This will be serialized for use by the tsbs_run_queries_mongo program.

func NewMongo

func NewMongo() *Mongo

NewMongo returns a new Mongo Query instance

func (*Mongo) GetID

func (q *Mongo) GetID() uint64

GetID returns the ID of this Query

func (*Mongo) HumanDescriptionName

func (q *Mongo) HumanDescriptionName() []byte

HumanDescriptionName returns the human readable description of this Query

func (*Mongo) HumanLabelName

func (q *Mongo) HumanLabelName() []byte

HumanLabelName returns the human readable name of this Query

func (*Mongo) Release

func (q *Mongo) Release()

Release resets and returns this Query to its pool

func (*Mongo) SetID

func (q *Mongo) SetID(id uint64)

SetID sets the ID for this Query

func (*Mongo) String

func (q *Mongo) String() string

String produces a debug-ready description of a Query.

type Processor

type Processor interface {
	// Init initializes at global state for the Processor, possibly based on its worker number / ID
	Init(workerNum int)

	// ProcessQuery handles a given query and reports its stats
	ProcessQuery(q Query, isWarm bool) ([]*Stat, error)
}

Processor is an interface that handles the setup of a query processing worker and executes queries one at a time

type ProcessorCreate

type ProcessorCreate func() Processor

ProcessorCreate is a function that creates a new Processor (called in Run)

type Query

type Query interface {
	Release()
	HumanLabelName() []byte
	HumanDescriptionName() []byte
	GetID() uint64
	SetID(uint64)
	fmt.Stringer
}

Query is an interface used for encoding a benchmark query for different databases

type SiriDB

type SiriDB struct {
	HumanLabel       []byte
	HumanDescription []byte
	SqlQuery         []byte
	// contains filtered or unexported fields
}

func NewSiriDB

func NewSiriDB() *SiriDB

func (*SiriDB) GetID

func (q *SiriDB) GetID() uint64

GetID returns the ID of this Query

func (*SiriDB) HumanDescriptionName

func (q *SiriDB) HumanDescriptionName() []byte

HumanDescriptionName returns the human readable description of this Query

func (*SiriDB) HumanLabelName

func (q *SiriDB) HumanLabelName() []byte

HumanLabelName returns the human readable name of this Query

func (*SiriDB) Release

func (q *SiriDB) Release()

Release resets and returns this Query to its pool

func (*SiriDB) SetID

func (q *SiriDB) SetID(id uint64)

SetID sets the ID for this Query

func (*SiriDB) String

func (q *SiriDB) String() string

String produces a debug-ready description of a Query.

type Stat

type Stat struct {
	// contains filtered or unexported fields
}

Stat represents one statistical measurement, typically used to store the latency of a query (or part of query).

func GetPartialStat

func GetPartialStat() *Stat

GetPartialStat returns a partial Stat for use from a pool

func GetStat

func GetStat() *Stat

GetStat returns a Stat for use from a pool

func (*Stat) Init

func (s *Stat) Init(label []byte, id uint64, value float64) *Stat

Init safely initializes a Stat while minimizing heap allocations.

type TimescaleDB

type TimescaleDB struct {
	HumanLabel       []byte
	HumanDescription []byte

	Hypertable []byte // e.g. "cpu"
	SqlQuery   []byte
	// contains filtered or unexported fields
}

TimescaleDB encodes a TimescaleDB request. This will be serialized for use by the tsbs_run_queries_timescaledb program.

func NewTimescaleDB

func NewTimescaleDB() *TimescaleDB

NewTimescaleDB returns a new TimescaleDB Query instance

func (*TimescaleDB) GetID

func (q *TimescaleDB) GetID() uint64

GetID returns the ID of this Query

func (*TimescaleDB) HumanDescriptionName

func (q *TimescaleDB) HumanDescriptionName() []byte

HumanDescriptionName returns the human readable description of this Query

func (*TimescaleDB) HumanLabelName

func (q *TimescaleDB) HumanLabelName() []byte

HumanLabelName returns the human readable name of this Query

func (*TimescaleDB) Release

func (q *TimescaleDB) Release()

Release resets and returns this Query to its pool

func (*TimescaleDB) SetID

func (q *TimescaleDB) SetID(n uint64)

SetID sets the ID for this Query

func (*TimescaleDB) String

func (q *TimescaleDB) String() string

String produces a debug-ready description of a Query.

type Timestream

type Timestream struct {
	HumanLabel       []byte
	HumanDescription []byte

	Table    []byte // e.g. "cpu"
	SqlQuery []byte
	// contains filtered or unexported fields
}

Timestream encodes a Timestream request. This will be serialized for use by the tsbs_run_queries_timestream program.

func NewTimestream

func NewTimestream() *Timestream

NewTimestream returns a new Timestream Query instance

func (*Timestream) GetID

func (q *Timestream) GetID() uint64

GetID returns the ID of this Query

func (*Timestream) HumanDescriptionName

func (q *Timestream) HumanDescriptionName() []byte

HumanDescriptionName returns the human readable description of this Query

func (*Timestream) HumanLabelName

func (q *Timestream) HumanLabelName() []byte

HumanLabelName returns the human readable name of this Query

func (*Timestream) Release

func (q *Timestream) Release()

Release resets and returns this Query to its pool

func (*Timestream) SetID

func (q *Timestream) SetID(n uint64)

SetID sets the ID for this Query

func (*Timestream) String

func (q *Timestream) String() string

String produces a debug-ready description of a Query.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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