Skip to main content

QueryEngine

Struct QueryEngine 

Source
pub struct QueryEngine { /* private fields */ }
Expand description

Query engine with caching and statistics

Implementations§

Source§

impl QueryEngine

Source

pub fn new( storage: Arc<StorageEngine>, schema: Arc<SchemaManager>, _memory: Arc<MemoryManager>, config: &Config, ) -> Result<Self>

Create a new query engine

Source

pub async fn execute(&self, cql: &str) -> Result<QueryResult>

Execute a CQL query

This is the parent of the query span tree (epic #1031, issue #1035): the query.execute span created here is the context every read-path span (issue #1034) and SELECT sub-span nests under. Bounded span attributes (plan type, access path, rows returned) are recorded once the result is known via Self::update_execution_stats; the query text is never attached.

Source

pub async fn execute_streaming( &self, cql: &str, config: StreamingConfig, ) -> Result<QueryResultIterator>

Execute a CQL query with streaming results (Issue #280)

Returns a QueryResultIterator that yields rows incrementally via a bounded channel, enabling memory-efficient processing of large result sets.

§Arguments
  • cql - The CQL query string to execute (must be a SELECT statement)
  • config - Streaming configuration (buffer size, chunk hints)
§Errors

Returns an error if:

  • Query is not a SELECT statement
  • SQL syntax is invalid
  • Query execution fails
§Memory Budget

The streaming approach stays within the 128MB target by using bounded channels and processing rows incrementally rather than materializing all results.

Source

pub async fn execute_with_params( &self, cql: &str, params: &[Value], ) -> Result<QueryResult>

Execute a query with positional ? parameters (Issue #961).

The supplied params are bound, in source order, into the ? placeholders of the parsed statement before planning and execution, so the bound values participate in partition-key classification, encoding, and typed coercion. A WHERE pk = ? therefore engages the same partition-targeted fast path (#949/#956) as the equivalent literal query.

Binding is currently supported for SELECT statements only. A non-SELECT CQL with parameters, or any use of named (:name) parameters, is rejected with a clear error (named-parameter binding is intentionally out of scope: the SELECT grammar only tokenizes positional ?).

§Routing parity with execute (Finding 1)

When the parsed SELECT has zero bind markers and params is empty, this delegates straight back to Self::execute so that a markerless execute_with_params(sql, &[]) is byte-for-byte equivalent to execute(sql) — which since issue #1750 routes every literal SELECT through the modern SELECT optimizer + executor. Only when markers are present (> 0) is the statement bound and driven through that pipeline.

Arity stays strict in both directions: markers > 0 with a wrong params.len() is an error, and markers == 0 with a non-empty params is also an error (a supplied parameter with no placeholder is a caller bug). The latter matches [SelectStatement::bind_parameters]’s contract and the documented strictness of this API.

Source

pub async fn prepare(&self, cql: &str) -> Result<Arc<PreparedQuery>>

Prepare a query for repeated execution

Source

pub async fn execute_prepared( &self, prepared: &PreparedQuery, params: &[Value], ) -> Result<QueryResult>

Execute a prepared query

Source

pub fn stats(&self) -> QueryStats

Get query statistics

Source

pub fn clear_caches(&self)

Clear all caches

Source

pub fn clear_prepared_cache(&self)

Clear prepared statement cache

Source

pub fn clear_plan_cache(&self)

Clear query plan cache

Source

pub fn cache_stats(&self) -> CacheStats

Get cache statistics

Source

pub async fn explain(&self, cql: &str) -> Result<ExplainResult>

Optimize a query (return execution plan without executing)

Source

pub async fn analyze(&self, cql: &str) -> Result<AnalyzeResult>

Analyze query performance

Source

pub async fn has_schema_for_table(&self, table: &str) -> bool

Check if schema is available for a table

Source

pub async fn schema_status(&self, table: &str) -> SchemaStatus

Get detailed schema status for debugging

Trait Implementations§

Source§

impl Debug for QueryEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more