Skip to main content

CatalogReader

Trait CatalogReader 

Source
pub trait CatalogReader: Debug + Send {
Show 14 methods // Required methods fn reset_session(&mut self); fn instruments( &mut self, query: &CatalogInstrumentQuery, ) -> Result<Vec<InstrumentAny>>; fn query_batch(&mut self, query: &CatalogQuery) -> Result<DataBatch>; fn query_batch_session( &mut self, query: &CatalogQuery, chunk_size: Option<usize>, ) -> Result<DataBatchQueryResult>; // Provided methods fn fork_query_catalog(&self) -> Result<Option<DataCatalog>> { ... } fn query_identifiers( &mut self, _query: &CatalogQuery, ) -> Result<Vec<String>> { ... } fn query_metadata( &mut self, _query: &CatalogQuery, ) -> Result<Vec<CatalogMetadata>> { ... } fn get_missing_intervals_for_request( &mut self, _start: UnixNanos, _end: UnixNanos, _data_type: NautilusDataType, _identifier: Option<&str>, ) -> Result<Vec<(u64, u64)>> { ... } fn get_missing_intervals_for_identifiers( &mut self, start: UnixNanos, end: UnixNanos, data_type: NautilusDataType, identifiers: &[String], ) -> Result<AHashMap<String, Vec<(u64, u64)>>> { ... } fn get_coverage_intervals_for_identifiers( &mut self, start: UnixNanos, end: UnixNanos, data_type: NautilusDataType, identifiers: &[String], ) -> Result<AHashMap<String, CoverageIntervals>> { ... } fn query_last_timestamp( &mut self, _data_type: NautilusDataType, _identifier: Option<&str>, ) -> Result<Option<u64>> { ... } fn query_display_record_batches( &mut self, _query: &CatalogQuery, ) -> Result<Vec<RecordBatch>> { ... } fn query_record_batches( &mut self, _query: &CatalogRecordQuery, ) -> Result<Vec<RecordBatch>> { ... } fn query_record_display_batches( &mut self, query: &CatalogRecordQuery, ) -> Result<Vec<RecordBatch>> { ... }
}
Expand description

Runtime catalog read API used by data loading code.

The methods are object-safe so callers in other crates can accept a catalog backend without depending on a concrete table format. Implementations must preserve the typed logical schema of built-in data, records, and instruments. Only user-defined [Data::Custom] values may use an opaque, self-describing payload.

Required Methods§

Source

fn reset_session(&mut self)

Resets any per-query session state.

Source

fn instruments( &mut self, query: &CatalogInstrumentQuery, ) -> Result<Vec<InstrumentAny>>

Queries instruments known by the catalog.

Applies where_clause as an additional SQL predicate when supported by the backend.

§Errors

Returns an error if the backend cannot query instruments.

Source

fn query_batch(&mut self, query: &CatalogQuery) -> Result<DataBatch>

Queries catalog data as a typed batch.

§Errors

Returns an error if the backend query fails.

Source

fn query_batch_session( &mut self, query: &CatalogQuery, chunk_size: Option<usize>, ) -> Result<DataBatchQueryResult>

Queries catalog data as a typed batch session.

chunk_size configures this query session only. None uses the default streaming chunk size; Some(n) yields timestamp-aligned typed batches no smaller than n when same-ts rows cross the boundary.

§Errors

Returns an error if the backend query fails.

Provided Methods§

Source

fn fork_query_catalog(&self) -> Result<Option<DataCatalog>>

Creates an independent catalog for a lazy query while sharing backend resources.

Backends with mutable per-query state should return a catalog with isolated session state. The default keeps external catalogs on the existing one-instance-per-query path.

§Errors

Returns an error if the backend cannot create the query catalog.

Source

fn query_identifiers(&mut self, _query: &CatalogQuery) -> Result<Vec<String>>

Queries the concrete catalog row identifiers matched by a data query.

Implementations should use backend-native projection (for example, DataFusion SELECT DISTINCT identifier) so callers can discover identifiers without materializing full market data rows.

§Errors

Returns an error if the backend identifier query fails, or if the backend does not override this default implementation.

Source

fn query_metadata( &mut self, _query: &CatalogQuery, ) -> Result<Vec<CatalogMetadata>>

Queries Arrow schema metadata and the first queried timestamp where each metadata is used.

§Errors

Returns an error if the backend query or metadata lookup fails.

Source

fn get_missing_intervals_for_request( &mut self, _start: UnixNanos, _end: UnixNanos, _data_type: NautilusDataType, _identifier: Option<&str>, ) -> Result<Vec<(u64, u64)>>

Returns request intervals not covered by catalog data or known-empty coverage.

§Errors

Returns an error if interval discovery fails.

Source

fn get_missing_intervals_for_identifiers( &mut self, start: UnixNanos, end: UnixNanos, data_type: NautilusDataType, identifiers: &[String], ) -> Result<AHashMap<String, Vec<(u64, u64)>>>

Returns missing request intervals for each identifier.

Backends should override this method when all identifiers can share one coverage scan.

§Errors

Returns an error if interval discovery fails.

Source

fn get_coverage_intervals_for_identifiers( &mut self, start: UnixNanos, end: UnixNanos, data_type: NautilusDataType, identifiers: &[String], ) -> Result<AHashMap<String, CoverageIntervals>>

Returns effective data and known-empty coverage for each identifier.

Backends should override this method when all identifiers can share one coverage scan.

§Errors

Returns an error if interval discovery fails.

Source

fn query_last_timestamp( &mut self, _data_type: NautilusDataType, _identifier: Option<&str>, ) -> Result<Option<u64>>

Returns the last timestamp covered by the catalog for a data type and optional identifier.

§Errors

Returns an error if backend coverage discovery fails.

Source

fn query_display_record_batches( &mut self, _query: &CatalogQuery, ) -> Result<Vec<RecordBatch>>

Queries catalog data as display-friendly Arrow record batches.

Display conversion normalizes fixed-point prices and quantities to floating-point columns and preserves catalog query semantics for the concrete backend. Implementations should accept multiple identifiers in one call; shared-table backends can use a single multi-identifier predicate, while file-oriented backends can concatenate matching results.

§Errors

Returns an error if the backend query or display conversion fails.

Source

fn query_record_batches( &mut self, _query: &CatalogRecordQuery, ) -> Result<Vec<RecordBatch>>

Queries catalog records as raw Arrow record batches.

This supports record types outside the [Data] enum, such as account state, order/position events, snapshots, reports, and instruments. Backends must preserve the fixed schema selected by [NautilusRecordType] rather than returning an opaque serialized payload.

§Errors

Returns an error if backend query execution fails.

Source

fn query_record_display_batches( &mut self, query: &CatalogRecordQuery, ) -> Result<Vec<RecordBatch>>

Queries catalog records as display-friendly Arrow record batches.

Implementations may return raw batches for record types with no specialized display conversion.

§Errors

Returns an error if backend query or display conversion fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§