diff --git a/grovedb/src/element/query.rs b/grovedb/src/element/query.rs index 8c412cdc0..cc9149493 100644 --- a/grovedb/src/element/query.rs +++ b/grovedb/src/element/query.rs @@ -59,6 +59,20 @@ use crate::{ #[cfg(any(feature = "full", feature = "verify"))] use crate::{Element, SizedQuery}; +#[cfg(feature = "full")] +#[derive(Copy, Clone, Debug)] +pub struct QueryOptions { + pub allow_get_raw: bool, + pub allow_cache: bool, + /// Should we decrease the limit of elements found when we have no + /// subelements in the subquery? This should generally be set to true, + /// as having it false could mean very expensive queries. The queries + /// would be expensive because we could go through many many trees where the + /// sub elements have no matches, hence the limit would not decrease and + /// hence we would continue on the increasingly expensive query. + pub decrease_limit_on_range_with_no_sub_elements: bool, +} + #[cfg(feature = "full")] /// Path query push arguments pub struct PathQueryPushArgs<'db, 'ctx, 'a> @@ -73,8 +87,7 @@ where pub subquery_path: Option, pub subquery: Option, pub left_to_right: bool, - pub allow_get_raw: bool, - pub allow_cache: bool, + pub query_options: QueryOptions, pub result_type: QueryResultType, pub results: &'a mut Vec, pub limit: &'a mut Option, @@ -97,6 +110,7 @@ impl Element { merk_path, &sized_query, true, + true, result_type, transaction, ) @@ -139,8 +153,7 @@ impl Element { storage: &RocksDbStorage, path: &[&[u8]], sized_query: &SizedQuery, - allow_get_raw: bool, - allow_cache: bool, + query_options: QueryOptions, result_type: QueryResultType, transaction: TransactionArg, add_element_function: fn(PathQueryPushArgs) -> CostResult<(), Error>, @@ -166,8 +179,7 @@ impl Element { transaction, &mut limit, &mut offset, - allow_get_raw, - allow_cache, + query_options, result_type, add_element_function, ) @@ -189,8 +201,7 @@ impl Element { transaction, &mut limit, &mut offset, - allow_get_raw, - allow_cache, + query_options, result_type, add_element_function, ) @@ -216,6 +227,7 @@ impl Element { storage: &RocksDbStorage, path_query: &PathQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, result_type: QueryResultType, transaction: TransactionArg, ) -> CostResult<(QueryResultElements, u16), Error> { @@ -228,8 +240,11 @@ impl Element { storage, path_slices.as_slice(), &path_query.query, - false, - allow_cache, + QueryOptions { + allow_get_raw: false, + allow_cache, + decrease_limit_on_range_with_no_sub_elements, + }, result_type, transaction, Element::path_query_push, @@ -243,6 +258,7 @@ impl Element { storage: &RocksDbStorage, path_query: &PathQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, result_type: QueryResultType, transaction: TransactionArg, ) -> CostResult<(QueryResultElements, u16), Error> { @@ -255,8 +271,11 @@ impl Element { storage, path_slices.as_slice(), &path_query.query, - true, - allow_cache, + QueryOptions { + allow_get_raw: true, + allow_cache, + decrease_limit_on_range_with_no_sub_elements, + }, result_type, transaction, Element::path_query_push, @@ -270,6 +289,7 @@ impl Element { path: &[&[u8]], sized_query: &SizedQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, result_type: QueryResultType, transaction: TransactionArg, ) -> CostResult<(QueryResultElements, u16), Error> { @@ -277,8 +297,11 @@ impl Element { storage, path, sized_query, - false, - allow_cache, + QueryOptions { + allow_get_raw: false, + allow_cache, + decrease_limit_on_range_with_no_sub_elements, + }, result_type, transaction, Element::path_query_push, @@ -299,13 +322,17 @@ impl Element { subquery_path, subquery, left_to_right, - allow_get_raw, - allow_cache, + query_options, result_type, results, limit, offset, } = args; + let QueryOptions { + allow_get_raw, + allow_cache, + decrease_limit_on_range_with_no_sub_elements, + } = query_options; if element.is_tree() { let mut path_vec = path.to_vec(); let key = cost_return_on_error_no_add!( @@ -331,13 +358,19 @@ impl Element { storage, &inner_path_query, allow_cache, + decrease_limit_on_range_with_no_sub_elements, result_type, transaction ) ); if let Some(limit) = limit { - *limit = limit.saturating_sub(sub_elements.len() as u16); + if sub_elements.is_empty() && decrease_limit_on_range_with_no_sub_elements { + // we should decrease by 1 in this case + *limit = limit.saturating_sub(1); + } else { + *limit = limit.saturating_sub(sub_elements.len() as u16); + } } if let Some(offset) = offset { *offset = offset.saturating_sub(skipped); @@ -455,8 +488,7 @@ impl Element { subquery_path, subquery, left_to_right, - allow_get_raw, - allow_cache, + query_options, result_type, results, limit, @@ -483,8 +515,7 @@ impl Element { subquery_path, subquery, left_to_right, - allow_get_raw, - allow_cache, + query_options, result_type, results, limit, @@ -530,6 +561,12 @@ impl Element { (subquery_path, subquery) } + /// `decrease_limit_on_range_with_no_sub_elements` should generally be set + /// to true, as having it false could mean very expensive queries. + /// The queries would be expensive because we could go through many many + /// trees where the sub elements have no matches, hence the limit would + /// not decrease and hence we would continue on the increasingly + /// expensive query. #[cfg(feature = "full")] // TODO: refactor fn query_item( @@ -541,8 +578,7 @@ impl Element { transaction: TransactionArg, limit: &mut Option, offset: &mut Option, - allow_get_raw: bool, - allow_cache: bool, + query_options: QueryOptions, result_type: QueryResultType, add_element_function: fn(PathQueryPushArgs) -> CostResult<(), Error>, ) -> CostResult<(), Error> { @@ -560,7 +596,10 @@ impl Element { None, transaction, subtree, - { Element::get(&subtree, key, allow_cache).unwrap_add_cost(&mut cost) } + { + Element::get(&subtree, key, query_options.allow_cache) + .unwrap_add_cost(&mut cost) + } ); match element_res { Ok(element) => { @@ -575,8 +614,7 @@ impl Element { subquery_path, subquery, left_to_right: sized_query.query.left_to_right, - allow_get_raw, - allow_cache, + query_options, result_type, results, limit, @@ -630,8 +668,7 @@ impl Element { subquery_path, subquery, left_to_right: sized_query.query.left_to_right, - allow_get_raw, - allow_cache, + query_options, result_type, results, limit, @@ -939,6 +976,7 @@ mod tests { &[TEST_LEAF], &ascending_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -973,6 +1011,7 @@ mod tests { &[TEST_LEAF], &backwards_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1062,6 +1101,7 @@ mod tests { &[TEST_LEAF], &ascending_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1079,6 +1119,7 @@ mod tests { &[TEST_LEAF], &backwards_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1099,6 +1140,7 @@ mod tests { &[TEST_LEAF], &backwards_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1161,6 +1203,7 @@ mod tests { &[TEST_LEAF], &backwards_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1187,6 +1230,7 @@ mod tests { &[TEST_LEAF], &backwards_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1208,6 +1252,7 @@ mod tests { &[TEST_LEAF], &limit_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1229,6 +1274,7 @@ mod tests { &[TEST_LEAF], &limit_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1249,6 +1295,7 @@ mod tests { &[TEST_LEAF], &limit_offset_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1274,6 +1321,7 @@ mod tests { &[TEST_LEAF], &limit_offset_backwards_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1298,6 +1346,7 @@ mod tests { &[TEST_LEAF], &limit_full_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1323,6 +1372,7 @@ mod tests { &[TEST_LEAF], &limit_offset_backwards_query, true, + true, QueryKeyElementPairResultType, None, ) @@ -1348,6 +1398,7 @@ mod tests { &[TEST_LEAF], &limit_backwards_query, true, + true, QueryKeyElementPairResultType, None, ) diff --git a/grovedb/src/operations/get/query.rs b/grovedb/src/operations/get/query.rs index 2dbd89b8c..efdcfa637 100644 --- a/grovedb/src/operations/get/query.rs +++ b/grovedb/src/operations/get/query.rs @@ -51,6 +51,7 @@ impl GroveDb { &self, path_queries: &[&PathQuery], allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, transaction: TransactionArg, ) -> CostResult>, Error> { let mut cost = OperationCost::default(); @@ -60,6 +61,7 @@ impl GroveDb { self.query_many_raw( path_queries, allow_cache, + decrease_limit_on_range_with_no_sub_elements, QueryResultType::QueryElementResultType, transaction ) @@ -109,6 +111,7 @@ impl GroveDb { &self, path_queries: &[&PathQuery], allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, result_type: QueryResultType, transaction: TransactionArg, ) -> CostResult @@ -118,7 +121,13 @@ where { let query = cost_return_on_error_no_add!(&cost, PathQuery::merge(path_queries.to_vec())); let (result, _) = cost_return_on_error!( &mut cost, - self.query_raw(&query, allow_cache, result_type, transaction) + self.query_raw( + &query, + allow_cache, + decrease_limit_on_range_with_no_sub_elements, + result_type, + transaction + ) ); Ok(result).wrap_with_cost(cost) } @@ -189,6 +198,7 @@ where { &self, path_query: &PathQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, result_type: QueryResultType, transaction: TransactionArg, ) -> CostResult<(QueryResultElements, u16), Error> { @@ -196,7 +206,13 @@ where { let (elements, skipped) = cost_return_on_error!( &mut cost, - self.query_raw(path_query, allow_cache, result_type, transaction) + self.query_raw( + path_query, + allow_cache, + decrease_limit_on_range_with_no_sub_elements, + result_type, + transaction + ) ); let results_wrapped = elements @@ -218,6 +234,7 @@ where { &self, path_query: &PathQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, transaction: TransactionArg, ) -> CostResult<(Vec>, u16), Error> { let mut cost = OperationCost::default(); @@ -227,6 +244,7 @@ where { self.query_raw( path_query, allow_cache, + decrease_limit_on_range_with_no_sub_elements, QueryResultType::QueryElementResultType, transaction ) @@ -288,6 +306,7 @@ where { &self, path_query: &PathQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, transaction: TransactionArg, ) -> CostResult<(Vec, u16), Error> { let mut cost = OperationCost::default(); @@ -297,6 +316,7 @@ where { self.query_raw( path_query, allow_cache, + decrease_limit_on_range_with_no_sub_elements, QueryResultType::QueryElementResultType, transaction ) @@ -360,10 +380,18 @@ where { &self, path_query: &PathQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, result_type: QueryResultType, transaction: TransactionArg, ) -> CostResult<(QueryResultElements, u16), Error> { - Element::get_raw_path_query(&self.db, path_query, allow_cache, result_type, transaction) + Element::get_raw_path_query( + &self.db, + path_query, + allow_cache, + decrease_limit_on_range_with_no_sub_elements, + result_type, + transaction, + ) } /// Splits the result set of a path query by query path. @@ -372,6 +400,7 @@ where { &self, path_query: &PathQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, transaction: TransactionArg, ) -> CostResult, Error> { let max_results = cost_return_on_error_default!(path_query.query.limit.ok_or( @@ -393,6 +422,7 @@ where { self.query( path_query, allow_cache, + decrease_limit_on_range_with_no_sub_elements, QueryResultType::QueryPathKeyElementTrioResultType, transaction ) @@ -415,6 +445,7 @@ where { &self, path_query: &PathQuery, allow_cache: bool, + decrease_limit_on_range_with_no_sub_elements: bool, transaction: TransactionArg, ) -> CostResult, Error> { let max_results = cost_return_on_error_default!(path_query.query.limit.ok_or( @@ -436,6 +467,7 @@ where { self.query_raw( path_query, allow_cache, + decrease_limit_on_range_with_no_sub_elements, QueryResultType::QueryPathKeyElementTrioResultType, transaction ) @@ -507,7 +539,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path.clone(), SizedQuery::new(query, Some(5), None)); let raw_result = db - .query_raw_keys_optional(&path_query, true, None) + .query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("should get successfully"); @@ -563,7 +595,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path.clone(), SizedQuery::new(query, Some(5), None)); let raw_result = db - .query_raw_keys_optional(&path_query, true, None) + .query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("should get successfully"); @@ -620,7 +652,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path.clone(), SizedQuery::new(query, Some(5), None)); let raw_result = db - .query_raw_keys_optional(&path_query, true, None) + .query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("should get successfully"); @@ -688,7 +720,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(4), None)); - db.query_raw_keys_optional(&path_query, true, None) + db.query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect_err("range a should error"); @@ -697,7 +729,7 @@ mod tests { query.insert_key(b"5".to_vec()); // 3 let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(3), None)); - db.query_raw_keys_optional(&path_query, true, None) + db.query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("range b should not error"); @@ -706,7 +738,7 @@ mod tests { query.insert_key(b"5".to_vec()); // 4 let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(3), None)); - db.query_raw_keys_optional(&path_query, true, None) + db.query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect_err("range c should error"); @@ -715,7 +747,7 @@ mod tests { query.insert_key(b"5".to_vec()); // 3 let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(2), None)); - db.query_raw_keys_optional(&path_query, true, None) + db.query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect_err("range d should error"); @@ -723,7 +755,7 @@ mod tests { query.insert_range(b"z".to_vec()..b"10".to_vec()); let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(1000), None)); - db.query_raw_keys_optional(&path_query, true, None) + db.query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect_err("range using 2 bytes should error"); } @@ -774,7 +806,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path.clone(), SizedQuery::new(query, Some(1000), None)); let raw_result = db - .query_raw_keys_optional(&path_query, true, None) + .query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("range starting with null should not error"); @@ -857,7 +889,7 @@ mod tests { query.insert_range(b"".to_vec()..b"c".to_vec()); let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(1000), None)); - db.query_keys_optional(&path_query, true, None) + db.query_keys_optional(&path_query, true, true, None) .unwrap() .expect_err("range should error because we didn't subquery"); @@ -867,7 +899,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(1000), None)); let raw_result = db - .query_raw_keys_optional(&path_query, true, None) + .query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("query with subquery should not error"); @@ -975,7 +1007,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(1000), None)); let raw_result = db - .query_raw_keys_optional(&path_query, true, None) + .query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("query with subquery should not error"); @@ -1123,7 +1155,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(1000), None)); let raw_result = db - .query_raw_keys_optional(&path_query, true, None) + .query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("query with subquery should not error"); @@ -1290,7 +1322,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(1000), None)); let raw_result = db - .query_raw_keys_optional(&path_query, true, None) + .query_raw_keys_optional(&path_query, true, true, None) .unwrap() .expect("query with subquery should not error"); @@ -1470,7 +1502,7 @@ mod tests { let path = vec![TEST_LEAF.to_vec()]; let path_query = PathQuery::new(path, SizedQuery::new(query, Some(1000), None)); let result = db - .query_keys_optional(&path_query, true, None) + .query_keys_optional(&path_query, true, true, None) .unwrap() .expect("query with subquery should not error"); diff --git a/grovedb/src/query/mod.rs b/grovedb/src/query/mod.rs index 7563dc73d..ce052cb95 100644 --- a/grovedb/src/query/mod.rs +++ b/grovedb/src/query/mod.rs @@ -534,6 +534,7 @@ mod tests { .query_raw( &merged_path_query, true, + true, QueryResultType::QueryPathKeyElementTrioResultType, None, ) @@ -826,6 +827,7 @@ mod tests { .query_raw( &merged_path_query, true, + true, QueryResultType::QueryPathKeyElementTrioResultType, None, ) diff --git a/grovedb/src/reference_path.rs b/grovedb/src/reference_path.rs index 41dd9b6b5..359628e6c 100644 --- a/grovedb/src/reference_path.rs +++ b/grovedb/src/reference_path.rs @@ -387,7 +387,7 @@ mod tests { let path_query = PathQuery::new_unsized(vec![TEST_LEAF.to_vec(), b"innertree4".to_vec()], query); let result = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("should query items"); assert_eq!(result.0.len(), 5); diff --git a/grovedb/src/tests/mod.rs b/grovedb/src/tests/mod.rs index 451b2307a..3d9052245 100644 --- a/grovedb/src/tests/mod.rs +++ b/grovedb/src/tests/mod.rs @@ -541,7 +541,7 @@ fn test_element_with_flags() { SizedQuery::new(query, None, None), ); let (flagged_ref_no_follow, _) = db - .query_raw(&path_query, true, QueryKeyElementPairResultType, None) + .query_raw(&path_query, true, true, QueryKeyElementPairResultType, None) .unwrap() .expect("should get successfully"); @@ -2622,6 +2622,7 @@ fn test_get_full_query() { db.query_many_raw( &[&path_query1, &path_query2], true, + true, QueryKeyElementPairResultType, None ) diff --git a/grovedb/src/tests/query_tests.rs b/grovedb/src/tests/query_tests.rs index 7d5fc6804..830a18e0a 100644 --- a/grovedb/src/tests/query_tests.rs +++ b/grovedb/src/tests/query_tests.rs @@ -365,7 +365,7 @@ fn test_get_range_query_with_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -402,7 +402,7 @@ fn test_get_range_query_with_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -437,7 +437,7 @@ fn test_get_range_query_with_unique_subquery_on_references() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -481,7 +481,7 @@ fn test_get_range_query_with_unique_subquery_with_non_unique_null_values() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -524,7 +524,7 @@ fn test_get_range_query_with_unique_subquery_ignore_non_unique_null_values() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -562,7 +562,7 @@ fn test_get_range_inclusive_query_with_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -602,7 +602,7 @@ fn test_get_range_inclusive_query_with_non_unique_subquery_on_references() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -642,7 +642,7 @@ fn test_get_range_inclusive_query_with_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -680,7 +680,7 @@ fn test_get_range_from_query_with_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -717,7 +717,7 @@ fn test_get_range_from_query_with_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -755,7 +755,7 @@ fn test_get_range_to_query_with_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -792,7 +792,7 @@ fn test_get_range_to_query_with_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -830,7 +830,7 @@ fn test_get_range_to_inclusive_query_with_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -870,7 +870,7 @@ fn test_get_range_to_inclusive_query_with_non_unique_subquery_and_key_out_of_bou let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -907,7 +907,7 @@ fn test_get_range_to_inclusive_query_with_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -945,7 +945,7 @@ fn test_get_range_after_query_with_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -985,7 +985,7 @@ fn test_get_range_after_to_query_with_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1027,7 +1027,7 @@ fn test_get_range_after_to_inclusive_query_with_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1069,7 +1069,7 @@ fn test_get_range_after_to_inclusive_query_with_non_unique_subquery_and_key_out_ let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1117,7 +1117,7 @@ fn test_get_range_inclusive_query_with_double_non_unique_subquery() { let path_query = PathQuery::new_unsized(path, query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1156,7 +1156,7 @@ fn test_get_range_query_with_limit_and_offset() { let path_query = PathQuery::new(path.clone(), SizedQuery::new(query.clone(), None, None)); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1187,7 +1187,7 @@ fn test_get_range_query_with_limit_and_offset() { let path_query = PathQuery::new(path.clone(), SizedQuery::new(query.clone(), None, None)); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1218,7 +1218,7 @@ fn test_get_range_query_with_limit_and_offset() { let path_query = PathQuery::new(path.clone(), SizedQuery::new(query.clone(), Some(55), None)); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1249,7 +1249,7 @@ fn test_get_range_query_with_limit_and_offset() { ); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1287,7 +1287,7 @@ fn test_get_range_query_with_limit_and_offset() { ); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1322,7 +1322,7 @@ fn test_get_range_query_with_limit_and_offset() { ); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1343,7 +1343,7 @@ fn test_get_range_query_with_limit_and_offset() { ); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1366,7 +1366,7 @@ fn test_get_range_query_with_limit_and_offset() { let path_query = PathQuery::new(path, SizedQuery::new(query.clone(), Some(5), Some(2))); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("expected successful get_path_query"); @@ -1609,7 +1609,7 @@ fn test_mixed_level_proofs() { let path_query = PathQuery::new_unsized(path.clone(), query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("successful get_path_query"); @@ -1625,7 +1625,7 @@ fn test_mixed_level_proofs() { // Test mixed element proofs with limit and offset let path_query = PathQuery::new_unsized(path.clone(), query.clone()); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("successful get_path_query"); @@ -1642,7 +1642,7 @@ fn test_mixed_level_proofs() { let path_query = PathQuery::new(path.clone(), SizedQuery::new(query.clone(), Some(1), None)); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("successful get_path_query"); @@ -1660,7 +1660,7 @@ fn test_mixed_level_proofs() { SizedQuery::new(query.clone(), Some(3), Some(0)), ); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("successful get_path_query"); @@ -1678,7 +1678,7 @@ fn test_mixed_level_proofs() { SizedQuery::new(query.clone(), Some(4), Some(0)), ); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("successful get_path_query"); @@ -1693,7 +1693,7 @@ fn test_mixed_level_proofs() { let path_query = PathQuery::new(path, SizedQuery::new(query.clone(), Some(10), Some(4))); let (elements, _) = db - .query_item_value(&path_query, true, None) + .query_item_value(&path_query, true, true, None) .unwrap() .expect("successful get_path_query"); @@ -1789,6 +1789,7 @@ fn test_mixed_level_proofs_with_tree() { .query_raw( &path_query, true, + true, QueryResultType::QueryPathKeyElementTrioResultType, None, ) @@ -1811,6 +1812,7 @@ fn test_mixed_level_proofs_with_tree() { .query_raw( &path_query, true, + true, QueryResultType::QueryPathKeyElementTrioResultType, None, ) diff --git a/node-grove/src/lib.rs b/node-grove/src/lib.rs index 26eb5188a..a955b744e 100644 --- a/node-grove/src/lib.rs +++ b/node-grove/src/lib.rs @@ -663,6 +663,7 @@ impl GroveDbWrapper { .query_item_value( &path_query, allows_cache, + true, using_transaction.then_some(transaction).flatten(), ) .unwrap(); // Todo: Costs;