Diffusion .NET Client Library  6.1.5
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue > Interface Template Reference

The builder for queries that select a range of events from a time series. More...

Inheritance diagram for PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >:
PushTechnology.ClientInterface.Client.Features.TimeSeries.IQuery< TValue >

Public Member Functions

IRangeQuery< TValue > ForValues ()
 Returns a copy of this IRangeQuery{TValue} configured to perform a value range query with the view range set to the entire time series. More...
 
IRangeQuery< TValue > ForEdits ()
 Returns a copy of this IRangeQuery{TValue} configured to perform an edit range query with the view range set to the entire time series. More...
 
IRangeQuery< TValue > EditRange ()
 Returns a copy of this IRangeQuery{TValue} configured to perform a value range query with the edit range set to the entire time series. More...
 
IRangeQuery< TValue > AllEdits ()
 Returns a copy of this IRangeQuery{TValue} configured to perform an edit range query with the edit range that selects all edits in the entire time series. More...
 
IRangeQuery< TValue > LatestEdits ()
 Returns a copy of this IRangeQuery{TValue} configured to perform an edit range query with the edit range that selects latest edits in the entire time series. More...
 
IRangeQuery< TValue > From (long sequence)
 Returns a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be an absolute sequence number. More...
 
IRangeQuery< TValue > From (DateTimeOffset dateTimeOffset)
 Returns a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be an absolute time. More...
 
IRangeQuery< TValue > FromStart ()
 Return a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be the start of the time series. More...
 
IRangeQuery< TValue > FromLast (long count)
 Returns a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be a relative offset before the end of the time series. More...
 
IRangeQuery< TValue > FromLast (TimeSpan timeSpan)
 Returns a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be a relative time from the timestamp of the last event in the time series. More...
 
IRangeQuery< TValue > FromLastMilliseconds (long milliseconds)
 Returns a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be a relative time from the timestamp of the last event in the time series. More...
 
IRangeQuery< TValue > To (long sequence)
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to end at an absolute sequence number. More...
 
IRangeQuery< TValue > To (DateTimeOffset dateTimeOffset)
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to end at an absolute time. More...
 
IRangeQuery< TValue > ToStart ()
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to end at the start of the time series. More...
 
IRangeQuery< TValue > Next (long count)
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a range of events following the anchor. More...
 
IRangeQuery< TValue > Next (TimeSpan timeSpan)
 Return a copy of this IRangeQuery{TValue} with the span of the current range configured to select a temporal range of events following the anchor. More...
 
IRangeQuery< TValue > NextMilliseconds (long milliseconds)
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a temporal range of events following the anchor. More...
 
IRangeQuery< TValue > Previous (long count)
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a range of events preceding the anchor. More...
 
IRangeQuery< TValue > Previous (TimeSpan timeSpan)
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a temporal range of events preceding the anchor. More...
 
IRangeQuery< TValue > PreviousMilliseconds (long milliseconds)
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a temporal range of events preceding the anchor. More...
 
IRangeQuery< TValue > UntilLast (long count)
 Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to end a number of events before the end of the time series. More...
 
IRangeQuery< TValue > UntilLast (TimeSpan timeSpan)
 Returns a copy of this IRangeQuery{TValue} 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. More...
 
IRangeQuery< TValue > UntilLastMilliseconds (long milliseconds)
 Returns a copy of this IRangeQuery{TValue} 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. More...
 
IRangeQuery< TValue > Limit (long count)
 Returns a copy of this IRangeQuery{TValue} that returns at most count events. More...
 
IRangeQuery< TNewValue > As< TNewValue > ()
 Returns a copy of this IRangeQuery{TValue} with a different query value type. More...
 
- Public Member Functions inherited from PushTechnology.ClientInterface.Client.Features.TimeSeries.IQuery< TValue >
Task< IQueryResult< TValue > > SelectFromAsync (string topicPath)
 Evaluates this query for a time series topic. More...
 
Task< IQueryResult< TValue > > SelectFromAsync (string topicPath, CancellationToken cancellationToken)
 Evaluates this query for a time series topic. More...
 

Detailed Description

The builder for queries that select a range of events from a time series.

See ITimeSeries for an overview of the various types of range query:

  • value range queries
  • latest edits edit range queries
  • all edits edit range queries

ITimeSeries.RangeQuery returns a default IRangeQuery{TValue}. Further queries with different parameters can be configured using the methods of this interface. IRangeQuery{TValue} 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.

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 a 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.

Query Meaning
RangeQuery.ForValues(); For each original event in the time series, either return the latest edit event or if it has no edit events, return the original event.
RangeQuery.ForValues().From( 100 ).To( 150 ); For each original event with a sequence number between 100 and 150 (inclusive), either return the latest edit event or if it has no edit events, return the original event.
RangeQuery.ForValues().From( 100 ).To( 150 ).EditRange().From( 400 );

For each original event with a sequence number between 100 and 150 (inclusive), return the latest edit event with a sequence number greater than or equal to 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(long) and As{TNewValue} 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 a 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.

Query Meaning
RangeQuery.ForEdits(); Return all events in a time series.
RangeQuery.ForEdits().From( 100 ).To( 150 ); Return the original events with a sequence number between 100 and 150 (inclusive) and all edit events in the time series that refer to the original events.
RangeQuery.ForEdits().From( 100 ).To( 150 ).LatestEdits(); Return the original events with a sequence number between 100 and 150 (inclusive) and the latest edit events in the time series that refer to the original events.
RangeQuery.ForEdits().From( 100 ).To( 150 ).AllEdits().From( 400 );

For each original event with a sequence number between 100 and 150, (inclusive) return all edit events with a sequence number greater than or equal to 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(long) and As{TNewValue} 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.

Anchor Meaning
From(long) Sets the anchor at an absolute sequence number.
FromStart Sets the anchor at the start of the time series.
From(DateTimeOffset) Sets the anchor at an absolute time.
FromLast(long) Sets the anchor at a relative offset 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.
FromLast(TimeSpan) Sets the anchor at a relative time before the timestamp of the last event of the time series.

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.

Span Meaning
To(long) The range ends at an absolute sequence number. The sequence argument may be before or after the anchor.
ToStart The range ends at the start of the time series.
To(DateTimeOffset) The range ends at an absolute time. The timeSpan argument may be before or after the anchor.
Next(long) The range ends at an event that is a relative number of events after 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.
Next(TimeSpan) The range ends at an event that is a relative time after the anchor.
Previous(long) The range ends at an event that is a relative number of events before 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.
Previous(TimeSpan) The range ends at an event that is a relative time before the anchor.
UntilLast(long) The range ends at an event that is a relative 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.
UntilLast(TimeSpan) The range ends at an event that is a relative time before the timestamp of the last event of the time series.

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

RangeQuery builder methods - those that return another RangeQuery - can be applied in any order with the following exceptions:

Each method overrides some configuration of the RangeQuery to which it is applied, as summarized in the following table.

Builder method Operator type Overridden configuration
ForValues Value range Overrides the existing query type to create a new value range query. Overrides the existing view range with a new view range that selects the entire time series. The existing edit range is copied unchanged.
ForEdits Value range Overrides the existing query type to create a new edit range query that includes all edits. Overrides the existing view range with a new view range that selects the entire time series. The existing edit range is copied unchanged.
EditRange Edit range Overrides the existing edit range with a new edit range that selects the entire time series. The existing view range is copied unchanged.
LatestEdits, AllEdits Edit range Overrides the existing edit range with a new edit range that selects the entire time series. The existing view range is copied unchanged.
From(long), FromStart, FromLast(long) Anchor Overrides the anchor of the current range.
To(long), ToStart, Next(long), Previous(long), UntilLast(long) Span Overrides the span of the current range.
Limit(long) Limit Overrides the limit.
As{TNewValue} Query value type Overrides the query value type.

Added in version 6.1.

Template Parameters
TValueThe value data type.
See Also
ITimeSeries, ITimeSeries.RangeQuery

Member Function Documentation

IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.AllEdits ( )

Returns a copy of this IRangeQuery{TValue} 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 ITimeSeries.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

Returns
The 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.
Exceptions
InvalidOperationExceptionThe current range query is not an edit range query.
IRangeQuery<TNewValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.As< TNewValue > ( )

Returns a copy of this IRangeQuery{TValue} 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 value type can be checked using IDataType.CanReadAs(Type). The default ITimeSeries.RangeQuery has a query value type of IBytes, which is compatible with all time series value data types.

Operator type: query value type

Template Parameters
TNewValueThe new value type.
Returns
The copy of this range query with a new query value type.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.EditRange ( )

Returns a copy of this IRangeQuery{TValue} 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 ITimeSeries.RangeQuery is a value range query. The ForValues operator can be used to create a value range query from an edit range query.

Operator type: edit range

Returns
The copy of this range query configured to perform a view range query with a new edit range that selects the entire time series.
Exceptions
InvalidOperationExceptionThe current range query is not a value range query.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.ForEdits ( )

Returns a copy of this IRangeQuery{TValue} configured to perform an edit range query with the view range set to the entire time series.

Operator type: value range

Returns
The copy of this range query configured to perform an edit range query with a new view range that selects the entire time series.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.ForValues ( )

Returns a copy of this IRangeQuery{TValue} configured to perform a value range query with the view range set to the entire time series.

Operator type: value range

Returns
The copy of this range query configured to perform a view range query with a new view range that selects the entire time series.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.From ( long  sequence)

Returns a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be an absolute sequence number.

Operator type: anchor

Parameters
sequenceThe absolute sequence number specifying the anchor of the returned range.
Returns
The copy of this range query with a new anchor.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.From ( DateTimeOffset  dateTimeOffset)

Returns a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be an absolute time.

Operator type: anchor

Parameters
dateTimeOffsetAbsolute time specifying the anchor of the range.
Returns
The copy of this range query with a new anchor.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.FromLast ( long  count)

Returns a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be a relative offset 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.

Operator type: anchor

Parameters
countThe anchor as a number of events before the end of the time series.
Returns
The copy of this range query with a new anchor.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.FromLast ( TimeSpan  timeSpan)

Returns a copy of this IRangeQuery{TValue} 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

Parameters
timeSpanThe time-span relative to the timestamp of the latest event in the time series.
Returns
The copy of this range query with a new anchor.
See Also
FromLastMilliseconds(long)
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.FromLastMilliseconds ( long  milliseconds)

Returns a copy of this IRangeQuery{TValue} 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

Parameters
millisecondsThe milliseconds relative to the timestamp of the latest event in the time series.
Returns
The copy of this range query with a new anchor.
See Also
FromLast(TimeSpan)
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.FromStart ( )

Return a copy of this IRangeQuery{TValue} with the anchor of the current range configured to be the start of the time series.

There is a difference between FromStart and 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

Returns
The copy of this range query with a new anchor.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.LatestEdits ( )

Returns a copy of this IRangeQuery{TValue} 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 ITimeSeries.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

Returns
The 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.
Exceptions
InvalidOperationExceptionThe current range query is not an edit range query.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.Limit ( long  count)

Returns a copy of this IRangeQuery{TValue} 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 Next(TimeSpan) or Previous(TimeSpan), where the potential number of returned events is unknown.

IQueryResult{TValue}.IsComplete can be used to determine whether a query has returned an incomplete result.

Operator type: limit

Parameters
countThe maximum number of events to return.
Returns
The copy of this range query with a new limit.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.Next ( long  count)

Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a range of events 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.

Operator type: span

Parameters
countThe end of the range of events to select following the anchor.
Returns
The copy of this range query with a new span.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.Next ( TimeSpan  timeSpan)

Return a copy of this IRangeQuery{TValue} with the span of the current range configured to select a temporal range of events following the anchor.

Operator type: span

Parameters
timeSpanThe time span of events following the anchor to select.
Returns
The copy of this range query with a new span.
See Also
NextMilliseconds(long)
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.NextMilliseconds ( long  milliseconds)

Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a temporal range of events following the anchor.

Operator type: span

Parameters
millisecondsThe time span in milliseconds of events following the anchor to select.
Returns
See Also
Next(TimeSpan)
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.Previous ( long  count)

Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a range of events 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.

Operator type: span

Parameters
countThe end of the range of events to select preceding the anchor.
Returns
The copy of this range query with a new span.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.Previous ( TimeSpan  timeSpan)

Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a temporal range of events preceding the anchor.

Operator type: span

Parameters
timeSpanThe time span of events preceding the anchor to select.
Returns
The copy of this range query with a new span.
See Also
PreviousMilliseconds(long)
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.PreviousMilliseconds ( long  milliseconds)

Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to select a temporal range of events preceding the anchor.

Operator type: span

Parameters
millisecondsThe time span in milliseconds of events preceding the anchor to select.
Returns
The copy of this range query with a new span.
See Also
Previous(TimeSpan)
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.To ( long  sequence)

Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to end at an absolute sequence number.

Operator type: span

Parameters
sequenceThe absolute sequence number specifying the end of the returned range.
Returns
The copy of this range query with a new span.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.To ( DateTimeOffset  dateTimeOffset)

Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to end at an absolute time.

Operator type: span

Parameters
dateTimeOffsetThe absolute time specifying the end of the range.
Returns
The copy of this range query with a new span.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.ToStart ( )

Returns a copy of this IRangeQuery{TValue} 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

Returns
The copy of this range query with a new span.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.UntilLast ( long  count)

Returns a copy of this IRangeQuery{TValue} with the span of the current range configured to end 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.

Operator type: span

Parameters
countThe end of the range of events to select as a number of events before the end of the time series.
Returns
The copy of this range query with a new span.
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.UntilLast ( TimeSpan  timeSpan)

Returns a copy of this IRangeQuery{TValue} 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

Parameters
timeSpanThe end of the range of events to select relative to the timestamp of the latest event in the time series.
Returns
The copy of this range query with a new span.
See Also
UntilLastMilliseconds(long)
IRangeQuery<TValue> PushTechnology.ClientInterface.Client.Features.TimeSeries.IRangeQuery< TValue >.UntilLastMilliseconds ( long  milliseconds)

Returns a copy of this IRangeQuery{TValue} 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

Parameters
millisecondsThe 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.
Returns
The copy of this range query with a new span.
See Also
UntilLast(TimeSpan)

The documentation for this interface was generated from the following file: