Skip to content

Commit

Permalink
refactor!: replace DataAccessor in ProofPlan with `&IndexMap<Tabl…
Browse files Browse the repository at this point in the history
…eRef, Table<'a, S>>`
  • Loading branch information
iajoiner committed Nov 14, 2024
1 parent e1ac21d commit 0a27287
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions crates/proof-of-sql/src/sql/proof/proof_plan.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{CountBuilder, FinalRoundBuilder, FirstRoundBuilder, VerificationBuilder};
use crate::base::{
database::{Column, ColumnField, ColumnRef, DataAccessor, OwnedTable, TableRef},
database::{Column, ColumnField, ColumnRef, OwnedTable, Table, TableRef},
map::{IndexMap, IndexSet},
proof::ProofError,
scalar::Scalar,
Expand Down Expand Up @@ -39,7 +39,7 @@ pub trait ProverEvaluate {
fn result_evaluate<'a, S: Scalar>(
&self,
alloc: &'a Bump,
accessor: &'a dyn DataAccessor<S>,
accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>>;

/// Evaluate the query and modify `FirstRoundBuilder` to form the query's proof.
Expand All @@ -55,7 +55,7 @@ pub trait ProverEvaluate {
&self,
builder: &mut FinalRoundBuilder<'a, S>,
alloc: &'a Bump,
accessor: &'a dyn DataAccessor<S>,
accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>>;
}

Expand Down
48 changes: 24 additions & 24 deletions crates/proof-of-sql/src/sql/proof/query_proof_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
database::{
owned_table_utility::{bigint, owned_table},
Column, ColumnField, ColumnRef, ColumnType, DataAccessor, OwnedTable,
OwnedTableTestAccessor, TableRef,
OwnedTableTestAccessor, Table, TableRef,
},
map::{indexset, IndexMap, IndexSet},
proof::ProofError,
Expand Down Expand Up @@ -43,7 +43,7 @@ impl ProverEvaluate for TrivialTestProofPlan {
fn result_evaluate<'a, S: Scalar>(
&self,
alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let col = alloc.alloc_slice_fill_copy(self.length, self.column_fill_value);
vec![Column::BigInt(col)]
Expand All @@ -55,7 +55,7 @@ impl ProverEvaluate for TrivialTestProofPlan {
&self,
builder: &mut FinalRoundBuilder<'a, S>,
alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let col = alloc.alloc_slice_fill_copy(self.length, self.column_fill_value);
builder.produce_intermediate_mle(col as &[_]);
Expand Down Expand Up @@ -212,7 +212,7 @@ impl ProverEvaluate for SquareTestProofPlan {
fn result_evaluate<'a, S: Scalar>(
&self,
alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let res: &[_] = alloc.alloc_slice_copy(&self.res);
vec![Column::BigInt(res)]
Expand All @@ -224,13 +224,13 @@ impl ProverEvaluate for SquareTestProofPlan {
&self,
builder: &mut FinalRoundBuilder<'a, S>,
alloc: &'a Bump,
accessor: &'a dyn DataAccessor<S>,
accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let x = accessor.get_column(ColumnRef::new(
"sxt.test".parse().unwrap(),
"x".parse().unwrap(),
ColumnType::BigInt,
));
let x = accessor
.get(&TableRef::new("sxt.test".parse().unwrap()))
.inner_table()
.get("x".parse().unwrap())
.unwrap();
let res: &[_] = alloc.alloc_slice_copy(&self.res);
builder.produce_intermediate_mle(res);
builder.produce_sumcheck_subpolynomial(
Expand Down Expand Up @@ -389,7 +389,7 @@ impl ProverEvaluate for DoubleSquareTestProofPlan {
fn result_evaluate<'a, S: Scalar>(
&self,
alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let res: &[_] = alloc.alloc_slice_copy(&self.res);
vec![Column::BigInt(res)]
Expand All @@ -401,13 +401,13 @@ impl ProverEvaluate for DoubleSquareTestProofPlan {
&self,
builder: &mut FinalRoundBuilder<'a, S>,
alloc: &'a Bump,
accessor: &'a dyn DataAccessor<S>,
accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let x = accessor.get_column(ColumnRef::new(
"sxt.test".parse().unwrap(),
"x".parse().unwrap(),
ColumnType::BigInt,
));
let x = accessor
.get(&TableRef::new("sxt.test".parse().unwrap()))
.inner_table()
.get("x".parse().unwrap())
.unwrap();
let res: &[_] = alloc.alloc_slice_copy(&self.res);
let z: &[_] = alloc.alloc_slice_copy(&self.z);
builder.produce_intermediate_mle(z);
Expand Down Expand Up @@ -596,7 +596,7 @@ impl ProverEvaluate for ChallengeTestProofPlan {
fn result_evaluate<'a, S: Scalar>(
&self,
_alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
vec![Column::BigInt(&[9, 25])]
}
Expand All @@ -609,13 +609,13 @@ impl ProverEvaluate for ChallengeTestProofPlan {
&self,
builder: &mut FinalRoundBuilder<'a, S>,
alloc: &'a Bump,
accessor: &'a dyn DataAccessor<S>,
accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let x = accessor.get_column(ColumnRef::new(
"sxt.test".parse().unwrap(),
"x".parse().unwrap(),
ColumnType::BigInt,
));
let x = accessor
.get(&TableRef::new("sxt.test".parse().unwrap()))
.inner_table()
.get("x".parse().unwrap())
.unwrap();
let res: &[_] = alloc.alloc_slice_copy(&[9, 25]);
let alpha = builder.consume_post_result_challenge();
let _beta = builder.consume_post_result_challenge();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
database::{
owned_table_utility::{bigint, owned_table},
Column, ColumnField, ColumnRef, ColumnType, DataAccessor, OwnedTable,
OwnedTableTestAccessor, TableRef,
OwnedTableTestAccessor, Table, TableRef,
},
map::{indexset, IndexMap, IndexSet},
proof::ProofError,
Expand All @@ -28,7 +28,7 @@ impl ProverEvaluate for EmptyTestQueryExpr {
fn result_evaluate<'a, S: Scalar>(
&self,
alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let zeros = vec![0; self.length];
let res: &[_] = alloc.alloc_slice_copy(&zeros);
Expand All @@ -39,7 +39,7 @@ impl ProverEvaluate for EmptyTestQueryExpr {
&self,
builder: &mut FinalRoundBuilder<'a, S>,
alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
let zeros = vec![0; self.length];
let res: &[_] = alloc.alloc_slice_copy(&zeros);
Expand Down
6 changes: 3 additions & 3 deletions crates/proof-of-sql/src/sql/proof_plans/empty_exec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
base::{
database::{Column, ColumnField, ColumnRef, DataAccessor, OwnedTable, TableRef},
database::{Column, ColumnField, ColumnRef, OwnedTable, TableRef},
map::{IndexMap, IndexSet},
proof::ProofError,
scalar::Scalar,
Expand Down Expand Up @@ -66,7 +66,7 @@ impl ProverEvaluate for EmptyExec {
fn result_evaluate<'a, S: Scalar>(
&self,
_alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
Vec::new()
}
Expand All @@ -79,7 +79,7 @@ impl ProverEvaluate for EmptyExec {
&self,
_builder: &mut FinalRoundBuilder<'a, S>,
_alloc: &'a Bump,
_accessor: &'a dyn DataAccessor<S>,
_accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
Vec::new()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/proof-of-sql/src/sql/proof_plans/table_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ impl ProverEvaluate for TableExec {
fn result_evaluate<'a, S: Scalar>(
&self,
_alloc: &'a Bump,
accessor: &'a dyn DataAccessor<S>,
accessor: &IndexMap<TableRef, Table<'a, S>>,
) -> Vec<Column<'a, S>> {
self.get_table(accessor)
self.get
}

fn first_round_evaluate(&self, _builder: &mut FirstRoundBuilder) {}
Expand Down

0 comments on commit 0a27287

Please sign in to comment.