Skip to content

Commit

Permalink
Merge pull request pingcap#4 from JinheLin/unordered_set_to_vector
Browse files Browse the repository at this point in the history
Change unordered_set to vector
  • Loading branch information
Lloyd-Pottiger committed Apr 2, 2024
2 parents 844ed57 + b042950 commit 6b4dc35
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dbms/src/Storages/DeltaMerge/File/ColumnCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ RangeWithStrategys ColumnCache::getReadStrategy(size_t start_pack_idx, size_t pa
RangeWithStrategys ColumnCache::getReadStrategy(
size_t start_pack_idx,
size_t pack_count,
const std::unordered_set<size_t> & clean_read_pack_idx)
const std::vector<size_t> & clean_read_pack_idx)
{
PackRange target_range{start_pack_idx, start_pack_idx + pack_count};

Expand All @@ -73,7 +73,7 @@ RangeWithStrategys ColumnCache::getReadStrategy(
size_t range_start = 0;
for (size_t cursor = target_range.first; cursor < target_range.second; ++cursor)
{
if (clean_read_pack_idx.contains(cursor))
if (std::find(clean_read_pack_idx.cbegin(), clean_read_pack_idx.cend(), cursor) != clean_read_pack_idx.cend())
{
if (strategy == Strategy::Memory)
{
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/File/ColumnCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ColumnCache
static RangeWithStrategys getReadStrategy(
size_t start_pack_idx,
size_t pack_count,
const std::unordered_set<size_t> & clean_read_pack_idx);
const std::vector<size_t> & clean_read_pack_idx);

void tryPutColumn(size_t pack_id, ColId column_id, const ColumnPtr & column, size_t rows_offset, size_t rows_count);

Expand Down
24 changes: 13 additions & 11 deletions dbms/src/Storages/DeltaMerge/File/DMFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ Block DMFileReader::read()
const auto & pack_properties = dmfile->getPackProperties();
const auto & handle_res = pack_filter.getHandleRes(); // alias of handle_res in pack_filter
const size_t read_packs = next_pack_id - start_pack_id;
std::unordered_set<size_t> handle_column_clean_read_packs;
std::unordered_set<size_t> del_column_clean_read_packs;
std::unordered_set<size_t> version_column_clean_read_packs;
std::vector<size_t> handle_column_clean_read_packs;
std::vector<size_t> del_column_clean_read_packs;
std::vector<size_t> version_column_clean_read_packs;
if (is_fast_scan)
{
if (enable_del_clean_read)
Expand All @@ -337,7 +337,7 @@ Block DMFileReader::read()
&& (pack_properties.property(i).deleted_rows() == 0
|| pack_properties.property(i).deleted_rows() == pack_stats[i].rows))
{
del_column_clean_read_packs.insert(i);
del_column_clean_read_packs.push_back(i);
}
}
}
Expand All @@ -347,14 +347,16 @@ Block DMFileReader::read()
for (size_t i = start_pack_id; i < next_pack_id; ++i)
{
// If all handle in a pack are in the given range, and del column do clean read, we do not need to read handle column.
if (del_column_clean_read_packs.contains(i) && handle_res[i] == All)
if (handle_res[i] == All
&& std::find(del_column_clean_read_packs.cbegin(), del_column_clean_read_packs.cend(), i)
!= del_column_clean_read_packs.cend())
{
handle_column_clean_read_packs.insert(i);
handle_column_clean_read_packs.push_back(i);
}
// If all handle in a pack are in the given range, but disable del clean read, we do not need to read handle column.
else if (!enable_del_clean_read && handle_res[i] == All)
{
handle_column_clean_read_packs.insert(i);
handle_column_clean_read_packs.push_back(i);
}
}
}
Expand All @@ -371,9 +373,9 @@ Block DMFileReader::read()
if (handle_res[i] == All && pack_stats[i].not_clean == 0
&& pack_filter.getMaxVersion(i) <= max_read_version)
{
handle_column_clean_read_packs.insert(i);
version_column_clean_read_packs.insert(i);
del_column_clean_read_packs.insert(i);
handle_column_clean_read_packs.push_back(i);
version_column_clean_read_packs.push_back(i);
del_column_clean_read_packs.push_back(i);
}
}
}
Expand Down Expand Up @@ -463,7 +465,7 @@ ColumnPtr DMFileReader::readExtraColumn(
size_t start_pack_id,
size_t pack_count,
size_t read_rows,
const std::unordered_set<size_t> & clean_read_packs,
const std::vector<size_t> & clean_read_packs,
size_t column_index)
{
const auto & pack_stats = dmfile->getPackStats();
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/File/DMFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class DMFileReader
size_t start_pack_id,
size_t pack_count,
size_t read_rows,
const std::unordered_set<size_t> & clean_read_packs,
const std::vector<size_t> & clean_read_packs,
size_t column_index);
void readFromDisk(
const ColumnDefine & column_define,
Expand Down

0 comments on commit 6b4dc35

Please sign in to comment.