From f7b2992337d9bf0bac861832043ccd58ca2f6928 Mon Sep 17 00:00:00 2001 From: "dustin.ray" Date: Wed, 18 Dec 2024 18:21:16 -0800 Subject: [PATCH] fix: docs, initial range_lengths in tests --- .../proof-of-sql/src/sql/proof/first_round_builder.rs | 10 ++-------- .../src/sql/proof_plans/filter_exec_test.rs | 3 ++- .../src/sql/proof_plans/projection_exec_test.rs | 3 ++- .../src/sql/proof_plans/slice_exec_test.rs | 3 ++- .../src/sql/proof_plans/union_exec_test.rs | 8 +++++++- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/crates/proof-of-sql/src/sql/proof/first_round_builder.rs b/crates/proof-of-sql/src/sql/proof/first_round_builder.rs index 8af52a325..8a6fe5f27 100644 --- a/crates/proof-of-sql/src/sql/proof/first_round_builder.rs +++ b/crates/proof-of-sql/src/sql/proof/first_round_builder.rs @@ -8,16 +8,10 @@ pub struct FirstRoundBuilder { num_post_result_challenges: usize, /// The extra one evaluation lengths used in the proof. one_evaluation_lengths: Vec, - /// The range length used in the proof. + /// The max of all `range_lengths` used in sumcheck. range_length: usize, } -impl Default for FirstRoundBuilder { - fn default() -> Self { - Self::new(0) - } -} - impl FirstRoundBuilder { pub fn new(initial_range_length: usize) -> Self { Self { @@ -32,7 +26,7 @@ impl FirstRoundBuilder { self.range_length } - /// Update the range length used in the proof. + /// Update the range length used in the proof only if the new range is larger than the existing range. pub(crate) fn update_range_length(&mut self, new_range_length: usize) { if new_range_length > self.range_length { self.range_length = new_range_length; diff --git a/crates/proof-of-sql/src/sql/proof_plans/filter_exec_test.rs b/crates/proof-of-sql/src/sql/proof_plans/filter_exec_test.rs index cd8560b18..abe250e74 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/filter_exec_test.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/filter_exec_test.rs @@ -171,6 +171,7 @@ fn we_can_get_an_empty_result_from_a_basic_filter_on_an_empty_table_using_first_ borrowed_varchar("d", [""; 0], &alloc), borrowed_scalar("e", [0; 0], &alloc), ]); + let data_length = data.num_rows(); let t = "sxt.t".parse().unwrap(); let table_map = indexmap! { t => data.clone() @@ -192,7 +193,7 @@ fn we_can_get_an_empty_result_from_a_basic_filter_on_an_empty_table_using_first_ ColumnType::Decimal75(Precision::new(75).unwrap(), 0), ), ]; - let first_round_builder = &mut FirstRoundBuilder::new(0); + let first_round_builder = &mut FirstRoundBuilder::new(data_length); let res: OwnedTable = ProvableQueryResult::from(expr.first_round_evaluate( first_round_builder, &alloc, diff --git a/crates/proof-of-sql/src/sql/proof_plans/projection_exec_test.rs b/crates/proof-of-sql/src/sql/proof_plans/projection_exec_test.rs index ce9c49dc4..704f2d69d 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/projection_exec_test.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/projection_exec_test.rs @@ -157,6 +157,7 @@ fn we_can_get_an_empty_result_from_a_basic_projection_on_an_empty_table_using_fi borrowed_varchar("d", [""; 0], &alloc), borrowed_scalar("e", [0; 0], &alloc), ]); + let data_length = data.num_rows(); let t = "sxt.t".parse().unwrap(); let table_map = indexmap! { t => data.clone() @@ -174,7 +175,7 @@ fn we_can_get_an_empty_result_from_a_basic_projection_on_an_empty_table_using_fi ColumnType::Decimal75(Precision::new(75).unwrap(), 0), ), ]; - let first_round_builder = &mut FirstRoundBuilder::new(0); + let first_round_builder = &mut FirstRoundBuilder::new(data_length); let res: OwnedTable = ProvableQueryResult::from(expr.first_round_evaluate( first_round_builder, &alloc, diff --git a/crates/proof-of-sql/src/sql/proof_plans/slice_exec_test.rs b/crates/proof-of-sql/src/sql/proof_plans/slice_exec_test.rs index 789462364..04bfd5dbe 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/slice_exec_test.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/slice_exec_test.rs @@ -76,6 +76,7 @@ fn we_can_get_an_empty_result_from_a_slice_on_an_empty_table_using_first_round_e borrowed_varchar("d", [""; 0], &alloc), borrowed_scalar("e", [0; 0], &alloc), ]); + let data_length = data.num_rows(); let t = "sxt.t".parse().unwrap(); let table_map = indexmap! { t => data.clone() @@ -102,7 +103,7 @@ fn we_can_get_an_empty_result_from_a_slice_on_an_empty_table_using_first_round_e ColumnType::Decimal75(Precision::new(75).unwrap(), 0), ), ]; - let first_round_builder = &mut FirstRoundBuilder::new(0); + let first_round_builder = &mut FirstRoundBuilder::new(data_length); let res: OwnedTable = ProvableQueryResult::from(expr.first_round_evaluate( first_round_builder, &alloc, diff --git a/crates/proof-of-sql/src/sql/proof_plans/union_exec_test.rs b/crates/proof-of-sql/src/sql/proof_plans/union_exec_test.rs index 2bc54aef6..b32fb3f1e 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/union_exec_test.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/union_exec_test.rs @@ -248,6 +248,7 @@ fn we_can_get_result_from_union_using_first_round_evaluate() { borrowed_bigint("a0", [1_i64, 2, 3, 4, 5], &alloc), borrowed_varchar("b0", ["1", "2", "3", "4", "5"], &alloc), ]); + let len_0 = data0.num_rows(); let t0 = "sxt.t0".parse().unwrap(); let data1 = table([ borrowed_bigint("a1", [2_i64, 3, 4, 5, 6], &alloc), @@ -258,6 +259,11 @@ fn we_can_get_result_from_union_using_first_round_evaluate() { t0 => data0.clone(), t1 => data1.clone() }; + + let len_1 = data1.num_rows(); + + let data_length = std::cmp::max(len_0, len_1); + let mut accessor = TableTestAccessor::::new_empty_with_setup(()); accessor.add_table(t0, data0, 0); accessor.add_table(t1, data1, 0); @@ -272,7 +278,7 @@ fn we_can_get_result_from_union_using_first_round_evaluate() { ], fields.clone(), ); - let first_round_builder = &mut FirstRoundBuilder::new(0); + let first_round_builder = &mut FirstRoundBuilder::new(data_length); let res: OwnedTable = ProvableQueryResult::from(ast.first_round_evaluate( first_round_builder, &alloc,