Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
zhli1142015 committed Dec 7, 2023
1 parent 941db05 commit 82510ed
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
17 changes: 1 addition & 16 deletions velox/exec/tests/HashJoinTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -4671,22 +4672,6 @@ TEST_F(HashJoinTest, dynamicFiltersWithSkippedSplits) {
}
}

template <typename T>
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;
Expand Down
36 changes: 36 additions & 0 deletions velox/exec/tests/utils/FlagUpdater.h
Original file line number Diff line number Diff line change
@@ -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 <typename T>
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

0 comments on commit 82510ed

Please sign in to comment.