From 82510ed8ef81aa392da5438213e81c48dd1277bb Mon Sep 17 00:00:00 2001 From: zhli1142015 Date: Thu, 7 Dec 2023 15:11:36 +0800 Subject: [PATCH] minor change --- velox/exec/tests/HashJoinTest.cpp | 17 +------------ velox/exec/tests/utils/FlagUpdater.h | 36 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 velox/exec/tests/utils/FlagUpdater.h diff --git a/velox/exec/tests/HashJoinTest.cpp b/velox/exec/tests/HashJoinTest.cpp index 1b365dd1b7047..83a4b69424e2a 100644 --- a/velox/exec/tests/HashJoinTest.cpp +++ b/velox/exec/tests/HashJoinTest.cpp @@ -26,6 +26,7 @@ #include "velox/exec/TableScan.h" #include "velox/exec/tests/utils/AssertQueryBuilder.h" #include "velox/exec/tests/utils/Cursor.h" +#include "velox/exec/tests/utils/FlagUpdater.h" #include "velox/exec/tests/utils/HiveConnectorTestBase.h" #include "velox/exec/tests/utils/PlanBuilder.h" #include "velox/exec/tests/utils/TempDirectoryPath.h" @@ -4671,22 +4672,6 @@ TEST_F(HashJoinTest, dynamicFiltersWithSkippedSplits) { } } -template -class FlagUpdater { - public: - FlagUpdater(T& flag, const T newValue) : originalValue_(flag), flag_(flag) { - flag_ = newValue; - } - - ~FlagUpdater() { - flag_ = originalValue_; - } - - private: - T originalValue_; - T& flag_; -}; - TEST_F(HashJoinTest, dynamicFiltersAppliedToPreloadedSplits) { vector_size_t size = 1000; const int32_t numSplits = 5; diff --git a/velox/exec/tests/utils/FlagUpdater.h b/velox/exec/tests/utils/FlagUpdater.h new file mode 100644 index 0000000000000..5f26922fc3170 --- /dev/null +++ b/velox/exec/tests/utils/FlagUpdater.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once +namespace facebook::velox::exec::test { + +// Generic RAII class to update GFlag. +template +class FlagUpdater { + public: + FlagUpdater(T& flag, const T newValue) : originalValue_(flag), flag_(flag) { + flag_ = newValue; + } + + ~FlagUpdater() { + flag_ = originalValue_; + } + + private: + T originalValue_; + T& flag_; +}; + +} // namespace facebook::velox::exec::test