pub struct HypertableRegistry { /* private fields */ }Expand description
In-memory catalog of hypertables and their chunks. Thread-safe because INSERTs can land from multiple writers simultaneously.
Implementations§
Source§impl HypertableRegistry
impl HypertableRegistry
pub fn new() -> Self
Sourcepub fn register(&self, spec: HypertableSpec)
pub fn register(&self, spec: HypertableSpec)
Register a new hypertable. Replaces the previous spec if one
existed with the same name; chunks for that name are kept —
the operator is assumed to know what they’re doing when they
redefine (e.g. widening chunk_interval_ns).
pub fn get(&self, name: &str) -> Option<HypertableSpec>
pub fn list(&self) -> Vec<HypertableSpec>
Sourcepub fn unregister(&self, name: &str) -> Option<HypertableSpec>
pub fn unregister(&self, name: &str) -> Option<HypertableSpec>
Drop a hypertable from the registry. Returns the removed spec
when present, or None for unknown names. Callers drop the
backing collection separately — this is registry housekeeping
only.
Sourcepub fn route(&self, hypertable: &str, timestamp_ns: u64) -> Option<ChunkId>
pub fn route(&self, hypertable: &str, timestamp_ns: u64) -> Option<ChunkId>
Route a write: returns the ChunkId the row belongs in,
allocating the chunk on first write. None when the
hypertable is unknown.
Sourcepub fn show_chunks(&self, hypertable: &str) -> Vec<ChunkMeta>
pub fn show_chunks(&self, hypertable: &str) -> Vec<ChunkMeta>
Return every chunk for hypertable, oldest-first.
Sourcepub fn drop_chunks_before(
&self,
hypertable: &str,
cutoff_ns: u64,
) -> Vec<ChunkMeta>
pub fn drop_chunks_before( &self, hypertable: &str, cutoff_ns: u64, ) -> Vec<ChunkMeta>
Drop every chunk of hypertable whose max_ts_ns is at or
below cutoff_ns. Returns the count dropped — the physical
storage release is the caller’s responsibility (this module
only owns the metadata).
Sourcepub fn sweep_expired(&self, hypertable: &str, now_ns: u64) -> Vec<ChunkMeta>
pub fn sweep_expired(&self, hypertable: &str, now_ns: u64) -> Vec<ChunkMeta>
Sweep chunks whose effective TTL has fired. A chunk is
droppable when now_ns ≥ max_ts_ns + effective_ttl_ns — the
registry hands back every removed ChunkMeta so the
physical-storage callback can release bytes + indexes. Chunks
without an effective TTL (neither per-chunk override nor
hypertable default) are never touched.
This is the “TTL applied at the partition level” primitive: one O(1) metadata sweep reclaims every row of every expired chunk, instead of scanning rows individually like an entity-level TTL would. Empty hypertables stay empty.
Sourcepub fn sweep_all_expired(&self, now_ns: u64) -> Vec<(String, ChunkMeta)>
pub fn sweep_all_expired(&self, now_ns: u64) -> Vec<(String, ChunkMeta)>
Sweep every registered hypertable in one shot — the loop the
retention daemon runs every cycle. Returns a flat list of
(hypertable_name, chunk_dropped) pairs.
Sourcepub fn set_default_ttl_ns(&self, hypertable: &str, ttl_ns: Option<u64>) -> bool
pub fn set_default_ttl_ns(&self, hypertable: &str, ttl_ns: Option<u64>) -> bool
Install / replace the hypertable-wide default TTL. None
disables automatic expiry — chunks live until explicit
drop_chunks / per-chunk override fires.
Sourcepub fn set_chunk_ttl_ns(&self, id: &ChunkId, ttl_ns: Option<u64>) -> bool
pub fn set_chunk_ttl_ns(&self, id: &ChunkId, ttl_ns: Option<u64>) -> bool
Override the TTL for a single chunk. Useful for “keep this
specific chunk longer because it contains an incident
replay” or “expire this one faster because it was filled
from a backfill we’re about to redo”. None removes the
override and falls back to the hypertable default.
Sourcepub fn chunks_expiring_within(
&self,
hypertable: &str,
now_ns: u64,
horizon_ns: u64,
) -> Vec<ChunkMeta>
pub fn chunks_expiring_within( &self, hypertable: &str, now_ns: u64, horizon_ns: u64, ) -> Vec<ChunkMeta>
Inspect the list of chunks that are about to expire within
horizon_ns. Powers preview endpoints (“what will the next
sweep drop?”) without actually dropping anything.
Sourcepub fn seal_chunk(&self, id: &ChunkId) -> bool
pub fn seal_chunk(&self, id: &ChunkId) -> bool
Seal a chunk — future writes to the same start_ns bucket
will still land (open-ended), but the sealed flag signals
the maintenance layer that the chunk can now be compressed /
uploaded / migrated. Returns true if the chunk existed.
Sourcepub fn total_rows(&self, hypertable: &str) -> u64
pub fn total_rows(&self, hypertable: &str) -> u64
Total row count across every chunk of hypertable. Used by
catalog views + benchmark harnesses.
Sourcepub fn drop_hypertable(&self, name: &str) -> usize
pub fn drop_hypertable(&self, name: &str) -> usize
Drop the whole hypertable (spec + every chunk). Returns the number of chunks removed.
Trait Implementations§
Source§impl Clone for HypertableRegistry
impl Clone for HypertableRegistry
Source§fn clone(&self) -> HypertableRegistry
fn clone(&self) -> HypertableRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HypertableRegistry
impl Debug for HypertableRegistry
Source§impl Default for HypertableRegistry
impl Default for HypertableRegistry
Source§fn default() -> HypertableRegistry
fn default() -> HypertableRegistry
Auto Trait Implementations§
impl Freeze for HypertableRegistry
impl RefUnwindSafe for HypertableRegistry
impl Send for HypertableRegistry
impl Sync for HypertableRegistry
impl Unpin for HypertableRegistry
impl UnsafeUnpin for HypertableRegistry
impl UnwindSafe for HypertableRegistry
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<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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request