vkdb
A time series database engine in C++.
Loading...
Searching...
No Matches
vkdb::FriendlyQueryBuilder< TValue > Class Template Reference

Friendly query builder for querying a Table. More...

#include <friendly_builder.h>

Public Types

using size_type = typename QueryBuilder<TValue>::size_type
 
using value_type = DataPoint<TValue>
 
using result_type = std::vector<value_type>
 

Public Member Functions

 FriendlyQueryBuilder ()=delete
 Deleted default constructor.
 
 FriendlyQueryBuilder (LSMTree< TValue > &lsm_tree, const TagColumns &tag_columns) noexcept
 Construct a new FriendlyQueryBuilder object.
 
 FriendlyQueryBuilder (QueryBuilder< TValue > &&query_builder)
 Construct a new FriendlyQueryBuilder object.
 
 FriendlyQueryBuilder (FriendlyQueryBuilder &&) noexcept=default
 Move-construct a FriendlyQueryBuilder object.
 
FriendlyQueryBuilderoperator= (FriendlyQueryBuilder &&) noexcept=default
 Move-assign a FriendlyQueryBuilder object.
 
 FriendlyQueryBuilder (const FriendlyQueryBuilder &) noexcept=default
 Copy-construct a FriendlyQueryBuilder object.
 
FriendlyQueryBuilderoperator= (const FriendlyQueryBuilder &) noexcept=default
 Copy-assign a FriendlyQueryBuilder object.
 
 ~FriendlyQueryBuilder () noexcept=default
 Destroy the FriendlyQueryBuilder object.
 
FriendlyQueryBuilderget (Timestamp timestamp, Metric metric, const TagTable &tag_table)
 Configure builder for get query.
 
FriendlyQueryBuilderwhereMetricIs (const Metric &metric)
 Configure builder for where metric is clause.
 
template<typename... Metrics>
requires (AllConvertibleToNoCVRefQuals<Metric, Metrics> && ...)
FriendlyQueryBuilderwhereMetricIsAnyOf (const Metrics &... metrics)
 Configure builder for where metric is any of clause.
 
FriendlyQueryBuilderwhereTimestampIs (const Timestamp &timestamp)
 Configure builder for where timestamp is clause.
 
FriendlyQueryBuilderwhereTimestampBetween (const Timestamp &start, const Timestamp &end)
 Configure builder for where timestamp is between clause.
 
template<typename... Timestamps>
requires (AllConvertibleToNoCVRefQuals<Timestamp, Timestamps> && ...)
FriendlyQueryBuilderwhereTimestampIsAnyOf (const Timestamps &... timestamps)
 Configure builder for where timestamp is any of clause.
 
FriendlyQueryBuilderwhereTagsContain (const Tag &tag)
 Configure builder for where tags contain clause.
 
template<typename... Tags>
requires (AllConvertibleToNoCVRefQuals<Tag, Tags> && ...)
FriendlyQueryBuilderwhereTagsContainAnyOf (const Tags &... tags)
 Configure builder for where tags contain any of clause.
 
template<typename... Tags>
requires (AllConvertibleToNoCVRefQuals<Tag, Tags> && ...)
FriendlyQueryBuilderwhereTagsContainAllOf (const Tags &... tags)
 Configure builder for where tags contain all of clause.
 
FriendlyQueryBuilderput (Timestamp timestamp, Metric metric, const TagTable &tag_table, TValue value)
 Configure builder for put query.
 
FriendlyQueryBuilderremove (Timestamp timestamp, Metric metric, const TagTable &tag_table)
 Configure builder for remove query.
 
size_type count ()
 Count the number of entries in the range.
 
TValue sum ()
 Sum the values in the range.
 
double avg ()
 Calculate the average of the values in the range.
 
TValue min ()
 Calculate the minimum value in the range.
 
TValue max ()
 Calculate the maximum value in the range.
 
result_type execute ()
 Execute the query.
 

Detailed Description

template<ArithmeticNoCVRefQuals TValue>
class vkdb::FriendlyQueryBuilder< TValue >

Friendly query builder for querying a Table.

Template Parameters
TValueType of the value of the TimeSeriesKey.

Definition at line 13 of file friendly_builder.h.

Member Typedef Documentation

◆ result_type

template<ArithmeticNoCVRefQuals TValue>
using vkdb::FriendlyQueryBuilder< TValue >::result_type = std::vector<value_type>

Definition at line 17 of file friendly_builder.h.

◆ size_type

template<ArithmeticNoCVRefQuals TValue>
using vkdb::FriendlyQueryBuilder< TValue >::size_type = typename QueryBuilder<TValue>::size_type

Definition at line 15 of file friendly_builder.h.

◆ value_type

template<ArithmeticNoCVRefQuals TValue>
using vkdb::FriendlyQueryBuilder< TValue >::value_type = DataPoint<TValue>

Definition at line 16 of file friendly_builder.h.

Constructor & Destructor Documentation

◆ FriendlyQueryBuilder() [1/2]

template<ArithmeticNoCVRefQuals TValue>
vkdb::FriendlyQueryBuilder< TValue >::FriendlyQueryBuilder ( LSMTree< TValue > & lsm_tree,
const TagColumns & tag_columns )
inlineexplicitnoexcept

Construct a new FriendlyQueryBuilder object.

Initialises the query builder with a QueryBuilder.

Parameters
lsm_treeReference to the LSMTree to query.
tag_columnsReference to the tag columns of the Table.

Definition at line 32 of file friendly_builder.h.

◆ FriendlyQueryBuilder() [2/2]

template<ArithmeticNoCVRefQuals TValue>
vkdb::FriendlyQueryBuilder< TValue >::FriendlyQueryBuilder ( QueryBuilder< TValue > && query_builder)
inlineexplicit

Construct a new FriendlyQueryBuilder object.

Parameters
query_builderQueryBuilder to use.

Definition at line 43 of file friendly_builder.h.

Member Function Documentation

◆ avg()

template<ArithmeticNoCVRefQuals TValue>
double vkdb::FriendlyQueryBuilder< TValue >::avg ( )
inlinenodiscard

Calculate the average of the values in the range.

Sets up the QueryBuilder for aggregation and returns the average of the values in the range.

Returns
double Average of the values in the range.
Exceptions
std::runtime_errorIf the average query fails.

Definition at line 329 of file friendly_builder.h.

◆ count()

template<ArithmeticNoCVRefQuals TValue>
size_type vkdb::FriendlyQueryBuilder< TValue >::count ( )
inlinenodiscard

Count the number of entries in the range.

Sets up the QueryBuilder for aggregation and returns the number of entries in the range.

Returns
size_type Number of entries in the range.
Exceptions
std::runtime_errorIf the count query fails.

Definition at line 303 of file friendly_builder.h.

◆ execute()

template<ArithmeticNoCVRefQuals TValue>
result_type vkdb::FriendlyQueryBuilder< TValue >::execute ( )
inline

Execute the query.

Executes the query and returns the result.

Returns
result_type Result of the query.
Exceptions
std::runtime_errorIf executing the query fails.

Definition at line 367 of file friendly_builder.h.

◆ get()

template<ArithmeticNoCVRefQuals TValue>
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::get ( Timestamp timestamp,
Metric metric,
const TagTable & tag_table )
inlinenodiscard

Configure builder for get query.

Adds a point query to the query builder.

Parameters
timestampTimestamp of the TimeSeriesKey.
metricMetric of the TimeSeriesKey.
tag_tableTagTable of the TimeSeriesKey.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf the point query fails.

Definition at line 92 of file friendly_builder.h.

◆ max()

template<ArithmeticNoCVRefQuals TValue>
TValue vkdb::FriendlyQueryBuilder< TValue >::max ( )
inlinenodiscard

Calculate the maximum value in the range.

Sets up the QueryBuilder for aggregation and returns the maximum value in the range.

Returns
TValue Maximum value in the range.
Exceptions
std::runtime_errorIf the maximum query fails.

Definition at line 355 of file friendly_builder.h.

◆ min()

template<ArithmeticNoCVRefQuals TValue>
TValue vkdb::FriendlyQueryBuilder< TValue >::min ( )
inlinenodiscard

Calculate the minimum value in the range.

Sets up the QueryBuilder for aggregation and returns the minimum value in the range.

Returns
TValue Minimum value in the range.
Exceptions
std::runtime_errorIf the minimum query fails.

Definition at line 342 of file friendly_builder.h.

◆ put()

template<ArithmeticNoCVRefQuals TValue>
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::put ( Timestamp timestamp,
Metric metric,
const TagTable & tag_table,
TValue value )
inlinenodiscard

Configure builder for put query.

Adds a put query to the query builder.

Parameters
timestampTimestamp of the TimeSeriesKey.
metricMetric of the TimeSeriesKey.
tag_tableTagTable of the TimeSeriesKey.
valueValue of the TimeSeriesKey.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf the metric is invalid or the put query fails.

Definition at line 254 of file friendly_builder.h.

◆ remove()

template<ArithmeticNoCVRefQuals TValue>
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::remove ( Timestamp timestamp,
Metric metric,
const TagTable & tag_table )
inlinenodiscard

Configure builder for remove query.

Adds a remove query to the query builder.

Parameters
timestampTimestamp of the TimeSeriesKey.
metricMetric of the TimeSeriesKey.
tag_tableTagTable of the TimeSeriesKey.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf the remove query fails.

Definition at line 284 of file friendly_builder.h.

◆ sum()

template<ArithmeticNoCVRefQuals TValue>
TValue vkdb::FriendlyQueryBuilder< TValue >::sum ( )
inlinenodiscard

Sum the values in the range.

Sets up the QueryBuilder for aggregation and returns the sum of the values in the range.

Returns
TValue Sum of the values in the range.
Exceptions
std::runtime_errorIf the sum query fails.

Definition at line 316 of file friendly_builder.h.

◆ whereMetricIs()

template<ArithmeticNoCVRefQuals TValue>
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::whereMetricIs ( const Metric & metric)
inlinenodiscard

Configure builder for where metric is clause.

Parameters
metricMetric to filter by.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf adding the filter fails.

Definition at line 110 of file friendly_builder.h.

◆ whereMetricIsAnyOf()

template<ArithmeticNoCVRefQuals TValue>
template<typename... Metrics>
requires (AllConvertibleToNoCVRefQuals<Metric, Metrics> && ...)
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::whereMetricIsAnyOf ( const Metrics &... metrics)
inlinenodiscard

Configure builder for where metric is any of clause.

Template Parameters
MetricsVariadic template parameter for metrics to filter by.
Parameters
metricsMetrics to filter by.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf adding any of the filters fails.

Definition at line 127 of file friendly_builder.h.

◆ whereTagsContain()

template<ArithmeticNoCVRefQuals TValue>
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::whereTagsContain ( const Tag & tag)
inlinenodiscard

Configure builder for where tags contain clause.

Parameters
tagTag to filter by.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf adding the filter fails.

Definition at line 198 of file friendly_builder.h.

◆ whereTagsContainAllOf()

template<ArithmeticNoCVRefQuals TValue>
template<typename... Tags>
requires (AllConvertibleToNoCVRefQuals<Tag, Tags> && ...)
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::whereTagsContainAllOf ( const Tags &... tags)
inlinenodiscard

Configure builder for where tags contain all of clause.

Template Parameters
TagsVariadic template parameter for tags to filter by.
Parameters
tagsTags to filter by.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf adding all of the filters fails.

Definition at line 234 of file friendly_builder.h.

◆ whereTagsContainAnyOf()

template<ArithmeticNoCVRefQuals TValue>
template<typename... Tags>
requires (AllConvertibleToNoCVRefQuals<Tag, Tags> && ...)
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::whereTagsContainAnyOf ( const Tags &... tags)
inlinenodiscard

Configure builder for where tags contain any of clause.

Template Parameters
TagsVariadic template parameter for tags to filter by.
Parameters
tagsTags to filter by.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf adding any of the filters fails.

Definition at line 215 of file friendly_builder.h.

◆ whereTimestampBetween()

template<ArithmeticNoCVRefQuals TValue>
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::whereTimestampBetween ( const Timestamp & start,
const Timestamp & end )
inlinenodiscard

Configure builder for where timestamp is between clause.

Parameters
startStart timestamp.
endEnd timestamp.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf the range query fails.

Definition at line 160 of file friendly_builder.h.

◆ whereTimestampIs()

template<ArithmeticNoCVRefQuals TValue>
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::whereTimestampIs ( const Timestamp & timestamp)
inlinenodiscard

Configure builder for where timestamp is clause.

Parameters
timestampTimestamp to filter by.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf adding the filter fails.

Definition at line 143 of file friendly_builder.h.

◆ whereTimestampIsAnyOf()

template<ArithmeticNoCVRefQuals TValue>
template<typename... Timestamps>
requires (AllConvertibleToNoCVRefQuals<Timestamp, Timestamps> && ...)
FriendlyQueryBuilder & vkdb::FriendlyQueryBuilder< TValue >::whereTimestampIsAnyOf ( const Timestamps &... timestamps)
inlinenodiscard

Configure builder for where timestamp is any of clause.

Template Parameters
TimestampsVariadic template parameter for timestamps to filter by.
Parameters
timestampsTimestamps to filter by.
Returns
FriendlyQueryBuilder& Reference to this FriendlyQueryBuilder object.
Exceptions
std::runtime_errorIf adding the filter fails.

Definition at line 182 of file friendly_builder.h.


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