Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyang-li committed May 11, 2024
1 parent f9d43c9 commit dd6774e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Functions/substringIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace
else
res_ref = substringIndexUTF8(searcher.get(), str_ref, delim, count);

appendToResultColumn(res_ref, res_data, res_offsets);
appendToResultColumn<true>(res_ref, res_data, res_offsets);
}
}

Expand Down Expand Up @@ -179,7 +179,7 @@ namespace
else
res_ref = substringIndexUTF8(searcher.get(), str_ref, delim, count);

appendToResultColumn(res_ref, res_data, res_offsets);
appendToResultColumn<true>(res_ref, res_data, res_offsets);
}
}

Expand Down Expand Up @@ -212,15 +212,21 @@ namespace
else
res_ref = substringIndexUTF8(searcher.get(), str_ref, delim, count);

appendToResultColumn(res_ref, res_data, res_offsets);
appendToResultColumn<false>(res_ref, res_data, res_offsets);
}
}

template <bool padded>
static void appendToResultColumn(const StringRef & res_ref, ColumnString::Chars & res_data, ColumnString::Offsets & res_offsets)
{
size_t res_offset = res_data.size();
res_data.resize(res_offset + res_ref.size + 1);
memcpy(&res_data[res_offset], res_ref.data, res_ref.size);

if constexpr (padded)
memcpySmallAllowReadWriteOverflow15(&res_data[res_offset], res_ref.data, res_ref.size);
else
memcpy(&res_data[res_offset], res_ref.data, res_ref.size);

res_offset += res_ref.size;
res_data[res_offset] = 0;
++res_offset;
Expand Down

0 comments on commit dd6774e

Please sign in to comment.