From bc1031be9bf7239a66c7de6312fb5acca2aa4840 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 16 Sep 2020 16:33:28 +0300 Subject: [PATCH] Split has. --- src/Functions/GatherUtils/GatherUtils.h | 21 +++++++++++++- src/Functions/GatherUtils/has.cpp | 35 ------------------------ src/Functions/GatherUtils/has_all.cpp | 23 ++++++++++++++++ src/Functions/GatherUtils/has_any.cpp | 23 ++++++++++++++++ src/Functions/GatherUtils/has_substr.cpp | 23 ++++++++++++++++ src/Functions/ya.make | 4 ++- 6 files changed, 92 insertions(+), 37 deletions(-) delete mode 100644 src/Functions/GatherUtils/has.cpp create mode 100644 src/Functions/GatherUtils/has_all.cpp create mode 100644 src/Functions/GatherUtils/has_any.cpp create mode 100644 src/Functions/GatherUtils/has_substr.cpp diff --git a/src/Functions/GatherUtils/GatherUtils.h b/src/Functions/GatherUtils/GatherUtils.h index 6c31898b202..180ffb92026 100644 --- a/src/Functions/GatherUtils/GatherUtils.h +++ b/src/Functions/GatherUtils/GatherUtils.h @@ -52,7 +52,26 @@ ColumnArray::MutablePtr sliceFromRightConstantOffsetBounded(IArraySource & src, ColumnArray::MutablePtr sliceDynamicOffsetUnbounded(IArraySource & src, const IColumn & offset_column); ColumnArray::MutablePtr sliceDynamicOffsetBounded(IArraySource & src, const IColumn & offset_column, const IColumn & length_column); -void sliceHas(IArraySource & first, IArraySource & second, ArraySearchType search_type, ColumnUInt8 & result); +void sliceHasAny(IArraySource & first, IArraySource & second, ColumnUInt8 & result); +void sliceHasAll(IArraySource & first, IArraySource & second, ColumnUInt8 & result); +void sliceHasSubstr(IArraySource & first, IArraySource & second, ColumnUInt8 & result); + +void sliceHas(IArraySource & first, IArraySource & second, ArraySearchType search_type, ColumnUInt8 & result) +{ + switch (search_type) + { + case ArraySearchType::All: + sliceHasAny(first, second, result); + break; + case ArraySearchType::Any: + sliceHasAll(first, second, result); + break; + case ArraySearchType::Substr: + sliceHasSubstr(first, second, result); + break; + + } +} void push(IArraySource & array_source, IValueSource & value_source, IArraySink & sink, bool push_front); diff --git a/src/Functions/GatherUtils/has.cpp b/src/Functions/GatherUtils/has.cpp deleted file mode 100644 index d996a155e76..00000000000 --- a/src/Functions/GatherUtils/has.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "GatherUtils.h" -#include "Selectors.h" -#include "Algorithms.h" - -namespace DB::GatherUtils -{ - -struct ArrayHasSelectArraySourcePair : public ArraySourcePairSelector -{ - template - static void selectSourcePair(FirstSource && first, SecondSource && second, ArraySearchType search_type, ColumnUInt8 & result) - { - switch (search_type) - { - case ArraySearchType::All: - arrayAllAny(first, second, result); - break; - case ArraySearchType::Any: - arrayAllAny(first, second, result); - break; - case ArraySearchType::Substr: - arrayAllAny(first, second, result); - break; - - } - } -}; - - -void sliceHas(IArraySource & first, IArraySource & second, ArraySearchType search_type, ColumnUInt8 & result) -{ - ArrayHasSelectArraySourcePair::select(first, second, search_type, result); -} - -} diff --git a/src/Functions/GatherUtils/has_all.cpp b/src/Functions/GatherUtils/has_all.cpp new file mode 100644 index 00000000000..d99430e1c43 --- /dev/null +++ b/src/Functions/GatherUtils/has_all.cpp @@ -0,0 +1,23 @@ +#include "GatherUtils.h" +#include "Selectors.h" +#include "Algorithms.h" + +namespace DB::GatherUtils +{ + +struct ArrayHasAllSelectArraySourcePair : public ArraySourcePairSelector +{ + template + static void selectSourcePair(FirstSource && first, SecondSource && second, ArraySearchType search_type, ColumnUInt8 & result) + { + arrayAllAny(first, second, result); + } +}; + + +void sliceHasAll(IArraySource & first, IArraySource & second, ColumnUInt8 & result) +{ + ArrayHasAllSelectArraySourcePair::select(first, second, result); +} + +} diff --git a/src/Functions/GatherUtils/has_any.cpp b/src/Functions/GatherUtils/has_any.cpp new file mode 100644 index 00000000000..b099d8d6785 --- /dev/null +++ b/src/Functions/GatherUtils/has_any.cpp @@ -0,0 +1,23 @@ +#include "GatherUtils.h" +#include "Selectors.h" +#include "Algorithms.h" + +namespace DB::GatherUtils +{ + +struct ArrayHasAnySelectArraySourcePair : public ArraySourcePairSelector +{ + template + static void selectSourcePair(FirstSource && first, SecondSource && second, ArraySearchType search_type, ColumnUInt8 & result) + { + arrayAllAny(first, second, result); + } +}; + + +void sliceHasAny(IArraySource & first, IArraySource & second, ColumnUInt8 & result) +{ + ArrayHasAnySelectArraySourcePair::select(first, second, result); +} + +} diff --git a/src/Functions/GatherUtils/has_substr.cpp b/src/Functions/GatherUtils/has_substr.cpp new file mode 100644 index 00000000000..319c3da8b83 --- /dev/null +++ b/src/Functions/GatherUtils/has_substr.cpp @@ -0,0 +1,23 @@ +#include "GatherUtils.h" +#include "Selectors.h" +#include "Algorithms.h" + +namespace DB::GatherUtils +{ + +struct ArrayHasSubstrSelectArraySourcePair : public ArraySourcePairSelector +{ + template + static void selectSourcePair(FirstSource && first, SecondSource && second, ArraySearchType search_type, ColumnUInt8 & result) + { + arrayAllAny(first, second, result); + } +}; + + +void sliceHasSubstr(IArraySource & first, IArraySource & second, ColumnUInt8 & result) +{ + ArrayHasSubstrSelectArraySourcePair::select(first, second, result); +} + +} diff --git a/src/Functions/ya.make b/src/Functions/ya.make index 388b140bf11..97847b99bf6 100644 --- a/src/Functions/ya.make +++ b/src/Functions/ya.make @@ -190,7 +190,9 @@ SRCS( GatherUtils/createArraySink.cpp GatherUtils/createArraySource.cpp GatherUtils/createValueSource.cpp - GatherUtils/has.cpp + GatherUtils/has_all.cpp + GatherUtils/has_any.cpp + GatherUtils/has_substr.cpp GatherUtils/push.cpp GatherUtils/resizeConstantSize.cpp GatherUtils/resizeDynamicSize.cpp