added IColumn::select

This commit is contained in:
Nikolai Kochetov 2018-04-23 20:19:24 +03:00
parent e6e29eef29
commit 8625686205
2 changed files with 18 additions and 32 deletions

View File

@ -238,38 +238,6 @@ ColumnPtr ColumnVector<T>::index(const ColumnPtr & indexes, size_t limit) const
return selectIndexImpl(*this, indexes, limit);
}
template <typename T>
template <typename Type>
ColumnPtr ColumnVector<T>::indexImpl(const PaddedPODArray<Type> & indexes, size_t limit) const
{
size_t size = indexes.size();
if (limit == 0)
limit = size;
else
limit = std::min(size, limit);
auto res = this->create(limit);
typename Self::Container & res_data = res->getData();
for (size_t i = 0; i < limit; ++i)
res_data[i] = data[indexes[i]];
return std::move(res);
}
template <>
template <typename T>
ColumnPtr ColumnVector<T>::indexImpl<UInt8>(const PaddedPODArray<UInt8> & indexes, size_t limit) const;
template <>
template <typename T>
ColumnPtr ColumnVector<T>::indexImpl<UInt16>(const PaddedPODArray<UInt16> & indexes, size_t limit) const;
template <>
template <typename T>
ColumnPtr ColumnVector<T>::indexImpl<UInt32>(const PaddedPODArray<UInt32> & indexes, size_t limit) const;
template <>
template <typename T>
ColumnPtr ColumnVector<T>::indexImpl<UInt64>(const PaddedPODArray<UInt64> & indexes, size_t limit) const;
template <typename T>
ColumnPtr ColumnVector<T>::replicate(const IColumn::Offsets & offsets) const
{

View File

@ -295,5 +295,23 @@ protected:
Container data;
};
template <typename T>
template <typename Type>
ColumnPtr ColumnVector<T>::indexImpl(const PaddedPODArray<Type> & indexes, size_t limit) const
{
size_t size = indexes.size();
if (limit == 0)
limit = size;
else
limit = std::min(size, limit);
auto res = this->create(limit);
typename Self::Container & res_data = res->getData();
for (size_t i = 0; i < limit; ++i)
res_data[i] = data[indexes[i]];
return std::move(res);
}
}