pub(super) struct RankState<RF: RankFuncCount> {
first_key: Option<StateKey>,
buffer: EstimatedVecDeque<StateKey>,
func_state: RF,
persistence_enabled: bool,
last_output_key: Option<StateKey>,
recover_skip_until: Option<StateKey>,
_phantom: PhantomData<RF>,
}Expand description
Generic state for rank window functions including row_number, rank and dense_rank.
Fields§
§first_key: Option<StateKey>First state key of the partition.
buffer: EstimatedVecDeque<StateKey>State keys that are waiting to be outputted.
func_state: RFFunction-specific state.
persistence_enabled: boolWhether persistence is enabled for this state.
last_output_key: Option<StateKey>The key of the last output row (for snapshot).
recover_skip_until: Option<StateKey>During recovery, skip updating func_state for rows up to and including this key.
_phantom: PhantomData<RF>Implementations§
Source§impl<RF: RankFuncCount> RankState<RF>
impl<RF: RankFuncCount> RankState<RF>
pub fn new(_call: &WindowFuncCall) -> Self
fn slide_inner(&mut self) -> (i64, StateEvictHint)
fn slide_no_output_inner(&mut self) -> StateEvictHint
Trait Implementations§
Source§impl<RF: RankFuncCount + EstimateSize> EstimateSize for RankState<RF>
impl<RF: RankFuncCount + EstimateSize> EstimateSize for RankState<RF>
Source§fn estimated_heap_size(&self) -> usize
fn estimated_heap_size(&self) -> usize
The estimated heap size of the current struct in bytes.
§fn estimated_size(&self) -> usizewhere
Self: Sized,
fn estimated_size(&self) -> usizewhere
Self: Sized,
The estimated total size of the current struct in bytes, including the
estimated_heap_size
and the size of Self.Source§impl<RF: RankFuncCount> WindowState for RankState<RF>
impl<RF: RankFuncCount> WindowState for RankState<RF>
Source§fn append(&mut self, key: StateKey, _args: SmallVec<[Datum; 2]>)
fn append(&mut self, key: StateKey, _args: SmallVec<[Datum; 2]>)
Append a new input row to the state. The
key is expected to be increasing.Source§fn curr_window(&self) -> StatePos<'_>
fn curr_window(&self) -> StatePos<'_>
Get the current window frame position.
Source§fn slide(&mut self) -> Result<(Datum, StateEvictHint)>
fn slide(&mut self) -> Result<(Datum, StateEvictHint)>
Slide the window frame forward and collect the output and evict hint. Similar to
Iterator::next.Source§fn slide_no_output(&mut self) -> Result<StateEvictHint>
fn slide_no_output(&mut self) -> Result<StateEvictHint>
Slide the window frame forward and collect the evict hint. Don’t calculate the output if possible.
Source§fn enable_persistence(&mut self)
fn enable_persistence(&mut self)
Enable persistence for this window state. When enabled, the state may return
CanEvict hints and should support snapshot/restore.Source§fn snapshot(&self) -> Option<WindowStateSnapshot>
fn snapshot(&self) -> Option<WindowStateSnapshot>
Create a snapshot of the current state for persistence.
Returns
None if the state doesn’t support persistence.Source§fn restore(&mut self, snapshot: WindowStateSnapshot) -> Result<()>
fn restore(&mut self, snapshot: WindowStateSnapshot) -> Result<()>
Restore the state from a snapshot. Called during recovery before replaying rows.
Source§fn readiness(&self) -> Readiness
fn readiness(&self) -> Readiness
Get the readiness of the current window, given that the rows are appended in the order of
the order key, so no future row is less than the last one. Unlike
StatePos::is_ready,
which is conservative and must not change for the recovery of existing jobs, this is exact.Auto Trait Implementations§
impl<RF> !Freeze for RankState<RF>
impl<RF> RefUnwindSafe for RankState<RF>where
RF: RefUnwindSafe,
impl<RF> Send for RankState<RF>where
RF: Send,
impl<RF> Sync for RankState<RF>where
RF: Sync,
impl<RF> Unpin for RankState<RF>where
RF: Unpin,
impl<RF> UnsafeUnpin for RankState<RF>where
RF: UnsafeUnpin,
impl<RF> UnwindSafe for RankState<RF>where
RF: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Forward to the method defined on the type
Any.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Forward to the method defined on the type
Any.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].impl<T> LruValue for T
impl<T> MaybeSend for Twhere
T: Send,
§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
Equivalent to [
RelabeledMetricVec::with_metric_level].§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
Equivalent to [
RelabeledMetricVec::with_metric_level_relabel_n].§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
Equivalent to [
RelabeledMetricVec::with_metric_level_relabel_n] with metric_level set to
MetricLevel::Debug and relabel_num set to 1.