|
35 | 35 | #include "execution/plans/seq_scan_plan.h" |
36 | 36 | #include "gtest/gtest.h" |
37 | 37 | #include "storage/b_plus_tree_test_util.h" // NOLINT |
| 38 | +#include "storage/table/tuple.h" |
38 | 39 | #include "type/value_factory.h" |
39 | 40 |
|
40 | 41 | namespace bustub { |
@@ -312,16 +313,18 @@ TEST_F(ExecutorTest, DISABLED_SimpleRawInsertWithIndexTest) { |
312 | 313 | std::vector<RID> rids; |
313 | 314 |
|
314 | 315 | // Get RID from index, fetch tuple and then compare |
315 | | - for (size_t i = 0; i < result_set.size(); ++i) { |
316 | | - index_info->index_->ScanKey(result_set[i], &rids, GetTxn()); |
| 316 | + for (auto &table_tuple : result_set) { |
| 317 | + rids.clear(); |
| 318 | + auto index_key = table_tuple.KeyFromTuple(schema, index_info->key_schema_, index_info->index_->GetKeyAttrs()); |
| 319 | + index_info->index_->ScanKey(index_key, &rids, GetTxn()); |
317 | 320 | Tuple indexed_tuple; |
318 | | - auto fetch_tuple = table_info->table_->GetTuple(rids[i], &indexed_tuple, GetTxn()); |
| 321 | + auto fetch_tuple = table_info->table_->GetTuple(rids[0], &indexed_tuple, GetTxn()); |
319 | 322 |
|
320 | 323 | ASSERT_TRUE(fetch_tuple); |
321 | 324 | ASSERT_EQ(indexed_tuple.GetValue(out_schema, out_schema->GetColIdx("colA")).GetAs<int32_t>(), |
322 | | - result_set[i].GetValue(out_schema, out_schema->GetColIdx("colA")).GetAs<int32_t>()); |
| 325 | + table_tuple.GetValue(out_schema, out_schema->GetColIdx("colA")).GetAs<int32_t>()); |
323 | 326 | ASSERT_EQ(indexed_tuple.GetValue(out_schema, out_schema->GetColIdx("colB")).GetAs<int32_t>(), |
324 | | - result_set[i].GetValue(out_schema, out_schema->GetColIdx("colB")).GetAs<int32_t>()); |
| 327 | + table_tuple.GetValue(out_schema, out_schema->GetColIdx("colB")).GetAs<int32_t>()); |
325 | 328 |
|
326 | 329 | std::cout << indexed_tuple.GetValue(out_schema, out_schema->GetColIdx("colA")).GetAs<int32_t>() << ", " |
327 | 330 | << indexed_tuple.GetValue(out_schema, out_schema->GetColIdx("colB")).GetAs<int32_t>() << std::endl; |
|
0 commit comments