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

zhaoc 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 f968537  Fix bloom filter bug #2526 (#2532)
f968537 is described below

commit f9685372a1a3f677e1e0ffe1e2ed26f0bd437c66
Author: kangpinghuang <[email protected]>
AuthorDate: Tue Dec 24 07:45:11 2019 +0800

    Fix bloom filter bug #2526 (#2532)
---
 be/src/olap/decimal12.h                            |  1 +
 .../segment_v2/bloom_filter_index_writer.cpp       | 14 +++++--
 .../bloom_filter_index_reader_writer_test.cpp      | 44 +++++++++++++++++++++-
 3 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/be/src/olap/decimal12.h b/be/src/olap/decimal12.h
index 92cc52c..9670d11 100644
--- a/be/src/olap/decimal12.h
+++ b/be/src/olap/decimal12.h
@@ -171,6 +171,7 @@ struct decimal12_t {
 } __attribute__((packed));
 
 inline std::ostream& operator<<(std::ostream& os, const decimal12_t& val) {
+    os << val.to_string();
     return os;
 }
 
diff --git a/be/src/olap/rowset/segment_v2/bloom_filter_index_writer.cpp 
b/be/src/olap/rowset/segment_v2/bloom_filter_index_writer.cpp
index ac3d070..c3ca532 100644
--- a/be/src/olap/rowset/segment_v2/bloom_filter_index_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/bloom_filter_index_writer.cpp
@@ -154,14 +154,11 @@ private:
 
 } // namespace
 
-// TODO currently we don't support bloom filter index for 
float/double/date/datetime/decimal/hll
+// TODO currently we don't support bloom filter index for 
tinyint/hll/float/double
 Status BloomFilterIndexWriter::create(const BloomFilterOptions& bf_options,
         const TypeInfo* typeinfo, std::unique_ptr<BloomFilterIndexWriter>* 
res) {
     FieldType type = typeinfo->type();
     switch (type) {
-        case OLAP_FIELD_TYPE_TINYINT:
-            res->reset(new 
BloomFilterIndexWriterImpl<OLAP_FIELD_TYPE_TINYINT>(bf_options, typeinfo));
-            break;
         case OLAP_FIELD_TYPE_SMALLINT:
             res->reset(new 
BloomFilterIndexWriterImpl<OLAP_FIELD_TYPE_SMALLINT>(bf_options, typeinfo));
             break;
@@ -180,6 +177,15 @@ Status BloomFilterIndexWriter::create(const 
BloomFilterOptions& bf_options,
         case OLAP_FIELD_TYPE_VARCHAR:
             res->reset(new 
BloomFilterIndexWriterImpl<OLAP_FIELD_TYPE_VARCHAR>(bf_options, typeinfo));
             break;
+        case OLAP_FIELD_TYPE_DATE:
+            res->reset(new 
BloomFilterIndexWriterImpl<OLAP_FIELD_TYPE_DATE>(bf_options, typeinfo));
+            break;
+        case OLAP_FIELD_TYPE_DATETIME:
+            res->reset(new 
BloomFilterIndexWriterImpl<OLAP_FIELD_TYPE_DATETIME>(bf_options, typeinfo));
+            break;
+        case OLAP_FIELD_TYPE_DECIMAL:
+            res->reset(new 
BloomFilterIndexWriterImpl<OLAP_FIELD_TYPE_DECIMAL>(bf_options, typeinfo));
+            break;
         default:
             return Status::NotSupported("unsupported type for bitmap index: " 
+ std::to_string(type));
     }
diff --git 
a/be/test/olap/rowset/segment_v2/bloom_filter_index_reader_writer_test.cpp 
b/be/test/olap/rowset/segment_v2/bloom_filter_index_reader_writer_test.cpp
index 89ec32e..70f051d 100644
--- a/be/test/olap/rowset/segment_v2/bloom_filter_index_reader_writer_test.cpp
+++ b/be/test/olap/rowset/segment_v2/bloom_filter_index_reader_writer_test.cpp
@@ -117,7 +117,7 @@ void test_bloom_filter_index_reader_writer_template(const 
std::string file_name,
                 Slice* value = (Slice*)(val + i);
                 ASSERT_TRUE(bf->test_bytes(value->data, value->size));
             } else {
-                ASSERT_TRUE(bf->test_bytes((char*)&val[i], sizeof(CppType)));
+                ASSERT_TRUE(bf->test_bytes((char*)&val[i], sizeof(CppType))) 
<< "index:" << i << ", value:" << val[i];
             }
         }
 
@@ -217,6 +217,48 @@ TEST_F(BloomFilterIndexReaderWriterTest, test_char) {
     delete[] slices;
 }
 
+TEST_F(BloomFilterIndexReaderWriterTest, test_date) {
+    size_t num = 1024 * 3 - 1;
+    uint24_t* val = new uint24_t[num];
+    for (int i = 0; i < num; ++i) {
+        // there will be 3 bloom filter pages
+        val[i] = 10000 + i + 1;
+    }
+
+    std::string file_name = "bloom_filter_date";
+    uint24_t not_exist_value = 18888;
+    
test_bloom_filter_index_reader_writer_template<OLAP_FIELD_TYPE_DATE>(file_name, 
val, num, 1, &not_exist_value);
+    delete[] val;
+}
+
+TEST_F(BloomFilterIndexReaderWriterTest, test_datetime) {
+    size_t num = 1024 * 3 - 1;
+    int64_t* val = new int64_t[num];
+    for (int i = 0; i < num; ++i) {
+        // there will be 3 bloom filter pages
+        val[i] = 10000 + i + 1;
+    }
+
+    std::string file_name = "bloom_filter_datetime";
+    int64_t not_exist_value = 18888;
+    
test_bloom_filter_index_reader_writer_template<OLAP_FIELD_TYPE_DATETIME>(file_name,
 val, num, 1, &not_exist_value);
+    delete[] val;
+}
+
+TEST_F(BloomFilterIndexReaderWriterTest, test_decimal) {
+    size_t num = 1024 * 3 - 1;
+    decimal12_t* val = new decimal12_t[num];
+    for (int i = 0; i < num; ++i) {
+        // there will be 3 bloom filter pages
+        val[i] = decimal12_t(i + 1, i + 1);
+    }
+
+    std::string file_name = "bloom_filter_decimal";
+    decimal12_t not_exist_value = decimal12_t(666, 666);
+    
test_bloom_filter_index_reader_writer_template<OLAP_FIELD_TYPE_DECIMAL>(file_name,
 val, num, 1, &not_exist_value);
+    delete[] val;
+}
+
 }
 }
 


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

Reply via email to