Return a copy of this RangeQuery configured to perform an edit range query with the edit range that selects all edits in the entire time series.
This operator can only be applied to edit range queries. The default query returned by rangeQuery() is a value range query. The RangeQuery.forEdits operator can be used to create an edit range query form a value range query.
Operator type: edit range
a copy of this range query configured to perform an edit range query with a new edit range that selects all edits in the entire time series
Return a copy of this RangeQuery with a different query value type.
A query can only be evaluated successfully against time series topics with a compatible event data type. If a query method is called for a time series topic with an incompatible event data type, the query will complete exceptionally.
If the event data type of the time series topic is known,
compatibility of a particular valueClass
can be checked using
canReadAs. The
default range query has a query value
type of Bytes, which is compatible with all time series value
data types.
Operator type: query value type
the value class or data type to read event values as
a copy of this range query with a new query value type
Return a copy of this RangeQuery configured to perform a value range query with the edit range set to the entire time series.
This operator can only be applied to value range queries. The default query returned by rangeQuery() is a value range query. The RangeQuery.forValues operator can be used to create a value range query from an edit range query.
Operator type: edit range
a copy of this range query configured to perform a view range query with a new edit range that selects the entire time series
Return a copy of this RangeQuery configured to perform an edit range query within the view range set to the entire time series.
Operator type: value range
a copy of this range query configured to perform an edit range query with a new view range that selects the entire time series
Return a copy of this RangeQuery configured to perform a value range query within the view range set to the entire time series.
Operator type: value range
a copy of this range query configured to perform a view range query within a new view range that selects the time time series.
Return a copy of this RangeQuery with the anchor of the current range configured to be either an absolute sequence number, or a Date instance.
Operator type: anchor
absolute sequence number or Date specifying the anchor of the returned range
a copy of this range query with a new anchor
Return a copy of this RangeQuery with the anchor of the current range configured to be a relative offset before the end of the time series.
Operator type: anchor
specifies the anchor as a number of events before the end of the time series. For value range queries, count is the number of original events. For edit range queries, count is the number of events of any type.
a copy of this range query with a new anchor
Return a copy of this RangeQuery with the anchor of the current range configured to be a relative time from the timestamp of the last event in the time series.
Operator type: anchor
specifies anchor as a number of milliseconds relative to the timestamp of the latest event in the time series
a copy of this range query with a new anchor
Return a copy of this RangeQuery with the anchor of the current range configured to be the start of the time series.
There is a difference between from(0)
if the range also ends before the first event of the time series. For
example, fromStart().toStart()
is always empty, but
from(0).toStart()
includes the event with sequence number
0
.
Operator type: anchor
a copy of this range query with a new anchor
Return a copy of this RangeQuery configured to perform an edit range query with the edit range that selects latest edits in the entire time series.
This operator can only be applied to edit range queries. The default query returned by rangeQuery() is a value range query. The forEdits() operator can be used to create an edit range query from a value range query.
Operator type: edit range
a copy of this range query configured to perform an edit range query with a new edit range that selects the latest edits in the entire time series
Return a copy of this RangeQuery that returns at most count events.
If the query would otherwise select more than count events, only the latest count values (those with the highest sequence numbers) are returned.
This is most useful when a temporal span has been configured with RangeQuery.nextMillis or RangeQuery.previousMillis, where the potential number of returned events is unknown.
isComplete() can be used to determine whether a query has returned an incomplete result.
Operator type: limit
the maximum number of events to return
a copy of this range query with a new limit
Return a copy of this RangeQuery with the span of the current range configured to select a range of events following the anchor.
Operator type: span
specifies the end of the range of events to select following the anchor. For value range queries, count is the number of original events. For edit range queries, count is the number of events of any type.
a copy of this range query with a new span
Return a copy of this RangeQuery with the span of the current range configured to select a temporal range of events following the anchor.
Operator type: span
the time span in milliseconds of events following the anchor to select
a copy of this range query with a new span
Return a copy of this RangeQuery with the span of the current range configured to select a range of events preceding the anchor.
Operator type: span
specifies the end of the range of events to select preceding the anchor. For value range queries, count is the number of original events. For edit range queries, count is the number of events of any type.
a copy of this range query with a new span
Return a copy of this RangeQuery with the span of the current range configured to select a temporal range of events preceding the anchor.
Operator type: span
the time span in milliseconds of events preceding the anchor to select
a copy of this range query with a new span
Evaluate this query for a time series topic.
The session must have the READ_TOPIC
path permission for topicPath
to evaluate a query. The QUERY_OBSOLETE_TIME_SERIES_EVENTS
topic
permission is also required if this is an edit range query, or a value range query with an
edit range.
the path of the time series topic to query
a result that completes when a response is received from the server.
If the query returned results, the result will complete successfully and provide an QueryResult.
Otherwise, the result will complete exceptionally with an ErrorReason.
Return a copy of this RangeQuery with the span of the current range configured to end at an absolute sequence number or Date instance.
Operator type: span
absolute sequence number or Date instance specifying the end of the returned range
a copy of this range query with a new span
Return a copy of this RangeQuery with the span of the current range configured to end at the start of the time series.
There is a difference between toStart()
and to(0)
if
the range also starts before the first event of the time series. For
example, fromStart().toStart()
is always empty, but
fromStart().to(0)
includes the event with sequence number
0
.
Operator type: span
a copy of this range query with a new span
Return a copy of this RangeQuery with the span of the current range configured to end a number of events before the end of the time series.
Operator type: span
specifies the end of the range of events to select as a number of events before the end of the time series. For value range queries, count is the number of original events. For edit range queries, count is the number of events of any type.
a copy of this range query with a new span
Return a copy of this RangeQuery with the span of the current range configured to end at a relative time from the timestamp of the last event in the time series.
Operator type: span
specifies the end of the range of events to select as a number of milliseconds relative to the timestamp of the latest event in the time series
a copy of this range query with a new span
Builder for queries that select a range of events from a time series.
See Session.timeseries for an overview of the various types of range query:
rangeQuery returns a default RangeQuery. Further queries with different parameters can be configured using the methods of this interface. RangeQuery instances are immutable. Each method returns a copy of this query with a modified setting. Method calls can be chained together in a fluent manner to create a query. For example:
var defaultQuery = session.timeseries.rangeQuery(); // A value range query that selects up to 100 original events from the // start of a time series. first100 = defaultQuery.forValues().fromStart().next(100);
Creating value range queries
A value range query returns a merged view of part of a time series. This is the most common time series query and appropriate for most applications. A value range query begins with the forValues operator, followed by the view range. The view range determines the range of original events the time series that are of interest. See Range expressions below for the various ways to specify
RANGE
.The events returned by the query are constrained by an optional edit range, introduced by the editRange operator. An event will only be included in the result if it is in the edit range. Let's consider some examples to see how the view range and the edit range interact.
rangeQuery().forValues();
rangeQuery().forValues().from(100).to(150);
rangeQuery().forValues().from(100).to(150).editRange().from(400);
The result of this query will not include any original events because there is no overlap between the view range and the edit range.
Value range queries can be further refined using the limit() and as() operators.
Creating edit range queries
An edit range query returns an unmerged view of a time series than can include both original events and the edit events that replace them. Edit range queries are rarely needed – value range queries satisfy most use cases.
An edit range query begins with the forEdits operator, followed by the view range. The view range determines the range of original events the time series that are of interest. The result will only contain original events that are in the view range, and edit events for original events in the view range. See Range expressions below for the various ways to specify
RANGE
.The events returned by the query are constrained by an optional edit range, introduced by the latestEdits or allEdits operators. An event will only be included in the result if it is in the edit range. Let's consider some example edit range queries.
rangeQuery().forEdits();
rangeQuery().forEdits().from(100).to(150);
rangeQuery().forEdits().from(100).to(150).latestEdits();
rangeQuery().forEdits().from(100).to(150).allEdits().from(400);
The result of this query will not include any original events because there is no overlap between the view range and the edit range.
Edit range queries can be further refined using the limit() and as() operators.
Range expressions
Range expressions are used to specify the view and edit ranges in value range and edit range queries. Each range expression has an anchor that determines where to start, and a span that determines where the range ends. Both anchor and span are inclusive – if an anchor or span falls on an event, the event is included in the result.
Both anchor and the span are optional. If the anchor is unspecified, the range begins at the start of the time series. If the span is unspecified, the range continues until the end of the time series.
Anchors
There are five ways to specify an anchor.
count
is the number of original events. For edit range queries,count
is the number of events of any type.fromLastMillis
An anchor point can be before the start or after the end of the time series.
Spans
There are nine ways to specify a span.
sequence
argument may be before or after the anchor.date
argument may be before or after the anchor.count
is the number of original events. For edit range queries,count
is the number of events of any type.nextMillis
count
is the number of original events. For edit range queries,count
is the number of events of any type.previousMillis
count
is the number of original events. For edit range queries,count
is the number of events of any type.untilLastMillis
A span can specify an end point that is before the start or after the end of the time series.
If the span specifies an end point after the anchor, the range includes the first event at or following the anchor and ends at the last event at or preceding the end point. If the span specifies an end point before the anchor, the range includes the first event at or preceding the anchor and ends at the last event at or after the end point.
Using the builder methods
Although the natural order of operators in a query is as shown in the syntax diagrams above, RangeQuery builder methods – those that return another RangeQuery – can be applied in any order with the following exceptions:
forEdits()
without an interveningforValues();
forValues()
without an interveningforEdits()
.Each method overrides some configuration of the RangeQuery to which it is applied, as summarized in the following table.
forValues()
forEdits()
editRange()
Throws
IllegalStateException
if this is not a value range query.latestEdits()
allEdits()
Throws
Error
if this is not an edit range query.from()
fromStart()
fromLast()
to()
toStart()
next()
previous()
untilLast()
limit()
as()
Session.timeseries.rangeQuery