pub struct CompileCacheKey {
pub plan_hash: u64,
pub dialect: SqlDialect,
pub quote_style: IdentifierQuoting,
}Expand description
Key used to cache compiled SQL results.
The key is derived from the QueryPlan
content (via a deterministic hash of its normalised JSON form) and
the dialect/quoting parameters that affect the generated SQL.
Fields§
§plan_hash: u6464-bit hash of the normalised query plan.
dialect: SqlDialectTarget SQL dialect.
quote_style: IdentifierQuotingIdentifier quoting style.
Implementations§
Source§impl CompileCacheKey
impl CompileCacheKey
Sourcepub fn new(plan: &ValidatedPlan, profile: &DialectProfile) -> Self
pub fn new(plan: &ValidatedPlan, profile: &DialectProfile) -> Self
Creates a new key from a validated plan and a dialect profile.
The plan is normalised (serialised to JSON with sorted keys,
None values skipped) before hashing, so two semantically
equivalent plans always produce the same key.
§Examples
use vlorql_core::cache::CompileCacheKey;
use vlorql_core::schema::{DialectProfile, QueryPlan, Projection, FromClause};
use vlorql_core::validate::ValidatedPlan;
use std::sync::Arc;
let plan = QueryPlan {
select: vec![Projection::Column {
table: None, column: "id".to_owned(), alias: None,
}],
from: FromClause { table: "users".to_owned(), alias: None },
r#where: None, group_by: None, having: None,
order_by: None, limit: None, offset: None,
joins: None, ctes: None, distinct: false, distinct_on: None, set_operation: None,
};
let validated = ValidatedPlan(Arc::new(plan));
let profile = DialectProfile::default();
let key = CompileCacheKey::new(&validated, &profile);
assert!(key.plan_hash != 0);Trait Implementations§
Source§impl Clone for CompileCacheKey
impl Clone for CompileCacheKey
Source§fn clone(&self) -> CompileCacheKey
fn clone(&self) -> CompileCacheKey
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompileCacheKey
impl Debug for CompileCacheKey
Source§impl<'de> Deserialize<'de> for CompileCacheKey
impl<'de> Deserialize<'de> for CompileCacheKey
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for CompileCacheKey
Source§impl Hash for CompileCacheKey
impl Hash for CompileCacheKey
Source§impl PartialEq for CompileCacheKey
impl PartialEq for CompileCacheKey
Source§impl Serialize for CompileCacheKey
impl Serialize for CompileCacheKey
impl StructuralPartialEq for CompileCacheKey
Auto Trait Implementations§
impl Freeze for CompileCacheKey
impl RefUnwindSafe for CompileCacheKey
impl Send for CompileCacheKey
impl Sync for CompileCacheKey
impl Unpin for CompileCacheKey
impl UnsafeUnpin for CompileCacheKey
impl UnwindSafe for CompileCacheKey
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request