From 11ca0953f31776a5c26a3246d8208acf8ed07ccc Mon Sep 17 00:00:00 2001 From: Kould Date: Wed, 16 Jul 2025 12:11:16 +0800 Subject: [PATCH] fix: incorrect remapped primary key indices --- README.md | 12 ++++++------ src/execution/dql/index_scan.rs | 20 +++++++++----------- src/storage/mod.rs | 17 ++++------------- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index ef492051..ca772d91 100755 --- a/README.md +++ b/README.md @@ -67,13 +67,13 @@ run `cargo run -p tpcc --release` to run tpcc - Tips: TPC-C currently only supports single thread ```shell <90th Percentile RT (MaxRT)> - New-Order : 0.002 (0.004) - Payment : 0.001 (0.025) -Order-Status : 0.053 (0.175) - Delivery : 0.022 (0.027) - Stock-Level : 0.003 (0.019) + New-Order : 0.002 (0.025) + Payment : 0.001 (0.013) +Order-Status : 0.054 (0.159) + Delivery : 0.020 (0.034) + Stock-Level : 0.003 (0.004) -7815 tpmC +7892 Tpmc ``` #### 👉[check more](tpcc/README.md) diff --git a/src/execution/dql/index_scan.rs b/src/execution/dql/index_scan.rs index c218aac8..8844db53 100644 --- a/src/execution/dql/index_scan.rs +++ b/src/execution/dql/index_scan.rs @@ -43,17 +43,15 @@ impl<'a, T: Transaction + 'a> ReadExecutor<'a, T> for IndexScan { .. } = self.op; - let mut iter = unsafe { &(*transaction) } - .read_by_index( - table_cache, - table_name, - limit, - columns, - self.index_by, - self.ranges, - with_pk, - ) - .unwrap(); + let mut iter = throw!(unsafe { &(*transaction) }.read_by_index( + table_cache, + table_name, + limit, + columns, + self.index_by, + self.ranges, + with_pk, + )); while let Some(tuple) = throw!(iter.next_tuple()) { yield Ok(tuple); diff --git a/src/storage/mod.rs b/src/storage/mod.rs index c2d0d532..67aad752 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -1208,19 +1208,10 @@ pub trait Iter { } fn remap_pk_indices(projection: &[usize], pk_indices: &[usize]) -> Vec { - let mut result = Vec::with_capacity(pk_indices.len()); - let mut proj_idx = 0; - let mut pk_idx = 0; - - while pk_idx < pk_indices.len() && proj_idx < projection.len() { - if projection[proj_idx] == pk_indices[pk_idx] { - result.push(proj_idx); - pk_idx += 1; - } else { - proj_idx += 1; - } - } - result + pk_indices + .iter() + .filter_map(|pk| projection.binary_search(pk).ok()) + .collect() } #[cfg(test)]