Skip to main content

ReadSegmentHandle

Trait ReadSegmentHandle 

Source
pub trait ReadSegmentHandle: Send + Sync {
    type Segment: ReadSegmentEntry + ?Sized;

    // Required methods
    fn read_segment(&self) -> RwLockReadGuard<'_, Self::Segment>;
    fn segment_arc(&self) -> Arc<RwLock<Self::Segment>>;
}
Expand description

A handle to a single segment that can be read-locked to yield a [ReadSegmentEntry].

Abstracting over the handle (rather than the segment type) keeps the read path monomorphic for homogeneous callers — a read-only follower’s handle is the concrete Arc<RwLock<ReadOnlySegment<S>>> — while the read-write shard, whose holder is intrinsically heterogeneous (Segment and ProxySegment coexist during optimization), uses the [LockedSegment] enum. Dynamic dispatch is confined to the LockedSegment impl, mirroring the pre-existing [LockedSegment::get_read].

Send + Sync so a snapshot of handles can be shared across the shard’s search thread pool and read in parallel (see EdgeReadView::par_map_segments). Both concrete handles — Arc<RwLock<ReadOnlySegment<S>>> and [LockedSegment] — already satisfy this.

Required Associated Types§

Source

type Segment: ReadSegmentEntry + ?Sized

Required Methods§

Source

fn read_segment(&self) -> RwLockReadGuard<'_, Self::Segment>

Acquire a read guard. One guard is held for the whole per-segment operation, so reads that call several methods on the same segment observe a consistent state.

Source

fn segment_arc(&self) -> Arc<RwLock<Self::Segment>>

Owned handle for the retrieval / version-dedup path (retrieve_over).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<S: UniversalReadExt + 'static> ReadSegmentHandle for Arc<RwLock<ReadOnlySegment<S>>>
where S::Fs: Send + Sync,

Source§

type Segment = ReadOnlySegment<S>

Source§

fn read_segment(&self) -> RwLockReadGuard<'_, ReadOnlySegment<S>>

Source§

fn segment_arc(&self) -> Arc<RwLock<ReadOnlySegment<S>>>

Implementors§