pub struct QueryExpr {
pub source: SourceExpr,
pub query: Vec<Query>,
}Fields§
§source: SourceExpr§query: Vec<Query>Implementations§
Source§impl QueryExpr
impl QueryExpr
pub fn new<T: Into<SourceExpr>>(source: T) -> Self
Sourcepub fn walk_sources<E>(
&self,
on_source: &mut impl FnMut(&SourceExpr) -> Result<(), E>,
) -> Result<(), E>
pub fn walk_sources<E>( &self, on_source: &mut impl FnMut(&SourceExpr) -> Result<(), E>, ) -> Result<(), E>
Iterate over all SourceExprs involved in the QueryExpr.
Sources are yielded from left to right. Duplicates are not filtered out.
Sourcepub fn head(&self) -> &Arc<Header>
pub fn head(&self) -> &Arc<Header>
Returns the last Header of this query.
Starts the scan from the back to the front,
looking for query operations that change the Header.
These are JoinInner and Project.
If there are no operations that alter the Header,
this falls back to the origin self.source.head().
Sourcepub fn reads_from_table(&self, id: &TableId) -> bool
pub fn reads_from_table(&self, id: &TableId) -> bool
Does this query read from a given table?
pub fn with_index_eq( self, table: DbTable, columns: ColList, value: AlgebraicValue, ) -> Self
pub fn with_index_lower_bound( self, table: DbTable, columns: ColList, value: AlgebraicValue, inclusive: bool, ) -> Self
pub fn with_index_upper_bound( self, table: DbTable, columns: ColList, value: AlgebraicValue, inclusive: bool, ) -> Self
pub fn with_select<O>(self, op: O) -> Result<Self, RelationError>
pub fn with_select_cmp<LHS, RHS, O>( self, op: O, lhs: LHS, rhs: RHS, ) -> Result<Self, RelationError>
pub fn with_project( self, fields: Vec<FieldExpr>, wildcard_table: Option<TableId>, ) -> Result<Self, RelationError>
pub fn with_join_inner_raw( self, q_rhs: QueryExpr, c_lhs: ColId, c_rhs: ColId, inner: Option<Arc<Header>>, ) -> Self
pub fn with_join_inner( self, q_rhs: impl Into<QueryExpr>, c_lhs: ColId, c_rhs: ColId, semi: bool, ) -> Self
Sourcepub fn try_semi_join(self) -> QueryExpr
pub fn try_semi_join(self) -> QueryExpr
Try to turn an inner join followed by a projection into a semijoin.
This optimization recognizes queries of the form:
ⓘ
QueryExpr {
source: LHS,
query: [
JoinInner(JoinExpr {
rhs: RHS,
semi: false,
..
}),
Project(LHS.*),
...
]
}And combines the JoinInner with the Project into a JoinInner with semi: true.
Current limitations of this optimization:
- The
JoinInnermust be the first (0th) element of thequery. Future work could search through thequeryto find any applicableJoinInners, but the current implementation inspects only the first expr. This is likely sufficient because this optimization is primarily useful for enablingtry_index_join, which is fundamentally limited to operate on the first expr. Note that we still get to optimize incremental joins, because we first optimize the original query withDbTablesources, which results in anIndexJointhen we replace the sources withMemTables and go back to a [JoinInner] withsemi: true. - The
Projectmust immediately follow theJoinInner, with no intervening exprs. Future work could search through intervening exprs to detect that the RHS table is unused. - The LHS/source table must be a
DbTable, not aMemTable. This is so we can recognize a wildcard project by its table id. Future work could inspect the set of projected fields and compare them to the LHS table’s header instead.
pub fn optimize(self, row_count: &impl Fn(TableId, &str) -> i64) -> Self
Trait Implementations§
Source§impl AuthAccess for QueryExpr
impl AuthAccess for QueryExpr
Source§impl From<SourceExpr> for QueryExpr
impl From<SourceExpr> for QueryExpr
Source§fn from(source: SourceExpr) -> Self
fn from(source: SourceExpr) -> Self
Converts to this type from the input type.
impl Eq for QueryExpr
impl StructuralPartialEq for QueryExpr
Auto Trait Implementations§
impl Freeze for QueryExpr
impl RefUnwindSafe for QueryExpr
impl Send for QueryExpr
impl Sync for QueryExpr
impl Unpin for QueryExpr
impl UnwindSafe for QueryExpr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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>
Converts
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>
Converts
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 more