Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 4c6c12f

Browse files
authored
Merge branch 'master' into bug_fix
2 parents c371986 + 6b2cdfd commit 4c6c12f

File tree

2 files changed

+70
-34
lines changed

2 files changed

+70
-34
lines changed

script/testing/psql/psql_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PELOTON_DIR="$CODE_SOURCE_DIR/../../.."
1515
PELOTON_PID=""
1616
PELOTON_PORT="57721"
1717
PELOTON_HOST="localhost"
18-
PELOTON_USER="postgres"
18+
PELOTON_USER="default_database"
1919
PELOTON_PASS="postgres"
2020
PELOTON_ARGS='sslmode=disable'
2121

src/executor/index_scan_executor.cpp

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ bool IndexScanExecutor::ExecPrimaryIndexLookup() {
199199
auto current_txn = executor_context_->GetTransaction();
200200
auto &manager = catalog::Manager::GetInstance();
201201
std::vector<ItemPointer> visible_tuple_locations;
202-
std::map<oid_t, std::vector<oid_t>> visible_tuples;
203202

204203
#ifdef LOG_TRACE_ENABLED
205204
int num_tuples_examined = 0;
@@ -326,27 +325,53 @@ bool IndexScanExecutor::ExecPrimaryIndexLookup() {
326325
LOG_TRACE("%ld tuples after pruning boundaries",
327326
visible_tuple_locations.size());
328327

328+
// Add the tuple locations to the result vector in the order returned by
329+
// the index scan. We might end up reading the same tile group multiple
330+
// times. However, this is necessary to adhere to the ORDER BY clause
331+
oid_t current_tile_group_oid = INVALID_OID;
332+
std::vector<oid_t> tuples;
333+
329334
for (auto &visible_tuple_location : visible_tuple_locations) {
330-
visible_tuples[visible_tuple_location.block]
331-
.push_back(visible_tuple_location.offset);
332-
}
335+
if (current_tile_group_oid == INVALID_OID) {
336+
current_tile_group_oid = visible_tuple_location.block;
337+
}
338+
if (current_tile_group_oid == visible_tuple_location.block) {
339+
tuples.push_back(visible_tuple_location.offset);
340+
} else {
341+
// Since the tile_group_oids differ, fill in the current tile group
342+
// into the result vector
343+
auto &manager = catalog::Manager::GetInstance();
344+
auto tile_group = manager.GetTileGroup(current_tile_group_oid);
345+
std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
346+
// Add relevant columns to logical tile
347+
logical_tile->AddColumns(tile_group, full_column_ids_);
348+
logical_tile->AddPositionList(std::move(tuples));
349+
if (column_ids_.size() != 0) {
350+
logical_tile->ProjectColumns(full_column_ids_, column_ids_);
351+
}
352+
result_.push_back(logical_tile.release());
333353

334-
// Construct a logical tile for each block
335-
for (auto tuples : visible_tuples) {
336-
auto &manager = catalog::Manager::GetInstance();
337-
auto tile_group = manager.GetTileGroup(tuples.first);
354+
// Change the current_tile_group_oid and add the current tuple
355+
tuples.clear();
356+
current_tile_group_oid = visible_tuple_location.block;
357+
tuples.push_back(visible_tuple_location.offset);
358+
}
359+
}
338360

361+
// Add the remaining tuples to the result vector
362+
if ((current_tile_group_oid != INVALID_OID) && (!tuples.empty())) {
363+
auto tile_group = manager.GetTileGroup(current_tile_group_oid);
339364
std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
340365
// Add relevant columns to logical tile
341366
logical_tile->AddColumns(tile_group, full_column_ids_);
342-
logical_tile->AddPositionList(std::move(tuples.second));
367+
logical_tile->AddPositionList(std::move(tuples));
343368
if (column_ids_.size() != 0) {
344369
logical_tile->ProjectColumns(full_column_ids_, column_ids_);
345370
}
346-
347371
result_.push_back(logical_tile.release());
348372
}
349373

374+
350375
done_ = true;
351376

352377
LOG_TRACE("Result tiles : %lu", result_.size());
@@ -408,7 +433,6 @@ bool IndexScanExecutor::ExecSecondaryIndexLookup() {
408433
auto current_txn = executor_context_->GetTransaction();
409434

410435
std::vector<ItemPointer> visible_tuple_locations;
411-
std::map<oid_t, std::vector<oid_t>> visible_tuples;
412436
auto &manager = catalog::Manager::GetInstance();
413437

414438
// Quickie Hack
@@ -567,24 +591,49 @@ bool IndexScanExecutor::ExecSecondaryIndexLookup() {
567591
// Check whether the boundaries satisfy the required condition
568592
CheckOpenRangeWithReturnedTuples(visible_tuple_locations);
569593

594+
// Add the tuple locations to the result vector in the order returned by
595+
// the index scan. We might end up reading the same tile group multiple
596+
// times. However, this is necessary to adhere to the ORDER BY clause
597+
oid_t current_tile_group_oid = INVALID_OID;
598+
std::vector<oid_t> tuples;
599+
570600
for (auto &visible_tuple_location : visible_tuple_locations) {
571-
visible_tuples[visible_tuple_location.block]
572-
.push_back(visible_tuple_location.offset);
573-
}
601+
if (current_tile_group_oid == INVALID_OID) {
602+
current_tile_group_oid = visible_tuple_location.block;
603+
}
604+
if (current_tile_group_oid == visible_tuple_location.block) {
605+
tuples.push_back(visible_tuple_location.offset);
606+
} else {
607+
// Since the tile_group_oids differ, fill in the current tile group
608+
// into the result vector
609+
auto &manager = catalog::Manager::GetInstance();
610+
auto tile_group = manager.GetTileGroup(current_tile_group_oid);
611+
std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
612+
// Add relevant columns to logical tile
613+
logical_tile->AddColumns(tile_group, full_column_ids_);
614+
logical_tile->AddPositionList(std::move(tuples));
615+
if (column_ids_.size() != 0) {
616+
logical_tile->ProjectColumns(full_column_ids_, column_ids_);
617+
}
618+
result_.push_back(logical_tile.release());
574619

575-
// Construct a logical tile for each block
576-
for (auto tuples : visible_tuples) {
577-
auto &manager = catalog::Manager::GetInstance();
578-
auto tile_group = manager.GetTileGroup(tuples.first);
620+
// Change the current_tile_group_oid and add the current tuple
621+
tuples.clear();
622+
current_tile_group_oid = visible_tuple_location.block;
623+
tuples.push_back(visible_tuple_location.offset);
624+
}
625+
}
579626

627+
// Add the remaining tuples (if any) to the result vector
628+
if ((current_tile_group_oid != INVALID_OID) && (!tuples.empty())) {
629+
auto tile_group = manager.GetTileGroup(current_tile_group_oid);
580630
std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
581631
// Add relevant columns to logical tile
582632
logical_tile->AddColumns(tile_group, full_column_ids_);
583-
logical_tile->AddPositionList(std::move(tuples.second));
633+
logical_tile->AddPositionList(std::move(tuples));
584634
if (column_ids_.size() != 0) {
585635
logical_tile->ProjectColumns(full_column_ids_, column_ids_);
586636
}
587-
588637
result_.push_back(logical_tile.release());
589638
}
590639

@@ -663,19 +712,6 @@ bool IndexScanExecutor::CheckKeyConditions(const ItemPointer &tuple_location) {
663712
// To make the procedure more uniform, we interpret IN as EQUAL
664713
// and NOT IN as NOT EQUAL, and react based on expression type below
665714
// accordingly
666-
/*if (expr_type == ExpressionType::COMPARE_IN) {
667-
bool bret = lhs.InList(rhs);
668-
669-
if (bret == true) {
670-
diff = VALUE_COMPARE_EQUAL;
671-
} else {
672-
diff = VALUE_COMPARE_NO_EQUAL;
673-
}
674-
} else {
675-
diff = lhs.Compare(rhs);
676-
}
677-
678-
LOG_TRACE("Difference : %d ", diff);*/
679715
if (lhs.CompareEquals(rhs) == CmpBool::TRUE) {
680716
switch (expr_type) {
681717
case ExpressionType::COMPARE_EQUAL:

0 commit comments

Comments
 (0)