Fill result vector only for empty input in multiSearch functions

This commit is contained in:
vdimir 2021-08-05 11:36:35 +03:00
parent b8558a1716
commit fbcefaee5d
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
4 changed files with 10 additions and 4 deletions

View File

@ -109,7 +109,7 @@ public:
auto & vec_res = col_res->getData();
auto & offsets_res = col_offsets->getData();
vec_res.resize_fill(column_haystack_size * refs.size());
vec_res.resize(column_haystack_size * refs.size());
if (col_haystack_vector)
Impl::vectorConstant(col_haystack_vector->getChars(), col_haystack_vector->getOffsets(), refs, vec_res);

View File

@ -26,7 +26,7 @@ struct MultiSearchFirstIndexImpl
{
auto searcher = Impl::createMultiSearcherInBigHaystack(needles);
const size_t haystack_string_size = haystack_offsets.size();
res.resize_fill(haystack_string_size);
res.resize(haystack_string_size);
size_t iteration = 0;
while (searcher.hasMoreToSearch())
{
@ -42,6 +42,8 @@ struct MultiSearchFirstIndexImpl
}
++iteration;
}
if (iteration == 0)
std::fill(res.begin(), res.end(), 0);
}
};

View File

@ -30,7 +30,7 @@ struct MultiSearchFirstPositionImpl
};
auto searcher = Impl::createMultiSearcherInBigHaystack(needles);
const size_t haystack_string_size = haystack_offsets.size();
res.resize_fill(haystack_string_size);
res.resize(haystack_string_size);
size_t iteration = 0;
while (searcher.hasMoreToSearch())
{
@ -51,6 +51,8 @@ struct MultiSearchFirstPositionImpl
}
++iteration;
}
if (iteration == 0)
std::fill(res.begin(), res.end(), 0);
}
};

View File

@ -26,7 +26,7 @@ struct MultiSearchImpl
{
auto searcher = Impl::createMultiSearcherInBigHaystack(needles);
const size_t haystack_string_size = haystack_offsets.size();
res.resize_fill(haystack_string_size);
res.resize(haystack_string_size);
size_t iteration = 0;
while (searcher.hasMoreToSearch())
{
@ -41,6 +41,8 @@ struct MultiSearchImpl
}
++iteration;
}
if (iteration == 0)
std::fill(res.begin(), res.end(), 0);
}
};