pub struct QueryBuilder<'a> { /* private fields */ }Expand description
Query builder for fluent query construction
Implementations§
Source§impl<'a> QueryBuilder<'a>
impl<'a> QueryBuilder<'a>
Sourcepub fn execute(self) -> Result<QueryResult>
pub fn execute(self) -> Result<QueryResult>
Execute the query
Scans packed rows and unpacks them. Each key is “table/row_id” pointing to a packed row.
Sourcepub fn execute_iter(self) -> Result<QueryRowIterator>
pub fn execute_iter(self) -> Result<QueryRowIterator>
Execute with lazy iteration - avoids materializing all rows
Returns an iterator over rows as Vec<SochValue> in schema column order.
This is more memory-efficient than execute() for large result sets.
§Performance
- No upfront materialization of all rows
- ~40% less memory for large result sets
- Ideal for streaming to network or aggregations
§Example
ⓘ
for row_result in db.query(txn, "users").execute_iter()? {
let row = row_result?;
// row is Vec<SochValue> in column order
}Sourcepub fn as_columnar(self) -> Result<ColumnarQueryResult>
pub fn as_columnar(self) -> Result<ColumnarQueryResult>
Execute and return columnar (SIMD-friendly) result format
Instead of row-oriented Vec<HashMap<String, SochValue>>, returns
column-oriented Vec<TypedColumn> for vectorized operations.
§Performance Benefits
- SIMD: Aggregate operations (sum, avg) use vectorized instructions
- Cache: Sequential access maximizes L1/L2 hits
- Memory: ~30% less overhead than row-based format
- Analytics: Ideal for ML preprocessing and statistics
§Example
ⓘ
let result = db.query(txn, "users")
.columns(&["id", "score"])
.as_columnar()?;
// SIMD-optimized sum
let total = result.sum_i64("score").unwrap_or(0);
// Direct column access
if let Some(scores) = result.column("score") {
for i in 0..scores.len() {
if let Some(v) = scores.get_i64(i) {
println!("Score: {}", v);
}
}
}Auto Trait Implementations§
impl<'a> !RefUnwindSafe for QueryBuilder<'a>
impl<'a> !UnwindSafe for QueryBuilder<'a>
impl<'a> Freeze for QueryBuilder<'a>
impl<'a> Send for QueryBuilder<'a>
impl<'a> Sync for QueryBuilder<'a>
impl<'a> Unpin for QueryBuilder<'a>
impl<'a> UnsafeUnpin for QueryBuilder<'a>
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> 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> 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