Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GLUTEN-8434][CH] Function bloomFilterContains process improvement #8435

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions cpp-ch/local-engine/Functions/FunctionsBloomFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include <cstddef>
#include <cstring>
#include <memory>
#include <type_traits>
#include <AggregateFunctions/AggregateFunctionFactory.h>
Expand Down Expand Up @@ -118,7 +119,7 @@ class FunctionBloomFilterContains : public DB::IFunction
mutable DB::AggregateFunctionPtr agg_func;

template <typename T>
typename std::enable_if<std::is_same_v<T, Int64> || std::is_same_v<T, UInt64>, void>::type internalExecute(
std::enable_if_t<std::is_same_v<T, Int64> || std::is_same_v<T, UInt64>, void> internalExecute(
const DB::ColumnsWithTypeAndName & arguments,
size_t input_rows_count,
typename DB::ColumnVector<UInt8>::Container & vec_to,
Expand All @@ -129,16 +130,21 @@ class FunctionBloomFilterContains : public DB::IFunction
const auto * column_ptr = arguments[1].column.get();
auto second_arg_const = isColumnConst(*column_ptr);

AggregateFunctionGroupBloomFilterData & bloom_filter_data_0
= *reinterpret_cast<AggregateFunctionGroupBloomFilterData *>(bloom_filter_state);
if (second_arg_const)
container_of_int = &typeid_cast<const ColumnType &>(typeid_cast<const DB::ColumnConst &>(*column_ptr).getDataColumn()).getData();
else
container_of_int = &typeid_cast<const ColumnType &>(*column_ptr).getData();
{
vec_to[0] = bloom_filter_data_0.bloom_filter.find(typeid_cast<const DB::ColumnConst &>(*column_ptr).getDataAt(0).data, sizeof(T));
// copy to all rows, better use constant column
std::memcpy(&vec_to[1], &vec_to[0], (input_rows_count - 1) * sizeof(UInt8));

return;
}

container_of_int = &typeid_cast<const ColumnType &>(*column_ptr).getData();
for (size_t i = 0; i < input_rows_count; ++i)
{
const T v = second_arg_const ? (*container_of_int)[0] : (*container_of_int)[i];
AggregateFunctionGroupBloomFilterData & bloom_filter_data_0
= *reinterpret_cast<AggregateFunctionGroupBloomFilterData *>(bloom_filter_state);
const T v = (*container_of_int)[i];
vec_to[i] = bloom_filter_data_0.bloom_filter.find(reinterpret_cast<const char *>(&v), sizeof(T));
}
}
Expand Down Expand Up @@ -195,7 +201,6 @@ class FunctionBloomFilterContains : public DB::IFunction
arguments[0].type->getName());
}


const DB::IColumn * second_column_ptr = arguments[1].column.get();
if (isColumnNullable(*second_column_ptr))
second_column_ptr = &typeid_cast<const DB::ColumnNullable &>(*second_column_ptr).getNestedColumn();
Expand Down
Loading