gen

package
v1.7.9 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareSeries

func CompareSeries(a, b seriesKeyField) int

Compare returns an integer comparing two SeriesGenerator instances lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b. A nil argument is equivalent to an empty SeriesGenerator.

func TagValuesLimitOption

func TagValuesLimitOption(n int) tagsValuesOption

func TagValuesSampleOption

func TagValuesSampleOption(n float64) tagsValuesOption

func WalkDown

func WalkDown(v Visitor, node SchemaNode)

WalkDown performs a pre-order, depth-first traversal of the graph, calling v for each node. Pre-order starts by calling the visitor for the root and each child as it traverses down the graph to the leaves.

func WalkUp

func WalkUp(v Visitor, node SchemaNode)

WalkUp performs a post-order, depth-first traversal of the graph, calling v for each node. Post-order starts by calling the visitor for the leaves then each parent as it traverses up the graph to the root.

Types

type BooleanValuesSequence

type BooleanValuesSequence interface {
	Reset()
	Write(v []bool)
}

func NewBooleanArrayValuesSequence

func NewBooleanArrayValuesSequence(v []bool) BooleanValuesSequence

func NewBooleanConstantValuesSequence

func NewBooleanConstantValuesSequence(v bool) BooleanValuesSequence

type CountableSequence

type CountableSequence interface {
	Sequence
	Count() int
}

type CounterByteSequence

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

func NewCounterByteSequence

func NewCounterByteSequence(format string, start, end int) *CounterByteSequence

func NewCounterByteSequenceCount

func NewCounterByteSequenceCount(n int) *CounterByteSequence

func (*CounterByteSequence) Count

func (s *CounterByteSequence) Count() int

func (*CounterByteSequence) Next

func (s *CounterByteSequence) Next() bool

func (*CounterByteSequence) Value

func (s *CounterByteSequence) Value() string

type Field

type Field struct {
	Name          string
	Count         int64
	TimePrecision *precision `toml:"time-precision"` // TimePrecision determines the precision for generated timestamp values
	TimeInterval  *duration  `toml:"time-interval"`  // TimeInterval determines the duration between timestamp values
	Source        FieldSource
}

func (*Field) TimeSequenceSpec

func (t *Field) TimeSequenceSpec() TimeSequenceSpec

func (*Field) UnmarshalTOML

func (t *Field) UnmarshalTOML(data interface{}) error

type FieldArraySource

type FieldArraySource struct {
	Value interface{}
}

func (*FieldArraySource) String

func (f *FieldArraySource) String() string

type FieldConstantValue

type FieldConstantValue struct {
	Value interface{}
}

func (*FieldConstantValue) String

func (f *FieldConstantValue) String() string

type FieldFloatRandomSource

type FieldFloatRandomSource struct {
	Seed     int64
	Min, Max float64
}

func (*FieldFloatRandomSource) String

func (f *FieldFloatRandomSource) String() string

type FieldIntegerZipfSource

type FieldIntegerZipfSource struct {
	Seed int64
	S, V float64
	IMAX uint64
}

func (*FieldIntegerZipfSource) String

func (f *FieldIntegerZipfSource) String() string

type FieldSource

type FieldSource interface {
	fmt.Stringer
	SchemaNode
	// contains filtered or unexported methods
}

type FieldValuesSpec

type FieldValuesSpec struct {
	TimeSequenceSpec
	Name     string
	DataType models.FieldType
	Values   NewTimeValuesSequenceFn
}

type Fields

type Fields []Field

type FloatValuesSequence

type FloatValuesSequence interface {
	Reset()
	Write(v []float64)
}

func NewFloatArrayValuesSequence

func NewFloatArrayValuesSequence(v []float64) FloatValuesSequence

func NewFloatConstantValuesSequence

func NewFloatConstantValuesSequence(v float64) FloatValuesSequence

func NewFloatRandomValuesSequence

func NewFloatRandomValuesSequence(min, max float64, r *rand.Rand) FloatValuesSequence

type IntegerValuesSequence

type IntegerValuesSequence interface {
	Reset()
	Write(v []int64)
}

func NewIntegerArrayValuesSequence

func NewIntegerArrayValuesSequence(v []int64) IntegerValuesSequence

func NewIntegerConstantValuesSequence

func NewIntegerConstantValuesSequence(v int64) IntegerValuesSequence

func NewIntegerZipfValuesSequence

func NewIntegerZipfValuesSequence(s *FieldIntegerZipfSource) IntegerValuesSequence

NewIntegerZipfValuesSequence produces int64 values using a Zipfian distribution described by s.

type Measurement

type Measurement struct {
	Name        string
	SeriesLimit *SeriesLimit `toml:"series-limit"`
	Sample      *sample
	Tags        Tags
	Fields      Fields
}

type MeasurementSpec

type MeasurementSpec struct {
	Name            string
	SeriesLimit     *SeriesLimit
	TagsSpec        *TagsSpec
	FieldValuesSpec *FieldValuesSpec
}

type Measurements

type Measurements []Measurement

type NewCountableSequenceFn

type NewCountableSequenceFn func() CountableSequence

type NewTagsValuesSequenceFn

type NewTagsValuesSequenceFn func() TagsSequence

type NewTimeValuesSequenceFn

type NewTimeValuesSequenceFn func(spec TimeSequenceSpec) TimeValuesSequence

NewTimeValuesSequenceFn returns a TimeValuesSequence that will generate a sequence of values based on the spec.

type Schema

type Schema struct {
	Title        string
	Version      string
	SeriesLimit  *SeriesLimit `toml:"series-limit"`
	Measurements Measurements
}

func NewSchemaFromPath

func NewSchemaFromPath(path string) (*Schema, error)

type SchemaNode

type SchemaNode interface {
	// contains filtered or unexported methods
}

type Sequence

type Sequence interface {
	Next() bool
	Value() string
}

type SeriesGenerator

type SeriesGenerator interface {
	// Next advances the series generator to the next series key.
	Next() bool

	// Key returns the series key.
	// The returned value may be cached.
	Key() []byte

	// Name returns the name of the measurement.
	// The returned value may be modified by a subsequent call to Next.
	Name() []byte

	// Tags returns the tag set.
	// The returned value may be modified by a subsequent call to Next.
	Tags() models.Tags

	// Field returns the name of the field.
	// The returned value may be modified by a subsequent call to Next.
	Field() []byte

	// TimeValuesGenerator returns a values sequence for the current series.
	TimeValuesGenerator() TimeValuesSequence
}

func NewMergedSeriesGenerator

func NewMergedSeriesGenerator(s []SeriesGenerator) SeriesGenerator

func NewMergedSeriesGeneratorLimit

func NewMergedSeriesGeneratorLimit(s []SeriesGenerator, n int64) SeriesGenerator

func NewSeriesGenerator

func NewSeriesGenerator(name []byte, field []byte, vg TimeValuesSequence, tags TagsSequence) SeriesGenerator

func NewSeriesGeneratorFromSpec

func NewSeriesGeneratorFromSpec(s *Spec, tr TimeRange) SeriesGenerator

func NewSeriesGeneratorLimit

func NewSeriesGeneratorLimit(name []byte, field []byte, vg TimeValuesSequence, tags TagsSequence, n int64) SeriesGenerator

type SeriesLimit

type SeriesLimit int64

func (*SeriesLimit) UnmarshalTOML

func (s *SeriesLimit) UnmarshalTOML(data interface{}) error

type Spec

type Spec struct {
	SeriesLimit  *int64
	Measurements []MeasurementSpec
}

func NewSpecFromPath

func NewSpecFromPath(p string) (*Spec, error)

func NewSpecFromSchema

func NewSpecFromSchema(root *Schema) (*Spec, error)

func NewSpecFromToml

func NewSpecFromToml(s string) (*Spec, error)

type StringArraySequence

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

func NewStringArraySequence

func NewStringArraySequence(vals []string) *StringArraySequence

func (*StringArraySequence) Count

func (s *StringArraySequence) Count() int

func (*StringArraySequence) Next

func (s *StringArraySequence) Next() bool

func (*StringArraySequence) Value

func (s *StringArraySequence) Value() string

type StringConstantSequence

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

func NewStringConstantSequence

func NewStringConstantSequence(val string) *StringConstantSequence

func (*StringConstantSequence) Count

func (s *StringConstantSequence) Count() int

func (*StringConstantSequence) Next

func (s *StringConstantSequence) Next() bool

func (*StringConstantSequence) Value

func (s *StringConstantSequence) Value() string

type StringValuesSequence

type StringValuesSequence interface {
	Reset()
	Write(v []string)
}

func NewStringArrayValuesSequence

func NewStringArrayValuesSequence(v []string) StringValuesSequence

func NewStringConstantValuesSequence

func NewStringConstantValuesSequence(v string) StringValuesSequence

type Tag

type Tag struct {
	Name   string
	Source TagSource
}

func (*Tag) UnmarshalTOML

func (t *Tag) UnmarshalTOML(data interface{}) error

type TagArraySource

type TagArraySource struct {
	Values []string
}

func (*TagArraySource) String

func (s *TagArraySource) String() string

type TagFileSource

type TagFileSource struct {
	Path string
}

func (*TagFileSource) String

func (s *TagFileSource) String() string

type TagSequenceSource

type TagSequenceSource struct {
	Format string
	Start  int64
	Count  int64
}

func (*TagSequenceSource) String

func (t *TagSequenceSource) String() string

type TagSource

type TagSource interface {
	fmt.Stringer
	SchemaNode
	// contains filtered or unexported methods
}

type TagValuesSpec

type TagValuesSpec struct {
	TagKey string
	Values NewCountableSequenceFn
}

type Tags

type Tags []Tag

type TagsSequence

type TagsSequence interface {
	Next() bool
	Value() models.Tags
	Count() int
}

func NewTagsValuesSequenceCounts

func NewTagsValuesSequenceCounts(prefix string, counts []int) TagsSequence

func NewTagsValuesSequenceKeysValues

func NewTagsValuesSequenceKeysValues(keys []string, vals []CountableSequence, opts ...tagsValuesOption) TagsSequence

func NewTagsValuesSequenceValues

func NewTagsValuesSequenceValues(prefix string, vals []CountableSequence) TagsSequence

type TagsSpec

type TagsSpec struct {
	Tags   []*TagValuesSpec
	Sample *sample
}

type TimeRange

type TimeRange struct {
	Start time.Time
	End   time.Time
}

func (TimeRange) Truncate

func (t TimeRange) Truncate(d time.Duration) TimeRange

type TimeSequenceSpec

type TimeSequenceSpec struct {
	// Count specifies the maximum number of values to generate.
	Count int

	// Start specifies the starting time for the values.
	Start time.Time

	// Delta specifies the interval between time stamps.
	Delta time.Duration

	// Precision specifies the precision of timestamp intervals
	Precision time.Duration
}

func (TimeSequenceSpec) ForTimeRange

func (ts TimeSequenceSpec) ForTimeRange(tr TimeRange) TimeSequenceSpec

type TimeValuesSequence

type TimeValuesSequence interface {
	Reset()
	Next() bool
	Values() Values
}

func NewTimeBooleanValuesSequence

func NewTimeBooleanValuesSequence(count int, ts TimestampSequence, vs BooleanValuesSequence) TimeValuesSequence

func NewTimeFloatValuesSequence

func NewTimeFloatValuesSequence(count int, ts TimestampSequence, vs FloatValuesSequence) TimeValuesSequence

func NewTimeIntegerValuesSequence

func NewTimeIntegerValuesSequence(count int, ts TimestampSequence, vs IntegerValuesSequence) TimeValuesSequence

func NewTimeStringValuesSequence

func NewTimeStringValuesSequence(count int, ts TimestampSequence, vs StringValuesSequence) TimeValuesSequence

func NewTimeUnsignedValuesSequence

func NewTimeUnsignedValuesSequence(count int, ts TimestampSequence, vs UnsignedValuesSequence) TimeValuesSequence

type TimestampSequence

type TimestampSequence interface {
	Reset()
	Write(ts []int64)
}

func NewTimestampSequenceFromSpec

func NewTimestampSequenceFromSpec(spec TimeSequenceSpec) TimestampSequence

type UnsignedValuesSequence

type UnsignedValuesSequence interface {
	Reset()
	Write(v []uint64)
}

func NewUnsignedArrayValuesSequence

func NewUnsignedArrayValuesSequence(v []uint64) UnsignedValuesSequence

func NewUnsignedConstantValuesSequence

func NewUnsignedConstantValuesSequence(v uint64) UnsignedValuesSequence

type Values

type Values interface {
	MinTime() int64
	MaxTime() int64
	Encode([]byte) ([]byte, error)
}

type Visitor

type Visitor interface {
	Visit(node SchemaNode) (w Visitor)
}

type VisitorFn

type VisitorFn func(node SchemaNode) bool

func (VisitorFn) Visit

func (fn VisitorFn) Visit(node SchemaNode) (w Visitor)

Jump to

Keyboard shortcuts

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