pub struct LogicalPlan {
pub root: PlanNode,
pub schema: GenomicSchema,
}Expand description
A lazy query plan that can be optimized before execution
LogicalPlan represents a series of operations (scan, filter, select, etc.) without actually performing them. This enables optimization passes that can reorder operations, combine filters, and push predicates down to readers.
Fields§
§root: PlanNodeThe root node of the plan tree
schema: GenomicSchemaSchema information for this plan
Implementations§
Source§impl LogicalPlan
impl LogicalPlan
Sourcepub fn scan<P: Into<PathBuf>>(path: P, format: FileFormat) -> Self
pub fn scan<P: Into<PathBuf>>(path: P, format: FileFormat) -> Self
Create a plan to scan a file
§Examples
use genomicframe_core::plan::LogicalPlan;
use genomicframe_core::schema::FileFormat;
let plan = LogicalPlan::scan("data.vcf", FileFormat::Vcf);Sourcepub fn filter(self, predicate: Expr) -> Self
pub fn filter(self, predicate: Expr) -> Self
Add a filter to the plan
§Examples
use genomicframe_core::plan::LogicalPlan;
use genomicframe_core::expression::{col, lit};
use genomicframe_core::schema::FileFormat;
let plan = LogicalPlan::scan("variants.vcf", FileFormat::Vcf)
.filter(col("qual").gt(lit(30.0)));Sourcepub fn select(self, columns: &[&str]) -> Self
pub fn select(self, columns: &[&str]) -> Self
Select specific columns
§Examples
use genomicframe_core::plan::LogicalPlan;
use genomicframe_core::schema::FileFormat;
let plan = LogicalPlan::scan("data.vcf", FileFormat::Vcf)
.select(&["chrom", "pos", "ref", "alt"]);Sourcepub fn with_column(self, name: &str, expr: Expr) -> Self
pub fn with_column(self, name: &str, expr: Expr) -> Self
Add a computed column
§Examples
use genomicframe_core::plan::LogicalPlan;
use genomicframe_core::expression::{col, Expr};
use genomicframe_core::schema::FileFormat;
let plan = LogicalPlan::scan("data.vcf", FileFormat::Vcf)
.with_column("is_high_qual", col("qual").gt(lit(30.0)));Sourcepub fn limit(self, count: usize) -> Self
pub fn limit(self, count: usize) -> Self
Limit the number of records
§Examples
use genomicframe_core::plan::LogicalPlan;
use genomicframe_core::schema::FileFormat;
let plan = LogicalPlan::scan("data.vcf", FileFormat::Vcf)
.limit(1000);Sourcepub fn max_scan(self, count: usize) -> Self
pub fn max_scan(self, count: usize) -> Self
Limit the maximum number of records to scan from source (before filtering)
This is useful for sampling large files or preventing long-running queries on huge datasets. The scan limit is applied before any filters, so you may get fewer results than the scan limit if filters are selective.
§Examples
use genomicframe_core::plan::LogicalPlan;
use genomicframe_core::schema::FileFormat;
use genomicframe_core::expression::{col, lit};
// Scan only first 10,000 records, then filter
let plan = LogicalPlan::scan("huge.vcf", FileFormat::Vcf)
.max_scan(10_000)
.filter(col("qual").gte(lit(30.0)));Sourcepub fn format(&self) -> Option<FileFormat>
pub fn format(&self) -> Option<FileFormat>
Get the file format of this plan’s source
Source§impl LogicalPlan
impl LogicalPlan
Sourcepub fn optimize(self) -> Self
pub fn optimize(self) -> Self
Optimize this plan
Applies multiple optimization passes:
- Combine adjacent filters into single AND filter
- Push filters down closer to scans
- Prune unnecessary columns early
§Examples
use genomicframe_core::plan::LogicalPlan;
use genomicframe_core::expression::{col, lit};
use genomicframe_core::schema::FileFormat;
let plan = LogicalPlan::scan("data.vcf", FileFormat::Vcf)
.filter(col("qual").gt(lit(30.0)))
.filter(col("chrom").eq(lit("chr1")));
// Before: Scan -> Filter(qual) -> Filter(chrom)
// After: Scan -> Filter(qual AND chrom)
let optimized = plan.optimize();Sourcepub fn combine_filters(self) -> Self
pub fn combine_filters(self) -> Self
Combine adjacent filter operations into single filter with AND
Sourcepub fn push_down_filters(self) -> Self
pub fn push_down_filters(self) -> Self
Push filter operations down toward the scan
Sourcepub fn prune_columns(self) -> Self
pub fn prune_columns(self) -> Self
Push column selection down (prune early)
Trait Implementations§
Source§impl Clone for LogicalPlan
impl Clone for LogicalPlan
Source§fn clone(&self) -> LogicalPlan
fn clone(&self) -> LogicalPlan
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LogicalPlan
impl RefUnwindSafe for LogicalPlan
impl Send for LogicalPlan
impl Sync for LogicalPlan
impl Unpin for LogicalPlan
impl UnsafeUnpin for LogicalPlan
impl UnwindSafe for LogicalPlan
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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