Skip to content

Commit 11ca095

Browse files
committed
fix: incorrect remapped primary key indices
1 parent f7de8b9 commit 11ca095

File tree

3 files changed

+19
-30
lines changed

3 files changed

+19
-30
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ run `cargo run -p tpcc --release` to run tpcc
6767
- Tips: TPC-C currently only supports single thread
6868
```shell
6969
<90th Percentile RT (MaxRT)>
70-
New-Order : 0.002 (0.004)
71-
Payment : 0.001 (0.025)
72-
Order-Status : 0.053 (0.175)
73-
Delivery : 0.022 (0.027)
74-
Stock-Level : 0.003 (0.019)
70+
New-Order : 0.002 (0.025)
71+
Payment : 0.001 (0.013)
72+
Order-Status : 0.054 (0.159)
73+
Delivery : 0.020 (0.034)
74+
Stock-Level : 0.003 (0.004)
7575
<TpmC>
76-
7815 tpmC
76+
7892 Tpmc
7777
```
7878
#### 👉[check more](tpcc/README.md)
7979

src/execution/dql/index_scan.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,15 @@ impl<'a, T: Transaction + 'a> ReadExecutor<'a, T> for IndexScan {
4343
..
4444
} = self.op;
4545

46-
let mut iter = unsafe { &(*transaction) }
47-
.read_by_index(
48-
table_cache,
49-
table_name,
50-
limit,
51-
columns,
52-
self.index_by,
53-
self.ranges,
54-
with_pk,
55-
)
56-
.unwrap();
46+
let mut iter = throw!(unsafe { &(*transaction) }.read_by_index(
47+
table_cache,
48+
table_name,
49+
limit,
50+
columns,
51+
self.index_by,
52+
self.ranges,
53+
with_pk,
54+
));
5755

5856
while let Some(tuple) = throw!(iter.next_tuple()) {
5957
yield Ok(tuple);

src/storage/mod.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,19 +1208,10 @@ pub trait Iter {
12081208
}
12091209

12101210
fn remap_pk_indices(projection: &[usize], pk_indices: &[usize]) -> Vec<usize> {
1211-
let mut result = Vec::with_capacity(pk_indices.len());
1212-
let mut proj_idx = 0;
1213-
let mut pk_idx = 0;
1214-
1215-
while pk_idx < pk_indices.len() && proj_idx < projection.len() {
1216-
if projection[proj_idx] == pk_indices[pk_idx] {
1217-
result.push(proj_idx);
1218-
pk_idx += 1;
1219-
} else {
1220-
proj_idx += 1;
1221-
}
1222-
}
1223-
result
1211+
pk_indices
1212+
.iter()
1213+
.filter_map(|pk| projection.binary_search(pk).ok())
1214+
.collect()
12241215
}
12251216

12261217
#[cfg(test)]

0 commit comments

Comments
 (0)