You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by pa...@apache.org on 2023/04/10 10:06:00 UTC

[doris] branch master updated: [Chore](build) fix some compile fail on gnu20 && remove some unused compatibility codes (#18467)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 297764b37d [Chore](build) fix some compile fail on gnu20 && remove some unused compatibility codes (#18467)
297764b37d is described below

commit 297764b37d33f4870d5198b6783f4e8d4332fe23
Author: Pxl <px...@qq.com>
AuthorDate: Mon Apr 10 18:05:52 2023 +0800

    [Chore](build) fix some compile fail on gnu20 && remove some unused compatibility codes (#18467)
---
 be/src/geo/geo_types.cpp                           | 35 ++--------------------
 be/src/geo/geo_types.h                             |  6 ++--
 .../rowset/segment_v2/inverted_index_writer.cpp    |  8 ++---
 be/src/util/brpc_client_cache.h                    | 21 ++-----------
 be/src/vec/exec/format/table/iceberg_reader.cpp    |  8 +----
 be/test/olap/itoken_extractor_test.cpp             | 28 ++++++++++++-----
 6 files changed, 34 insertions(+), 72 deletions(-)

diff --git a/be/src/geo/geo_types.cpp b/be/src/geo/geo_types.cpp
index 8949e33855..5d2ec76c5a 100644
--- a/be/src/geo/geo_types.cpp
+++ b/be/src/geo/geo_types.cpp
@@ -148,37 +148,6 @@ static GeoParseStatus to_s2polyline(const GeoCoordinateList& coords,
     return GEO_PARSE_OK;
 }
 
-// remove those compatibility codes when we finish upgrade s2geo.
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#elif defined(__GNUC__) || defined(__GNUG__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-template <typename T, bool (T::*)(const T*) const = &T::Contains>
-constexpr bool is_pointer_argument() {
-    return true;
-}
-
-constexpr bool is_pointer_argument(...) {
-    return false;
-}
-
-template <typename T>
-bool adapt_contains(const T* lhs, const T* rhs) {
-    if constexpr (is_pointer_argument<T>()) {
-        return lhs->Contains(rhs);
-    } else {
-        return lhs->Contains(*rhs);
-    }
-}
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#elif defined(__GNUC__) || defined(__GNUG__)
-#pragma GCC diagnostic pop
-#endif
-
 static GeoParseStatus to_s2polygon(const GeoCoordinateListList& coords_list,
                                    std::unique_ptr<S2Polygon>* polygon) {
     std::vector<std::unique_ptr<S2Loop>> loops(coords_list.list.size());
@@ -187,7 +156,7 @@ static GeoParseStatus to_s2polygon(const GeoCoordinateListList& coords_list,
         if (res != GEO_PARSE_OK) {
             return res;
         }
-        if (i != 0 && !adapt_contains(loops[0].get(), loops[i].get())) {
+        if (i != 0 && !(loops[0]->Contains(*loops[i]))) {
             return GEO_PARSE_POLYGON_NOT_HOLE;
         }
     }
@@ -439,7 +408,7 @@ bool GeoPolygon::contains(const GeoShape* rhs) const {
     }
     case GEO_SHAPE_POLYGON: {
         const GeoPolygon* other = (const GeoPolygon*)rhs;
-        return adapt_contains(_polygon.get(), other->polygon());
+        return _polygon->Contains(*other->polygon());
     }
     default:
         return false;
diff --git a/be/src/geo/geo_types.h b/be/src/geo/geo_types.h
index bb7e65fbdd..a7e43f92c5 100644
--- a/be/src/geo/geo_types.h
+++ b/be/src/geo/geo_types.h
@@ -30,14 +30,16 @@ class S2Cap;
 
 template <typename T>
 class Vector3;
-typedef Vector3<double> Vector3_d;
+
+using Vector3_d = Vector3<double>;
+
 using S2Point = Vector3_d;
 
 namespace doris {
 
 class GeoShape {
 public:
-    virtual ~GeoShape() {}
+    virtual ~GeoShape() = default;
 
     virtual GeoShapeType type() const = 0;
 
diff --git a/be/src/olap/rowset/segment_v2/inverted_index_writer.cpp b/be/src/olap/rowset/segment_v2/inverted_index_writer.cpp
index 466dd5867a..77a95bb505 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index_writer.cpp
@@ -170,12 +170,12 @@ public:
         _index_writer->setUseCompoundFile(false);
         _doc->clear();
 
-        int field_config =
-                lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_NONORMS;
+        int field_config = int(lucene::document::Field::STORE_NO) |
+                           int(lucene::document::Field::INDEX_NONORMS);
         if (_parser_type == InvertedIndexParserType::PARSER_NONE) {
-            field_config |= lucene::document::Field::INDEX_UNTOKENIZED;
+            field_config |= int(lucene::document::Field::INDEX_UNTOKENIZED);
         } else {
-            field_config |= lucene::document::Field::INDEX_TOKENIZED;
+            field_config |= int(lucene::document::Field::INDEX_TOKENIZED);
         }
         _field = _CLNEW lucene::document::Field(_field_name.c_str(), field_config);
         _doc->add(*_field);
diff --git a/be/src/util/brpc_client_cache.h b/be/src/util/brpc_client_cache.h
index fbe9ce56c1..364f11e6ea 100644
--- a/be/src/util/brpc_client_cache.h
+++ b/be/src/util/brpc_client_cache.h
@@ -66,14 +66,7 @@ public:
 
     std::shared_ptr<T> get_client(const std::string& host_port) {
         std::shared_ptr<T> stub_ptr;
-        auto get_value = [&stub_ptr](const auto& v) {
-            // remove those compatibility codes when we finish upgrade phmap.
-            if constexpr (std::is_same_v<const typename StubMap<T>::mapped_type&, decltype(v)>) {
-                stub_ptr = v;
-            } else {
-                stub_ptr = v.second;
-            }
-        };
+        auto get_value = [&stub_ptr](const auto& v) { stub_ptr = v.second; };
         if (LIKELY(_stub_map.if_contains(host_port, get_value))) {
             return stub_ptr;
         }
@@ -81,17 +74,7 @@ public:
         // new one stub and insert into map
         auto stub = get_new_client_no_cache(host_port);
         _stub_map.try_emplace_l(
-                host_port,
-                [&stub](const auto& v) {
-                    // remove those compatibility codes when we finish upgrade phmap.
-                    if constexpr (std::is_same_v<const typename StubMap<T>::mapped_type&,
-                                                 decltype(v)>) {
-                        stub = v;
-                    } else {
-                        stub = v.second;
-                    }
-                },
-                stub);
+                host_port, [&stub](const auto& v) { stub = v.second; }, stub);
         return stub;
     }
 
diff --git a/be/src/vec/exec/format/table/iceberg_reader.cpp b/be/src/vec/exec/format/table/iceberg_reader.cpp
index d925720931..c21630b6c9 100644
--- a/be/src/vec/exec/format/table/iceberg_reader.cpp
+++ b/be/src/vec/exec/format/table/iceberg_reader.cpp
@@ -293,13 +293,7 @@ Status IcebergTableReader::_position_delete(
 
         DeleteFile& delete_file_map = *((DeleteFile*)delete_file_cache);
         auto get_value = [&](const auto& v) {
-            DeleteRows* row_ids;
-            // remove those compatibility codes when we finish upgrade phmap.
-            if constexpr (std::is_same_v<const typename DeleteFile::mapped_type&, decltype(v)>) {
-                row_ids = v.get();
-            } else {
-                row_ids = v.second.get();
-            }
+            DeleteRows* row_ids = v.second.get();
             if (row_ids->size() > 0) {
                 delete_rows_array.emplace_back(row_ids);
                 num_delete_rows += row_ids->size();
diff --git a/be/test/olap/itoken_extractor_test.cpp b/be/test/olap/itoken_extractor_test.cpp
index d57682a1ee..00b45afede 100644
--- a/be/test/olap/itoken_extractor_test.cpp
+++ b/be/test/olap/itoken_extractor_test.cpp
@@ -60,19 +60,33 @@ void runNextInStringLike(const ITokenExtractor& extractor, std::string statement
     ASSERT_EQ(expect, actual);
 }
 
+#if __cplusplus > 201703L
+std::string from_u8string(const std::u8string& s) {
+    return std::string(s.begin(), s.end());
+}
+#else
+std::string from_u8string(const std::string& s) {
+    return std::string(s.begin(), s.end());
+}
+#endif
+
 TEST_F(TestITokenExtractor, ngram_extractor) {
-    std::string statement = u8"预计09发布i13手机。";
-    std::vector<std::string> expect = {u8"预计", u8"计0", u8"09",  u8"9发",  u8"发布", u8"布i",
-                                       u8"i1",   u8"13",  u8"3手", u8"手机", u8"机。"};
+    std::string statement = from_u8string(u8"预计09发布i13手机。");
+    std::vector<std::string> expect = {
+            from_u8string(u8"预计"), from_u8string(u8"计0"),  from_u8string(u8"09"),
+            from_u8string(u8"9发"),  from_u8string(u8"发布"), from_u8string(u8"布i"),
+            from_u8string(u8"i1"),   from_u8string(u8"13"),   from_u8string(u8"3手"),
+            from_u8string(u8"手机"), from_u8string(u8"机。")};
     NgramTokenExtractor ngram_extractor(2);
     runNextInString(ngram_extractor, statement, expect);
 }
 
 TEST_F(TestITokenExtractor, ngram_like_extractor) {
     NgramTokenExtractor ngram_extractor(2);
-    runNextInStringLike(ngram_extractor, u8"%手机%", {u8"手机"});
-    runNextInStringLike(ngram_extractor, u8"%机%", {});
-    runNextInStringLike(ngram_extractor, {u8"i_%手机%"}, {u8"手机"});
-    runNextInStringLike(ngram_extractor, {u8"\\_手机%"}, {u8"_手", u8"手机"});
+    runNextInStringLike(ngram_extractor, from_u8string(u8"%手机%"), {from_u8string(u8"手机")});
+    runNextInStringLike(ngram_extractor, from_u8string(u8"%机%"), {});
+    runNextInStringLike(ngram_extractor, {from_u8string(u8"i_%手机%")}, {from_u8string(u8"手机")});
+    runNextInStringLike(ngram_extractor, {from_u8string(u8"\\_手机%")},
+                        {from_u8string(u8"_手"), from_u8string(u8"手机")});
 }
 } // namespace doris


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org