Skip to content

Commit

Permalink
Fix review naming
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchengchenghh committed Apr 13, 2023
1 parent df43e1b commit b0e49f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
3 changes: 1 addition & 2 deletions velox/functions/sparksql/MightContain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class BloomFilterMightContainFunction final : public exec::VectorFunction {
try {
output.merge(serialized->valueAt<StringView>(0).str().c_str());
} catch (const std::exception& e) {
rows.applyToSelected(
[&](int row) { context.setError(row, std::current_exception()); });
context.setErrors(rows, std::current_exception());
return;
}

Expand Down
28 changes: 9 additions & 19 deletions velox/functions/sparksql/tests/MightContainTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
namespace facebook::velox::functions::sparksql::test {
namespace {

using namespace facebook::velox::test;

class MightContainTest : public SparkFunctionBaseTest {
protected:
void testMightContain(
Expand All @@ -33,19 +31,19 @@ class MightContainTest : public SparkFunctionBaseTest {
auto result = evaluate(
"might_contain(cast(c0 as varbinary), c1)",
makeRowVector({bloom, value}));
assertEqualVectors(expected, result);
velox::test::assertEqualVectors(expected, result);
}

std::string getSerializedBloomFilter() {
constexpr int64_t kSize = 10;
BloomFilter bloom;
bloom.reset(kSize);
BloomFilter bloomFilter;
bloomFilter.reset(kSize);
for (auto i = 0; i < kSize; ++i) {
bloom.insert(folly::hasher<int64_t>()(i));
bloomFilter.insert(folly::hasher<int64_t>()(i));
}
std::string data;
data.resize(bloom.serializedSize());
bloom.serialize(data.data());
data.resize(bloomFilter.serializedSize());
bloomFilter.serialize(data.data());
return data;
}
};
Expand All @@ -65,24 +63,16 @@ TEST_F(MightContainTest, basic) {

auto values = makeNullableFlatVector<int64_t>(
{1, 2, 3, 4, 5, std::nullopt, 123451, 23456, 4, 5});
auto expects = makeNullableFlatVector<bool>(
auto expected = makeNullableFlatVector<bool>(
{true, true, true, true, true, std::nullopt, false, false, true, true});
testMightContain(bloom, values, expects);
testMightContain(bloom, values, expected);
}

TEST_F(MightContainTest, nullBloom) {
TEST_F(MightContainTest, nullBloomFilter) {
auto bloom = makeConstant<StringView>(std::nullopt, 2);
auto value = makeFlatVector<int64_t>({2, 4});
auto expected = makeNullConstant(TypeKind::BOOLEAN, 2);
testMightContain(bloom, value, expected);
}

TEST_F(MightContainTest, nullValue) {
auto serializedBloom = getSerializedBloomFilter();
auto bloom = makeConstant<StringView>(StringView(serializedBloom), 2);
auto value = makeNullableFlatVector<int64_t>({std::nullopt, 2});
auto expected = makeNullableFlatVector<bool>({std::nullopt, true});
testMightContain(bloom, value, expected);
}
} // namespace
} // namespace facebook::velox::functions::sparksql::test

0 comments on commit b0e49f3

Please sign in to comment.