This is an automated email from the ASF dual-hosted git repository.

lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 68b24d6  [fix] (vectorization)Fix nullable column compute the hash 
value error (#8105)
68b24d6 is described below

commit 68b24d608fa45d90aecdc9ba06e79afb6c61ddb8
Author: HappenLee <[email protected]>
AuthorDate: Fri Feb 18 11:20:47 2022 +0800

    [fix] (vectorization)Fix nullable column compute the hash value error 
(#8105)
    
    Co-authored-by: lihaopeng <[email protected]>
---
 be/src/vec/columns/column.h               |  1 -
 be/src/vec/columns/column_nullable.cpp    |  7 +++--
 be/test/vec/core/CMakeLists.txt           |  1 +
 be/test/vec/core/column_nullable_test.cpp | 52 +++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/be/src/vec/columns/column.h b/be/src/vec/columns/column.h
index 09b4892..10b1e00 100644
--- a/be/src/vec/columns/column.h
+++ b/be/src/vec/columns/column.h
@@ -33,7 +33,6 @@ class SipHash;
 namespace doris::vectorized {
 
 class Arena;
-class ColumnGathererStream;
 class Field;
 
 /// Declares interface to store columns in memory.
diff --git a/be/src/vec/columns/column_nullable.cpp 
b/be/src/vec/columns/column_nullable.cpp
index f7326a0..bae8f9a 100644
--- a/be/src/vec/columns/column_nullable.cpp
+++ b/be/src/vec/columns/column_nullable.cpp
@@ -44,9 +44,10 @@ ColumnNullable::ColumnNullable(MutableColumnPtr&& 
nested_column_, MutableColumnP
 }
 
 void ColumnNullable::update_hash_with_value(size_t n, SipHash& hash) const {
-    const auto& arr = get_null_map_data();
-    hash.update(arr[n]);
-    if (arr[n] == 0) get_nested_column().update_hash_with_value(n, hash);
+    if (is_null_at(n))
+        hash.update(0);
+    else
+        get_nested_column().update_hash_with_value(n, hash);
 }
 
 MutableColumnPtr ColumnNullable::clone_resized(size_t new_size) const {
diff --git a/be/test/vec/core/CMakeLists.txt b/be/test/vec/core/CMakeLists.txt
index 1531091..cdcf5c2 100644
--- a/be/test/vec/core/CMakeLists.txt
+++ b/be/test/vec/core/CMakeLists.txt
@@ -20,4 +20,5 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/test/vec/core")
 
 ADD_BE_TEST(block_test)
 ADD_BE_TEST(column_complex_test)
+ADD_BE_TEST(column_nullable_test)
 
diff --git a/be/test/vec/core/column_nullable_test.cpp 
b/be/test/vec/core/column_nullable_test.cpp
new file mode 100644
index 0000000..c808897
--- /dev/null
+++ b/be/test/vec/core/column_nullable_test.cpp
@@ -0,0 +1,52 @@
+
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 "vec/columns/column_nullable.h"
+#include "vec/columns/column_vector.h"
+#include "vec/common/sip_hash.h"
+
+#include <gtest/gtest.h>
+
+#include <memory>
+#include <string>
+
+namespace doris::vectorized {
+
+TEST(ColumnNullableTest, HashTest) {
+    ColumnPtr column = ColumnVector<int>::create({10, 20});
+    ASSERT_EQ(column->size(), 2);
+
+    auto nullable_column = ColumnNullable::create(column, 
ColumnUInt8::create(column->size(), 0));
+    SipHash hashes[2];
+    column->update_hash_with_value(0, hashes[0]);
+    nullable_column->update_hash_with_value(0, hashes[1]);
+    ASSERT_EQ(hashes[0].get64(), hashes[1].get64());
+
+    auto& null_map = ((ColumnNullable)(*nullable_column)).get_null_map_data();
+    null_map[1] = true;
+    column->update_hash_with_value(1, hashes[0]);
+    nullable_column->update_hash_with_value(1, hashes[1]);
+    ASSERT_NE(hashes[0].get64(), hashes[1].get64());
+}
+
+} // namespace doris::vectorized
+
+int main(int argc, char** argv) {
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to