pub struct LocalityProviderExecutor<S: StateStore> {Show 13 fields
upstream: Executor,
locality_columns: Vec<usize>,
state_table: StateTable<S>,
progress_table: StateTable<S>,
sort_buffer_table: Option<StateTable<S>>,
sort_buffer_settings: SortBufferSettings,
input_schema: Schema,
progress: CreateMviewProgressReporter,
fragment_id: FragmentId,
actor_id: ActorId,
metrics: Arc<StreamingMetrics>,
chunk_size: usize,
rate_limiter: MonitoredRateLimiter,
}Expand description
The LocalityProviderExecutor provides locality for operators during backfilling.
It buffers input data into a state table using locality columns as primary key prefix.
The executor implements a proper backfill process similar to arrangement backfill:
- Backfill phase: Buffer incoming data and provide locality-ordered snapshot reads
- Completion transition: Drain buffered input and forward new input directly until the barrier that persists backfill completion
- Forward phase: Optionally sort amplified epochs after that completion barrier
The sort buffer intentionally does not cover the completion transition. Input drained when the snapshot reaches EOF, or received while waiting for the completion barrier, is forwarded in arrival order. Only input after that barrier is eligible for sorting.
Key improvements over the original implementation:
- Removes arbitrary barrier buffer limit
- Implements proper upstream chunk tracking during backfill
- Uses per-vnode progress tracking for better state management
Fields§
§upstream: ExecutorUpstream input
locality_columns: Vec<usize>Locality columns (indices in input schema)
state_table: StateTable<S>State table for buffering input data
progress_table: StateTable<S>Progress table for tracking backfill progress per vnode
sort_buffer_table: Option<StateTable<S>>Ephemeral sorted log table for buffering and re-ordering amplified input within an epoch
after backfill is finished. None if the feature was not enabled at plan time.
sort_buffer_settings: SortBufferSettingsRuntime settings for the sort buffer.
input_schema: Schema§progress: CreateMviewProgressReporterProgress reporter for materialized view creation
fragment_id: FragmentId§actor_id: ActorId§metrics: Arc<StreamingMetrics>Metrics
chunk_size: usizeChunk size for output
rate_limiter: MonitoredRateLimiterImplementations§
Source§impl<S: StateStore> LocalityProviderExecutor<S>
impl<S: StateStore> LocalityProviderExecutor<S>
pub fn new( upstream: Executor, locality_columns: Vec<usize>, state_table: StateTable<S>, progress_table: StateTable<S>, sort_buffer_table: Option<StateTable<S>>, sort_buffer_settings: SortBufferSettings, input_schema: Schema, progress: CreateMviewProgressReporter, metrics: Arc<StreamingMetrics>, chunk_size: usize, fragment_id: FragmentId, rate_limit: RateLimit, ) -> Self
Sourcefn apply_throttle(
rate_limiter: &MonitoredRateLimiter,
fragment_id: FragmentId,
barrier: &Barrier,
) -> Option<RateLimit>
fn apply_throttle( rate_limiter: &MonitoredRateLimiter, fragment_id: FragmentId, barrier: &Barrier, ) -> Option<RateLimit>
Returns the new rate limit if it changed.
Sourcefn make_snapshot_stream<'a>(
reader: FlushedStateTableReader<S>,
backfill_state: LocalityBackfillState,
rate_limiter: &'a MonitoredRateLimiter,
) -> impl Stream<Item = Result<(VirtualNode, OwnedRow), StreamExecutorError>> + 'a
fn make_snapshot_stream<'a>( reader: FlushedStateTableReader<S>, backfill_state: LocalityBackfillState, rate_limiter: &'a MonitoredRateLimiter, ) -> impl Stream<Item = Result<(VirtualNode, OwnedRow), StreamExecutorError>> + 'a
Creates a snapshot stream that reads from state table in locality order
Sourceasync fn persist_backfill_state(
progress_table: &mut StateTable<S>,
backfill_state: &LocalityBackfillState,
) -> StreamExecutorResult<()>
async fn persist_backfill_state( progress_table: &mut StateTable<S>, backfill_state: &LocalityBackfillState, ) -> StreamExecutorResult<()>
Persist backfill state to progress table
Sourceasync fn load_backfill_state(
progress_table: &StateTable<S>,
) -> StreamExecutorResult<LocalityBackfillState>
async fn load_backfill_state( progress_table: &StateTable<S>, ) -> StreamExecutorResult<LocalityBackfillState>
Load backfill state from progress table
Sourcefn mark_chunk(
chunk: StreamChunk,
backfill_state: &LocalityBackfillState,
state_table: &StateTable<S>,
) -> StreamExecutorResult<StreamChunk>
fn mark_chunk( chunk: StreamChunk, backfill_state: &LocalityBackfillState, state_table: &StateTable<S>, ) -> StreamExecutorResult<StreamChunk>
Mark chunk for forwarding based on backfill progress
fn handle_snapshot_chunk( data_chunk: DataChunk, vnode: VirtualNode, pk_indices: &[usize], backfill_state: &mut LocalityBackfillState, cur_barrier_snapshot_processed_rows: &mut u64, ) -> StreamExecutorResult<StreamChunk>
Sourcefn write_chunk_to_sort_buffer(
sort_buffer_table: &mut StateTable<S>,
chunk: &StreamChunk,
generation: i64,
seq: &mut i64,
)
fn write_chunk_to_sort_buffer( sort_buffer_table: &mut StateTable<S>, chunk: &StreamChunk, generation: i64, seq: &mut i64, )
Write a compacted input chunk into the sort buffer table as an append-only log.
Each row is extended with gen (the current epoch generation), op (normalized op code)
and seq (monotonic sequence number within the epoch), all writes using Op::Insert with
unique keys.
Sourcefn make_sort_buffer_replay_stream(
reader: FlushedStateTableReader<S>,
generation: i64,
group_key_indices: Vec<usize>,
input_len: usize,
data_types: Vec<DataType>,
chunk_size: usize,
) -> impl Stream<Item = Result<StreamChunk, StreamExecutorError>>
fn make_sort_buffer_replay_stream( reader: FlushedStateTableReader<S>, generation: i64, group_key_indices: Vec<usize>, input_len: usize, data_types: Vec<DataType>, chunk_size: usize, ) -> impl Stream<Item = Result<StreamChunk, StreamExecutorError>>
Replay this epoch’s buffered changes from the sort buffer table in locality order, compacting consecutive changes of the same key (locality columns + stream key) into at most one record.
Must be called after the sort buffer table has been committed for the epoch, so that all buffered rows are visible to the flushed snapshot reader (staging imms + spilled SSTs).
Source§impl<S: StateStore> LocalityProviderExecutor<S>
impl<S: StateStore> LocalityProviderExecutor<S>
fn execute_inner( self, ) -> impl Stream<Item = Result<Message, StreamExecutorError>>
Trait Implementations§
Auto Trait Implementations§
impl<S> !Freeze for LocalityProviderExecutor<S>
impl<S> !RefUnwindSafe for LocalityProviderExecutor<S>
impl<S> !Sync for LocalityProviderExecutor<S>
impl<S> !UnwindSafe for LocalityProviderExecutor<S>
impl<S> Send for LocalityProviderExecutor<S>
impl<S> Unpin for LocalityProviderExecutor<S>
impl<S> UnsafeUnpin for LocalityProviderExecutor<S>
Blanket Implementations§
§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,
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
§impl<T> Conv for T
impl<T> Conv for T
§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,
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,
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>
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>
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)
&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)
&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> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
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>,
Layered].impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
Source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level.Source§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>
RelabeledMetricVec::with_metric_level_relabel_n.Source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n with metric_level set to
MetricLevel::Debug and relabel_num set to 1.§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Scope for T
impl<T> Scope for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.