Skip to main content

Source

Trait Source 

Source
pub trait Source {
    type TypeSystem: TypeSystem;
    type Partition: SourcePartition<TypeSystem = Self::TypeSystem, Error = Self::Error> + Send;
    type Error: From<ConnectorXError> + Send + Debug;

    const DATA_ORDERS: &'static [DataOrder];

    // Required methods
    fn set_data_order(
        &mut self,
        data_order: DataOrder,
    ) -> Result<(), Self::Error>;
    fn set_queries<Q: ToString>(&mut self, queries: &[CXQuery<Q>]);
    fn set_origin_query(&mut self, query: Option<String>);
    fn fetch_metadata(&mut self) -> Result<(), Self::Error>;
    fn result_rows(&mut self) -> Result<Option<usize>, Self::Error>;
    fn names(&self) -> Vec<String>;
    fn schema(&self) -> Vec<Self::TypeSystem>;
    fn partition(self) -> Result<Vec<Self::Partition>, Self::Error>;

    // Provided method
    fn set_pre_execution_queries(
        &mut self,
        _pre_execution_queries: Option<&[String]>,
    ) { ... }
}
Expand description

A Source connects to a database, fetches the metadata of a query and splits the work into SourcePartitions, one per partitioned query.

Dispatcher drives a Source in this order: set_data_order, set_queries, set_origin_query, fetch_metadata, then schema and names, optionally result_rows, and finally partition.

Required Associated Constants§

Source

const DATA_ORDERS: &'static [DataOrder]

Supported data orders, ordering by preference.

Required Associated Types§

Source

type TypeSystem: TypeSystem

The type system this Source associated with.

Source

type Partition: SourcePartition<TypeSystem = Self::TypeSystem, Error = Self::Error> + Send

The partition type produced by partition. It is sent to a worker thread, so it must be Send.

Source

type Error: From<ConnectorXError> + Send + Debug

The error type returned by this source and its partitions.

Required Methods§

Source

fn set_data_order(&mut self, data_order: DataOrder) -> Result<(), Self::Error>

Set the data order negotiated between this source and the destination, one of DATA_ORDERS. Return an error if the order is not supported.

Source

fn set_queries<Q: ToString>(&mut self, queries: &[CXQuery<Q>])

Set the partitioned queries. Each query becomes one SourcePartition.

Source

fn set_origin_query(&mut self, query: Option<String>)

Set the original, unpartitioned query, if there is one. Sources can use it to count the rows of the whole result in result_rows.

Source

fn fetch_metadata(&mut self) -> Result<(), Self::Error>

Fetch the result schema (column names and types) of the queries, e.g. by preparing the statement or running a LIMIT 0 query. Called before names and schema.

Source

fn result_rows(&mut self) -> Result<Option<usize>, Self::Error>

Get total number of rows if available.

Return Ok(None) when the total cannot be derived; the dispatcher then counts each partition with SourcePartition::result_rows instead.

Source

fn names(&self) -> Vec<String>

The column names of the result, available after fetch_metadata.

Source

fn schema(&self) -> Vec<Self::TypeSystem>

The column types of the result, available after fetch_metadata.

Source

fn partition(self) -> Result<Vec<Self::Partition>, Self::Error>

Consume the source and create one partition per query given to set_queries, in the same order.

Provided Methods§

Source

fn set_pre_execution_queries( &mut self, _pre_execution_queries: Option<&[String]>, )

Set queries to run on each connection before the partitioned queries. The default implementation panics; sources that support it override it.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Source for BigQuerySource

Source§

impl Source for CSVSource

Source§

impl Source for ClickHouseSource

Source§

impl Source for DummySource

Source§

impl Source for MsSQLSource

Source§

impl Source for OracleSource

Source§

impl Source for SQLiteSource

Source§

impl Source for TrinoSource

Source§

impl<P, C> Source for PostgresSource<P, C>
where PostgresSourcePartition<P, C>: SourcePartition<TypeSystem = PostgresTypeSystem, Error = PostgresSourceError>, P: Send, C: MakeTlsConnect<Socket> + Clone + 'static + Sync + Send, C::TlsConnect: Send, C::Stream: Send, <C::TlsConnect as TlsConnect<Socket>>::Future: Send,

Source§

impl<P> Source for MySQLSource<P>