fluxcsv

package
v2.7.5 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResultCol  = "result"
	TableIdCol = "table"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ColType

type ColType int
const (
	StringDatatype ColType = iota
	DoubleDatatype
	BoolDatatype
	LongDatatype
	ULongDatatype
	DurationDatatype
	Base64BinaryDataType
	TimeDatatypeRFC
	TimeDatatypeRFCNano
	InvalidDatatype
)

func ParseType

func ParseType(s string) (ColType, error)

type FluxColumn

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

FluxColumn holds flux query table column properties

func NewFluxColumn

func NewFluxColumn() *FluxColumn

NewFluxColumn creates FluxColumn for id

func NewFluxColumnFull

func NewFluxColumnFull(dataType ColType, defaultValue string, name string, group bool) *FluxColumn

NewFluxColumnFull creates FluxColumn

func (*FluxColumn) DataType

func (f *FluxColumn) DataType() ColType

DataType returns data type of the column

func (*FluxColumn) DefaultValue

func (f *FluxColumn) DefaultValue() string

DefaultValue returns default value of the column

func (*FluxColumn) IsGroup

func (f *FluxColumn) IsGroup() bool

IsGroup return true if the column is grouping column

func (*FluxColumn) Name

func (f *FluxColumn) Name() string

Name returns name of the column

func (*FluxColumn) SetDataType

func (f *FluxColumn) SetDataType(dataType ColType)

SetDataType sets data type for the column

func (*FluxColumn) SetDefaultValue

func (f *FluxColumn) SetDefaultValue(defaultValue string)

SetDefaultValue sets default value for the column

func (*FluxColumn) SetGroup

func (f *FluxColumn) SetGroup(group bool)

SetGroup set group flag for the column

func (*FluxColumn) SetName

func (f *FluxColumn) SetName(name string)

SetName sets name of the column

func (*FluxColumn) String

func (f *FluxColumn) String() string

String returns FluxColumn string dump

type FluxRecord

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

FluxRecord represents row in the flux query result table

func NewFluxRecord

func NewFluxRecord(metadata *FluxTableMetadata, values map[string]interface{}) (*FluxRecord, error)

NewFluxRecord returns new record for the table with values

func (*FluxRecord) Field

func (r *FluxRecord) Field() string

Field returns the field name. Returns empty string if there is no column "_field".

func (*FluxRecord) Measurement

func (r *FluxRecord) Measurement() string

Measurement returns the measurement name of the record Returns empty string if there is no column "_measurement".

func (*FluxRecord) Result

func (r *FluxRecord) Result() string

Result returns the name of the result containing this record as specified by the query.

func (*FluxRecord) Start

func (r *FluxRecord) Start() time.Time

Start returns the inclusive lower time bound of all records in the current table. Returns empty time.Time if there is no column "_start".

func (*FluxRecord) Stop

func (r *FluxRecord) Stop() time.Time

Stop returns the exclusive upper time bound of all records in the current table. Returns empty time.Time if there is no column "_stop".

func (*FluxRecord) String

func (r *FluxRecord) String() string

String returns FluxRecord string dump

func (*FluxRecord) TableId

func (r *FluxRecord) TableId() int64

TableId returns index of the table record belongs to within its result.

func (*FluxRecord) Time

func (r *FluxRecord) Time() time.Time

Time returns the time of the record. Returns empty time.Time if there is no column "_time".

func (*FluxRecord) Value

func (r *FluxRecord) Value() interface{}

Value returns the default _value column value or nil if not present

func (*FluxRecord) ValueByKey

func (r *FluxRecord) ValueByKey(key string) interface{}

ValueByKey returns value for given column key for the record or nil of result has no value the column key

func (*FluxRecord) Values

func (r *FluxRecord) Values() map[string]interface{}

Values returns map of the values where key is the column name

type FluxTableMetadata

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

FluxTableMetadata holds flux query result table information represented by collection of columns. Each new table is introduced by annotations

func NewFluxTableMetadataFull

func NewFluxTableMetadataFull(columns ...*FluxColumn) *FluxTableMetadata

NewFluxTableMetadataFull creates FluxTableMetadata containing the given columns

func (*FluxTableMetadata) Column

func (f *FluxTableMetadata) Column(index int) *FluxColumn

Column returns flux table column by index. Returns nil if index is out of the bounds.

func (*FluxTableMetadata) Columns

func (f *FluxTableMetadata) Columns() []FluxColumn

Columns returns slice of flux query result table

func (*FluxTableMetadata) GroupKeyCols

func (f *FluxTableMetadata) GroupKeyCols() []string

GroupKeyCols returns the names of the grouping columns in the table, sorted in ascending order.

func (*FluxTableMetadata) ResultColumn

func (f *FluxTableMetadata) ResultColumn() *FluxColumn

ResultColumn returns metadata about the column naming results as specified by the query

func (*FluxTableMetadata) String

func (f *FluxTableMetadata) String() string

String returns FluxTableMetadata string dump

func (*FluxTableMetadata) TableIdColumn

func (f *FluxTableMetadata) TableIdColumn() *FluxColumn

TableIdColumn returns metadata about the column tracking table IDs within a result

type QueryTableResult

type QueryTableResult struct {
	io.Closer
	// contains filtered or unexported fields
}

QueryTableResult parses streamed flux query response into structures representing flux table parts Walking though the result is done by repeatedly calling Next() until returns false. Actual flux table info (columns with names, data types, etc) is returned by TableMetadata() method. Data are acquired by Record() method. Preliminary end can be caused by an error, so when Next() return false, check Err() for an error

func NewQueryTableResult

func NewQueryTableResult(rawResponse io.ReadCloser) *QueryTableResult

func (*QueryTableResult) AnnotationsChanged

func (q *QueryTableResult) AnnotationsChanged() bool

AnnotationsChanged returns true if last call of Next() found new CSV annotations

func (*QueryTableResult) Err

func (q *QueryTableResult) Err() error

Err returns an error raised during flux query response parsing

func (*QueryTableResult) Metadata

func (q *QueryTableResult) Metadata() *FluxTableMetadata

Metadata returns table-level info for last parsed flux table data row

func (*QueryTableResult) Next

func (q *QueryTableResult) Next() bool

Next advances to next row in query result. During the first time it is called, Next creates also table metadata Actual parsed row is available through Record() function Returns false in case of end or an error, otherwise true

func (*QueryTableResult) Record

func (q *QueryTableResult) Record() *FluxRecord

Record returns last parsed flux table data row Use Record methods to access value and row properties

func (*QueryTableResult) ResultChanged

func (q *QueryTableResult) ResultChanged() bool

ResultChanged returns true if the last call of Next() found a new query result

func (*QueryTableResult) TableIdChanged

func (q *QueryTableResult) TableIdChanged() bool

TableIdChanged returns true if the last call of Next() found a new table within the query result

Jump to

Keyboard shortcuts

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