forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix addNullsForUnselectedRows (facebookincubator#9279)
Summary: Pull Request resolved: facebookincubator#9279 addNullsForUnselectedRows used memcpy to copy bits from SelectivityVector into the nulls buffer. Memcpy copies full bytes, hence, it copies a few extra bits at the tail when rows.end() is not a multiple of 8. This causes lambda functions that use addNullsForUnselectedRows to generate invalid vectors and results in crashes. See facebookincubator#5990 for additional context. Reviewed By: bikramSingh91 Differential Revision: D55455300 fbshipit-source-id: e98b515b1f4f1876bacb7a483a305fba098522cd
- Loading branch information
1 parent
a5ae9cc
commit 0c86a0a
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "velox/functions/lib/LambdaFunctionUtil.h" | ||
#include "velox/vector/tests/utils/VectorTestBase.h" | ||
|
||
namespace facebook::velox::functions { | ||
namespace { | ||
|
||
class LambdaFunctionUtilTest : public testing::Test, | ||
public test::VectorTestBase { | ||
protected: | ||
static void SetUpTestCase() { | ||
memory::MemoryManager::testingSetInstance({}); | ||
} | ||
}; | ||
|
||
TEST_F(LambdaFunctionUtilTest, addNullsForUnselectedRows) { | ||
auto vector = makeFlatVector<int64_t>({1, 2, 3, 4, 5}); | ||
|
||
SelectivityVector rows(3); | ||
auto nulls = addNullsForUnselectedRows(vector, rows); | ||
|
||
auto* rawNulls = nulls->as<uint64_t>(); | ||
|
||
EXPECT_FALSE(bits::isBitNull(rawNulls, 0)); | ||
EXPECT_FALSE(bits::isBitNull(rawNulls, 1)); | ||
EXPECT_FALSE(bits::isBitNull(rawNulls, 2)); | ||
EXPECT_TRUE(bits::isBitNull(rawNulls, 3)); | ||
EXPECT_TRUE(bits::isBitNull(rawNulls, 4)); | ||
} | ||
|
||
} // namespace | ||
} // namespace facebook::velox::functions |