Skip to content

Commit

Permalink
Merge pull request #768 from powdr-labs/column_by_name
Browse files Browse the repository at this point in the history
Retain column access by name.
  • Loading branch information
Leo authored Nov 15, 2023
2 parents 51c48e7 + 3f4d2eb commit cf7cae1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion executor/src/witgen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashMap};

use ast::analyzed::{
AlgebraicReference, Analyzed, Expression, FunctionValueDefinition, PolyID, PolynomialType,
SymbolKind,
};
use number::{DegreeType, FieldElement};

Expand Down Expand Up @@ -155,6 +156,7 @@ pub struct FixedData<'a, T> {
degree: DegreeType,
fixed_cols: FixedColumnMap<FixedColumn<'a, T>>,
witness_cols: WitnessColumnMap<WitnessColumn<'a, T>>,
column_by_name: HashMap<String, PolyID>,
}

impl<'a, T: FieldElement> FixedData<'a, T> {
Expand Down Expand Up @@ -193,6 +195,14 @@ impl<'a, T: FieldElement> FixedData<'a, T> {
degree: analyzed.degree(),
fixed_cols,
witness_cols,
column_by_name: analyzed
.definitions
.iter()
.filter_map(|(name, (symbol, _))| {
matches!(symbol.kind, SymbolKind::Poly(_))
.then(|| (name.clone(), symbol.into()))
})
.collect(),
}
}

Expand All @@ -208,6 +218,10 @@ impl<'a, T: FieldElement> FixedData<'a, T> {
}
}

pub fn column_by_name(&self, name: &str) -> PolyID {
self.column_by_name[name]
}

fn external_witness(&self, row: DegreeType, column: &PolyID) -> Option<T> {
let row = row % self.degree;
self.witness_cols[column]
Expand Down

0 comments on commit cf7cae1

Please sign in to comment.