Improved predicate splitting (#445)
* Multi-batch splitting * Invoke split predicates by name, passing in full argument list * Reorder batches to prevent failure of forward references where possible * Rename APIs for clarity * Simplify example * Add more docs * Review updates * Remove duplicate code * Comment topological sort algorithm
This commit is contained in:
parent
9c9a2c454c
commit
d1b7b4d37e
12 changed files with 2090 additions and 466 deletions
|
|
@ -22,6 +22,9 @@ pub enum LangError {
|
|||
|
||||
#[error("Lowering error: {0}")]
|
||||
Lowering(Box<LoweringError>),
|
||||
|
||||
#[error("Batching error: {0}")]
|
||||
Batching(Box<BatchingError>),
|
||||
}
|
||||
|
||||
/// Validation errors from frontend AST validation
|
||||
|
|
@ -90,14 +93,6 @@ pub enum ValidationError {
|
|||
/// Lowering errors from frontend AST lowering to middleware
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum LoweringError {
|
||||
#[error("Too many custom predicates in batch '{batch_name}': {count} exceeds limit of {max}{}", if *.original_count != *.count { format!(" (started with {} predicates before automatic splitting)", original_count) } else { String::new() })]
|
||||
TooManyPredicates {
|
||||
batch_name: String,
|
||||
count: usize,
|
||||
max: usize,
|
||||
original_count: usize,
|
||||
},
|
||||
|
||||
#[error("Too many statements in predicate '{predicate}': {count} exceeds limit of {max}")]
|
||||
TooManyStatements {
|
||||
predicate: String,
|
||||
|
|
@ -127,6 +122,9 @@ pub enum LoweringError {
|
|||
#[error("Splitting error: {0}")]
|
||||
Splitting(#[from] SplittingError),
|
||||
|
||||
#[error("Batching error: {0}")]
|
||||
Batching(#[from] BatchingError),
|
||||
|
||||
#[error("Cannot lower document with validation errors")]
|
||||
ValidationErrors,
|
||||
}
|
||||
|
|
@ -235,6 +233,13 @@ fn format_public_args_at_split_error(
|
|||
msg
|
||||
}
|
||||
|
||||
/// Batching errors from multi-batch packing
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum BatchingError {
|
||||
#[error("Internal batching error: {message}")]
|
||||
Internal { message: String },
|
||||
}
|
||||
|
||||
/// Splitting errors from predicate splitting
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum SplittingError {
|
||||
|
|
@ -271,13 +276,6 @@ pub enum SplittingError {
|
|||
max_allowed: usize,
|
||||
suggestion: Option<Box<RefactorSuggestion>>,
|
||||
},
|
||||
|
||||
#[error("Too many predicates in chain for '{predicate}': {count} exceeds batch limit of {max_allowed}")]
|
||||
TooManyPredicatesInChain {
|
||||
predicate: String,
|
||||
count: usize,
|
||||
max_allowed: usize,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<ParseError> for LangError {
|
||||
|
|
@ -303,3 +301,9 @@ impl From<LoweringError> for LangError {
|
|||
LangError::Lowering(Box::new(err))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BatchingError> for LangError {
|
||||
fn from(err: BatchingError) -> Self {
|
||||
LangError::Batching(Box::new(err))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue