responses

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 13 Imported by: 13

Documentation

Overview

Package responses contains routines for handling influx ql result sets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DivideRows

func DivideRows(lhs, rhs []models.Row, columnNames []string) (
	[]models.Row, error)

DivideRows divides two sets of rows. rows in lhs are the sums of values while the rows in rhs are the counts of the same values. The name and tags of a row in lhs must match the name and tags of a row in rhs to be divided. umatching rows are not included in result. columnNames are the names of the columns of the results.

func ExtractRows

func ExtractRows(resp *client.Response) ([]models.Row, error)

ExtractRows extracts the rows from the single result in the given response. ExtractRows returns an error if there are multiple results or if resp.Error() returns a non-nil value.

func FromTaggedTimeSeriesSets

func FromTaggedTimeSeriesSets(
	series []*tsdb.TaggedTimeSeriesSet,
	colNames [][]string,
	pqs []tsdbjson.ParsedQuery,
	epochConversion func(ts int64) int64) *client.Response

FromTaggedTimeSeriesSets converts a group of TaggedTimeSeriesSet instances to an influx db client.Response instance Elements in the pqs slice correspond to elements in the series and colNames slice. Elements in the series slice may be nil. FromTaggedTimeSeriesSets panics if pqs, series, and colNames have different lengths.

func Merge

func Merge(responses ...*client.Response) (*client.Response, error)

Merge merges responses from multiple servers into a single response. Merge expects the same query to be sent to all servers except for different time ranges. An error in any respone means an error in the merged response.

The returned response will contain time series with values sorted by time in increasing order even if the responses merged had times in decreasing order.

If the returned responses contain multiple series, they will be sorted first by name and then by the tags. When sorting tags, Merge first places the tag keys of the time series to be sorted in ascending order. To compare two sets of tags, Merge first compares the first pair of tag keys. If they match, Merge uses the values of those first keys to break the tie. If those match, Merge uses the second pair of tag keys to break the tie. If those match, Merge uses the values of the second keys to brak the tie etc.

If multiple responses contain different values for the same timestamp within the same series, then the value from the response listed last shows up in returned response while the other values for that same timestamp within that same series do not show up in returned response.

Merge includes all messages from the responses being merged in the merged response.

func MergePreferred

func MergePreferred(response, preferred *client.Response) (
	*client.Response, error)

MergePreferred merges a response from a preferred source, such as scotty, with an existing response using the following rules.

  1. MergePreferred combines the rows from preferred with the rows in response.
  2. If preferred and response both contain a row with both the same name and the same tags then MergePreferred merges that row using the the following rules:

2a. Find the earliest time for which the row in preferred has data 2b. To merge use the values in original for times before the time in 2a and

use the values in preferred for times on or after the time in 2a

func Serialise

func Serialise(resp *client.Response) (interface{}, error)

Serialise converts an influx response into a structure ready for json encoding. If resp contains an error within it, Serialise() returns nil with that error.

func SumRowsTogether

func SumRowsTogether(rows ...[]models.Row) ([]models.Row, error)

SumRowsTogether sums together the values in multiple sets of rows. values in rows are summed together only if they have the same name and tags. Rows with different names and tags are kept separate in the returned result.

Types

This section is empty.

Jump to

Keyboard shortcuts

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