pub struct QueryBuilder { /* private fields */ }Expand description
Implementations§
Source§impl QueryBuilder
impl QueryBuilder
Sourcepub fn measurement(self, name: impl Into<String>) -> Self
pub fn measurement(self, name: impl Into<String>) -> Self
Set the measurement to query.
Sourcepub fn tag(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn tag(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add a tag equality filter.
Add multiple tag equality filters.
Sourcepub fn field(self, name: impl Into<String>) -> Self
pub fn field(self, name: impl Into<String>) -> Self
Add a field to the projection (select only these columns).
Sourcepub fn last(self, duration: Duration) -> Self
pub fn last(self, duration: Duration) -> Self
Set the time range to the last duration from now.
Uses the current system time as the end point.
Sourcepub fn estimated_cardinality(self, cardinality: usize) -> Self
pub fn estimated_cardinality(self, cardinality: usize) -> Self
Set the estimated group-key cardinality.
When set, the query engine selects between hash-based and sort-based aggregation strategies. Low cardinality (≤ 1024) uses sort-based grouping for better cache locality and sorted output.
Sourcepub fn downsample(self, bucket: TimeBucket, function: AggFn) -> Self
pub fn downsample(self, bucket: TimeBucket, function: AggFn) -> Self
Bucket results by bucket, and aggregate each bucket with function.
The bucket carries its own calendar, so all three of these mean what they say:
// A fixed five minutes, aligned to the Unix epoch.
.downsample(TimeBucket::fixed(Duration::from_secs(300)), AggFn::Avg)
// A calendar day in Berlin — 23 hours on the spring transition.
.downsample(TimeBucket::parse("1d", Some("Europe/Berlin"))?, AggFn::Max)
// A calendar month, which is not a span of anything.
.downsample(TimeBucket::parse("1mo", None)?, AggFn::Sum)Sourcepub fn offset(self, n: usize) -> Self
pub fn offset(self, n: usize) -> Self
Skip the first n rows before returning results.
Must be used together with limit().
Sourcepub fn window_partition_by(self, columns: &[&str]) -> Self
pub fn window_partition_by(self, columns: &[&str]) -> Self
Set the partition-by columns for window functions.
Sourcepub fn window_value_column(self, column: impl Into<String>) -> Self
pub fn window_value_column(self, column: impl Into<String>) -> Self
Set the value column for window functions.
If not set, the first numeric field column is used by default.
Sourcepub fn namespace(self, ns: impl Into<String>) -> Self
pub fn namespace(self, ns: impl Into<String>) -> Self
Set the namespace scope for tenant isolation.
This embeds the NamespaceId structurally in the query plan AND
injects the __namespace__ tag filter, ensuring data isolation
even if the HTTP layer is bypassed.
Sourcepub fn namespace_scope(self, ns: Option<&str>) -> Self
pub fn namespace_scope(self, ns: Option<&str>) -> Self
Apply an optional namespace scope.
None means “no tenancy” — the single-tenant server and the embedded
API, where points carry no namespace tag and a filter on one would
match nothing. Call sites use this rather than branching, so that
scoping a read is one uniform call instead of an if each of them can
forget.
Trait Implementations§
Source§impl Clone for QueryBuilder
impl Clone for QueryBuilder
Source§fn clone(&self) -> QueryBuilder
fn clone(&self) -> QueryBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more