pub struct MaterializedViewRegistry { /* private fields */ }Expand description
구체화된 뷰 레지스트리 (이벤트 기반 갱신)
CREATE MATERIALIZED VIEW / REFRESH / DROP 명령어를 처리합니다. 각 뷰는 등록된 SQL과 사전 계산된 Arrow RecordBatch 캐시를 가집니다.
DML 발생 시 notify_change(table) 호출로 해당 테이블을 참조하는 MV를 즉시 갱신합니다.
min_refresh_interval_ms로 갱신 폭풍을 방지합니다 (debounce).
Implementations§
Source§impl MaterializedViewRegistry
impl MaterializedViewRegistry
pub fn new() -> Self
Sourcepub fn set_min_refresh_interval_ms(&self, ms: u64)
pub fn set_min_refresh_interval_ms(&self, ms: u64)
Sourcepub fn min_refresh_interval_ms(&self) -> u64
pub fn min_refresh_interval_ms(&self) -> u64
현재 설정된 최소 갱신 주기 (밀리초)
Sourcepub fn min_refresh_interval(&self) -> Duration
pub fn min_refresh_interval(&self) -> Duration
최소 갱신 주기를 Duration으로 반환
Sourcepub fn create(
&self,
name: &str,
sql: &str,
refresh_interval_secs: Option<u64>,
) -> DbxResult<()>
pub fn create( &self, name: &str, sql: &str, refresh_interval_secs: Option<u64>, ) -> DbxResult<()>
구체화된 뷰 등록 (최초에는 stale — cache 없음)
SQL에서 FROM/JOIN 절을 파싱하여 source_tables를 자동 추출합니다.
Sourcepub fn set_cache(&self, name: &str, batches: Vec<RecordBatch>) -> DbxResult<()>
pub fn set_cache(&self, name: &str, batches: Vec<RecordBatch>) -> DbxResult<()>
캐시 저장 (REFRESH MATERIALIZED VIEW 호출 후)
Sourcepub fn is_fresh(&self, name: &str) -> bool
pub fn is_fresh(&self, name: &str) -> bool
캐시가 유효한지 확인
- 한 번도 갱신되지 않았으면 false (stale)
- 수동 갱신 전용(interval 없음): 갱신된 적 있으면 true
- interval이 있으면: 마지막 갱신으로부터 interval 초 미만이면 true
Sourcepub fn remove(&self, name: &str) -> DbxResult<()>
pub fn remove(&self, name: &str) -> DbxResult<()>
구체화된 뷰 삭제 (remove: Rust의 Drop 트레이트와 이름 충돌 방지)
Sourcepub fn notify_change(&self, table: &str)
pub fn notify_change(&self, table: &str)
DML(INSERT/UPDATE/DELETE) 발생 시 호출.
변경된 테이블을 참조하는 모든 MV를 dirty로 마킹하고 백그라운드 갱신 스레드를 즉시 깨웁니다.
이 메서드는 멱등적이며, 빈번하게 호출해도 안전합니다.
Sourcepub fn wait_and_take_dirty(&self) -> HashSet<String>
pub fn wait_and_take_dirty(&self) -> HashSet<String>
백그라운드 스레드용: dirty MV가 생길 때까지 블로킹 대기 후 drain
Sourcepub fn take_dirty(&self) -> HashSet<String>
pub fn take_dirty(&self) -> HashSet<String>
백그라운드 스레드용: 현재 dirty set을 non-blocking으로 drain
Sourcepub fn stale_views(&self) -> Vec<String>
pub fn stale_views(&self) -> Vec<String>
등록된 MV 중 stale(갱신 필요)인 것들의 이름 반환 (폴링 호환)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MaterializedViewRegistry
impl !RefUnwindSafe for MaterializedViewRegistry
impl Send for MaterializedViewRegistry
impl Sync for MaterializedViewRegistry
impl Unpin for MaterializedViewRegistry
impl UnsafeUnpin for MaterializedViewRegistry
impl UnwindSafe for MaterializedViewRegistry
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
Mutably borrows from an owned value. Read more
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