Skip to content

Commit df4c3f6

Browse files
LaurentiuCristoforLaurentiu Cristofor
andauthored
Cleanup of index scan test (#1540)
Co-authored-by: Laurentiu Cristofor <[email protected]>
1 parent 53b428e commit df4c3f6

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

production/db/query_processor/tests/test_index_scan.cpp

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ using namespace gaia::direct_access;
2525
using namespace gaia::db::query_processor::scan;
2626
using namespace gaia::catalog;
2727
using namespace gaia::db::index;
28+
using namespace gaia::db::catalog_core;
2829

2930
constexpr size_t c_num_initial_rows = 20;
3031
constexpr size_t c_query_limit_rows = 5;
@@ -73,10 +74,10 @@ TEST_F(db__query_processor__index_scan__test, verify_cardinality)
7374

7475
gaia_id_t table_id = type_id_mapping_t::instance().get_table_id(gaia::index_sandbox::sandbox_t::s_gaia_type);
7576

76-
for (const auto& idx : catalog_core::list_indexes(table_id))
77+
for (const index_view_t& index : list_indexes(table_id))
7778
{
7879
// Open an index scan operator for this operator.
79-
auto scan = index_scan_t(idx.id());
80+
auto scan = index_scan_t(index.id());
8081
size_t scan_count = 0;
8182
for (const auto& p : scan)
8283
{
@@ -95,7 +96,7 @@ TEST_F(db__query_processor__index_scan__test, verify_cardinality_empty)
9596

9697
gaia_id_t table_id = type_id_mapping_t::instance().get_table_id(gaia::index_sandbox::empty_t::s_gaia_type);
9798

98-
for (const auto& index : catalog_core::list_indexes(table_id))
99+
for (const index_view_t& index : list_indexes(table_id))
99100
{
100101
auto scan = index_scan_t(index.id());
101102
size_t scan_count = 0;
@@ -118,10 +119,10 @@ TEST_F(db__query_processor__index_scan__test, test_limits)
118119

119120
gaia_id_t table_id = type_id_mapping_t::instance().get_table_id(gaia::index_sandbox::sandbox_t::s_gaia_type);
120121

121-
for (const auto& idx : catalog_core::list_indexes(table_id))
122+
for (const index_view_t& index : list_indexes(table_id))
122123
{
123124
// Open an index scan operator for this operator with the fixed limit.
124-
auto scan = index_scan_t(idx.id(), nullptr, limit);
125+
auto scan = index_scan_t(index.id(), nullptr, limit);
125126
size_t scan_count = 0;
126127
for (const auto& p : scan)
127128
{
@@ -132,7 +133,7 @@ TEST_F(db__query_processor__index_scan__test, test_limits)
132133
EXPECT_TRUE(limit == scan_count);
133134

134135
// Open an index scan operator for this operator with limit 0.
135-
auto scan2 = index_scan_t(idx.id(), nullptr, 0);
136+
auto scan2 = index_scan_t(index.id(), nullptr, 0);
136137
scan_count = 0;
137138
for (const auto& p : scan2)
138139
{
@@ -143,7 +144,7 @@ TEST_F(db__query_processor__index_scan__test, test_limits)
143144
EXPECT_TRUE(0 == scan_count);
144145

145146
// Open an index scan operator for this operator with limit 1.
146-
auto scan3 = index_scan_t(idx.id(), nullptr, 1);
147+
auto scan3 = index_scan_t(index.id(), nullptr, 1);
147148
scan_count = 0;
148149
for (const auto& p : scan3)
149150
{
@@ -154,7 +155,7 @@ TEST_F(db__query_processor__index_scan__test, test_limits)
154155
EXPECT_TRUE(1 == scan_count);
155156

156157
// Open an index scan operator for this operator greater than the number of rows.
157-
auto scan4 = index_scan_t(idx.id(), nullptr, c_num_initial_rows + 1);
158+
auto scan4 = index_scan_t(index.id(), nullptr, c_num_initial_rows + 1);
158159
scan_count = 0;
159160
for (const auto& p : scan4)
160161
{
@@ -175,11 +176,11 @@ TEST_F(db__query_processor__index_scan__test, query_single_match)
175176

176177
auto_transaction_t txn;
177178

178-
for (const auto& index : catalog_core::list_indexes(table_id))
179+
for (const index_view_t& index : list_indexes(table_id))
179180
{
180-
for (const auto& field_id : *index.fields())
181+
for (const gaia::common::gaia_id_t field_id : *index.fields())
181182
{
182-
const auto& field = catalog_core::field_view_t(gaia::db::id_to_ptr(field_id));
183+
const auto& field = field_view_t(gaia::db::id_to_ptr(field_id));
183184
if (field.data_type() == data_type_t::e_int32 && !field.optional() && index.type() == index_type_t::range)
184185
{
185186
range_index_id = index.id();
@@ -252,11 +253,11 @@ TEST_F(db__query_processor__index_scan__test, query_multi_match)
252253

253254
auto_transaction_t txn;
254255

255-
for (const auto& index : catalog_core::list_indexes(table_id))
256+
for (const index_view_t& index : list_indexes(table_id))
256257
{
257-
for (const auto& field_id : *index.fields())
258+
for (const gaia::common::gaia_id_t field_id : *index.fields())
258259
{
259-
const auto& field = catalog_core::field_view_t(gaia::db::id_to_ptr(field_id));
260+
const auto& field = field_view_t(gaia::db::id_to_ptr(field_id));
260261
if (field.data_type() == data_type_t::e_string && index.type() == index_type_t::range)
261262
{
262263
range_index_id = index.id();
@@ -326,11 +327,11 @@ TEST_F(db__query_processor__index_scan__test, query_match_optional)
326327

327328
auto_transaction_t txn;
328329

329-
for (const auto& index : catalog_core::list_indexes(table_id))
330+
for (const index_view_t& index : catalog_core::list_indexes(table_id))
330331
{
331-
for (const auto& field_id : *index.fields())
332+
for (const auto field_id : *index.fields())
332333
{
333-
const auto& field = catalog_core::field_view_t(gaia::db::id_to_ptr(field_id));
334+
const auto& field = field_view_t(gaia::db::id_to_ptr(field_id));
334335

335336
if (field.data_type() == data_type_t::e_int32 && field.optional() && index.type() == index_type_t::range)
336337
{
@@ -408,11 +409,11 @@ TEST_F(db__query_processor__index_scan__test, query_local_modify_no_match)
408409
w.i = -1;
409410
w.insert_row();
410411

411-
for (const auto& index : catalog_core::list_indexes(table_id))
412+
for (const index_view_t& index : list_indexes(table_id))
412413
{
413-
for (const auto& field_id : *index.fields())
414+
for (const gaia::common::gaia_id_t field_id : *index.fields())
414415
{
415-
const auto& field = catalog_core::field_view_t(gaia::db::id_to_ptr(field_id));
416+
const auto& field = field_view_t(gaia::db::id_to_ptr(field_id));
416417
if (field.data_type() == data_type_t::e_string && index.type() == index_type_t::range)
417418
{
418419
range_index_id = index.id();
@@ -490,11 +491,11 @@ TEST_F(db__query_processor__index_scan__test, query_local_modify_match)
490491
w.i = -1;
491492
w.insert_row();
492493

493-
for (const auto& index : catalog_core::list_indexes(table_id))
494+
for (const index_view_t& index : list_indexes(table_id))
494495
{
495-
for (const auto& field_id : *index.fields())
496+
for (const gaia::common::gaia_id_t field_id : *index.fields())
496497
{
497-
const auto& field = catalog_core::field_view_t(gaia::db::id_to_ptr(field_id));
498+
const auto& field = field_view_t(gaia::db::id_to_ptr(field_id));
498499
if (field.data_type() == data_type_t::e_string && index.type() == index_type_t::range)
499500
{
500501
range_index_id = index.id();
@@ -566,11 +567,11 @@ TEST_F(db__query_processor__index_scan__test, query_no_match)
566567

567568
auto_transaction_t txn;
568569

569-
for (const auto& index : catalog_core::list_indexes(table_id))
570+
for (const index_view_t& index : list_indexes(table_id))
570571
{
571-
for (const auto& field_id : *index.fields())
572+
for (const gaia::common::gaia_id_t field_id : *index.fields())
572573
{
573-
const auto& field = catalog_core::field_view_t(gaia::db::id_to_ptr(field_id));
574+
const auto& field = field_view_t(gaia::db::id_to_ptr(field_id));
574575
if (field.data_type() == data_type_t::e_string && index.type() == index_type_t::range)
575576
{
576577
range_index_id = index.id();
@@ -645,10 +646,10 @@ TEST_F(db__query_processor__index_scan__test, rollback_txn)
645646
gaia::db::begin_transaction();
646647
gaia_id_t table_id = type_id_mapping_t::instance().get_table_id(gaia::index_sandbox::sandbox_t::s_gaia_type);
647648

648-
for (const auto& idx : catalog_core::list_indexes(table_id))
649+
for (const index_view_t& index : list_indexes(table_id))
649650
{
650651
// Open an index scan operator for this operator.
651-
auto scan = index_scan_t(idx.id());
652+
auto scan = index_scan_t(index.id());
652653
size_t scan_count = 0;
653654
for (const auto& p : scan)
654655
{
@@ -674,10 +675,10 @@ TEST_F(db__query_processor__index_scan__test, insert_followed_by_delete)
674675
// Insert should be visible.
675676
gaia_id_t table_id = type_id_mapping_t::instance().get_table_id(gaia::index_sandbox::sandbox_t::s_gaia_type);
676677

677-
for (const auto& idx : catalog_core::list_indexes(table_id))
678+
for (const index_view_t& index : list_indexes(table_id))
678679
{
679680
// Open an index scan operator for this operator.
680-
auto scan = index_scan_t(idx.id());
681+
auto scan = index_scan_t(index.id());
681682
size_t scan_count = 0;
682683
for (const auto& p : scan)
683684
{
@@ -692,10 +693,10 @@ TEST_F(db__query_processor__index_scan__test, insert_followed_by_delete)
692693
gaia::index_sandbox::sandbox_t::get(to_delete).delete_row();
693694

694695
// Delete in effect.
695-
for (const auto& idx : catalog_core::list_indexes(table_id))
696+
for (const index_view_t& index : list_indexes(table_id))
696697
{
697698
// Open an index scan operator for this operator.
698-
auto scan = index_scan_t(idx.id());
699+
auto scan = index_scan_t(index.id());
699700
size_t scan_count = 0;
700701
for (const auto& p : scan)
701702
{
@@ -723,10 +724,10 @@ TEST_F(db__query_processor__index_scan__test, multi_insert_followed_by_delete)
723724
// Insert should be visible.
724725
gaia_id_t table_id = type_id_mapping_t::instance().get_table_id(gaia::index_sandbox::sandbox_t::s_gaia_type);
725726

726-
for (const auto& idx : catalog_core::list_indexes(table_id))
727+
for (const index_view_t& index : list_indexes(table_id))
727728
{
728729
// Open an index scan operator for this operator.
729-
auto scan = index_scan_t(idx.id());
730+
auto scan = index_scan_t(index.id());
730731
size_t scan_count = 0;
731732
for (const auto& p : scan)
732733
{
@@ -743,10 +744,10 @@ TEST_F(db__query_processor__index_scan__test, multi_insert_followed_by_delete)
743744
gaia::index_sandbox::sandbox_t::get(to_delete3).delete_row();
744745

745746
// Delete in effect.
746-
for (const auto& idx : catalog_core::list_indexes(table_id))
747+
for (const index_view_t& index : list_indexes(table_id))
747748
{
748749
// Open an index scan operator for this operator.
749-
auto scan = index_scan_t(idx.id());
750+
auto scan = index_scan_t(index.id());
750751
size_t scan_count = 0;
751752
for (const auto& p : scan)
752753
{

0 commit comments

Comments
 (0)