Skip to main content

MaterializedViewRegistry

Struct MaterializedViewRegistry 

Source
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

Source

pub fn new() -> Self

Source

pub fn set_min_refresh_interval_ms(&self, ms: u64)

최소 갱신 주기를 밀리초 단위로 설정합니다.

이 값은 DML 이벤트 발생 후 실제 MV 갱신까지의 최소 대기 시간입니다. 빈번한 쓰기 시 갱신 폭풍을 방지하는 debounce 역할을 합니다.

§예시
registry.set_min_refresh_interval_ms(500); // 0.5초 debounce
Source

pub fn min_refresh_interval_ms(&self) -> u64

현재 설정된 최소 갱신 주기 (밀리초)

Source

pub fn min_refresh_interval(&self) -> Duration

최소 갱신 주기를 Duration으로 반환

Source

pub fn create( &self, name: &str, sql: &str, refresh_interval_secs: Option<u64>, ) -> DbxResult<()>

구체화된 뷰 등록 (최초에는 stale — cache 없음)

SQL에서 FROM/JOIN 절을 파싱하여 source_tables를 자동 추출합니다.

Source

pub fn set_cache(&self, name: &str, batches: Vec<RecordBatch>) -> DbxResult<()>

캐시 저장 (REFRESH MATERIALIZED VIEW 호출 후)

Source

pub fn is_fresh(&self, name: &str) -> bool

캐시가 유효한지 확인

  • 한 번도 갱신되지 않았으면 false (stale)
  • 수동 갱신 전용(interval 없음): 갱신된 적 있으면 true
  • interval이 있으면: 마지막 갱신으로부터 interval 초 미만이면 true
Source

pub fn get_cache(&self, name: &str) -> Option<Vec<RecordBatch>>

캐시 읽기 (SELECT 캐시 히트 시 사용)

Source

pub fn get_sql(&self, name: &str) -> Option<String>

뷰 SQL 읽기 (REFRESH 시 재실행 대상)

Source

pub fn list(&self) -> Vec<String>

등록된 구체화된 뷰 이름 목록

Source

pub fn remove(&self, name: &str) -> DbxResult<()>

구체화된 뷰 삭제 (remove: Rust의 Drop 트레이트와 이름 충돌 방지)

Source

pub fn notify_change(&self, table: &str)

DML(INSERT/UPDATE/DELETE) 발생 시 호출.

변경된 테이블을 참조하는 모든 MV를 dirty로 마킹하고 백그라운드 갱신 스레드를 즉시 깨웁니다.

이 메서드는 멱등적이며, 빈번하게 호출해도 안전합니다.

Source

pub fn wait_and_take_dirty(&self) -> HashSet<String>

백그라운드 스레드용: dirty MV가 생길 때까지 블로킹 대기 후 drain

Source

pub fn take_dirty(&self) -> HashSet<String>

백그라운드 스레드용: 현재 dirty set을 non-blocking으로 drain

Source

pub fn stale_views(&self) -> Vec<String>

등록된 MV 중 stale(갱신 필요)인 것들의 이름 반환 (폴링 호환)

Trait Implementations§

Source§

impl Default for MaterializedViewRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more