pub struct QueryTimeRange { /* private fields */ }Expand description
A time range for querying journal entries with automatic alignment.
This type encapsulates:
- The original requested time boundaries
- The computed bucket duration based on the range
- The aligned boundaries for consistent indexing and querying
All alignment logic is handled internally, ensuring consistency between histogram computation, file indexing, and log queries.
Implementations§
Source§impl QueryTimeRange
impl QueryTimeRange
Sourcepub fn new(start: u32, end: u32) -> Result<Self, EngineError>
pub fn new(start: u32, end: u32) -> Result<Self, EngineError>
Create a new query time range with automatic alignment.
The bucket duration is computed based on the range duration, and the boundaries are aligned to bucket boundaries:
aligned_startrounds down to the nearest bucket boundaryaligned_endrounds up to the nearest bucket boundary
§Arguments
start- Start time in seconds (inclusive)end- End time in seconds (exclusive)
§Returns
Ok(QueryTimeRange)if the range is validErr(EngineError::InvalidTimeRange)if start >= end
§Example
use journal_engine::QueryTimeRange;
let range = QueryTimeRange::new(100, 500).unwrap();
assert_eq!(range.requested_start(), 100);
assert_eq!(range.requested_end(), 500);
assert!(range.aligned_start() <= 100);
assert!(range.aligned_end() >= 500);Sourcepub fn requested_start(&self) -> u32
pub fn requested_start(&self) -> u32
Get the original requested start time (seconds).
Sourcepub fn requested_end(&self) -> u32
pub fn requested_end(&self) -> u32
Get the original requested end time (seconds).
Sourcepub fn bucket_duration(&self) -> u32
pub fn bucket_duration(&self) -> u32
Get the computed bucket duration (seconds).
This is used for file indexing to ensure all files are indexed with the same bucket size.
Sourcepub fn bucket_duration_seconds(&self) -> Seconds
pub fn bucket_duration_seconds(&self) -> Seconds
Get the bucket duration as Seconds.
Sourcepub fn aligned_start(&self) -> u32
pub fn aligned_start(&self) -> u32
Get the aligned start time (seconds).
This is the start time rounded down to the nearest bucket boundary.
Sourcepub fn aligned_end(&self) -> u32
pub fn aligned_end(&self) -> u32
Get the aligned end time (seconds).
This is the end time rounded up to the nearest bucket boundary.
Sourcepub fn aligned_duration(&self) -> u32
pub fn aligned_duration(&self) -> u32
Get the duration of the aligned range (seconds).
Sourcepub fn requested_duration(&self) -> u32
pub fn requested_duration(&self) -> u32
Get the duration of the requested range (seconds).
Sourcepub fn buckets(&self) -> impl Iterator<Item = (u32, u32)> + '_
pub fn buckets(&self) -> impl Iterator<Item = (u32, u32)> + '_
Returns an iterator over the bucket time ranges.
Each bucket is a (start, end) tuple in seconds, where:
startis inclusiveendis exclusiveend - start == bucket_duration
§Example
use journal_engine::QueryTimeRange;
let range = QueryTimeRange::new(0, 1000).unwrap();
for (start, end) in range.buckets() {
println!("Bucket: [{}, {})", start, end);
}Trait Implementations§
Source§impl Clone for QueryTimeRange
impl Clone for QueryTimeRange
Source§fn clone(&self) -> QueryTimeRange
fn clone(&self) -> QueryTimeRange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for QueryTimeRange
Source§impl Debug for QueryTimeRange
impl Debug for QueryTimeRange
impl Eq for QueryTimeRange
Source§impl PartialEq for QueryTimeRange
impl PartialEq for QueryTimeRange
Source§fn eq(&self, other: &QueryTimeRange) -> bool
fn eq(&self, other: &QueryTimeRange) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for QueryTimeRange
Auto Trait Implementations§
impl Freeze for QueryTimeRange
impl RefUnwindSafe for QueryTimeRange
impl Send for QueryTimeRange
impl Sync for QueryTimeRange
impl Unpin for QueryTimeRange
impl UnsafeUnpin for QueryTimeRange
impl UnwindSafe for QueryTimeRange
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more