Skip to content

Commit 3cf0f01

Browse files
Claude feedback round 2
1 parent bea5280 commit 3cf0f01

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

‎src/mysql-util/src/partition.rs‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ async fn children_prefixes<D: PrimaryKeyProber>(
180180
}
181181
}
182182

183-
/// Wrapper around [KeyProber] for testing purposes. See [KeyProber] for more details.
183+
/// Probing operations of [`KeyProber`], as a trait so tests can substitute
184+
/// an in-memory implementation. See [`KeyProber`]'s methods for each
185+
/// operation's contract.
184186
trait PrimaryKeyProber {
185187
async fn estimate_range_rows(
186188
&mut self,
@@ -240,7 +242,9 @@ mod tests {
240242
use crate::probe::tests::{connect, drop_db, setup_table};
241243

242244
/// In-memory [`PrimaryKeyProber`] over a sorted key list with exact
243-
/// "estimates". Byte order stands in for the collation.
245+
/// "estimates". Byte order stands in for the collation, so the PAD SPACE
246+
/// below-space cases are deliberately out of scope here, the live tests
247+
/// cover them.
244248
struct MockDb {
245249
keys: Vec<String>,
246250
}
@@ -356,7 +360,7 @@ mod tests {
356360
}
357361

358362
#[mz_ore::test(tokio::test)]
359-
async fn low_min_bucket_rows_splits_small_tables() -> Result<(), MySqlError> {
363+
async fn low_min_rows_per_worker_splits_small_tables() -> Result<(), MySqlError> {
360364
let mut db = MockDb { keys: keys(1000) };
361365
let count = u64::cast_from(db.keys.len());
362366
let boundaries = partition(&mut db, 4, count, 10).await?;
@@ -423,6 +427,7 @@ mod tests {
423427
"c_1".to_string(),
424428
"c%2".to_string(),
425429
"c\\3".to_string(),
430+
"c|4".to_string(),
426431
];
427432
all_keys.extend((0..900).map(|i| format!("a{i:05}")));
428433
all_keys.extend((0..100).map(|i| format!("b{i:05}")));
@@ -438,7 +443,7 @@ mod tests {
438443
// A low minimum splits inside the 'a' extensions rather than stopping
439444
// at the exact key.
440445
let bounds = partition_table(&mut conn, table, "id", 4, total, 10).await?;
441-
assert!(bounds.len() == 3, "{bounds:?}");
446+
assert_eq!(bounds.len(), 3, "{bounds:?}");
442447

443448
// MySQL agrees the boundaries are strictly increasing.
444449
for pair in bounds.windows(2) {
@@ -486,10 +491,11 @@ mod tests {
486491
let bounds = partition_table(&mut conn, table, "id", 4, total, 250).await?;
487492
assert_eq!(bounds.len(), 3);
488493
let counts = partition_counts(&mut conn, DB, &bounds, total).await?;
489-
// ~8k are visible, so each count should have at least 2k for perfect partitioning and the ranges are
490-
// cleanly partitionable except for the hidden tab prefixes, so we should be reliably able to assert
491-
// that each count is greater than 1600 -- this makes room for single partitions being misallocated (~250)
492-
// and some inaccuracy on top of that (~150).
494+
// ~8k keys are visible, so each count gets at least 2k under perfect
495+
// partitioning, and the ranges partition cleanly except for the
496+
// hidden tab prefixes. Asserting each count above 1600 makes room
497+
// for single partitions being misallocated (~250) and some
498+
// inaccuracy on top of that (~150).
493499
assert!(counts.iter().all(|&c| c > 1600), "{counts:?}");
494500

495501
// Each hidden group piles into the partition left of the next visible

0 commit comments

Comments
 (0)