influxql

package
v1.0.0-beta2.0...-9fb1c51 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2016 License: MIT Imports: 24 Imported by: 0

README

The Influx Query Language Specification

Introduction

This is a reference for the Influx Query Language ("InfluxQL").

InfluxQL is a SQL-like query language for interacting with InfluxDB. It has been lovingly crafted to feel familiar to those coming from other SQL or SQL-like environments while providing features specific to storing and analyzing time series data.

Notation

The syntax is specified using Extended Backus-Naur Form ("EBNF"). EBNF is the same notation used in the Go programming language specification, which can be found here. Not so coincidentally, InfluxDB is written in Go.

Production  = production_name "=" [ Expression ] "." .
Expression  = Alternative { "|" Alternative } .
Alternative = Term { Term } .
Term        = production_name | token [ "…" token ] | Group | Option | Repetition .
Group       = "(" Expression ")" .
Option      = "[" Expression "]" .
Repetition  = "{" Expression "}" .

Notation operators in order of increasing precedence:

|   alternation
()  grouping
[]  option (0 or 1 times)
{}  repetition (0 to n times)

Query representation

Characters

InfluxQL is Unicode text encoded in UTF-8.

newline             = /* the Unicode code point U+000A */ .
unicode_char        = /* an arbitrary Unicode code point except newline */ .

Letters and digits

Letters are the set of ASCII characters plus the underscore character _ (U+005F) is considered a letter.

Only decimal digits are supported.

letter              = ascii_letter | "_" .
ascii_letter        = "A" … "Z" | "a" … "z" .
digit               = "0" … "9" .

Identifiers

Identifiers are tokens which refer to database names, retention policy names, user names, measurement names, tag keys, and field keys.

The rules:

  • double quoted identifiers can contain any unicode character other than a new line
  • double quoted identifiers can contain escaped " characters (i.e., \")
  • unquoted identifiers must start with an upper or lowercase ASCII character or "_"
  • unquoted identifiers may contain only ASCII letters, decimal digits, and "_"
identifier          = unquoted_identifier | quoted_identifier .
unquoted_identifier = ( letter ) { letter | digit } .
quoted_identifier   = `"` unicode_char { unicode_char } `"` .
Examples:
cpu
_cpu_stats
"1h"
"anything really"
"1_Crazy-1337.identifier>NAME👍"

Keywords

ALL           ALTER         ANY           AS            ASC           BEGIN
BY            CREATE        CONTINUOUS    DATABASE      DATABASES     DEFAULT
DELETE        DESC          DESTINATIONS  DIAGNOSTICS   DISTINCT      DROP
DURATION      END           EVERY         EXISTS        EXPLAIN       FIELD
FOR           FORCE         FROM          GRANT         GRANTS        GROUP
GROUPS        IF            IN            INF           INNER         INSERT
INTO          KEY           KEYS          LIMIT         SHOW          MEASUREMENT
MEASUREMENTS  NAME          NOT           OFFSET        ON            ORDER
PASSWORD      POLICY        POLICIES      PRIVILEGES    QUERIES       QUERY
READ          REPLICATION   RESAMPLE      RETENTION     REVOKE        SELECT
SERIES        SET           SHARD         SHARDS        SLIMIT        SOFFSET
STATS         SUBSCRIPTION  SUBSCRIPTIONS TAG           TO            USER
USERS         VALUES        WHERE         WITH          WRITE

Literals

Integers

InfluxQL supports decimal integer literals. Hexadecimal and octal literals are not currently supported.

int_lit             = ( "1" … "9" ) { digit } .
Floats

InfluxQL supports floating-point literals. Exponents are not currently supported.

float_lit           = int_lit "." int_lit .
Strings

String literals must be surrounded by single quotes. Strings may contain ' characters as long as they are escaped (i.e., \').

string_lit          = `'` { unicode_char } `'` .
Durations

Duration literals specify a length of time. An integer literal followed immediately (with no spaces) by a duration unit listed below is interpreted as a duration literal.

Duration units
Units Meaning
u or µ microseconds (1 millionth of a second)
ms milliseconds (1 thousandth of a second)
s second
m minute
h hour
d day
w week
duration_lit        = int_lit duration_unit .
duration_unit       = "u" | "µ" | "s" | "h" | "d" | "w" | "ms" .
Dates & Times

The date and time literal format is not specified in EBNF like the rest of this document. It is specified using Go's date / time parsing format, which is a reference date written in the format required by InfluxQL. The reference date time is:

InfluxQL reference date time: January 2nd, 2006 at 3:04:05 PM

time_lit            = "2006-01-02 15:04:05.999999" | "2006-01-02" .
Booleans
bool_lit            = TRUE | FALSE .
Regular Expressions
regex_lit           = "/" { unicode_char } "/" .

Queries

A query is composed of one or more statements separated by a semicolon.

query               = statement { ";" statement } .

statement           = alter_retention_policy_stmt |
                      create_continuous_query_stmt |
                      create_database_stmt |
                      create_retention_policy_stmt |
                      create_subscription_stmt |
                      create_user_stmt |
                      delete_stmt |
                      drop_continuous_query_stmt |
                      drop_database_stmt |
                      drop_measurement_stmt |
                      drop_retention_policy_stmt |
                      drop_series_stmt |
                      drop_subscription_stmt |
                      drop_user_stmt |
                      grant_stmt |
                      show_continuous_queries_stmt |
                      show_databases_stmt |
                      show_field_keys_stmt |
                      show_grants_stmt |
                      show_measurements_stmt |
                      show_retention_policies |
                      show_series_stmt |
                      show_shard_groups_stmt |
                      show_shards_stmt |
                      show_subscriptions_stmt|
                      show_tag_keys_stmt |
                      show_tag_values_stmt |
                      show_users_stmt |
                      revoke_stmt |
                      select_stmt .

Statements

ALTER RETENTION POLICY
alter_retention_policy_stmt  = "ALTER RETENTION POLICY" policy_name on_clause
                               retention_policy_option
                               [ retention_policy_option ]
                               [ retention_policy_option ] .
Examples:
-- Set default retention policy for mydb to 1h.cpu.
ALTER RETENTION POLICY "1h.cpu" ON mydb DEFAULT;

-- Change duration and replication factor.
ALTER RETENTION POLICY policy1 ON somedb DURATION 1h REPLICATION 4
CREATE CONTINUOUS QUERY
create_continuous_query_stmt = "CREATE CONTINUOUS QUERY" query_name on_clause
                               [ "RESAMPLE" resample_opts ]
                               "BEGIN" select_stmt "END" .

query_name                   = identifier .

resample_opts                = (every_stmt for_stmt | every_stmt | for_stmt) .
every_stmt                   = "EVERY" duration_lit
for_stmt                     = "FOR" duration_lit
Examples:
-- selects from default retention policy and writes into 6_months retention policy
CREATE CONTINUOUS QUERY "10m_event_count"
ON db_name
BEGIN
  SELECT count(value)
  INTO "6_months".events
  FROM events
  GROUP BY time(10m)
END;

-- this selects from the output of one continuous query in one retention policy and outputs to another series in another retention policy
CREATE CONTINUOUS QUERY "1h_event_count"
ON db_name
BEGIN
  SELECT sum(count) as count
  INTO "2_years".events
  FROM "6_months".events
  GROUP BY time(1h)
END;

-- this customizes the resample interval so the interval is queried every 10s and intervals are resampled until 2m after their start time
-- when resample is used, at least one of "EVERY" or "FOR" must be used
CREATE CONTINUOUS QUERY "cpu_mean"
ON db_name
RESAMPLE EVERY 10s FOR 2m
BEGIN
  SELECT mean(value)
  INTO "cpu_mean"
  FROM "cpu"
  GROUP BY time(1m)
END;
CREATE DATABASE
create_database_stmt = "CREATE DATABASE" db_name .
Example:
CREATE DATABASE foo
CREATE RETENTION POLICY
create_retention_policy_stmt = "CREATE RETENTION POLICY" policy_name on_clause
                               retention_policy_duration
                               retention_policy_replication
                               [ "DEFAULT" ] .
Examples
-- Create a retention policy.
CREATE RETENTION POLICY "10m.events" ON somedb DURATION 10m REPLICATION 2;

-- Create a retention policy and set it as the default.
CREATE RETENTION POLICY "10m.events" ON somedb DURATION 10m REPLICATION 2 DEFAULT;
CREATE SUBSCRIPTION
create_subscription_stmt = "CREATE SUBSCRIPTION" subscription_name "ON" db_name "." retention_policy "DESTINATIONS" ("ANY"|"ALL") host { "," host} .
Examples:
-- Create a SUBSCRIPTION on database 'mydb' and retention policy 'default' that send data to 'example.com:9090' via UDP.
CREATE SUBSCRIPTION sub0 ON "mydb"."default" DESTINATIONS ALL 'udp://example.com:9090' ;

-- Create a SUBSCRIPTION on database 'mydb' and retention policy 'default' that round robins the data to 'h1.example.com:9090' and 'h2.example.com:9090'.
CREATE SUBSCRIPTION sub0 ON "mydb"."default" DESTINATIONS ANY 'udp://h1.example.com:9090', 'udp://h2.example.com:9090';
CREATE USER
create_user_stmt = "CREATE USER" user_name "WITH PASSWORD" password
                   [ "WITH ALL PRIVILEGES" ] .
Examples:
-- Create a normal database user.
CREATE USER jdoe WITH PASSWORD '1337password';

-- Create a cluster admin.
-- Note: Unlike the GRANT statement, the "PRIVILEGES" keyword is required here.
CREATE USER jdoe WITH PASSWORD '1337password' WITH ALL PRIVILEGES;
DELETE
delete_stmt = "DELETE" ( from_clause | where_clause | from_clause where_clause ) .
Example:
DELETE FROM cpu
DELETE FROM cpu WHERE time < '2000-01-01T00:00:00Z'
DELETE WHERE time < '2000-01-01T00:00:00Z'
DROP CONTINUOUS QUERY
drop_continuous_query_stmt = "DROP CONTINUOUS QUERY" query_name on_clause .
Example:
DROP CONTINUOUS QUERY myquery ON mydb;
DROP DATABASE
drop_database_stmt = "DROP DATABASE" db_name .
Example:
DROP DATABASE mydb;
DROP MEASUREMENT
drop_measurement_stmt = "DROP MEASUREMENT" measurement_name .
Examples:
-- drop the cpu measurement
DROP MEASUREMENT cpu;
DROP RETENTION POLICY
drop_retention_policy_stmt = "DROP RETENTION POLICY" policy_name on_clause .
Example:
-- drop the retention policy named 1h.cpu from mydb
DROP RETENTION POLICY "1h.cpu" ON mydb;
DROP SERIES
drop_series_stmt = "DROP SERIES" ( from_clause | where_clause | from_clause where_clause ) .
Example:

DROP SUBSCRIPTION
drop_subscription_stmt = "DROP SUBSCRIPTION" subscription_name "ON" db_name "." retention_policy .
Example:
DROP SUBSCRIPTION sub0 ON "mydb"."default";

DROP USER
drop_user_stmt = "DROP USER" user_name .
Example:
DROP USER jdoe;

GRANT

NOTE: Users can be granted privileges on databases that do not exist.

grant_stmt = "GRANT" privilege [ on_clause ] to_clause .
Examples:
-- grant cluster admin privileges
GRANT ALL TO jdoe;

-- grant read access to a database
GRANT READ ON mydb TO jdoe;
SHOW CONTINUOUS QUERIES
show_continuous_queries_stmt = "SHOW CONTINUOUS QUERIES" .
Example:
-- show all continuous queries
SHOW CONTINUOUS QUERIES;
SHOW DATABASES
show_databases_stmt = "SHOW DATABASES" .
Example:
-- show all databases
SHOW DATABASES;
SHOW FIELD KEYS
show_field_keys_stmt = "SHOW FIELD KEYS" [ from_clause ] .
Examples:
-- show field keys from all measurements
SHOW FIELD KEYS;

-- show field keys from specified measurement
SHOW FIELD KEYS FROM cpu;
SHOW GRANTS
show_grants_stmt = "SHOW GRANTS FOR" user_name .
Example:
-- show grants for jdoe
SHOW GRANTS FOR jdoe;
SHOW MEASUREMENTS
show_measurements_stmt = "SHOW MEASUREMENTS" [ with_measurement_clause ] [ where_clause ] [ limit_clause ] [ offset_clause ] .
-- show all measurements
SHOW MEASUREMENTS;

-- show measurements where region tag = 'uswest' AND host tag = 'serverA'
SHOW MEASUREMENTS WHERE region = 'uswest' AND host = 'serverA';
SHOW RETENTION POLICIES
show_retention_policies = "SHOW RETENTION POLICIES" on_clause .
Example:
-- show all retention policies on a database
SHOW RETENTION POLICIES ON mydb;
SHOW SERIES
show_series_stmt = "SHOW SERIES" [ from_clause ] [ where_clause ] [ limit_clause ] [ offset_clause ] .
Example:

SHOW SHARD GROUPS
show_shard_groups_stmt = "SHOW SHARD GROUPS" .
Example:
SHOW SHARD GROUPS;
SHOW SHARDS
show_shards_stmt = "SHOW SHARDS" .
Example:
SHOW SHARDS;
SHOW SUBSCRIPTIONS
show_subscriptions_stmt = "SHOW SUBSCRIPTIONS" .
Example:
SHOW SUBSCRIPTIONS;
SHOW TAG KEYS
show_tag_keys_stmt = "SHOW TAG KEYS" [ from_clause ] [ where_clause ] [ group_by_clause ]
                     [ limit_clause ] [ offset_clause ] .
Examples:
-- show all tag keys
SHOW TAG KEYS;

-- show all tag keys from the cpu measurement
SHOW TAG KEYS FROM cpu;

-- show all tag keys from the cpu measurement where the region key = 'uswest'
SHOW TAG KEYS FROM cpu WHERE region = 'uswest';

-- show all tag keys where the host key = 'serverA'
SHOW TAG KEYS WHERE host = 'serverA';
SHOW TAG VALUES
show_tag_values_stmt = "SHOW TAG VALUES" [ from_clause ] with_tag_clause [ where_clause ]
                       [ group_by_clause ] [ limit_clause ] [ offset_clause ] .
Examples:
-- show all tag values across all measurements for the region tag
SHOW TAG VALUES WITH TAG = 'region';

-- show tag values from the cpu measurement for the region tag
SHOW TAG VALUES FROM cpu WITH KEY = 'region';

-- show tag values from the cpu measurement for region & host tag keys where service = 'redis'
SHOW TAG VALUES FROM cpu WITH KEY IN (region, host) WHERE service = 'redis';
SHOW USERS
show_users_stmt = "SHOW USERS" .
Example:
-- show all users
SHOW USERS;
REVOKE
revoke_stmt = "REVOKE" privilege [ on_clause ] "FROM" user_name .
Examples:
-- revoke cluster admin from jdoe
REVOKE ALL PRIVILEGES FROM jdoe;

-- revoke read privileges from jdoe on mydb
REVOKE READ ON mydb FROM jdoe;
SELECT
select_stmt = "SELECT" fields from_clause [ into_clause ] [ where_clause ]
              [ group_by_clause ] [ order_by_clause ] [ limit_clause ]
              [ offset_clause ] [ slimit_clause ] [ soffset_clause ] .
Examples:
-- select mean value from the cpu measurement where region = 'uswest' grouped by 10 minute intervals
SELECT mean(value) FROM cpu WHERE region = 'uswest' GROUP BY time(10m) fill(0);

-- select from all measurements beginning with cpu into the same measurement name in the cpu_1h retention policy
SELECT mean(value) INTO cpu_1h.:MEASUREMENT FROM /cpu.*/

Clauses

from_clause     = "FROM" measurements .

group_by_clause = "GROUP BY" dimensions fill(fill_option).

into_clause     = "INTO" ( measurement | back_ref ).

limit_clause    = "LIMIT" int_lit .

offset_clause   = "OFFSET" int_lit .

slimit_clause   = "SLIMIT" int_lit .

soffset_clause  = "SOFFSET" int_lit .

on_clause       = "ON" db_name .

order_by_clause = "ORDER BY" sort_fields .

to_clause       = "TO" user_name .

where_clause    = "WHERE" expr .

with_measurement_clause = "WITH MEASUREMENT" ( "=" measurement | "=~" regex_lit ) .

with_tag_clause = "WITH KEY" ( "=" tag_key | "IN (" tag_keys ")" ) .

Expressions

binary_op        = "+" | "-" | "*" | "/" | "AND" | "OR" | "=" | "!=" | "<" |
                   "<=" | ">" | ">=" .

expr             = unary_expr { binary_op unary_expr } .

unary_expr       = "(" expr ")" | var_ref | time_lit | string_lit | int_lit |
                   float_lit | bool_lit | duration_lit | regex_lit .

Other

alias            = "AS" identifier .

back_ref         = ( policy_name ".:MEASUREMENT" ) |
                   ( db_name "." [ policy_name ] ".:MEASUREMENT" ) .

db_name          = identifier .

dimension        = expr .

dimensions       = dimension { "," dimension } .

field_key        = identifier .

field            = expr [ alias ] .

fields           = field { "," field } .

fill_option      = "null" | "none" | "previous" | int_lit | float_lit .

host             = string_lit .

measurement      = measurement_name |
                   ( policy_name "." measurement_name ) |
                   ( db_name "." [ policy_name ] "." measurement_name ) .

measurements     = measurement { "," measurement } .

measurement_name = identifier | regex_lit .

password         = string_lit .

policy_name      = identifier .

privilege        = "ALL" [ "PRIVILEGES" ] | "READ" | "WRITE" .

query_name       = identifier .

retention_policy = identifier .

retention_policy_option      = retention_policy_duration |
                               retention_policy_replication |
                               "DEFAULT" .

retention_policy_duration    = "DURATION" duration_lit .
retention_policy_replication = "REPLICATION" int_lit

series_id        = int_lit .

sort_field       = field_key [ ASC | DESC ] .

sort_fields      = sort_field { "," sort_field } .

subscription_name = identifier .

tag_key          = identifier .

tag_keys         = tag_key { "," tag_key } .

user_name        = identifier .

var_ref          = measurement .

Query Engine Internals

Once you understand the language itself, it's important to know how these language constructs are implemented in the query engine. This gives you an intuitive sense for how results will be processed and how to create efficient queries.

The life cycle of a query looks like this:

  1. InfluxQL query string is tokenized and then parsed into an abstract syntax tree (AST). This is the code representation of the query itself.

  2. The AST is passed to the QueryExecutor which directs queries to the appropriate handlers. For example, queries related to meta data are executed by the meta service and SELECT statements are executed by the shards themselves.

  3. The query engine then determines the shards that match the SELECT statement's time range. From these shards, iterators are created for each field in the statement.

  4. Iterators are passed to the emitter which drains them and joins the resulting points. The emitter's job is to convert simple time/value points into the more complex result objects that are returned to the client.

Understanding Iterators

Iterators are at the heart of the query engine. They provide a simple interface for looping over a set of points. For example, this is an iterator over Float points:

type FloatIterator interface {
    Next() *FloatPoint
}

These iterators are created through the IteratorCreator interface:

type IteratorCreator interface {
    CreateIterator(opt *IteratorOptions) (Iterator, error)
}

The IteratorOptions provide arguments about field selection, time ranges, and dimensions that the iterator creator can use when planning an iterator. The IteratorCreator interface is used at many levels such as the Shards, Shard, and Engine. This allows optimizations to be performed when applicable such as returning a precomputed COUNT().

Iterators aren't just for reading raw data from storage though. Iterators can be composed so that they provided additional functionality around an input iterator. For example, a DistinctIterator can compute the distinct values for each time window for an input iterator. Or a FillIterator can generate additional points that are missing from an input iterator.

This composition also lends itself well to aggregation. For example, a statement such as this:

SELECT MEAN(value) FROM cpu GROUP BY time(10m)

In this case, MEAN(value) is a MeanIterator wrapping an iterator from the underlying shards. However, if we can add an additional iterator to determine the derivative of the mean:

SELECT DERIVATIVE(MEAN(value), 20m) FROM cpu GROUP BY time(10m)
Understanding Auxiliary Fields

Because InfluxQL allows users to use selector functions such as FIRST(), LAST(), MIN(), and MAX(), the engine must provide a way to return related data at the same time with the selected point.

For example, in this query:

SELECT FIRST(value), host FROM cpu GROUP BY time(1h)

We are selecting the first value that occurs every hour but we also want to retrieve the host associated with that point. Since the Point types only specify a single typed Value for efficiency, we push the host into the auxiliary fields of the point. These auxiliary fields are attached to the point until it is passed to the emitter where the fields get split off to their own iterator.

Built-in Iterators

There are many helper iterators that let us build queries:

  • Merge Iterator - This iterator combines one or more iterators into a single new iterator of the same type. This iterator guarantees that all points within a window will be output before starting the next window but does not provide ordering guarantees within the window. This allows for fast access for aggregate queries which do not need stronger sorting guarantees.

  • Sorted Merge Iterator - This iterator also combines one or more iterators into a new iterator of the same type. However, this iterator guarantees time ordering of every point. This makes it slower than the MergeIterator but this ordering guarantee is required for non-aggregate queries which return the raw data points.

  • Limit Iterator - This iterator limits the number of points per name/tag group. This is the implementation of the LIMIT & OFFSET syntax.

  • Fill Iterator - This iterator injects extra points if they are missing from the input iterator. It can provide null points, points with the previous value, or points with a specific value.

  • Buffered Iterator - This iterator provides the ability to "unread" a point back onto a buffer so it can be read again next time. This is used extensively to provide lookahead for windowing.

  • Reduce Iterator - This iterator calls a reduction function for each point in a window. When the window is complete then all points for that window are output. This is used for simple aggregate functions such as COUNT().

  • Reduce Slice Iterator - This iterator collects all points for a window first and then passes them all to a reduction function at once. The results are returned from the iterator. This is used for aggregate functions such as DERIVATIVE().

  • Transform Iterator - This iterator calls a transform function for each point from an input iterator. This is used for executing binary expressions.

  • Dedupe Iterator - This iterator only outputs unique points. It is resource intensive so it is only used for small queries such as meta query statements.

Call Iterators

Function calls in InfluxQL are implemented at two levels. Some calls can be wrapped at multiple layers to improve efficiency. For example, a COUNT() can be performed at the shard level and then multiple CountIterators can be wrapped with another CountIterator to compute the count of all shards. These iterators can be created using NewCallIterator().

Some iterators are more complex or need to be implemented at a higher level. For example, the DERIVATIVE() needs to retrieve all points for a window first before performing the calculation. This iterator is created by the engine itself and is never requested to be created by the lower levels.

Documentation

Overview

Package influxql implements a parser for the InfluxDB query language.

InfluxQL is a DML and DDL language for the InfluxDB time series database. It provides the ability to query for aggregate statistics as well as create and configure the InfluxDB server.

Selecting data

The SELECT query is used for retrieving data from one or more series. It allows for a list of columns followed by a list of series to select from.

SELECT value FROM cpu_load

You can also add a a conditional expression to limit the results of the query:

SELECT value FROM cpu_load WHERE host = 'influxdb.com'

Limits and ordering can be set on selection queries as well:

SELECT value FROM cpu_load LIMIT 100 ORDER DESC;

Removing data

The DELETE query is available to remove time series data points from the database. This query will delete "cpu_load" values older than an hour:

DELETE FROM cpu_load WHERE time < now() - 1h

Continuous Queries

Queries can be run indefinitely on the server in order to generate new series. This is done by running a "SELECT INTO" query. For example, this query computes the hourly mean for cpu_load and stores it into a "cpu_load" series in the "daily" shard space.

SELECT mean(value) AS value FROM cpu_load GROUP BY 1h
INTO daily.cpu_load

If there is existing data on the source series then this query will be run for all historic data. To only execute the query on new incoming data you can append "NO BACKFILL" to the end of the query:

SELECT mean(value) AS value FROM cpu_load GROUP BY 1h
INTO daily.cpu_load NO BACKFILL

Continuous queries will return an id that can be used to remove them in the future. To remove a continous query, use the DROP CONTINUOUS QUERY statement:

DROP CONTINUOUS QUERY 12

You can also list all continuous queries by running:

LIST CONTINUOUS QUERIES

Index

Constants

View Source
const (
	// Unknown primitive data type.
	Unknown DataType = 0
	// Float means the data type is a float
	Float = 1
	// Integer means the data type is a integer
	Integer = 2
	// String means the data type is a string of text.
	String = 3
	// Boolean means the data type is a boolean.
	Boolean = 4
	// Time means the data type is a time.
	Time = 5
	// Duration means the data type is a duration of time.
	Duration = 6
	// Tag means the data type is a tag.
	Tag = 7
	// AnyField means the data type is any field.
	AnyField = 8
)
View Source
const (
	// MinTime is used as the minimum time value when computing an unbounded range.
	MinTime = int64(0)

	// MaxTime is used as the maximum time value when computing an unbounded range.
	// This time is 2262-04-11 23:47:16.854775806 +0000 UTC
	MaxTime = models.MaxNanoTime
)
View Source
const (
	// DateFormat represents the format for date literals.
	DateFormat = "2006-01-02"

	// DateTimeFormat represents the format for date time literals.
	DateTimeFormat = "2006-01-02 15:04:05.999999"
)
View Source
const (
	// DefaultQueryTimeout is the default timeout for executing a query.
	// A value of zero will have no query timeout.
	DefaultQueryTimeout = time.Duration(0)
)
View Source
const DefaultStatsInterval = 10 * time.Second

DefaultStatsInterval is the default value for IteratorEncoder.StatsInterval.

View Source
const (
	// WarningLevel is the message level for a warning.
	WarningLevel = "warning"
)
View Source
const ZeroTime = int64(-6795364578871345152)

ZeroTime is the Unix nanosecond timestamp for time.Time{}.

Variables

View Source
var (
	// ErrInvalidQuery is returned when executing an unknown query type.
	ErrInvalidQuery = errors.New("invalid query")

	// ErrNotExecuted is returned when a statement is not executed in a query.
	// This can occur when a previous statement in the same query has errored.
	ErrNotExecuted = errors.New("not executed")

	// ErrQueryInterrupted is an error returned when the query is interrupted.
	ErrQueryInterrupted = errors.New("query interrupted")

	// ErrMaxConcurrentQueriesReached is an error when a query cannot be run
	// because the maximum number of queries has been reached.
	ErrMaxConcurrentQueriesReached = errors.New("max concurrent queries reached")

	// ErrQueryEngineShutdown is an error sent when the query cannot be
	// created because the query engine was shutdown.
	ErrQueryEngineShutdown = errors.New("query engine shutdown")

	// ErrMaxPointsReached is an error when a query hits the maximum number of
	// points.
	ErrMaxPointsReached = errors.New("max number of points reached")

	// ErrQueryTimeoutReached is an error when a query hits the timeout.
	ErrQueryTimeoutReached = errors.New("query timeout reached")
)
View Source
var ErrInvalidDuration = errors.New("invalid duration")

ErrInvalidDuration is returned when parsing a malformatted duration.

View Source
var (
	// ErrInvalidTime is returned when the timestamp string used to
	// compare against time field is invalid.
	ErrInvalidTime = errors.New("invalid timestamp string")
)
View Source
var ErrUnknownCall = errors.New("unknown call")

ErrUnknownCall is returned when operating on an unknown function call.

Functions

func AggregateBooleanPoints

func AggregateBooleanPoints(a BooleanPointAggregator, points []BooleanPoint)

AggregateBooleanPoints feeds a slice of BooleanPoint into an aggregator. If the aggregator is a BooleanBulkPointAggregator, it will use the AggregateBulk method.

func AggregateFloatPoints

func AggregateFloatPoints(a FloatPointAggregator, points []FloatPoint)

AggregateFloatPoints feeds a slice of FloatPoint into an aggregator. If the aggregator is a FloatBulkPointAggregator, it will use the AggregateBulk method.

func AggregateIntegerPoints

func AggregateIntegerPoints(a IntegerPointAggregator, points []IntegerPoint)

AggregateIntegerPoints feeds a slice of IntegerPoint into an aggregator. If the aggregator is a IntegerBulkPointAggregator, it will use the AggregateBulk method.

func AggregateStringPoints

func AggregateStringPoints(a StringPointAggregator, points []StringPoint)

AggregateStringPoints feeds a slice of StringPoint into an aggregator. If the aggregator is a StringBulkPointAggregator, it will use the AggregateBulk method.

func BinaryExprName

func BinaryExprName(expr *BinaryExpr) string

BinaryExprName returns the name of a binary expression by concatenating the variables in the binary expression with underscores.

func BooleanCountReduce

func BooleanCountReduce(prev *IntegerPoint, curr *BooleanPoint) (int64, int64, []interface{})

BooleanCountReduce returns the count of points.

func BooleanFirstReduce

func BooleanFirstReduce(prev, curr *BooleanPoint) (int64, bool, []interface{})

BooleanFirstReduce returns the first point sorted by time.

func BooleanLastReduce

func BooleanLastReduce(prev, curr *BooleanPoint) (int64, bool, []interface{})

BooleanLastReduce returns the first point sorted by time.

func BooleanMaxReduce

func BooleanMaxReduce(prev, curr *BooleanPoint) (int64, bool, []interface{})

BooleanMaxReduce returns the minimum value between prev & curr.

func BooleanMinReduce

func BooleanMinReduce(prev, curr *BooleanPoint) (int64, bool, []interface{})

BooleanMinReduce returns the minimum value between prev & curr.

func ContainsVarRef

func ContainsVarRef(expr Expr) bool

ContainsVarRef returns true if expr is a VarRef or contains one.

func DrainIterator

func DrainIterator(itr Iterator)

DrainIterator reads all points from an iterator.

func DrainIterators

func DrainIterators(itrs []Iterator)

DrainIterators reads all points from all iterators.

func ErrDatabaseNotFound

func ErrDatabaseNotFound(name string) error

ErrDatabaseNotFound returns a database not found error for the given database name.

func ErrMeasurementNotFound

func ErrMeasurementNotFound(name string) error

ErrMeasurementNotFound returns a measurement not found error for the given measurement name.

func Eval

func Eval(expr Expr, m map[string]interface{}) interface{}

Eval evaluates expr against a map.

func EvalBool

func EvalBool(expr Expr, m map[string]interface{}) bool

EvalBool evaluates expr and returns true if result is a boolean true. Otherwise returns false.

func FloatCountReduce

func FloatCountReduce(prev *IntegerPoint, curr *FloatPoint) (int64, int64, []interface{})

FloatCountReduce returns the count of points.

func FloatFirstReduce

func FloatFirstReduce(prev, curr *FloatPoint) (int64, float64, []interface{})

FloatFirstReduce returns the first point sorted by time.

func FloatLastReduce

func FloatLastReduce(prev, curr *FloatPoint) (int64, float64, []interface{})

FloatLastReduce returns the last point sorted by time.

func FloatMaxReduce

func FloatMaxReduce(prev, curr *FloatPoint) (int64, float64, []interface{})

FloatMaxReduce returns the maximum value between prev & curr.

func FloatMinReduce

func FloatMinReduce(prev, curr *FloatPoint) (int64, float64, []interface{})

FloatMinReduce returns the minimum value between prev & curr.

func FloatSumReduce

func FloatSumReduce(prev, curr *FloatPoint) (int64, float64, []interface{})

FloatSumReduce returns the sum prev value & curr value.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration to a string.

func HasTimeExpr

func HasTimeExpr(expr Expr) bool

HasTimeExpr returns true if the expression has a time term.

func IdentNeedsQuotes

func IdentNeedsQuotes(ident string) bool

IdentNeedsQuotes returns true if the ident string given would require quotes.

func IntegerCountReduce

func IntegerCountReduce(prev, curr *IntegerPoint) (int64, int64, []interface{})

IntegerCountReduce returns the count of points.

func IntegerFirstReduce

func IntegerFirstReduce(prev, curr *IntegerPoint) (int64, int64, []interface{})

IntegerFirstReduce returns the first point sorted by time.

func IntegerLastReduce

func IntegerLastReduce(prev, curr *IntegerPoint) (int64, int64, []interface{})

IntegerLastReduce returns the last point sorted by time.

func IntegerMaxReduce

func IntegerMaxReduce(prev, curr *IntegerPoint) (int64, int64, []interface{})

IntegerMaxReduce returns the maximum value between prev & curr.

func IntegerMinReduce

func IntegerMinReduce(prev, curr *IntegerPoint) (int64, int64, []interface{})

IntegerMinReduce returns the minimum value between prev & curr.

func IntegerSumReduce

func IntegerSumReduce(prev, curr *IntegerPoint) (int64, int64, []interface{})

IntegerSumReduce returns the sum prev value & curr value.

func IsRegexOp

func IsRegexOp(t Token) bool

IsRegexOp returns true if the operator accepts a regex operand.

func IsSystemName

func IsSystemName(name string) bool

IsSystemName returns true if name is an internal system name.

func MatchSource

func MatchSource(sources Sources, name string) string

MatchSource returns the source name that matches a field name. Returns a blank string if no sources match.

func OnlyTimeExpr

func OnlyTimeExpr(expr Expr) bool

OnlyTimeExpr returns true if the expression only has time constraints.

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a time duration from a string.

func QuoteIdent

func QuoteIdent(segments ...string) string

QuoteIdent returns a quoted identifier from multiple bare identifiers.

func QuoteString

func QuoteString(s string) string

QuoteString returns a quoted string.

func Sanitize

func Sanitize(query string) string

Sanitize attempts to sanitize passwords out of a raw query. It looks for patterns that may be related to the SET PASSWORD and CREATE USER statements and will redact the password that should be there. It will attempt to redact information from common invalid queries too, but it's not guaranteed to succeed on improper queries.

This function works on the raw query and attempts to retain the original input as much as possible.

func ScanBareIdent

func ScanBareIdent(r io.RuneScanner) string

ScanBareIdent reads bare identifier from a rune reader.

func ScanDelimited

func ScanDelimited(r io.RuneScanner, start, end rune, escapes map[rune]rune, escapesPassThru bool) ([]byte, error)

ScanDelimited reads a delimited set of runes

func ScanString

func ScanString(r io.RuneScanner) (string, error)

ScanString reads a quoted string from a rune reader.

func StringCountReduce

func StringCountReduce(prev *IntegerPoint, curr *StringPoint) (int64, int64, []interface{})

StringCountReduce returns the count of points.

func StringFirstReduce

func StringFirstReduce(prev, curr *StringPoint) (int64, string, []interface{})

StringFirstReduce returns the first point sorted by time.

func StringLastReduce

func StringLastReduce(prev, curr *StringPoint) (int64, string, []interface{})

StringLastReduce returns the first point sorted by time.

func TimeRange

func TimeRange(expr Expr) (min, max time.Time, err error)

TimeRange returns the minimum and maximum times specified by an expression. Returns zero times if there is no bound.

func TimeRangeAsEpochNano

func TimeRangeAsEpochNano(expr Expr) (min, max int64, err error)

TimeRangeAsEpochNano returns the minimum and maximum times, as epoch nano, specified by and expression. If there is no lower bound, the start of the epoch is returned for minimum. If there is no higher bound, now is returned for maximum.

func Walk

func Walk(v Visitor, node Node)

Walk traverses a node hierarchy in depth-first order.

func WalkFunc

func WalkFunc(node Node, fn func(Node))

WalkFunc traverses a node hierarchy in depth-first order.

Types

type AlterRetentionPolicyStatement

type AlterRetentionPolicyStatement struct {
	// Name of policy to alter.
	Name string

	// Name of the database this policy belongs to.
	Database string

	// Duration data written to this policy will be retained.
	Duration *time.Duration

	// Replication factor for data written to this policy.
	Replication *int

	// Should this policy be set as defalut for the database?
	Default bool

	// Duration of the Shard
	ShardGroupDuration *time.Duration
}

AlterRetentionPolicyStatement represents a command to alter an existing retention policy.

func (*AlterRetentionPolicyStatement) RequiredPrivileges

func (s *AlterRetentionPolicyStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute an AlterRetentionPolicyStatement.

func (*AlterRetentionPolicyStatement) String

String returns a string representation of the alter retention policy statement.

type AuxIterator

type AuxIterator interface {
	Iterator
	IteratorCreator

	// Auxilary iterator
	Iterator(name string, typ DataType) Iterator

	// Start starts writing to the created iterators.
	Start()

	// Backgrounds the iterator so that, when start is called, it will
	// continuously read from the iterator.
	Background()
}

AuxIterator represents an iterator that can split off separate auxilary iterators.

func NewAuxIterator

func NewAuxIterator(input Iterator, opt IteratorOptions) AuxIterator

NewAuxIterator returns a new instance of AuxIterator.

type BinaryExpr

type BinaryExpr struct {
	Op  Token
	LHS Expr
	RHS Expr
}

BinaryExpr represents an operation between two expressions.

func (*BinaryExpr) String

func (e *BinaryExpr) String() string

String returns a string representation of the binary expression.

type BooleanBulkPointAggregator

type BooleanBulkPointAggregator interface {
	AggregateBooleanBulk(points []BooleanPoint)
}

BooleanBulkPointAggregator aggregates multiple points at a time.

type BooleanDistinctReducer

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

BooleanDistinctReducer returns the distinct points in a series.

func NewBooleanDistinctReducer

func NewBooleanDistinctReducer() *BooleanDistinctReducer

NewBooleanDistinctReducer creates a new BooleanDistinctReducer.

func (*BooleanDistinctReducer) AggregateBoolean

func (r *BooleanDistinctReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean aggregates a point into the reducer.

func (*BooleanDistinctReducer) Emit

Emit emits the distinct points that have been aggregated into the reducer.

type BooleanElapsedReducer

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

BooleanElapsedReducer calculates the elapsed of the aggregated points.

func NewBooleanElapsedReducer

func NewBooleanElapsedReducer(interval Interval) *BooleanElapsedReducer

NewBooleanElapsedReducer creates a new BooleanElapsedReducer.

func (*BooleanElapsedReducer) AggregateBoolean

func (r *BooleanElapsedReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean aggregates a point into the reducer and updates the current window.

func (*BooleanElapsedReducer) Emit

func (r *BooleanElapsedReducer) Emit() []IntegerPoint

Emit emits the elapsed of the reducer at the current point.

type BooleanFuncFloatReducer

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

BooleanFuncFloatReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewBooleanFuncFloatReducer

func NewBooleanFuncFloatReducer(fn BooleanReduceFloatFunc, prev *FloatPoint) *BooleanFuncFloatReducer

NewBooleanFuncFloatReducer creates a new BooleanFuncFloatReducer.

func (*BooleanFuncFloatReducer) AggregateBoolean

func (r *BooleanFuncFloatReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean takes a BooleanPoint and invokes the reduce function with the current and new point to modify the current point.

func (*BooleanFuncFloatReducer) Emit

func (r *BooleanFuncFloatReducer) Emit() []FloatPoint

Emit emits the point that was generated when reducing the points fed in with AggregateBoolean.

type BooleanFuncIntegerReducer

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

BooleanFuncIntegerReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewBooleanFuncIntegerReducer

func NewBooleanFuncIntegerReducer(fn BooleanReduceIntegerFunc, prev *IntegerPoint) *BooleanFuncIntegerReducer

NewBooleanFuncIntegerReducer creates a new BooleanFuncIntegerReducer.

func (*BooleanFuncIntegerReducer) AggregateBoolean

func (r *BooleanFuncIntegerReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean takes a BooleanPoint and invokes the reduce function with the current and new point to modify the current point.

func (*BooleanFuncIntegerReducer) Emit

Emit emits the point that was generated when reducing the points fed in with AggregateBoolean.

type BooleanFuncReducer

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

BooleanFuncReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewBooleanFuncReducer

func NewBooleanFuncReducer(fn BooleanReduceFunc, prev *BooleanPoint) *BooleanFuncReducer

NewBooleanFuncReducer creates a new BooleanFuncBooleanReducer.

func (*BooleanFuncReducer) AggregateBoolean

func (r *BooleanFuncReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean takes a BooleanPoint and invokes the reduce function with the current and new point to modify the current point.

func (*BooleanFuncReducer) Emit

func (r *BooleanFuncReducer) Emit() []BooleanPoint

Emit emits the point that was generated when reducing the points fed in with AggregateBoolean.

type BooleanFuncStringReducer

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

BooleanFuncStringReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewBooleanFuncStringReducer

func NewBooleanFuncStringReducer(fn BooleanReduceStringFunc, prev *StringPoint) *BooleanFuncStringReducer

NewBooleanFuncStringReducer creates a new BooleanFuncStringReducer.

func (*BooleanFuncStringReducer) AggregateBoolean

func (r *BooleanFuncStringReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean takes a BooleanPoint and invokes the reduce function with the current and new point to modify the current point.

func (*BooleanFuncStringReducer) Emit

Emit emits the point that was generated when reducing the points fed in with AggregateBoolean.

type BooleanIterator

type BooleanIterator interface {
	Iterator
	Next() (*BooleanPoint, error)
}

BooleanIterator represents a stream of boolean points.

type BooleanLiteral

type BooleanLiteral struct {
	Val bool
}

BooleanLiteral represents a boolean literal.

func (*BooleanLiteral) String

func (l *BooleanLiteral) String() string

String returns a string representation of the literal.

type BooleanPoint

type BooleanPoint struct {
	Name string
	Tags Tags

	Time  int64
	Nil   bool
	Value bool
	Aux   []interface{}

	// Total number of points that were combined into this point from an aggregate.
	// If this is zero, the point is not the result of an aggregate function.
	Aggregated uint32
}

BooleanPoint represents a point with a bool value. DO NOT ADD ADDITIONAL FIELDS TO THIS STRUCT. See TestPoint_Fields in influxql/point_test.go for more details.

func (*BooleanPoint) Clone

func (v *BooleanPoint) Clone() *BooleanPoint

Clone returns a copy of v.

type BooleanPointAggregator

type BooleanPointAggregator interface {
	AggregateBoolean(p *BooleanPoint)
}

BooleanPointAggregator aggregates points to produce a single point.

type BooleanPointDecoder

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

BooleanPointDecoder decodes BooleanPoint points from a reader.

func NewBooleanPointDecoder

func NewBooleanPointDecoder(r io.Reader) *BooleanPointDecoder

NewBooleanPointDecoder returns a new instance of BooleanPointDecoder that reads from r.

func (*BooleanPointDecoder) DecodeBooleanPoint

func (dec *BooleanPointDecoder) DecodeBooleanPoint(p *BooleanPoint) error

DecodeBooleanPoint reads from the underlying reader and unmarshals into p.

func (*BooleanPointDecoder) Stats

func (dec *BooleanPointDecoder) Stats() IteratorStats

Stats returns iterator stats embedded within the stream.

type BooleanPointEmitter

type BooleanPointEmitter interface {
	Emit() []BooleanPoint
}

BooleanPointEmitter produces a single point from an aggregate.

type BooleanPointEncoder

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

BooleanPointEncoder encodes BooleanPoint points to a writer.

func NewBooleanPointEncoder

func NewBooleanPointEncoder(w io.Writer) *BooleanPointEncoder

NewBooleanPointEncoder returns a new instance of BooleanPointEncoder that writes to w.

func (*BooleanPointEncoder) EncodeBooleanPoint

func (enc *BooleanPointEncoder) EncodeBooleanPoint(p *BooleanPoint) error

EncodeBooleanPoint marshals and writes p to the underlying writer.

type BooleanReduceFloatFunc

type BooleanReduceFloatFunc func(prev *FloatPoint, curr *BooleanPoint) (t int64, v float64, aux []interface{})

BooleanReduceFloatFunc is the function called by a BooleanPoint reducer.

type BooleanReduceFloatSliceFunc

type BooleanReduceFloatSliceFunc func(a []BooleanPoint) []FloatPoint

BooleanReduceFloatSliceFunc is the function called by a BooleanPoint reducer.

type BooleanReduceFunc

type BooleanReduceFunc func(prev *BooleanPoint, curr *BooleanPoint) (t int64, v bool, aux []interface{})

BooleanReduceFunc is the function called by a BooleanPoint reducer.

type BooleanReduceIntegerFunc

type BooleanReduceIntegerFunc func(prev *IntegerPoint, curr *BooleanPoint) (t int64, v int64, aux []interface{})

BooleanReduceIntegerFunc is the function called by a BooleanPoint reducer.

type BooleanReduceIntegerSliceFunc

type BooleanReduceIntegerSliceFunc func(a []BooleanPoint) []IntegerPoint

BooleanReduceIntegerSliceFunc is the function called by a BooleanPoint reducer.

type BooleanReduceSliceFunc

type BooleanReduceSliceFunc func(a []BooleanPoint) []BooleanPoint

BooleanReduceSliceFunc is the function called by a BooleanPoint reducer.

type BooleanReduceStringFunc

type BooleanReduceStringFunc func(prev *StringPoint, curr *BooleanPoint) (t int64, v string, aux []interface{})

BooleanReduceStringFunc is the function called by a BooleanPoint reducer.

type BooleanReduceStringSliceFunc

type BooleanReduceStringSliceFunc func(a []BooleanPoint) []StringPoint

BooleanReduceStringSliceFunc is the function called by a BooleanPoint reducer.

type BooleanSliceFuncFloatReducer

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

BooleanSliceFuncFloatReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewBooleanSliceFuncFloatReducer

func NewBooleanSliceFuncFloatReducer(fn BooleanReduceFloatSliceFunc) *BooleanSliceFuncFloatReducer

NewBooleanSliceFuncFloatReducer creates a new BooleanSliceFuncFloatReducer.

func (*BooleanSliceFuncFloatReducer) AggregateBoolean

func (r *BooleanSliceFuncFloatReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean copies the BooleanPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*BooleanSliceFuncFloatReducer) AggregateBooleanBulk

func (r *BooleanSliceFuncFloatReducer) AggregateBooleanBulk(points []BooleanPoint)

AggregateBooleanBulk performs a bulk copy of BooleanPoints into the internal slice. This is a more efficient version of calling AggregateBoolean on each point.

func (*BooleanSliceFuncFloatReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type BooleanSliceFuncIntegerReducer

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

BooleanSliceFuncIntegerReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewBooleanSliceFuncIntegerReducer

func NewBooleanSliceFuncIntegerReducer(fn BooleanReduceIntegerSliceFunc) *BooleanSliceFuncIntegerReducer

NewBooleanSliceFuncIntegerReducer creates a new BooleanSliceFuncIntegerReducer.

func (*BooleanSliceFuncIntegerReducer) AggregateBoolean

func (r *BooleanSliceFuncIntegerReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean copies the BooleanPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*BooleanSliceFuncIntegerReducer) AggregateBooleanBulk

func (r *BooleanSliceFuncIntegerReducer) AggregateBooleanBulk(points []BooleanPoint)

AggregateBooleanBulk performs a bulk copy of BooleanPoints into the internal slice. This is a more efficient version of calling AggregateBoolean on each point.

func (*BooleanSliceFuncIntegerReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type BooleanSliceFuncReducer

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

BooleanSliceFuncReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewBooleanSliceFuncReducer

func NewBooleanSliceFuncReducer(fn BooleanReduceSliceFunc) *BooleanSliceFuncReducer

NewBooleanSliceFuncReducer creates a new BooleanSliceFuncReducer.

func (*BooleanSliceFuncReducer) AggregateBoolean

func (r *BooleanSliceFuncReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean copies the BooleanPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*BooleanSliceFuncReducer) AggregateBooleanBulk

func (r *BooleanSliceFuncReducer) AggregateBooleanBulk(points []BooleanPoint)

AggregateBooleanBulk performs a bulk copy of BooleanPoints into the internal slice. This is a more efficient version of calling AggregateBoolean on each point.

func (*BooleanSliceFuncReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type BooleanSliceFuncStringReducer

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

BooleanSliceFuncStringReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewBooleanSliceFuncStringReducer

func NewBooleanSliceFuncStringReducer(fn BooleanReduceStringSliceFunc) *BooleanSliceFuncStringReducer

NewBooleanSliceFuncStringReducer creates a new BooleanSliceFuncStringReducer.

func (*BooleanSliceFuncStringReducer) AggregateBoolean

func (r *BooleanSliceFuncStringReducer) AggregateBoolean(p *BooleanPoint)

AggregateBoolean copies the BooleanPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*BooleanSliceFuncStringReducer) AggregateBooleanBulk

func (r *BooleanSliceFuncStringReducer) AggregateBooleanBulk(points []BooleanPoint)

AggregateBooleanBulk performs a bulk copy of BooleanPoints into the internal slice. This is a more efficient version of calling AggregateBoolean on each point.

func (*BooleanSliceFuncStringReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type Call

type Call struct {
	Name string
	Args []Expr
}

Call represents a function call.

func (*Call) Fields

func (c *Call) Fields() []string

Fields will extract any field names from the call. Only specific calls support this.

func (*Call) String

func (c *Call) String() string

String returns a string representation of the call.

type CreateContinuousQueryStatement

type CreateContinuousQueryStatement struct {
	// Name of the continuous query to be created.
	Name string

	// Name of the database to create the continuous query on.
	Database string

	// Source of data (SELECT statement).
	Source *SelectStatement

	// Interval to resample previous queries
	ResampleEvery time.Duration

	// Maximum duration to resample previous queries
	ResampleFor time.Duration
}

CreateContinuousQueryStatement represents a command for creating a continuous query.

func (*CreateContinuousQueryStatement) DefaultDatabase

func (s *CreateContinuousQueryStatement) DefaultDatabase() string

DefaultDatabase returns the default database from the statement.

func (*CreateContinuousQueryStatement) RequiredPrivileges

func (s *CreateContinuousQueryStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a CreateContinuousQueryStatement.

func (*CreateContinuousQueryStatement) String

String returns a string representation of the statement.

type CreateDatabaseStatement

type CreateDatabaseStatement struct {
	// Name of the database to be created.
	Name string

	// IfNotExists indicates whether to return without error if the database
	// already exists.
	IfNotExists bool

	// RetentionPolicyCreate indicates whether the user explicitly wants to create a retention policy
	RetentionPolicyCreate bool

	// RetentionPolicyDuration indicates retention duration for the new database
	RetentionPolicyDuration time.Duration

	// RetentionPolicyReplication indicates retention replication for the new database
	RetentionPolicyReplication int

	// RetentionPolicyName indicates retention name for the new database
	RetentionPolicyName string

	// RetentionPolicyShardGroupDuration indicates shard group duration for the new database
	RetentionPolicyShardGroupDuration time.Duration
}

CreateDatabaseStatement represents a command for creating a new database.

func (*CreateDatabaseStatement) RequiredPrivileges

func (s *CreateDatabaseStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a CreateDatabaseStatement.

func (*CreateDatabaseStatement) String

func (s *CreateDatabaseStatement) String() string

String returns a string representation of the create database statement.

type CreateRetentionPolicyStatement

type CreateRetentionPolicyStatement struct {
	// Name of policy to create.
	Name string

	// Name of database this policy belongs to.
	Database string

	// Duration data written to this policy will be retained.
	Duration time.Duration

	// Replication factor for data written to this policy.
	Replication int

	// Should this policy be set as default for the database?
	Default bool

	// Shard Duration
	ShardGroupDuration time.Duration
}

CreateRetentionPolicyStatement represents a command to create a retention policy.

func (*CreateRetentionPolicyStatement) RequiredPrivileges

func (s *CreateRetentionPolicyStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a CreateRetentionPolicyStatement.

func (*CreateRetentionPolicyStatement) String

String returns a string representation of the create retention policy.

type CreateSubscriptionStatement

type CreateSubscriptionStatement struct {
	Name            string
	Database        string
	RetentionPolicy string
	Destinations    []string
	Mode            string
}

CreateSubscriptionStatement represents a command to add a subscription to the incoming data stream

func (*CreateSubscriptionStatement) RequiredPrivileges

func (s *CreateSubscriptionStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a CreateSubscriptionStatement

func (*CreateSubscriptionStatement) String

func (s *CreateSubscriptionStatement) String() string

String returns a string representation of the CreateSubscriptionStatement.

type CreateUserStatement

type CreateUserStatement struct {
	// Name of the user to be created.
	Name string

	// User's password.
	Password string

	// User's admin privilege.
	Admin bool
}

CreateUserStatement represents a command for creating a new user.

func (*CreateUserStatement) RequiredPrivileges

func (s *CreateUserStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a CreateUserStatement.

func (*CreateUserStatement) String

func (s *CreateUserStatement) String() string

String returns a string representation of the create user statement.

type DataType

type DataType int

DataType represents the primitive data types available in InfluxQL.

func InspectDataType

func InspectDataType(v interface{}) DataType

InspectDataType returns the data type of a given value.

func InspectDataTypes

func InspectDataTypes(a []interface{}) []DataType

InspectDataTypes returns all of the data types for an interface slice.

func (DataType) String

func (d DataType) String() string

type DeleteSeriesStatement

type DeleteSeriesStatement struct {
	// Data source that fields are extracted from (optional)
	Sources Sources

	// An expression evaluated on data point (optional)
	Condition Expr
}

DeleteSeriesStatement represents a command for deleting all or part of a series from a database.

func (DeleteSeriesStatement) RequiredPrivileges

func (s DeleteSeriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a DeleteSeriesStatement.

func (*DeleteSeriesStatement) String

func (s *DeleteSeriesStatement) String() string

String returns a string representation of the delete series statement.

type DeleteStatement

type DeleteStatement struct {
	// Data source that values are removed from.
	Source Source

	// An expression evaluated on data point.
	Condition Expr
}

DeleteStatement represents a command for removing data from the database.

func (*DeleteStatement) RequiredPrivileges

func (s *DeleteStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a DeleteStatement.

func (*DeleteStatement) String

func (s *DeleteStatement) String() string

String returns a string representation of the delete statement.

type Dimension

type Dimension struct {
	Expr Expr
}

Dimension represents an expression that a select statement is grouped by.

func (*Dimension) String

func (d *Dimension) String() string

String returns a string representation of the dimension.

type Dimensions

type Dimensions []*Dimension

Dimensions represents a list of dimensions.

func (Dimensions) Normalize

func (a Dimensions) Normalize() (time.Duration, []string)

Normalize returns the interval and tag dimensions separately. Returns 0 if no time interval is specified.

func (Dimensions) String

func (a Dimensions) String() string

String returns a string representation of the dimensions.

type Distinct

type Distinct struct {
	// Identifier following DISTINCT
	Val string
}

Distinct represents a DISTINCT expression.

func (*Distinct) NewCall

func (d *Distinct) NewCall() *Call

NewCall returns a new call expression from this expressions.

func (*Distinct) String

func (d *Distinct) String() string

String returns a string representation of the expression.

type DropContinuousQueryStatement

type DropContinuousQueryStatement struct {
	Name     string
	Database string
}

DropContinuousQueryStatement represents a command for removing a continuous query.

func (*DropContinuousQueryStatement) RequiredPrivileges

func (s *DropContinuousQueryStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a DropContinuousQueryStatement

func (*DropContinuousQueryStatement) String

String returns a string representation of the statement.

type DropDatabaseStatement

type DropDatabaseStatement struct {
	// Name of the database to be dropped.
	Name string

	// IfExists indicates whether to return without error if the database
	// does not exists.
	IfExists bool
}

DropDatabaseStatement represents a command to drop a database.

func (*DropDatabaseStatement) RequiredPrivileges

func (s *DropDatabaseStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a DropDatabaseStatement.

func (*DropDatabaseStatement) String

func (s *DropDatabaseStatement) String() string

String returns a string representation of the drop database statement.

type DropMeasurementStatement

type DropMeasurementStatement struct {
	// Name of the measurement to be dropped.
	Name string
}

DropMeasurementStatement represents a command to drop a measurement.

func (*DropMeasurementStatement) RequiredPrivileges

func (s *DropMeasurementStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a DropMeasurementStatement

func (*DropMeasurementStatement) String

func (s *DropMeasurementStatement) String() string

String returns a string representation of the drop measurement statement.

type DropRetentionPolicyStatement

type DropRetentionPolicyStatement struct {
	// Name of the policy to drop.
	Name string

	// Name of the database to drop the policy from.
	Database string
}

DropRetentionPolicyStatement represents a command to drop a retention policy from a database.

func (*DropRetentionPolicyStatement) RequiredPrivileges

func (s *DropRetentionPolicyStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a DropRetentionPolicyStatement.

func (*DropRetentionPolicyStatement) String

String returns a string representation of the drop retention policy statement.

type DropSeriesStatement

type DropSeriesStatement struct {
	// Data source that fields are extracted from (optional)
	Sources Sources

	// An expression evaluated on data point (optional)
	Condition Expr
}

DropSeriesStatement represents a command for removing a series from the database.

func (DropSeriesStatement) RequiredPrivileges

func (s DropSeriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a DropSeriesStatement.

func (*DropSeriesStatement) String

func (s *DropSeriesStatement) String() string

String returns a string representation of the drop series statement.

type DropShardStatement

type DropShardStatement struct {
	// ID of the shard to be dropped.
	ID uint64
}

DropShardStatement represents a command for removing a shard from the node.

func (*DropShardStatement) RequiredPrivileges

func (s *DropShardStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a DropShardStatement.

func (*DropShardStatement) String

func (s *DropShardStatement) String() string

String returns a string representation of the drop series statement.

type DropSubscriptionStatement

type DropSubscriptionStatement struct {
	Name            string
	Database        string
	RetentionPolicy string
}

DropSubscriptionStatement represents a command to drop a subscription to the incoming data stream.

func (*DropSubscriptionStatement) RequiredPrivileges

func (s *DropSubscriptionStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a DropSubscriptionStatement

func (*DropSubscriptionStatement) String

func (s *DropSubscriptionStatement) String() string

String returns a string representation of the DropSubscriptionStatement.

type DropUserStatement

type DropUserStatement struct {
	// Name of the user to drop.
	Name string
}

DropUserStatement represents a command for dropping a user.

func (*DropUserStatement) RequiredPrivileges

func (s *DropUserStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a DropUserStatement.

func (*DropUserStatement) String

func (s *DropUserStatement) String() string

String returns a string representation of the drop user statement.

type DurationLiteral

type DurationLiteral struct {
	Val time.Duration
}

DurationLiteral represents a duration literal.

func (*DurationLiteral) String

func (l *DurationLiteral) String() string

String returns a string representation of the literal.

type Emitter

type Emitter struct {

	// The columns to attach to each row.
	Columns []string

	// Removes the "time" column from output.
	// Used for meta queries where time does not apply.
	OmitTime bool
	// contains filtered or unexported fields
}

Emitter groups values together by name,

func NewEmitter

func NewEmitter(itrs []Iterator, ascending bool, chunkSize int) *Emitter

NewEmitter returns a new instance of Emitter that pulls from itrs.

func (*Emitter) Close

func (e *Emitter) Close() error

Close closes the underlying iterators.

func (*Emitter) Emit

func (e *Emitter) Emit() (*models.Row, error)

Emit returns the next row from the iterators.

type ExecutionContext

type ExecutionContext struct {
	// The statement ID of the executing query.
	StatementID int

	// The query ID of the executing query.
	QueryID uint64

	// The query task information available to the StatementExecutor.
	Query *QueryTask

	// Output channel where results and errors should be sent.
	Results chan *Result

	// Hold the query executor's logger.
	Log *log.Logger

	// A channel that is closed when the query is interrupted.
	InterruptCh <-chan struct{}

	// Options used to start this query.
	ExecutionOptions
}

ExecutionContext contains state that the query is currently executing with.

type ExecutionOptions

type ExecutionOptions struct {
	// The database the query is running against.
	Database string

	// The requested maximum number of points to return in each result.
	ChunkSize int

	// If this query is being executed in a read-only context.
	ReadOnly bool

	// Node to execute on.
	NodeID uint64
}

ExecutionOptions contains the options for executing a query.

type ExecutionPrivilege

type ExecutionPrivilege struct {
	// Admin privilege required.
	Admin bool

	// Name of the database.
	Name string

	// Database privilege required.
	Privilege Privilege
}

ExecutionPrivilege is a privilege required for a user to execute a statement on a database or resource.

type ExecutionPrivileges

type ExecutionPrivileges []ExecutionPrivilege

ExecutionPrivileges is a list of privileges required to execute a statement.

type Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

Expr represents an expression that can be evaluated to a value.

func CloneExpr

func CloneExpr(expr Expr) Expr

CloneExpr returns a deep copy of the expression.

func MustParseExpr

func MustParseExpr(s string) Expr

MustParseExpr parses an expression string and returns its AST. Panic on error.

func ParseExpr

func ParseExpr(s string) (Expr, error)

ParseExpr parses an expression string and returns its AST representation.

func Reduce

func Reduce(expr Expr, valuer Valuer) Expr

Reduce evaluates expr using the available values in valuer. References that don't exist in valuer are ignored.

func RewriteExpr

func RewriteExpr(expr Expr, fn func(Expr) Expr) Expr

RewriteExpr recursively invokes the function to replace each expr. Nodes are traversed depth-first and rewritten from leaf to root.

type Field

type Field struct {
	Expr  Expr
	Alias string
}

Field represents an expression retrieved from a select statement.

func (*Field) Name

func (f *Field) Name() string

Name returns the name of the field. Returns alias, if set. Otherwise uses the function name or variable name.

func (*Field) String

func (f *Field) String() string

String returns a string representation of the field.

type Fields

type Fields []*Field

Fields represents a list of fields.

func (Fields) AliasNames

func (a Fields) AliasNames() []string

AliasNames returns a list of calculated field names in order of alias, function name, then field.

func (Fields) Len

func (a Fields) Len() int

Sort Interface for Fields

func (Fields) Less

func (a Fields) Less(i, j int) bool

func (Fields) Names

func (a Fields) Names() []string

Names returns a list of field names.

func (Fields) String

func (a Fields) String() string

String returns a string representation of the fields.

func (Fields) Swap

func (a Fields) Swap(i, j int)

type FillOption

type FillOption int

FillOption represents different options for aggregate windows.

const (
	// NullFill means that empty aggregate windows will just have null values.
	NullFill FillOption = iota
	// NoFill means that empty aggregate windows will be purged from the result.
	NoFill
	// NumberFill means that empty aggregate windows will be filled with the given number
	NumberFill
	// PreviousFill means that empty aggregate windows will be filled with whatever the previous aggregate window had
	PreviousFill
)

type FloatBulkPointAggregator

type FloatBulkPointAggregator interface {
	AggregateFloatBulk(points []FloatPoint)
}

FloatBulkPointAggregator aggregates multiple points at a time.

type FloatDerivativeReducer

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

FloatDerivativeReducer calculates the derivative of the aggregated points.

func NewFloatDerivativeReducer

func NewFloatDerivativeReducer(interval Interval, isNonNegative, ascending bool) *FloatDerivativeReducer

NewFloatDerivativeReducer creates a new FloatDerivativeReducer.

func (*FloatDerivativeReducer) AggregateFloat

func (r *FloatDerivativeReducer) AggregateFloat(p *FloatPoint)

AggregateFloat aggregates a point into the reducer and updates the current window.

func (*FloatDerivativeReducer) Emit

func (r *FloatDerivativeReducer) Emit() []FloatPoint

Emit emits the derivative of the reducer at the current point.

type FloatDifferenceReducer

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

FloatDifferenceReducer calculates the derivative of the aggregated points.

func NewFloatDifferenceReducer

func NewFloatDifferenceReducer() *FloatDifferenceReducer

NewFloatDifferenceReducer creates a new FloatDifferenceReducer.

func (*FloatDifferenceReducer) AggregateFloat

func (r *FloatDifferenceReducer) AggregateFloat(p *FloatPoint)

AggregateFloat aggregates a point into the reducer and updates the current window.

func (*FloatDifferenceReducer) Emit

func (r *FloatDifferenceReducer) Emit() []FloatPoint

Emit emits the difference of the reducer at the current point.

type FloatDistinctReducer

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

FloatDistinctReducer returns the distinct points in a series.

func NewFloatDistinctReducer

func NewFloatDistinctReducer() *FloatDistinctReducer

NewFloatDistinctReducer creates a new FloatDistinctReducer.

func (*FloatDistinctReducer) AggregateFloat

func (r *FloatDistinctReducer) AggregateFloat(p *FloatPoint)

AggregateFloat aggregates a point into the reducer.

func (*FloatDistinctReducer) Emit

func (r *FloatDistinctReducer) Emit() []FloatPoint

Emit emits the distinct points that have been aggregated into the reducer.

type FloatElapsedReducer

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

FloatElapsedReducer calculates the elapsed of the aggregated points.

func NewFloatElapsedReducer

func NewFloatElapsedReducer(interval Interval) *FloatElapsedReducer

NewFloatElapsedReducer creates a new FloatElapsedReducer.

func (*FloatElapsedReducer) AggregateFloat

func (r *FloatElapsedReducer) AggregateFloat(p *FloatPoint)

AggregateFloat aggregates a point into the reducer and updates the current window.

func (*FloatElapsedReducer) Emit

func (r *FloatElapsedReducer) Emit() []IntegerPoint

Emit emits the elapsed of the reducer at the current point.

type FloatFuncBooleanReducer

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

FloatFuncBooleanReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewFloatFuncBooleanReducer

func NewFloatFuncBooleanReducer(fn FloatReduceBooleanFunc, prev *BooleanPoint) *FloatFuncBooleanReducer

NewFloatFuncBooleanReducer creates a new FloatFuncBooleanReducer.

func (*FloatFuncBooleanReducer) AggregateFloat

func (r *FloatFuncBooleanReducer) AggregateFloat(p *FloatPoint)

AggregateFloat takes a FloatPoint and invokes the reduce function with the current and new point to modify the current point.

func (*FloatFuncBooleanReducer) Emit

Emit emits the point that was generated when reducing the points fed in with AggregateFloat.

type FloatFuncIntegerReducer

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

FloatFuncIntegerReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewFloatFuncIntegerReducer

func NewFloatFuncIntegerReducer(fn FloatReduceIntegerFunc, prev *IntegerPoint) *FloatFuncIntegerReducer

NewFloatFuncIntegerReducer creates a new FloatFuncIntegerReducer.

func (*FloatFuncIntegerReducer) AggregateFloat

func (r *FloatFuncIntegerReducer) AggregateFloat(p *FloatPoint)

AggregateFloat takes a FloatPoint and invokes the reduce function with the current and new point to modify the current point.

func (*FloatFuncIntegerReducer) Emit

Emit emits the point that was generated when reducing the points fed in with AggregateFloat.

type FloatFuncReducer

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

FloatFuncReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewFloatFuncReducer

func NewFloatFuncReducer(fn FloatReduceFunc, prev *FloatPoint) *FloatFuncReducer

NewFloatFuncReducer creates a new FloatFuncFloatReducer.

func (*FloatFuncReducer) AggregateFloat

func (r *FloatFuncReducer) AggregateFloat(p *FloatPoint)

AggregateFloat takes a FloatPoint and invokes the reduce function with the current and new point to modify the current point.

func (*FloatFuncReducer) Emit

func (r *FloatFuncReducer) Emit() []FloatPoint

Emit emits the point that was generated when reducing the points fed in with AggregateFloat.

type FloatFuncStringReducer

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

FloatFuncStringReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewFloatFuncStringReducer

func NewFloatFuncStringReducer(fn FloatReduceStringFunc, prev *StringPoint) *FloatFuncStringReducer

NewFloatFuncStringReducer creates a new FloatFuncStringReducer.

func (*FloatFuncStringReducer) AggregateFloat

func (r *FloatFuncStringReducer) AggregateFloat(p *FloatPoint)

AggregateFloat takes a FloatPoint and invokes the reduce function with the current and new point to modify the current point.

func (*FloatFuncStringReducer) Emit

func (r *FloatFuncStringReducer) Emit() []StringPoint

Emit emits the point that was generated when reducing the points fed in with AggregateFloat.

type FloatHoltWintersReducer

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

FloatHoltWintersReducer forecasts a series into the future. This is done using the Holt-Winters damped method.

  1. Using the series the initial values are calculated using a SSE.
  2. The series is forecasted into the future using the iterative relations.

func NewFloatHoltWintersReducer

func NewFloatHoltWintersReducer(h, m int, includeFitData bool, interval time.Duration) *FloatHoltWintersReducer

NewFloatHoltWintersReducer creates a new FloatHoltWintersReducer.

func (*FloatHoltWintersReducer) AggregateFloat

func (r *FloatHoltWintersReducer) AggregateFloat(p *FloatPoint)

AggregateFloat aggregates a point into the reducer and updates the current window.

func (*FloatHoltWintersReducer) AggregateInteger

func (r *FloatHoltWintersReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger aggregates a point into the reducer and updates the current window.

func (*FloatHoltWintersReducer) Emit

func (r *FloatHoltWintersReducer) Emit() []FloatPoint

Emit returns the points generated by the HoltWinters algorithm.

type FloatIterator

type FloatIterator interface {
	Iterator
	Next() (*FloatPoint, error)
}

FloatIterator represents a stream of float points.

type FloatMeanReducer

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

FloatMeanReducer calculates the mean of the aggregated points.

func NewFloatMeanReducer

func NewFloatMeanReducer() *FloatMeanReducer

NewFloatMeanReducer creates a new FloatMeanReducer.

func (*FloatMeanReducer) AggregateFloat

func (r *FloatMeanReducer) AggregateFloat(p *FloatPoint)

AggregateFloat aggregates a point into the reducer.

func (*FloatMeanReducer) Emit

func (r *FloatMeanReducer) Emit() []FloatPoint

Emit emits the mean of the aggregated points as a single point.

type FloatMovingAverageReducer

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

FloatMovingAverageReducer calculates the moving average of the aggregated points.

func NewFloatMovingAverageReducer

func NewFloatMovingAverageReducer(n int) *FloatMovingAverageReducer

NewFloatMovingAverageReducer creates a new FloatMovingAverageReducer.

func (*FloatMovingAverageReducer) AggregateFloat

func (r *FloatMovingAverageReducer) AggregateFloat(p *FloatPoint)

AggregateFloat aggregates a point into the reducer and updates the current window.

func (*FloatMovingAverageReducer) Emit

Emit emits the moving average of the current window. Emit should be called after every call to AggregateFloat and it will produce one point if there is enough data to fill a window, otherwise it will produce zero points.

type FloatPoint

type FloatPoint struct {
	Name string
	Tags Tags

	Time  int64
	Nil   bool
	Value float64
	Aux   []interface{}

	// Total number of points that were combined into this point from an aggregate.
	// If this is zero, the point is not the result of an aggregate function.
	Aggregated uint32
}

FloatPoint represents a point with a float64 value. DO NOT ADD ADDITIONAL FIELDS TO THIS STRUCT. See TestPoint_Fields in influxql/point_test.go for more details.

func FloatMedianReduceSlice

func FloatMedianReduceSlice(a []FloatPoint) []FloatPoint

FloatMedianReduceSlice returns the median value within a window.

func FloatSpreadReduceSlice

func FloatSpreadReduceSlice(a []FloatPoint) []FloatPoint

FloatSpreadReduceSlice returns the spread value within a window.

func FloatStddevReduceSlice

func FloatStddevReduceSlice(a []FloatPoint) []FloatPoint

FloatStddevReduceSlice returns the stddev value within a window.

func IntegerMedianReduceSlice

func IntegerMedianReduceSlice(a []IntegerPoint) []FloatPoint

IntegerMedianReduceSlice returns the median value within a window.

func IntegerStddevReduceSlice

func IntegerStddevReduceSlice(a []IntegerPoint) []FloatPoint

IntegerStddevReduceSlice returns the stddev value within a window.

func (*FloatPoint) Clone

func (v *FloatPoint) Clone() *FloatPoint

Clone returns a copy of v.

type FloatPointAggregator

type FloatPointAggregator interface {
	AggregateFloat(p *FloatPoint)
}

FloatPointAggregator aggregates points to produce a single point.

type FloatPointDecoder

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

FloatPointDecoder decodes FloatPoint points from a reader.

func NewFloatPointDecoder

func NewFloatPointDecoder(r io.Reader) *FloatPointDecoder

NewFloatPointDecoder returns a new instance of FloatPointDecoder that reads from r.

func (*FloatPointDecoder) DecodeFloatPoint

func (dec *FloatPointDecoder) DecodeFloatPoint(p *FloatPoint) error

DecodeFloatPoint reads from the underlying reader and unmarshals into p.

func (*FloatPointDecoder) Stats

func (dec *FloatPointDecoder) Stats() IteratorStats

Stats returns iterator stats embedded within the stream.

type FloatPointEmitter

type FloatPointEmitter interface {
	Emit() []FloatPoint
}

FloatPointEmitter produces a single point from an aggregate.

type FloatPointEncoder

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

FloatPointEncoder encodes FloatPoint points to a writer.

func NewFloatPointEncoder

func NewFloatPointEncoder(w io.Writer) *FloatPointEncoder

NewFloatPointEncoder returns a new instance of FloatPointEncoder that writes to w.

func (*FloatPointEncoder) EncodeFloatPoint

func (enc *FloatPointEncoder) EncodeFloatPoint(p *FloatPoint) error

EncodeFloatPoint marshals and writes p to the underlying writer.

type FloatReduceBooleanFunc

type FloatReduceBooleanFunc func(prev *BooleanPoint, curr *FloatPoint) (t int64, v bool, aux []interface{})

FloatReduceBooleanFunc is the function called by a FloatPoint reducer.

type FloatReduceBooleanSliceFunc

type FloatReduceBooleanSliceFunc func(a []FloatPoint) []BooleanPoint

FloatReduceBooleanSliceFunc is the function called by a FloatPoint reducer.

type FloatReduceFunc

type FloatReduceFunc func(prev *FloatPoint, curr *FloatPoint) (t int64, v float64, aux []interface{})

FloatReduceFunc is the function called by a FloatPoint reducer.

type FloatReduceIntegerFunc

type FloatReduceIntegerFunc func(prev *IntegerPoint, curr *FloatPoint) (t int64, v int64, aux []interface{})

FloatReduceIntegerFunc is the function called by a FloatPoint reducer.

type FloatReduceIntegerSliceFunc

type FloatReduceIntegerSliceFunc func(a []FloatPoint) []IntegerPoint

FloatReduceIntegerSliceFunc is the function called by a FloatPoint reducer.

type FloatReduceSliceFunc

type FloatReduceSliceFunc func(a []FloatPoint) []FloatPoint

FloatReduceSliceFunc is the function called by a FloatPoint reducer.

func NewFloatBottomReduceSliceFunc

func NewFloatBottomReduceSliceFunc(n int, tags []int, interval Interval) FloatReduceSliceFunc

NewFloatBottomReduceSliceFunc returns the bottom values within a window.

func NewFloatPercentileReduceSliceFunc

func NewFloatPercentileReduceSliceFunc(percentile float64) FloatReduceSliceFunc

NewFloatPercentileReduceSliceFunc returns the percentile value within a window.

func NewFloatTopReduceSliceFunc

func NewFloatTopReduceSliceFunc(n int, tags []int, interval Interval) FloatReduceSliceFunc

NewFloatTopReduceSliceFunc returns the top values within a window.

type FloatReduceStringFunc

type FloatReduceStringFunc func(prev *StringPoint, curr *FloatPoint) (t int64, v string, aux []interface{})

FloatReduceStringFunc is the function called by a FloatPoint reducer.

type FloatReduceStringSliceFunc

type FloatReduceStringSliceFunc func(a []FloatPoint) []StringPoint

FloatReduceStringSliceFunc is the function called by a FloatPoint reducer.

type FloatSliceFuncBooleanReducer

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

FloatSliceFuncBooleanReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewFloatSliceFuncBooleanReducer

func NewFloatSliceFuncBooleanReducer(fn FloatReduceBooleanSliceFunc) *FloatSliceFuncBooleanReducer

NewFloatSliceFuncBooleanReducer creates a new FloatSliceFuncBooleanReducer.

func (*FloatSliceFuncBooleanReducer) AggregateFloat

func (r *FloatSliceFuncBooleanReducer) AggregateFloat(p *FloatPoint)

AggregateFloat copies the FloatPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*FloatSliceFuncBooleanReducer) AggregateFloatBulk

func (r *FloatSliceFuncBooleanReducer) AggregateFloatBulk(points []FloatPoint)

AggregateFloatBulk performs a bulk copy of FloatPoints into the internal slice. This is a more efficient version of calling AggregateFloat on each point.

func (*FloatSliceFuncBooleanReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type FloatSliceFuncIntegerReducer

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

FloatSliceFuncIntegerReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewFloatSliceFuncIntegerReducer

func NewFloatSliceFuncIntegerReducer(fn FloatReduceIntegerSliceFunc) *FloatSliceFuncIntegerReducer

NewFloatSliceFuncIntegerReducer creates a new FloatSliceFuncIntegerReducer.

func (*FloatSliceFuncIntegerReducer) AggregateFloat

func (r *FloatSliceFuncIntegerReducer) AggregateFloat(p *FloatPoint)

AggregateFloat copies the FloatPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*FloatSliceFuncIntegerReducer) AggregateFloatBulk

func (r *FloatSliceFuncIntegerReducer) AggregateFloatBulk(points []FloatPoint)

AggregateFloatBulk performs a bulk copy of FloatPoints into the internal slice. This is a more efficient version of calling AggregateFloat on each point.

func (*FloatSliceFuncIntegerReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type FloatSliceFuncReducer

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

FloatSliceFuncReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewFloatSliceFuncReducer

func NewFloatSliceFuncReducer(fn FloatReduceSliceFunc) *FloatSliceFuncReducer

NewFloatSliceFuncReducer creates a new FloatSliceFuncReducer.

func (*FloatSliceFuncReducer) AggregateFloat

func (r *FloatSliceFuncReducer) AggregateFloat(p *FloatPoint)

AggregateFloat copies the FloatPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*FloatSliceFuncReducer) AggregateFloatBulk

func (r *FloatSliceFuncReducer) AggregateFloatBulk(points []FloatPoint)

AggregateFloatBulk performs a bulk copy of FloatPoints into the internal slice. This is a more efficient version of calling AggregateFloat on each point.

func (*FloatSliceFuncReducer) Emit

func (r *FloatSliceFuncReducer) Emit() []FloatPoint

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type FloatSliceFuncStringReducer

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

FloatSliceFuncStringReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewFloatSliceFuncStringReducer

func NewFloatSliceFuncStringReducer(fn FloatReduceStringSliceFunc) *FloatSliceFuncStringReducer

NewFloatSliceFuncStringReducer creates a new FloatSliceFuncStringReducer.

func (*FloatSliceFuncStringReducer) AggregateFloat

func (r *FloatSliceFuncStringReducer) AggregateFloat(p *FloatPoint)

AggregateFloat copies the FloatPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*FloatSliceFuncStringReducer) AggregateFloatBulk

func (r *FloatSliceFuncStringReducer) AggregateFloatBulk(points []FloatPoint)

AggregateFloatBulk performs a bulk copy of FloatPoints into the internal slice. This is a more efficient version of calling AggregateFloat on each point.

func (*FloatSliceFuncStringReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type GrantAdminStatement

type GrantAdminStatement struct {
	// Who to grant the privilege to.
	User string
}

GrantAdminStatement represents a command for granting admin privilege.

func (*GrantAdminStatement) RequiredPrivileges

func (s *GrantAdminStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a GrantAdminStatement.

func (*GrantAdminStatement) String

func (s *GrantAdminStatement) String() string

String returns a string representation of the grant admin statement.

type GrantStatement

type GrantStatement struct {
	// The privilege to be granted.
	Privilege Privilege

	// Database to grant the privilege to.
	On string

	// Who to grant the privilege to.
	User string
}

GrantStatement represents a command for granting a privilege.

func (*GrantStatement) RequiredPrivileges

func (s *GrantStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a GrantStatement.

func (*GrantStatement) String

func (s *GrantStatement) String() string

String returns a string representation of the grant statement.

type HasDefaultDatabase

type HasDefaultDatabase interface {
	Node

	DefaultDatabase() string
	// contains filtered or unexported methods
}

HasDefaultDatabase provides an interface to get the default database from a Statement.

type IntegerBulkPointAggregator

type IntegerBulkPointAggregator interface {
	AggregateIntegerBulk(points []IntegerPoint)
}

IntegerBulkPointAggregator aggregates multiple points at a time.

type IntegerDerivativeReducer

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

IntegerDerivativeReducer calculates the derivative of the aggregated points.

func NewIntegerDerivativeReducer

func NewIntegerDerivativeReducer(interval Interval, isNonNegative, ascending bool) *IntegerDerivativeReducer

NewIntegerDerivativeReducer creates a new IntegerDerivativeReducer.

func (*IntegerDerivativeReducer) AggregateInteger

func (r *IntegerDerivativeReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger aggregates a point into the reducer and updates the current window.

func (*IntegerDerivativeReducer) Emit

Emit emits the derivative of the reducer at the current point.

type IntegerDifferenceReducer

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

IntegerDifferenceReducer calculates the derivative of the aggregated points.

func NewIntegerDifferenceReducer

func NewIntegerDifferenceReducer() *IntegerDifferenceReducer

NewIntegerDifferenceReducer creates a new IntegerDifferenceReducer.

func (*IntegerDifferenceReducer) AggregateInteger

func (r *IntegerDifferenceReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger aggregates a point into the reducer and updates the current window.

func (*IntegerDifferenceReducer) Emit

Emit emits the difference of the reducer at the current point.

type IntegerDistinctReducer

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

IntegerDistinctReducer returns the distinct points in a series.

func NewIntegerDistinctReducer

func NewIntegerDistinctReducer() *IntegerDistinctReducer

NewIntegerDistinctReducer creates a new IntegerDistinctReducer.

func (*IntegerDistinctReducer) AggregateInteger

func (r *IntegerDistinctReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger aggregates a point into the reducer.

func (*IntegerDistinctReducer) Emit

Emit emits the distinct points that have been aggregated into the reducer.

type IntegerElapsedReducer

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

IntegerElapsedReducer calculates the elapsed of the aggregated points.

func NewIntegerElapsedReducer

func NewIntegerElapsedReducer(interval Interval) *IntegerElapsedReducer

NewIntegerElapsedReducer creates a new IntegerElapsedReducer.

func (*IntegerElapsedReducer) AggregateInteger

func (r *IntegerElapsedReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger aggregates a point into the reducer and updates the current window.

func (*IntegerElapsedReducer) Emit

func (r *IntegerElapsedReducer) Emit() []IntegerPoint

Emit emits the elapsed of the reducer at the current point.

type IntegerFuncBooleanReducer

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

IntegerFuncBooleanReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewIntegerFuncBooleanReducer

func NewIntegerFuncBooleanReducer(fn IntegerReduceBooleanFunc, prev *BooleanPoint) *IntegerFuncBooleanReducer

NewIntegerFuncBooleanReducer creates a new IntegerFuncBooleanReducer.

func (*IntegerFuncBooleanReducer) AggregateInteger

func (r *IntegerFuncBooleanReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger takes a IntegerPoint and invokes the reduce function with the current and new point to modify the current point.

func (*IntegerFuncBooleanReducer) Emit

Emit emits the point that was generated when reducing the points fed in with AggregateInteger.

type IntegerFuncFloatReducer

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

IntegerFuncFloatReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewIntegerFuncFloatReducer

func NewIntegerFuncFloatReducer(fn IntegerReduceFloatFunc, prev *FloatPoint) *IntegerFuncFloatReducer

NewIntegerFuncFloatReducer creates a new IntegerFuncFloatReducer.

func (*IntegerFuncFloatReducer) AggregateInteger

func (r *IntegerFuncFloatReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger takes a IntegerPoint and invokes the reduce function with the current and new point to modify the current point.

func (*IntegerFuncFloatReducer) Emit

func (r *IntegerFuncFloatReducer) Emit() []FloatPoint

Emit emits the point that was generated when reducing the points fed in with AggregateInteger.

type IntegerFuncReducer

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

IntegerFuncReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewIntegerFuncReducer

func NewIntegerFuncReducer(fn IntegerReduceFunc, prev *IntegerPoint) *IntegerFuncReducer

NewIntegerFuncReducer creates a new IntegerFuncIntegerReducer.

func (*IntegerFuncReducer) AggregateInteger

func (r *IntegerFuncReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger takes a IntegerPoint and invokes the reduce function with the current and new point to modify the current point.

func (*IntegerFuncReducer) Emit

func (r *IntegerFuncReducer) Emit() []IntegerPoint

Emit emits the point that was generated when reducing the points fed in with AggregateInteger.

type IntegerFuncStringReducer

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

IntegerFuncStringReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewIntegerFuncStringReducer

func NewIntegerFuncStringReducer(fn IntegerReduceStringFunc, prev *StringPoint) *IntegerFuncStringReducer

NewIntegerFuncStringReducer creates a new IntegerFuncStringReducer.

func (*IntegerFuncStringReducer) AggregateInteger

func (r *IntegerFuncStringReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger takes a IntegerPoint and invokes the reduce function with the current and new point to modify the current point.

func (*IntegerFuncStringReducer) Emit

Emit emits the point that was generated when reducing the points fed in with AggregateInteger.

type IntegerIterator

type IntegerIterator interface {
	Iterator
	Next() (*IntegerPoint, error)
}

IntegerIterator represents a stream of integer points.

type IntegerLiteral

type IntegerLiteral struct {
	Val int64
}

IntegerLiteral represents an integer literal.

func (*IntegerLiteral) String

func (l *IntegerLiteral) String() string

String returns a string representation of the literal.

type IntegerMeanReducer

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

IntegerMeanReducer calculates the mean of the aggregated points.

func NewIntegerMeanReducer

func NewIntegerMeanReducer() *IntegerMeanReducer

NewIntegerMeanReducer creates a new IntegerMeanReducer.

func (*IntegerMeanReducer) AggregateInteger

func (r *IntegerMeanReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger aggregates a point into the reducer.

func (*IntegerMeanReducer) Emit

func (r *IntegerMeanReducer) Emit() []FloatPoint

Emit emits the mean of the aggregated points as a single point.

type IntegerMovingAverageReducer

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

IntegerMovingAverageReducer calculates the moving average of the aggregated points.

func NewIntegerMovingAverageReducer

func NewIntegerMovingAverageReducer(n int) *IntegerMovingAverageReducer

NewIntegerMovingAverageReducer creates a new IntegerMovingAverageReducer.

func (*IntegerMovingAverageReducer) AggregateInteger

func (r *IntegerMovingAverageReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger aggregates a point into the reducer and updates the current window.

func (*IntegerMovingAverageReducer) Emit

Emit emits the moving average of the current window. Emit should be called after every call to AggregateInteger and it will produce one point if there is enough data to fill a window, otherwise it will produce zero points.

type IntegerPoint

type IntegerPoint struct {
	Name string
	Tags Tags

	Time  int64
	Nil   bool
	Value int64
	Aux   []interface{}

	// Total number of points that were combined into this point from an aggregate.
	// If this is zero, the point is not the result of an aggregate function.
	Aggregated uint32
}

IntegerPoint represents a point with a int64 value. DO NOT ADD ADDITIONAL FIELDS TO THIS STRUCT. See TestPoint_Fields in influxql/point_test.go for more details.

func IntegerSpreadReduceSlice

func IntegerSpreadReduceSlice(a []IntegerPoint) []IntegerPoint

IntegerSpreadReduceSlice returns the spread value within a window.

func (*IntegerPoint) Clone

func (v *IntegerPoint) Clone() *IntegerPoint

Clone returns a copy of v.

type IntegerPointAggregator

type IntegerPointAggregator interface {
	AggregateInteger(p *IntegerPoint)
}

IntegerPointAggregator aggregates points to produce a single point.

type IntegerPointDecoder

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

IntegerPointDecoder decodes IntegerPoint points from a reader.

func NewIntegerPointDecoder

func NewIntegerPointDecoder(r io.Reader) *IntegerPointDecoder

NewIntegerPointDecoder returns a new instance of IntegerPointDecoder that reads from r.

func (*IntegerPointDecoder) DecodeIntegerPoint

func (dec *IntegerPointDecoder) DecodeIntegerPoint(p *IntegerPoint) error

DecodeIntegerPoint reads from the underlying reader and unmarshals into p.

func (*IntegerPointDecoder) Stats

func (dec *IntegerPointDecoder) Stats() IteratorStats

Stats returns iterator stats embedded within the stream.

type IntegerPointEmitter

type IntegerPointEmitter interface {
	Emit() []IntegerPoint
}

IntegerPointEmitter produces a single point from an aggregate.

type IntegerPointEncoder

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

IntegerPointEncoder encodes IntegerPoint points to a writer.

func NewIntegerPointEncoder

func NewIntegerPointEncoder(w io.Writer) *IntegerPointEncoder

NewIntegerPointEncoder returns a new instance of IntegerPointEncoder that writes to w.

func (*IntegerPointEncoder) EncodeIntegerPoint

func (enc *IntegerPointEncoder) EncodeIntegerPoint(p *IntegerPoint) error

EncodeIntegerPoint marshals and writes p to the underlying writer.

type IntegerReduceBooleanFunc

type IntegerReduceBooleanFunc func(prev *BooleanPoint, curr *IntegerPoint) (t int64, v bool, aux []interface{})

IntegerReduceBooleanFunc is the function called by a IntegerPoint reducer.

type IntegerReduceBooleanSliceFunc

type IntegerReduceBooleanSliceFunc func(a []IntegerPoint) []BooleanPoint

IntegerReduceBooleanSliceFunc is the function called by a IntegerPoint reducer.

type IntegerReduceFloatFunc

type IntegerReduceFloatFunc func(prev *FloatPoint, curr *IntegerPoint) (t int64, v float64, aux []interface{})

IntegerReduceFloatFunc is the function called by a IntegerPoint reducer.

type IntegerReduceFloatSliceFunc

type IntegerReduceFloatSliceFunc func(a []IntegerPoint) []FloatPoint

IntegerReduceFloatSliceFunc is the function called by a IntegerPoint reducer.

type IntegerReduceFunc

type IntegerReduceFunc func(prev *IntegerPoint, curr *IntegerPoint) (t int64, v int64, aux []interface{})

IntegerReduceFunc is the function called by a IntegerPoint reducer.

type IntegerReduceSliceFunc

type IntegerReduceSliceFunc func(a []IntegerPoint) []IntegerPoint

IntegerReduceSliceFunc is the function called by a IntegerPoint reducer.

func NewIntegerBottomReduceSliceFunc

func NewIntegerBottomReduceSliceFunc(n int, tags []int, interval Interval) IntegerReduceSliceFunc

NewIntegerBottomReduceSliceFunc returns the bottom values within a window.

func NewIntegerPercentileReduceSliceFunc

func NewIntegerPercentileReduceSliceFunc(percentile float64) IntegerReduceSliceFunc

NewIntegerPercentileReduceSliceFunc returns the percentile value within a window.

func NewIntegerTopReduceSliceFunc

func NewIntegerTopReduceSliceFunc(n int, tags []int, interval Interval) IntegerReduceSliceFunc

NewIntegerTopReduceSliceFunc returns the top values within a window.

type IntegerReduceStringFunc

type IntegerReduceStringFunc func(prev *StringPoint, curr *IntegerPoint) (t int64, v string, aux []interface{})

IntegerReduceStringFunc is the function called by a IntegerPoint reducer.

type IntegerReduceStringSliceFunc

type IntegerReduceStringSliceFunc func(a []IntegerPoint) []StringPoint

IntegerReduceStringSliceFunc is the function called by a IntegerPoint reducer.

type IntegerSliceFuncBooleanReducer

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

IntegerSliceFuncBooleanReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewIntegerSliceFuncBooleanReducer

func NewIntegerSliceFuncBooleanReducer(fn IntegerReduceBooleanSliceFunc) *IntegerSliceFuncBooleanReducer

NewIntegerSliceFuncBooleanReducer creates a new IntegerSliceFuncBooleanReducer.

func (*IntegerSliceFuncBooleanReducer) AggregateInteger

func (r *IntegerSliceFuncBooleanReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger copies the IntegerPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*IntegerSliceFuncBooleanReducer) AggregateIntegerBulk

func (r *IntegerSliceFuncBooleanReducer) AggregateIntegerBulk(points []IntegerPoint)

AggregateIntegerBulk performs a bulk copy of IntegerPoints into the internal slice. This is a more efficient version of calling AggregateInteger on each point.

func (*IntegerSliceFuncBooleanReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type IntegerSliceFuncFloatReducer

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

IntegerSliceFuncFloatReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewIntegerSliceFuncFloatReducer

func NewIntegerSliceFuncFloatReducer(fn IntegerReduceFloatSliceFunc) *IntegerSliceFuncFloatReducer

NewIntegerSliceFuncFloatReducer creates a new IntegerSliceFuncFloatReducer.

func (*IntegerSliceFuncFloatReducer) AggregateInteger

func (r *IntegerSliceFuncFloatReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger copies the IntegerPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*IntegerSliceFuncFloatReducer) AggregateIntegerBulk

func (r *IntegerSliceFuncFloatReducer) AggregateIntegerBulk(points []IntegerPoint)

AggregateIntegerBulk performs a bulk copy of IntegerPoints into the internal slice. This is a more efficient version of calling AggregateInteger on each point.

func (*IntegerSliceFuncFloatReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type IntegerSliceFuncReducer

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

IntegerSliceFuncReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewIntegerSliceFuncReducer

func NewIntegerSliceFuncReducer(fn IntegerReduceSliceFunc) *IntegerSliceFuncReducer

NewIntegerSliceFuncReducer creates a new IntegerSliceFuncReducer.

func (*IntegerSliceFuncReducer) AggregateInteger

func (r *IntegerSliceFuncReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger copies the IntegerPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*IntegerSliceFuncReducer) AggregateIntegerBulk

func (r *IntegerSliceFuncReducer) AggregateIntegerBulk(points []IntegerPoint)

AggregateIntegerBulk performs a bulk copy of IntegerPoints into the internal slice. This is a more efficient version of calling AggregateInteger on each point.

func (*IntegerSliceFuncReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type IntegerSliceFuncStringReducer

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

IntegerSliceFuncStringReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewIntegerSliceFuncStringReducer

func NewIntegerSliceFuncStringReducer(fn IntegerReduceStringSliceFunc) *IntegerSliceFuncStringReducer

NewIntegerSliceFuncStringReducer creates a new IntegerSliceFuncStringReducer.

func (*IntegerSliceFuncStringReducer) AggregateInteger

func (r *IntegerSliceFuncStringReducer) AggregateInteger(p *IntegerPoint)

AggregateInteger copies the IntegerPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*IntegerSliceFuncStringReducer) AggregateIntegerBulk

func (r *IntegerSliceFuncStringReducer) AggregateIntegerBulk(points []IntegerPoint)

AggregateIntegerBulk performs a bulk copy of IntegerPoints into the internal slice. This is a more efficient version of calling AggregateInteger on each point.

func (*IntegerSliceFuncStringReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type Interval

type Interval struct {
	Duration time.Duration
	Offset   time.Duration
}

Interval represents a repeating interval for a query.

func (Interval) IsZero

func (i Interval) IsZero() bool

IsZero returns true if the interval has no duration.

type Iterator

type Iterator interface {
	Stats() IteratorStats
	Close() error
}

Iterator represents a generic interface for all Iterators. Most iterator operations are done on the typed sub-interfaces.

func NewCallIterator

func NewCallIterator(input Iterator, opt IteratorOptions) (Iterator, error)

NewCallIterator returns a new iterator for a Call.

func NewCloseInterruptIterator

func NewCloseInterruptIterator(input Iterator, closing <-chan struct{}) Iterator

NewCloseInterruptIterator returns an iterator that will invoke the Close() method on an iterator when a channel has been closed.

func NewDedupeIterator

func NewDedupeIterator(input Iterator) Iterator

NewDedupeIterator returns an iterator that only outputs unique points. This iterator maintains a serialized copy of each row so it is inefficient to use on large datasets. It is intended for small datasets such as meta queries.

func NewDistinctIterator

func NewDistinctIterator(input Iterator, opt IteratorOptions) (Iterator, error)

NewDistinctIterator returns an iterator for operating on a distinct() call.

func NewFillIterator

func NewFillIterator(input Iterator, expr Expr, opt IteratorOptions) Iterator

NewFillIterator returns an iterator that fills in missing points in an aggregate.

func NewInterruptIterator

func NewInterruptIterator(input Iterator, closing <-chan struct{}) Iterator

NewInterruptIterator returns an iterator that will stop producing output when a channel has been closed on the passed in channel.

func NewIntervalIterator

func NewIntervalIterator(input Iterator, opt IteratorOptions) Iterator

NewIntervalIterator returns an iterator that sets the time on each point to the interval.

func NewLimitIterator

func NewLimitIterator(input Iterator, opt IteratorOptions) Iterator

NewLimitIterator returns an iterator that limits the number of points per grouping.

func NewMergeIterator

func NewMergeIterator(inputs []Iterator, opt IteratorOptions) Iterator

NewMergeIterator returns an iterator to merge itrs into one. Inputs must either be merge iterators or only contain a single name/tag in sorted order. The iterator will output all points by window, name/tag, then time. This iterator is useful when you need all of the points for an interval.

func NewParallelMergeIterator

func NewParallelMergeIterator(inputs []Iterator, opt IteratorOptions, parallelism int) Iterator

NewParallelMergeIterator returns an iterator that breaks input iterators into groups and processes them in parallel.

func NewReaderIterator

func NewReaderIterator(r io.Reader, typ DataType, stats IteratorStats) Iterator

NewReaderIterator returns an iterator that streams from a reader.

func NewSortedMergeIterator

func NewSortedMergeIterator(inputs []Iterator, opt IteratorOptions) Iterator

NewSortedMergeIterator returns an iterator to merge itrs into one. Inputs must either be sorted merge iterators or only contain a single name/tag in sorted order. The iterator will output all points by name/tag, then time. This iterator is useful when you need all points for a name/tag to be in order.

func Select

func Select(stmt *SelectStatement, ic IteratorCreator, sopt *SelectOptions) ([]Iterator, error)

Select executes stmt against ic and returns a list of iterators to stream from.

Statements should have all rewriting performed before calling select(). This includes wildcard and source expansion.

type IteratorCreator

type IteratorCreator interface {
	// Creates a simple iterator for use in an InfluxQL query.
	CreateIterator(opt IteratorOptions) (Iterator, error)

	// Returns the unique fields and dimensions across a list of sources.
	FieldDimensions(sources Sources) (fields map[string]DataType, dimensions map[string]struct{}, err error)

	// Expands regex sources to all matching sources.
	ExpandSources(sources Sources) (Sources, error)
}

IteratorCreator represents an interface for objects that can create Iterators.

type IteratorCreators

type IteratorCreators []IteratorCreator

IteratorCreators represents a list of iterator creators.

func (IteratorCreators) Close

func (a IteratorCreators) Close() error

Close closes all iterator creators that implement io.Closer.

func (IteratorCreators) CreateIterator

func (a IteratorCreators) CreateIterator(opt IteratorOptions) (Iterator, error)

CreateIterator returns a single combined iterator from multiple iterator creators.

func (IteratorCreators) ExpandSources

func (a IteratorCreators) ExpandSources(sources Sources) (Sources, error)

ExpandSources expands sources across all iterator creators and returns a unique result.

func (IteratorCreators) FieldDimensions

func (a IteratorCreators) FieldDimensions(sources Sources) (fields map[string]DataType, dimensions map[string]struct{}, err error)

FieldDimensions returns unique fields and dimensions from multiple iterator creators.

type IteratorEncoder

type IteratorEncoder struct {

	// Frequency with which stats are emitted.
	StatsInterval time.Duration
	// contains filtered or unexported fields
}

IteratorEncoder is an encoder for encoding an iterator's points to w.

func NewIteratorEncoder

func NewIteratorEncoder(w io.Writer) *IteratorEncoder

NewIteratorEncoder encodes an iterator's points to w.

func (*IteratorEncoder) EncodeIterator

func (enc *IteratorEncoder) EncodeIterator(itr Iterator) error

EncodeIterator encodes and writes all of itr's points to the underlying writer.

type IteratorOptions

type IteratorOptions struct {
	// Expression to iterate for.
	// This can be VarRef or a Call.
	Expr Expr

	// Auxilary tags or values to also retrieve for the point.
	Aux []VarRef

	// Data sources from which to retrieve data.
	Sources []Source

	// Group by interval and tags.
	Interval   Interval
	Dimensions []string

	// Fill options.
	Fill      FillOption
	FillValue interface{}

	// Condition to filter by.
	Condition Expr

	// Time range for the iterator.
	StartTime int64
	EndTime   int64

	// Sorted in time ascending order if true.
	Ascending bool

	// Limits the number of points per series.
	Limit, Offset int

	// Limits the number of series.
	SLimit, SOffset int

	// Removes duplicate rows from raw queries.
	Dedupe bool

	// If this channel is set and is closed, the iterator should try to exit
	// and close as soon as possible.
	InterruptCh <-chan struct{}
}

IteratorOptions is an object passed to CreateIterator to specify creation options.

func (IteratorOptions) DerivativeInterval

func (opt IteratorOptions) DerivativeInterval() Interval

DerivativeInterval returns the time interval for the derivative function.

func (IteratorOptions) ElapsedInterval

func (opt IteratorOptions) ElapsedInterval() Interval

ElapsedInterval returns the time interval for the elapsed function.

func (*IteratorOptions) MarshalBinary

func (opt *IteratorOptions) MarshalBinary() ([]byte, error)

MarshalBinary encodes opt into a binary format.

func (IteratorOptions) MergeSorted

func (opt IteratorOptions) MergeSorted() bool

MergeSorted returns true if the options require a sorted merge. This is only needed when the expression is a variable reference or there is no expr.

func (IteratorOptions) SeekTime

func (opt IteratorOptions) SeekTime() int64

SeekTime returns the time the iterator should start from. For ascending iterators this is the start time, for descending iterators it's the end time.

func (*IteratorOptions) UnmarshalBinary

func (opt *IteratorOptions) UnmarshalBinary(buf []byte) error

UnmarshalBinary decodes from a binary format in to opt.

func (IteratorOptions) Window

func (opt IteratorOptions) Window(t int64) (start, end int64)

Window returns the time window [start,end) that t falls within.

type IteratorStats

type IteratorStats struct {
	SeriesN int // series represented
	PointN  int // points returned
}

IteratorStats represents statistics about an iterator. Some statistics are available immediately upon iterator creation while some are derived as the iterator processes data.

func (*IteratorStats) Add

func (s *IteratorStats) Add(other IteratorStats)

Add aggregates fields from s and other together. Overwrites s.

type Iterators

type Iterators []Iterator

Iterators represents a list of iterators.

func (Iterators) Close

func (a Iterators) Close() error

Close closes all iterators.

func (Iterators) Merge

func (a Iterators) Merge(opt IteratorOptions) (Iterator, error)

Merge combines all iterators into a single iterator. A sorted merge iterator or a merge iterator can be used based on opt.

func (Iterators) Stats

func (a Iterators) Stats() IteratorStats

Stats returns the aggregation of all iterator stats.

type KillQueryStatement

type KillQueryStatement struct {
	// The query to kill.
	QueryID uint64

	// The host to delegate the kill to.
	Host string
}

KillQueryStatement represents a command for killing a query.

func (*KillQueryStatement) RequiredPrivileges

func (s *KillQueryStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a KillQueryStatement.

func (*KillQueryStatement) String

func (s *KillQueryStatement) String() string

String returns a string representation of the kill query statement.

type ListLiteral

type ListLiteral struct {
	Vals []string
}

ListLiteral represents a list of strings literal.

func (*ListLiteral) String

func (s *ListLiteral) String() string

String returns a string representation of the literal.

type Literal

type Literal interface {
	Expr
	// contains filtered or unexported methods
}

Literal represents a static literal.

type Measurement

type Measurement struct {
	Database        string
	RetentionPolicy string
	Name            string
	Regex           *RegexLiteral
	IsTarget        bool
}

Measurement represents a single measurement used as a datasource.

func (*Measurement) String

func (m *Measurement) String() string

String returns a string representation of the measurement.

type Measurements

type Measurements []*Measurement

Measurements represents a list of measurements.

func (Measurements) String

func (a Measurements) String() string

String returns a string representation of the measurements.

type Message

type Message struct {
	Level string `json:"level"`
	Text  string `json:"text"`
}

Message represents a user-facing message to be included with the result.

func ReadOnlyWarning

func ReadOnlyWarning(stmt string) *Message

ReadOnlyWarning generates a warning message that tells the user the command they are using is being used for writing in a read only context.

This is a temporary method while to be used while transitioning to read only operations for issue #6290.

type Node

type Node interface {
	String() string
	// contains filtered or unexported methods
}

Node represents a node in the InfluxDB abstract syntax tree.

func Rewrite

func Rewrite(r Rewriter, node Node) Node

Rewrite recursively invokes the rewriter to replace each node. Nodes are traversed depth-first and rewritten from leaf to root.

func RewriteFunc

func RewriteFunc(node Node, fn func(Node) Node) Node

RewriteFunc rewrites a node hierarchy.

type NowValuer

type NowValuer struct {
	Now time.Time
}

NowValuer returns only the value for "now()".

func (*NowValuer) Value

func (v *NowValuer) Value(key string) (interface{}, bool)

Value is a method that returns the value and existence flag for a given key.

type NumberLiteral

type NumberLiteral struct {
	Val float64
}

NumberLiteral represents a numeric literal.

func (*NumberLiteral) String

func (l *NumberLiteral) String() string

String returns a string representation of the literal.

type ParenExpr

type ParenExpr struct {
	Expr Expr
}

ParenExpr represents a parenthesized expression.

func (*ParenExpr) String

func (e *ParenExpr) String() string

String returns a string representation of the parenthesized expression.

type ParseError

type ParseError struct {
	Message  string
	Found    string
	Expected []string
	Pos      Pos
}

ParseError represents an error that occurred during parsing.

func (*ParseError) Error

func (e *ParseError) Error() string

Error returns the string representation of the error.

type Parser

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

Parser represents an InfluxQL parser.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

func (*Parser) ParseExpr

func (p *Parser) ParseExpr() (Expr, error)

ParseExpr parses an expression.

func (*Parser) ParseQuery

func (p *Parser) ParseQuery() (*Query, error)

ParseQuery parses an InfluxQL string and returns a Query AST object.

func (*Parser) ParseStatement

func (p *Parser) ParseStatement() (Statement, error)

ParseStatement parses an InfluxQL string and returns a Statement AST object.

func (*Parser) SetParams

func (p *Parser) SetParams(params map[string]interface{})

SetParams sets the parameters that will be used for any bound parameter substitutions.

type Point

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

Point represents a value in a series that occurred at a given time.

type PointDecoder

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

PointDecoder decodes generic points from a reader.

func NewPointDecoder

func NewPointDecoder(r io.Reader) *PointDecoder

NewPointDecoder returns a new instance of PointDecoder that reads from r.

func (*PointDecoder) DecodePoint

func (dec *PointDecoder) DecodePoint(p *Point) error

DecodePoint reads from the underlying reader and unmarshals into p.

func (*PointDecoder) Stats

func (dec *PointDecoder) Stats() IteratorStats

Stats returns iterator stats embedded within the stream.

type Points

type Points []Point

Points represents a list of points.

func (Points) Clone

func (a Points) Clone() []Point

Clone returns a deep copy of a.

type Pos

type Pos struct {
	Line int
	Char int
}

Pos specifies the line and character position of a token. The Char and Line are both zero-based indexes.

type Privilege

type Privilege int

Privilege is a type of action a user can be granted the right to use.

const (
	// NoPrivileges means no privileges required / granted / revoked.
	NoPrivileges Privilege = iota
	// ReadPrivilege means read privilege required / granted / revoked.
	ReadPrivilege
	// WritePrivilege means write privilege required / granted / revoked.
	WritePrivilege
	// AllPrivileges means all privileges required / granted / revoked.
	AllPrivileges
)

func NewPrivilege

func NewPrivilege(p Privilege) *Privilege

NewPrivilege returns an initialized *Privilege.

func (Privilege) String

func (p Privilege) String() string

String returns a string representation of a Privilege.

type Query

type Query struct {
	Statements Statements
}

Query represents a collection of ordered statements.

func ParseQuery

func ParseQuery(s string) (*Query, error)

ParseQuery parses a query string and returns its AST representation.

func (*Query) String

func (q *Query) String() string

String returns a string representation of the query.

type QueryExecutor

type QueryExecutor struct {
	// Used for executing a statement in the query.
	StatementExecutor StatementExecutor

	// Used for tracking running queries.
	TaskManager *TaskManager

	// Logger to use for all logging.
	// Defaults to discarding all log output.
	Logger *log.Logger
	// contains filtered or unexported fields
}

QueryExecutor executes every statement in an Query.

func NewQueryExecutor

func NewQueryExecutor() *QueryExecutor

NewQueryExecutor returns a new instance of QueryExecutor.

func (*QueryExecutor) Close

func (e *QueryExecutor) Close() error

Close kills all running queries and prevents new queries from being attached.

func (*QueryExecutor) ExecuteQuery

func (e *QueryExecutor) ExecuteQuery(query *Query, opt ExecutionOptions, closing chan struct{}) <-chan *Result

ExecuteQuery executes each statement within a query.

func (*QueryExecutor) SetLogOutput

func (e *QueryExecutor) SetLogOutput(w io.Writer)

SetLogOutput sets the writer to which all logs are written. It must not be called after Open is called.

type QueryInfo

type QueryInfo struct {
	ID       uint64        `json:"id"`
	Query    string        `json:"query"`
	Database string        `json:"database"`
	Duration time.Duration `json:"duration"`
}

QueryInfo represents the information for a query.

type QueryMonitorFunc

type QueryMonitorFunc func(<-chan struct{}) error

QueryMonitorFunc is a function that will be called to check if a query is currently healthy. If the query needs to be interrupted for some reason, the error should be returned by this function.

func PointLimitMonitor

func PointLimitMonitor(itrs Iterators, interval time.Duration, limit int) QueryMonitorFunc

PointLimitMonitor is a query monitor that exits when the number of points emitted exceeds a threshold.

type QueryTask

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

QueryTask is the internal data structure for managing queries. For the public use data structure that gets returned, see QueryTask.

func (*QueryTask) Error

func (q *QueryTask) Error() error

Error returns any asynchronous error that may have occured while executing the query.

func (*QueryTask) Monitor

func (q *QueryTask) Monitor(fn QueryMonitorFunc)

Monitor starts a new goroutine that will monitor a query. The function will be passed in a channel to signal when the query has been finished normally. If the function returns with an error and the query is still running, the query will be terminated.

type RegexLiteral

type RegexLiteral struct {
	Val *regexp.Regexp
}

RegexLiteral represents a regular expression.

func CloneRegexLiteral

func CloneRegexLiteral(r *RegexLiteral) *RegexLiteral

CloneRegexLiteral returns a clone of the RegexLiteral.

func (*RegexLiteral) String

func (r *RegexLiteral) String() string

String returns a string representation of the literal.

type Result

type Result struct {
	// StatementID is just the statement's position in the query. It's used
	// to combine statement results if they're being buffered in memory.
	StatementID int `json:"-"`
	Series      models.Rows
	Messages    []*Message
	Err         error
}

Result represents a resultset returned from a single statement. Rows represents a list of rows that can be sorted consistently by name/tag.

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

MarshalJSON encodes the result into JSON.

func (*Result) UnmarshalJSON

func (r *Result) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the data into the Result struct

type RevokeAdminStatement

type RevokeAdminStatement struct {
	// Who to revoke admin privilege from.
	User string
}

RevokeAdminStatement represents a command to revoke admin privilege from a user.

func (*RevokeAdminStatement) RequiredPrivileges

func (s *RevokeAdminStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a RevokeAdminStatement.

func (*RevokeAdminStatement) String

func (s *RevokeAdminStatement) String() string

String returns a string representation of the revoke admin statement.

type RevokeStatement

type RevokeStatement struct {
	// The privilege to be revoked.
	Privilege Privilege

	// Database to revoke the privilege from.
	On string

	// Who to revoke privilege from.
	User string
}

RevokeStatement represents a command to revoke a privilege from a user.

func (*RevokeStatement) RequiredPrivileges

func (s *RevokeStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a RevokeStatement.

func (*RevokeStatement) String

func (s *RevokeStatement) String() string

String returns a string representation of the revoke statement.

type Rewriter

type Rewriter interface {
	Rewrite(Node) Node
}

Rewriter can be called by Rewrite to replace nodes in the AST hierarchy. The Rewrite() function is called once per node.

type Scanner

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

Scanner represents a lexical scanner for InfluxQL.

func NewScanner

func NewScanner(r io.Reader) *Scanner

NewScanner returns a new instance of Scanner.

func (*Scanner) Scan

func (s *Scanner) Scan() (tok Token, pos Pos, lit string)

Scan returns the next token and position from the underlying reader. Also returns the literal text read for strings, numbers, and duration tokens since these token types can have different literal representations.

func (*Scanner) ScanRegex

func (s *Scanner) ScanRegex() (tok Token, pos Pos, lit string)

ScanRegex consumes a token to find escapes

type SelectOptions

type SelectOptions struct {
	// The lower bound for a select call.
	MinTime time.Time

	// The upper bound for a select call.
	MaxTime time.Time

	// Node to exclusively read from.
	// If zero, all nodes are used.
	NodeID uint64

	// An optional channel that, if closed, signals that the select should be
	// interrupted.
	InterruptCh <-chan struct{}
}

SelectOptions are options that customize the select call.

type SelectStatement

type SelectStatement struct {
	// Expressions returned from the selection.
	Fields Fields

	// Target (destination) for the result of the select.
	Target *Target

	// Expressions used for grouping the selection.
	Dimensions Dimensions

	// Data sources that fields are extracted from.
	Sources Sources

	// An expression evaluated on data point.
	Condition Expr

	// Fields to sort results by
	SortFields SortFields

	// Maximum number of rows to be returned. Unlimited if zero.
	Limit int

	// Returns rows starting at an offset from the first row.
	Offset int

	// Maxiumum number of series to be returned. Unlimited if zero.
	SLimit int

	// Returns series starting at an offset from the first one.
	SOffset int

	// if it's a query for raw data values (i.e. not an aggregate)
	IsRawQuery bool

	// What fill option the select statement uses, if any
	Fill FillOption

	// The value to fill empty aggregate buckets with, if any
	FillValue interface{}

	// Renames the implicit time field name.
	TimeAlias string

	// Removes the "time" column from the output.
	OmitTime bool

	// Removes duplicate rows from raw queries.
	Dedupe bool
	// contains filtered or unexported fields
}

SelectStatement represents a command for extracting data from the database.

func (*SelectStatement) Clone

func (s *SelectStatement) Clone() *SelectStatement

Clone returns a deep copy of the statement.

func (*SelectStatement) ColumnNames

func (s *SelectStatement) ColumnNames() []string

ColumnNames will walk all fields and functions and return the appropriate field names for the select statement while maintaining order of the field names

func (*SelectStatement) FunctionCalls

func (s *SelectStatement) FunctionCalls() []*Call

FunctionCalls returns the Call objects from the query

func (*SelectStatement) FunctionCallsByPosition

func (s *SelectStatement) FunctionCallsByPosition() [][]*Call

FunctionCallsByPosition returns the Call objects from the query in the order they appear in the select statement

func (*SelectStatement) GroupByInterval

func (s *SelectStatement) GroupByInterval() (time.Duration, error)

GroupByInterval extracts the time interval, if specified.

func (*SelectStatement) GroupByOffset

func (s *SelectStatement) GroupByOffset(opt *IteratorOptions) (time.Duration, error)

GroupByOffset extracts the time interval offset, if specified.

func (*SelectStatement) HasDerivative

func (s *SelectStatement) HasDerivative() bool

HasDerivative returns true if one of the function calls in the statement is a derivative aggregate

func (*SelectStatement) HasDimensionWildcard

func (s *SelectStatement) HasDimensionWildcard() bool

HasDimensionWildcard returns whether or not the select statement has at least 1 wildcard in the dimensions aka `GROUP BY`

func (*SelectStatement) HasDistinct

func (s *SelectStatement) HasDistinct() bool

HasDistinct checks if a select statement contains DISTINCT

func (*SelectStatement) HasFieldWildcard

func (s *SelectStatement) HasFieldWildcard() bool

HasFieldWildcard returns whether or not the select statement has at least 1 wildcard in the fields

func (*SelectStatement) HasTimeFieldSpecified

func (s *SelectStatement) HasTimeFieldSpecified() bool

HasTimeFieldSpecified will walk all fields and determine if the user explicitly asked for time This is needed to determine re-write behaviors for functions like TOP and BOTTOM

func (*SelectStatement) HasWildcard

func (s *SelectStatement) HasWildcard() bool

HasWildcard returns whether or not the select statement has at least 1 wildcard

func (*SelectStatement) IsSimpleDerivative

func (s *SelectStatement) IsSimpleDerivative() bool

IsSimpleDerivative return true if one of the function call is a derivative function with a variable ref as the first arg

func (*SelectStatement) NamesInDimension

func (s *SelectStatement) NamesInDimension() []string

NamesInDimension returns the field and tag names (idents) in the group by

func (*SelectStatement) NamesInSelect

func (s *SelectStatement) NamesInSelect() []string

NamesInSelect returns the field and tag names (idents) in the select clause

func (*SelectStatement) NamesInWhere

func (s *SelectStatement) NamesInWhere() []string

NamesInWhere returns the field and tag names (idents) referenced in the where clause

func (*SelectStatement) RequiredPrivileges

func (s *SelectStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute the SelectStatement. NOTE: Statement should be normalized first (database name(s) in Sources and Target should be populated). If the statement has not been normalized, an empty string will be returned for the database name and it is up to the caller to interpret that as the default database.

func (*SelectStatement) RewriteDistinct

func (s *SelectStatement) RewriteDistinct()

RewriteDistinct rewrites the expression to be a call for map/reduce to work correctly This method assumes all validation has passed

func (*SelectStatement) RewriteFields

func (s *SelectStatement) RewriteFields(ic IteratorCreator) (*SelectStatement, error)

RewriteFields returns the re-written form of the select statement. Any wildcard query fields are replaced with the supplied fields, and any wildcard GROUP BY fields are replaced with the supplied dimensions. Any fields with no type specifier are rewritten with the appropriate type.

func (*SelectStatement) RewriteTimeFields

func (s *SelectStatement) RewriteTimeFields()

RewriteTimeFields removes any "time" field references.

func (*SelectStatement) SetTimeRange

func (s *SelectStatement) SetTimeRange(start, end time.Time) error

SetTimeRange sets the start and end time of the select statement to [start, end). i.e. start inclusive, end exclusive. This is used commonly for continuous queries so the start and end are in buckets.

func (*SelectStatement) String

func (s *SelectStatement) String() string

String returns a string representation of the select statement.

func (*SelectStatement) Substatement

func (s *SelectStatement) Substatement(ref *VarRef) (*SelectStatement, error)

Substatement returns a single-series statement for a given variable reference.

func (*SelectStatement) TimeAscending

func (s *SelectStatement) TimeAscending() bool

TimeAscending returns true if the time field is sorted in chronological order.

func (*SelectStatement) TimeFieldName

func (s *SelectStatement) TimeFieldName() string

TimeFieldName returns the name of the time field.

type SetPasswordUserStatement

type SetPasswordUserStatement struct {
	// Plain Password
	Password string

	// Who to grant the privilege to.
	Name string
}

SetPasswordUserStatement represents a command for changing user password.

func (*SetPasswordUserStatement) RequiredPrivileges

func (s *SetPasswordUserStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a SetPasswordUserStatement.

func (*SetPasswordUserStatement) String

func (s *SetPasswordUserStatement) String() string

String returns a string representation of the set password statement.

type ShowContinuousQueriesStatement

type ShowContinuousQueriesStatement struct{}

ShowContinuousQueriesStatement represents a command for listing continuous queries.

func (*ShowContinuousQueriesStatement) RequiredPrivileges

func (s *ShowContinuousQueriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a ShowContinuousQueriesStatement.

func (*ShowContinuousQueriesStatement) String

String returns a string representation of the list continuous queries statement.

type ShowDatabasesStatement

type ShowDatabasesStatement struct{}

ShowDatabasesStatement represents a command for listing all databases in the cluster.

func (*ShowDatabasesStatement) RequiredPrivileges

func (s *ShowDatabasesStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a ShowDatabasesStatement

func (*ShowDatabasesStatement) String

func (s *ShowDatabasesStatement) String() string

String returns a string representation of the list databases command.

type ShowDiagnosticsStatement

type ShowDiagnosticsStatement struct {
	// Module
	Module string
}

ShowDiagnosticsStatement represents a command for show node diagnostics.

func (*ShowDiagnosticsStatement) RequiredPrivileges

func (s *ShowDiagnosticsStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a ShowDiagnosticsStatement

func (*ShowDiagnosticsStatement) String

func (s *ShowDiagnosticsStatement) String() string

String returns a string representation of the ShowDiagnosticsStatement.

type ShowFieldKeysStatement

type ShowFieldKeysStatement struct {
	// Data sources that fields are extracted from.
	Sources Sources

	// Fields to sort results by
	SortFields SortFields

	// Maximum number of rows to be returned.
	// Unlimited if zero.
	Limit int

	// Returns rows starting at an offset from the first row.
	Offset int
}

ShowFieldKeysStatement represents a command for listing field keys.

func (*ShowFieldKeysStatement) RequiredPrivileges

func (s *ShowFieldKeysStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a ShowFieldKeysStatement

func (*ShowFieldKeysStatement) String

func (s *ShowFieldKeysStatement) String() string

String returns a string representation of the statement.

type ShowGrantsForUserStatement

type ShowGrantsForUserStatement struct {
	// Name of the user to display privileges.
	Name string
}

ShowGrantsForUserStatement represents a command for listing user privileges.

func (*ShowGrantsForUserStatement) RequiredPrivileges

func (s *ShowGrantsForUserStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a ShowGrantsForUserStatement

func (*ShowGrantsForUserStatement) String

func (s *ShowGrantsForUserStatement) String() string

String returns a string representation of the show grants for user.

type ShowMeasurementsStatement

type ShowMeasurementsStatement struct {
	// Measurement name or regex.
	Source Source

	// An expression evaluated on data point.
	Condition Expr

	// Fields to sort results by
	SortFields SortFields

	// Maximum number of rows to be returned.
	// Unlimited if zero.
	Limit int

	// Returns rows starting at an offset from the first row.
	Offset int
}

ShowMeasurementsStatement represents a command for listing measurements.

func (*ShowMeasurementsStatement) RequiredPrivileges

func (s *ShowMeasurementsStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a ShowMeasurementsStatement

func (*ShowMeasurementsStatement) String

func (s *ShowMeasurementsStatement) String() string

String returns a string representation of the statement.

type ShowQueriesStatement

type ShowQueriesStatement struct{}

ShowQueriesStatement represents a command for listing all running queries.

func (*ShowQueriesStatement) RequiredPrivileges

func (s *ShowQueriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a ShowQueriesStatement.

func (*ShowQueriesStatement) String

func (s *ShowQueriesStatement) String() string

String returns a string representation of the show queries statement.

type ShowRetentionPoliciesStatement

type ShowRetentionPoliciesStatement struct {
	// Name of the database to list policies for.
	Database string
}

ShowRetentionPoliciesStatement represents a command for listing retention policies.

func (*ShowRetentionPoliciesStatement) RequiredPrivileges

func (s *ShowRetentionPoliciesStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a ShowRetentionPoliciesStatement

func (*ShowRetentionPoliciesStatement) String

String returns a string representation of a ShowRetentionPoliciesStatement.

type ShowSeriesStatement

type ShowSeriesStatement struct {
	// Measurement(s) the series are listed for.
	Sources Sources

	// An expression evaluated on a series name or tag.
	Condition Expr

	// Fields to sort results by
	SortFields SortFields

	// Maximum number of rows to be returned.
	// Unlimited if zero.
	Limit int

	// Returns rows starting at an offset from the first row.
	Offset int
}

ShowSeriesStatement represents a command for listing series in the database.

func (*ShowSeriesStatement) RequiredPrivileges

func (s *ShowSeriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a ShowSeriesStatement.

func (*ShowSeriesStatement) String

func (s *ShowSeriesStatement) String() string

String returns a string representation of the list series statement.

type ShowShardGroupsStatement

type ShowShardGroupsStatement struct{}

ShowShardGroupsStatement represents a command for displaying shard groups in the cluster.

func (*ShowShardGroupsStatement) RequiredPrivileges

func (s *ShowShardGroupsStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privileges required to execute the statement.

func (*ShowShardGroupsStatement) String

func (s *ShowShardGroupsStatement) String() string

String returns a string representation of the SHOW SHARD GROUPS command.

type ShowShardsStatement

type ShowShardsStatement struct{}

ShowShardsStatement represents a command for displaying shards in the cluster.

func (*ShowShardsStatement) RequiredPrivileges

func (s *ShowShardsStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privileges required to execute the statement.

func (*ShowShardsStatement) String

func (s *ShowShardsStatement) String() string

String returns a string representation.

type ShowStatsStatement

type ShowStatsStatement struct {
	// Module
	Module string
}

ShowStatsStatement displays statistics for a given module.

func (*ShowStatsStatement) RequiredPrivileges

func (s *ShowStatsStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a ShowStatsStatement

func (*ShowStatsStatement) String

func (s *ShowStatsStatement) String() string

String returns a string representation of a ShowStatsStatement.

type ShowSubscriptionsStatement

type ShowSubscriptionsStatement struct {
}

ShowSubscriptionsStatement represents a command to show a list of subscriptions.

func (*ShowSubscriptionsStatement) RequiredPrivileges

func (s *ShowSubscriptionsStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege required to execute a ShowSubscriptionStatement

func (*ShowSubscriptionsStatement) String

func (s *ShowSubscriptionsStatement) String() string

String returns a string representation of the ShowSubscriptionStatement.

type ShowTagKeysStatement

type ShowTagKeysStatement struct {
	// Data sources that fields are extracted from.
	Sources Sources

	// An expression evaluated on data point.
	Condition Expr

	// Fields to sort results by
	SortFields SortFields

	// Maximum number of tag keys per measurement. Unlimited if zero.
	Limit int

	// Returns tag keys starting at an offset from the first row.
	Offset int

	// Maxiumum number of series to be returned. Unlimited if zero.
	SLimit int

	// Returns series starting at an offset from the first one.
	SOffset int
}

ShowTagKeysStatement represents a command for listing tag keys.

func (*ShowTagKeysStatement) RequiredPrivileges

func (s *ShowTagKeysStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a ShowTagKeysStatement

func (*ShowTagKeysStatement) String

func (s *ShowTagKeysStatement) String() string

String returns a string representation of the statement.

type ShowTagValuesStatement

type ShowTagValuesStatement struct {
	// Data source that fields are extracted from.
	Sources Sources

	// Operation to use when selecting tag key(s).
	Op Token

	// Literal to compare the tag key(s) with.
	TagKeyExpr Literal

	// An expression evaluated on data point.
	Condition Expr

	// Fields to sort results by
	SortFields SortFields

	// Maximum number of rows to be returned.
	// Unlimited if zero.
	Limit int

	// Returns rows starting at an offset from the first row.
	Offset int
}

ShowTagValuesStatement represents a command for listing tag values.

func (*ShowTagValuesStatement) RequiredPrivileges

func (s *ShowTagValuesStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a ShowTagValuesStatement

func (*ShowTagValuesStatement) String

func (s *ShowTagValuesStatement) String() string

String returns a string representation of the statement.

type ShowUsersStatement

type ShowUsersStatement struct{}

ShowUsersStatement represents a command for listing users.

func (*ShowUsersStatement) RequiredPrivileges

func (s *ShowUsersStatement) RequiredPrivileges() (ExecutionPrivileges, error)

RequiredPrivileges returns the privilege(s) required to execute a ShowUsersStatement

func (*ShowUsersStatement) String

func (s *ShowUsersStatement) String() string

String returns a string representation of the ShowUsersStatement.

type SortField

type SortField struct {
	// Name of the field
	Name string

	// Sort order.
	Ascending bool
}

SortField represents a field to sort results by.

func (*SortField) String

func (field *SortField) String() string

String returns a string representation of a sort field

type SortFields

type SortFields []*SortField

SortFields represents an ordered list of ORDER BY fields

func (SortFields) String

func (a SortFields) String() string

String returns a string representation of sort fields

type Source

type Source interface {
	Node
	// contains filtered or unexported methods
}

Source represents a source of data for a statement.

type Sources

type Sources []Source

Sources represents a list of sources.

func (Sources) Filter

func (a Sources) Filter(database, retentionPolicy string) []Source

Filter returns a list of source names filtered by the database/retention policy.

func (Sources) HasRegex

func (a Sources) HasRegex() bool

HasRegex returns true if any of the sources are regex measurements.

func (Sources) HasSystemSource

func (a Sources) HasSystemSource() bool

HasSystemSource returns true if any of the sources are internal, system sources.

func (Sources) MarshalBinary

func (a Sources) MarshalBinary() ([]byte, error)

MarshalBinary encodes a list of sources to a binary format.

func (Sources) Names

func (a Sources) Names() []string

Names returns a list of source names.

func (Sources) String

func (a Sources) String() string

String returns a string representation of a Sources array.

func (*Sources) UnmarshalBinary

func (a *Sources) UnmarshalBinary(buf []byte) error

UnmarshalBinary decodes binary data into a list of sources.

type Statement

type Statement interface {
	Node

	RequiredPrivileges() (ExecutionPrivileges, error)
	// contains filtered or unexported methods
}

Statement represents a single command in InfluxQL.

func MustParseStatement

func MustParseStatement(s string) Statement

MustParseStatement parses a statement string and returns its AST. Panic on error.

func ParseStatement

func ParseStatement(s string) (Statement, error)

ParseStatement parses a statement string and returns its AST representation.

func RewriteStatement

func RewriteStatement(stmt Statement) (Statement, error)

RewriteStatement rewrites stmt into a new statement, if applicable.

type StatementExecutor

type StatementExecutor interface {
	// ExecuteStatement executes a statement. Results should be sent to the
	// results channel in the ExecutionContext.
	ExecuteStatement(stmt Statement, ctx ExecutionContext) error
}

StatementExecutor executes a statement within the QueryExecutor.

type StatementNormalizer

type StatementNormalizer interface {
	// NormalizeStatement adds a default database and policy to the
	// measurements in the statement.
	NormalizeStatement(stmt Statement, database string) error
}

StatementNormalizer normalizes a statement before it is executed.

type Statements

type Statements []Statement

Statements represents a list of statements.

func (Statements) String

func (a Statements) String() string

String returns a string representation of the statements.

type StringBulkPointAggregator

type StringBulkPointAggregator interface {
	AggregateStringBulk(points []StringPoint)
}

StringBulkPointAggregator aggregates multiple points at a time.

type StringDistinctReducer

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

StringDistinctReducer returns the distinct points in a series.

func NewStringDistinctReducer

func NewStringDistinctReducer() *StringDistinctReducer

NewStringDistinctReducer creates a new StringDistinctReducer.

func (*StringDistinctReducer) AggregateString

func (r *StringDistinctReducer) AggregateString(p *StringPoint)

AggregateString aggregates a point into the reducer.

func (*StringDistinctReducer) Emit

func (r *StringDistinctReducer) Emit() []StringPoint

Emit emits the distinct points that have been aggregated into the reducer.

type StringElapsedReducer

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

StringElapsedReducer calculates the elapsed of the aggregated points.

func NewStringElapsedReducer

func NewStringElapsedReducer(interval Interval) *StringElapsedReducer

NewStringElapsedReducer creates a new StringElapsedReducer.

func (*StringElapsedReducer) AggregateString

func (r *StringElapsedReducer) AggregateString(p *StringPoint)

AggregateString aggregates a point into the reducer and updates the current window.

func (*StringElapsedReducer) Emit

func (r *StringElapsedReducer) Emit() []IntegerPoint

Emit emits the elapsed of the reducer at the current point.

type StringFuncBooleanReducer

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

StringFuncBooleanReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewStringFuncBooleanReducer

func NewStringFuncBooleanReducer(fn StringReduceBooleanFunc, prev *BooleanPoint) *StringFuncBooleanReducer

NewStringFuncBooleanReducer creates a new StringFuncBooleanReducer.

func (*StringFuncBooleanReducer) AggregateString

func (r *StringFuncBooleanReducer) AggregateString(p *StringPoint)

AggregateString takes a StringPoint and invokes the reduce function with the current and new point to modify the current point.

func (*StringFuncBooleanReducer) Emit

Emit emits the point that was generated when reducing the points fed in with AggregateString.

type StringFuncFloatReducer

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

StringFuncFloatReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewStringFuncFloatReducer

func NewStringFuncFloatReducer(fn StringReduceFloatFunc, prev *FloatPoint) *StringFuncFloatReducer

NewStringFuncFloatReducer creates a new StringFuncFloatReducer.

func (*StringFuncFloatReducer) AggregateString

func (r *StringFuncFloatReducer) AggregateString(p *StringPoint)

AggregateString takes a StringPoint and invokes the reduce function with the current and new point to modify the current point.

func (*StringFuncFloatReducer) Emit

func (r *StringFuncFloatReducer) Emit() []FloatPoint

Emit emits the point that was generated when reducing the points fed in with AggregateString.

type StringFuncIntegerReducer

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

StringFuncIntegerReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewStringFuncIntegerReducer

func NewStringFuncIntegerReducer(fn StringReduceIntegerFunc, prev *IntegerPoint) *StringFuncIntegerReducer

NewStringFuncIntegerReducer creates a new StringFuncIntegerReducer.

func (*StringFuncIntegerReducer) AggregateString

func (r *StringFuncIntegerReducer) AggregateString(p *StringPoint)

AggregateString takes a StringPoint and invokes the reduce function with the current and new point to modify the current point.

func (*StringFuncIntegerReducer) Emit

Emit emits the point that was generated when reducing the points fed in with AggregateString.

type StringFuncReducer

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

StringFuncReducer is a reducer that reduces the passed in points to a single point using a reduce function.

func NewStringFuncReducer

func NewStringFuncReducer(fn StringReduceFunc, prev *StringPoint) *StringFuncReducer

NewStringFuncReducer creates a new StringFuncStringReducer.

func (*StringFuncReducer) AggregateString

func (r *StringFuncReducer) AggregateString(p *StringPoint)

AggregateString takes a StringPoint and invokes the reduce function with the current and new point to modify the current point.

func (*StringFuncReducer) Emit

func (r *StringFuncReducer) Emit() []StringPoint

Emit emits the point that was generated when reducing the points fed in with AggregateString.

type StringIterator

type StringIterator interface {
	Iterator
	Next() (*StringPoint, error)
}

StringIterator represents a stream of string points.

type StringLiteral

type StringLiteral struct {
	Val string
}

StringLiteral represents a string literal.

func (*StringLiteral) String

func (l *StringLiteral) String() string

String returns a string representation of the literal.

type StringPoint

type StringPoint struct {
	Name string
	Tags Tags

	Time  int64
	Nil   bool
	Value string
	Aux   []interface{}

	// Total number of points that were combined into this point from an aggregate.
	// If this is zero, the point is not the result of an aggregate function.
	Aggregated uint32
}

StringPoint represents a point with a string value. DO NOT ADD ADDITIONAL FIELDS TO THIS STRUCT. See TestPoint_Fields in influxql/point_test.go for more details.

func StringStddevReduceSlice

func StringStddevReduceSlice(a []StringPoint) []StringPoint

StringStddevReduceSlice always returns "".

func (*StringPoint) Clone

func (v *StringPoint) Clone() *StringPoint

Clone returns a copy of v.

type StringPointAggregator

type StringPointAggregator interface {
	AggregateString(p *StringPoint)
}

StringPointAggregator aggregates points to produce a single point.

type StringPointDecoder

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

StringPointDecoder decodes StringPoint points from a reader.

func NewStringPointDecoder

func NewStringPointDecoder(r io.Reader) *StringPointDecoder

NewStringPointDecoder returns a new instance of StringPointDecoder that reads from r.

func (*StringPointDecoder) DecodeStringPoint

func (dec *StringPointDecoder) DecodeStringPoint(p *StringPoint) error

DecodeStringPoint reads from the underlying reader and unmarshals into p.

func (*StringPointDecoder) Stats

func (dec *StringPointDecoder) Stats() IteratorStats

Stats returns iterator stats embedded within the stream.

type StringPointEmitter

type StringPointEmitter interface {
	Emit() []StringPoint
}

StringPointEmitter produces a single point from an aggregate.

type StringPointEncoder

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

StringPointEncoder encodes StringPoint points to a writer.

func NewStringPointEncoder

func NewStringPointEncoder(w io.Writer) *StringPointEncoder

NewStringPointEncoder returns a new instance of StringPointEncoder that writes to w.

func (*StringPointEncoder) EncodeStringPoint

func (enc *StringPointEncoder) EncodeStringPoint(p *StringPoint) error

EncodeStringPoint marshals and writes p to the underlying writer.

type StringReduceBooleanFunc

type StringReduceBooleanFunc func(prev *BooleanPoint, curr *StringPoint) (t int64, v bool, aux []interface{})

StringReduceBooleanFunc is the function called by a StringPoint reducer.

type StringReduceBooleanSliceFunc

type StringReduceBooleanSliceFunc func(a []StringPoint) []BooleanPoint

StringReduceBooleanSliceFunc is the function called by a StringPoint reducer.

type StringReduceFloatFunc

type StringReduceFloatFunc func(prev *FloatPoint, curr *StringPoint) (t int64, v float64, aux []interface{})

StringReduceFloatFunc is the function called by a StringPoint reducer.

type StringReduceFloatSliceFunc

type StringReduceFloatSliceFunc func(a []StringPoint) []FloatPoint

StringReduceFloatSliceFunc is the function called by a StringPoint reducer.

type StringReduceFunc

type StringReduceFunc func(prev *StringPoint, curr *StringPoint) (t int64, v string, aux []interface{})

StringReduceFunc is the function called by a StringPoint reducer.

type StringReduceIntegerFunc

type StringReduceIntegerFunc func(prev *IntegerPoint, curr *StringPoint) (t int64, v int64, aux []interface{})

StringReduceIntegerFunc is the function called by a StringPoint reducer.

type StringReduceIntegerSliceFunc

type StringReduceIntegerSliceFunc func(a []StringPoint) []IntegerPoint

StringReduceIntegerSliceFunc is the function called by a StringPoint reducer.

type StringReduceSliceFunc

type StringReduceSliceFunc func(a []StringPoint) []StringPoint

StringReduceSliceFunc is the function called by a StringPoint reducer.

type StringSliceFuncBooleanReducer

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

StringSliceFuncBooleanReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewStringSliceFuncBooleanReducer

func NewStringSliceFuncBooleanReducer(fn StringReduceBooleanSliceFunc) *StringSliceFuncBooleanReducer

NewStringSliceFuncBooleanReducer creates a new StringSliceFuncBooleanReducer.

func (*StringSliceFuncBooleanReducer) AggregateString

func (r *StringSliceFuncBooleanReducer) AggregateString(p *StringPoint)

AggregateString copies the StringPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*StringSliceFuncBooleanReducer) AggregateStringBulk

func (r *StringSliceFuncBooleanReducer) AggregateStringBulk(points []StringPoint)

AggregateStringBulk performs a bulk copy of StringPoints into the internal slice. This is a more efficient version of calling AggregateString on each point.

func (*StringSliceFuncBooleanReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type StringSliceFuncFloatReducer

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

StringSliceFuncFloatReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewStringSliceFuncFloatReducer

func NewStringSliceFuncFloatReducer(fn StringReduceFloatSliceFunc) *StringSliceFuncFloatReducer

NewStringSliceFuncFloatReducer creates a new StringSliceFuncFloatReducer.

func (*StringSliceFuncFloatReducer) AggregateString

func (r *StringSliceFuncFloatReducer) AggregateString(p *StringPoint)

AggregateString copies the StringPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*StringSliceFuncFloatReducer) AggregateStringBulk

func (r *StringSliceFuncFloatReducer) AggregateStringBulk(points []StringPoint)

AggregateStringBulk performs a bulk copy of StringPoints into the internal slice. This is a more efficient version of calling AggregateString on each point.

func (*StringSliceFuncFloatReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type StringSliceFuncIntegerReducer

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

StringSliceFuncIntegerReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewStringSliceFuncIntegerReducer

func NewStringSliceFuncIntegerReducer(fn StringReduceIntegerSliceFunc) *StringSliceFuncIntegerReducer

NewStringSliceFuncIntegerReducer creates a new StringSliceFuncIntegerReducer.

func (*StringSliceFuncIntegerReducer) AggregateString

func (r *StringSliceFuncIntegerReducer) AggregateString(p *StringPoint)

AggregateString copies the StringPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*StringSliceFuncIntegerReducer) AggregateStringBulk

func (r *StringSliceFuncIntegerReducer) AggregateStringBulk(points []StringPoint)

AggregateStringBulk performs a bulk copy of StringPoints into the internal slice. This is a more efficient version of calling AggregateString on each point.

func (*StringSliceFuncIntegerReducer) Emit

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type StringSliceFuncReducer

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

StringSliceFuncReducer is a reducer that aggregates the passed in points and then invokes the function to reduce the points when they are emitted.

func NewStringSliceFuncReducer

func NewStringSliceFuncReducer(fn StringReduceSliceFunc) *StringSliceFuncReducer

NewStringSliceFuncReducer creates a new StringSliceFuncReducer.

func (*StringSliceFuncReducer) AggregateString

func (r *StringSliceFuncReducer) AggregateString(p *StringPoint)

AggregateString copies the StringPoint into the internal slice to be passed to the reduce function when Emit is called.

func (*StringSliceFuncReducer) AggregateStringBulk

func (r *StringSliceFuncReducer) AggregateStringBulk(points []StringPoint)

AggregateStringBulk performs a bulk copy of StringPoints into the internal slice. This is a more efficient version of calling AggregateString on each point.

func (*StringSliceFuncReducer) Emit

func (r *StringSliceFuncReducer) Emit() []StringPoint

Emit invokes the reduce function on the aggregated points to generate the aggregated points. This method does not clear the points from the internal slice.

type TagSet

type TagSet struct {
	Tags       map[string]string
	Filters    []Expr
	SeriesKeys []string
	Key        []byte
}

TagSet is a fundamental concept within the query system. It represents a composite series, composed of multiple individual series that share a set of tag attributes.

func LimitTagSets

func LimitTagSets(a []*TagSet, slimit, soffset int) []*TagSet

LimitTagSets returns a tag set list with SLIMIT and SOFFSET applied.

func (*TagSet) AddFilter

func (t *TagSet) AddFilter(key string, filter Expr)

AddFilter adds a series-level filter to the Tagset.

func (*TagSet) Len

func (t *TagSet) Len() int

func (*TagSet) Less

func (t *TagSet) Less(i, j int) bool

func (*TagSet) Swap

func (t *TagSet) Swap(i, j int)

type Tags

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

Tags represent a map of keys and values. It memoizes its key so it can be used efficiently during query execution.

func NewTags

func NewTags(m map[string]string) Tags

NewTags returns a new instance of Tags.

func (*Tags) Equals

func (t *Tags) Equals(other *Tags) bool

Equals returns true if t equals other.

func (Tags) ID

func (t Tags) ID() string

ID returns the string identifier for the tags.

func (Tags) KeyValues

func (t Tags) KeyValues() map[string]string

KeyValues returns the underlying map for the tags.

func (*Tags) Keys

func (t *Tags) Keys() []string

Keys returns a sorted list of all keys on the tag.

func (*Tags) Subset

func (t *Tags) Subset(keys []string) Tags

Subset returns a new tags object with a subset of the keys.

func (*Tags) Value

func (t *Tags) Value(k string) string

Value returns the value for a given key.

type Target

type Target struct {
	// Measurement to write into.
	Measurement *Measurement
}

Target represents a target (destination) policy, measurement, and DB.

func (*Target) String

func (t *Target) String() string

String returns a string representation of the Target.

type TaskManager

type TaskManager struct {
	// Query execution timeout.
	QueryTimeout time.Duration

	// Log queries if they are slower than this time.
	// If zero, slow queries will never be logged.
	LogQueriesAfter time.Duration

	// Maximum number of concurrent queries.
	MaxConcurrentQueries int

	// Logger to use for all logging.
	// Defaults to discarding all log output.
	Logger *log.Logger
	// contains filtered or unexported fields
}

TaskManager takes care of all aspects related to managing running queries.

func NewTaskManager

func NewTaskManager() *TaskManager

NewTaskManager creates a new TaskManager.

func (*TaskManager) AttachQuery

func (t *TaskManager) AttachQuery(q *Query, database string, interrupt <-chan struct{}) (uint64, *QueryTask, error)

AttachQuery attaches a running query to be managed by the TaskManager. Returns the query id of the newly attached query or an error if it was unable to assign a query id or attach the query to the TaskManager. This function also returns a channel that will be closed when this query finishes running.

After a query finishes running, the system is free to reuse a query id.

func (*TaskManager) Close

func (t *TaskManager) Close() error

Close kills all running queries and prevents new queries from being attached.

func (*TaskManager) ExecuteStatement

func (t *TaskManager) ExecuteStatement(stmt Statement, ctx ExecutionContext) error

ExecuteStatement executes a statement containing one of the task management queries.

func (*TaskManager) KillQuery

func (t *TaskManager) KillQuery(qid uint64) error

KillQuery stops and removes a query from the TaskManager. This method can be used to forcefully terminate a running query.

func (*TaskManager) Queries

func (t *TaskManager) Queries() []QueryInfo

Queries returns a list of all running queries with information about them.

type TimeLiteral

type TimeLiteral struct {
	Val time.Time
}

TimeLiteral represents a point-in-time literal.

func (*TimeLiteral) String

func (l *TimeLiteral) String() string

String returns a string representation of the literal.

type Token

type Token int

Token is a lexical token of the InfluxQL language.

const (
	// ILLEGAL Token, EOF, WS are Special InfluxQL tokens.
	ILLEGAL Token = iota
	EOF
	WS

	// IDENT and the following are InfluxQL literal tokens.
	IDENT       // main
	BOUNDPARAM  // $param
	NUMBER      // 12345.67
	INTEGER     // 12345
	DURATIONVAL // 13h
	STRING      // "abc"
	BADSTRING   // "abc
	BADESCAPE   // \q
	TRUE        // true
	FALSE       // false
	REGEX       // Regular expressions
	BADREGEX    // `.*

	// ADD and the following are InfluxQL Operators
	ADD // +
	SUB // -
	MUL // *
	DIV // /

	AND // AND
	OR  // OR

	EQ       // =
	NEQ      // !=
	EQREGEX  // =~
	NEQREGEX // !~
	LT       // <
	LTE      // <=
	GT       // >
	GTE      // >=

	LPAREN      // (
	RPAREN      // )
	COMMA       // ,
	COLON       // :
	DOUBLECOLON // ::
	SEMICOLON   // ;
	DOT         // .

	// ALL and the following are InfluxQL Keywords
	ALL
	ALTER
	ANY
	AS
	ASC
	BEGIN
	BY
	CREATE
	CONTINUOUS
	DATABASE
	DATABASES
	DEFAULT
	DELETE
	DESC
	DESTINATIONS
	DIAGNOSTICS
	DISTINCT
	DROP
	DURATION
	END
	EVERY
	EXISTS
	EXPLAIN
	FIELD
	FOR
	FROM
	GRANT
	GRANTS
	GROUP
	GROUPS
	IF
	IN
	INF
	INSERT
	INTO
	KEY
	KEYS
	KILL
	LIMIT
	MEASUREMENT
	MEASUREMENTS
	NAME
	NOT
	OFFSET
	ON
	ORDER
	PASSWORD
	POLICY
	POLICIES
	PRIVILEGES
	QUERIES
	QUERY
	READ
	REPLICATION
	RESAMPLE
	RETENTION
	REVOKE
	SELECT
	SERIES
	SET
	SHOW
	SHARD
	SHARDS
	SLIMIT
	SOFFSET
	STATS
	SUBSCRIPTION
	SUBSCRIPTIONS
	TAG
	TO
	USER
	USERS
	VALUES
	WHERE
	WITH
	WRITE
)

These are a comprehensive list of InfluxQL language tokens.

func Lookup

func Lookup(ident string) Token

Lookup returns the token associated with a given string.

func (Token) Precedence

func (tok Token) Precedence() int

Precedence returns the operator precedence of the binary operator token.

func (Token) String

func (tok Token) String() string

String returns the string representation of the token.

type Valuer

type Valuer interface {
	Value(key string) (interface{}, bool)
}

Valuer is the interface that wraps the Value() method.

Value returns the value and existence flag for a given key.

type VarRef

type VarRef struct {
	Val  string
	Type DataType
}

VarRef represents a reference to a variable.

func ExprNames

func ExprNames(expr Expr) []VarRef

ExprNames returns a list of non-"time" field names from an expression.

func (*VarRef) String

func (r *VarRef) String() string

String returns a string representation of the variable reference.

type VarRefs

type VarRefs []VarRef

VarRefs represents a slice of VarRef types.

func (VarRefs) Len

func (a VarRefs) Len() int

func (VarRefs) Less

func (a VarRefs) Less(i, j int) bool

func (VarRefs) Strings

func (a VarRefs) Strings() []string

Strings returns a slice of the variable names.

func (VarRefs) Swap

func (a VarRefs) Swap(i, j int)

type Visitor

type Visitor interface {
	Visit(Node) Visitor
}

Visitor can be called by Walk to traverse an AST hierarchy. The Visit() function is called once per node.

type Wildcard

type Wildcard struct {
	Type Token
}

Wildcard represents a wild card expression.

func (*Wildcard) String

func (e *Wildcard) String() string

String returns a string representation of the wildcard.

Directories

Path Synopsis
Package influxql is a generated protocol buffer package.
Package influxql is a generated protocol buffer package.
This is an implementation of the Nelder-Mead optimization method Based on work by Michael F. Hutt http://www.mikehutt.com/neldermead.html
This is an implementation of the Nelder-Mead optimization method Based on work by Michael F. Hutt http://www.mikehutt.com/neldermead.html

Jump to

Keyboard shortcuts

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