pub struct StreamBridge { /* private fields */ }Expand description
A bridge that connects push-based data producers with pull-based consumers.
The bridge creates a channel pair: a sender for pushing RecordBatch
instances from the producer side, and a stream for pulling batches
from the consumer side.
§Usage
let schema = Arc::new(Schema::new(vec![...]));
let bridge = StreamBridge::new(schema, 100);
let sender = bridge.sender();
// Producer side (`LaminarDB` Reactor)
sender.send(batch).await?;
// Consumer side (`DataFusion` query)
let stream = bridge.into_stream();
while let Some(batch) = stream.next().await { ... }Implementations§
Source§impl StreamBridge
impl StreamBridge
Sourcepub fn new(schema: SchemaRef, capacity: usize) -> Self
pub fn new(schema: SchemaRef, capacity: usize) -> Self
Creates a new bridge with the given schema and channel capacity.
§Arguments
schema- Schema ofRecordBatchinstances that will flow throughcapacity- Maximum number of batches that can be buffered
Sourcepub fn with_default_capacity(schema: SchemaRef) -> Self
pub fn with_default_capacity(schema: SchemaRef) -> Self
Creates a new bridge with default capacity.
Sourcepub fn sender(&self) -> BridgeSender
pub fn sender(&self) -> BridgeSender
Returns a cloneable sender for pushing batches into the bridge.
Multiple senders can be created by cloning the returned sender.
Sourcepub fn into_stream(self) -> BridgeStream
pub fn into_stream(self) -> BridgeStream
Converts this bridge into a RecordBatchStream for DataFusion.
This consumes the bridge, taking ownership of the receiver.
After calling this, you can still use senders obtained from sender().
§Panics
Panics if called more than once (the receiver can only be taken once).
Sourcepub fn take_stream(&mut self) -> Option<BridgeStream>
pub fn take_stream(&mut self) -> Option<BridgeStream>
Creates a stream without consuming the bridge.
This takes ownership of the receiver, so subsequent calls will return None.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamBridge
impl RefUnwindSafe for StreamBridge
impl Send for StreamBridge
impl Sync for StreamBridge
impl Unpin for StreamBridge
impl UnsafeUnpin for StreamBridge
impl UnwindSafe for StreamBridge
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> 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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.