Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pingcap/tiflash into leas…
Browse files Browse the repository at this point in the history
…t_greatest_string
  • Loading branch information
ywqzzy committed Feb 8, 2023
2 parents 15c3dfe + 0bb9cb4 commit d780b5c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
34 changes: 16 additions & 18 deletions dbms/src/Functions/LeastGreatest.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,22 @@ class FunctionLeastGreatestString : public IFunction

// 2. calculate result column for string columns
auto string_columns_size = string_columns.size();
ColumnString * result_col = nullptr;
if (string_columns_size == 1)
{
// 3A. merge result columns of const columns and result_col
ColumnString * result_col = nullptr;
result_col = const_cast<ColumnString *>(string_columns[0]);
auto col_str = ColumnString::create();
impl::stringVectorConstant(
collator,
result_col->getChars(),
result_col->getOffsets(),
const_res,
col_str->getChars(),
col_str->getOffsets());
block.getByPosition(result).column = std::move(col_str);
return;
}
else if (string_columns_size >= 2)
{
std::vector<StringRef> result_string_refs;
Expand Down Expand Up @@ -551,7 +564,7 @@ class FunctionLeastGreatestString : public IFunction
}
else
{
// 3A. merge result columns of const columns and vector columns
// 3B. merge result columns of const columns and vector columns
auto col_str = ColumnString::create();
impl::stringRefVectorConstant(
collator,
Expand All @@ -562,22 +575,7 @@ class FunctionLeastGreatestString : public IFunction
block.getByPosition(result).column = std::move(col_str);
return;
}
}

// 3B. merge result columns of const columns and result_col
if (string_columns_size == 1 && !const_columns.empty())
{
auto col_str = ColumnString::create();
impl::stringVectorConstant(
collator,
result_col->getChars(),
result_col->getOffsets(),
const_res,
col_str->getChars(),
col_str->getOffsets());
block.getByPosition(result).column = std::move(col_str);
return;
}
}
}

private:
Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ SegmentPtr DeltaMergeStore::gcTrySegmentMerge(const DMContextPtr & dm_context, c
auto new_segment = segmentMerge(*dm_context, segments_to_merge, SegmentMergeReason::BackgroundGCThread);
if (new_segment)
{
checkSegmentUpdate(dm_context, segment, ThreadType::BG_GC);
checkSegmentUpdate(dm_context, new_segment, ThreadType::BG_GC);
}

return new_segment;
Expand Down Expand Up @@ -718,7 +718,7 @@ SegmentPtr DeltaMergeStore::gcTrySegmentMergeDelta(const DMContextPtr & dm_conte
}

segment_snap = {};
checkSegmentUpdate(dm_context, segment, ThreadType::BG_GC);
checkSegmentUpdate(dm_context, new_segment, ThreadType::BG_GC);

return new_segment;
}
Expand Down

0 comments on commit d780b5c

Please sign in to comment.