You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/27 06:01:09 UTC

[GitHub] [doris] HappenLee commented on a diff in pull request #10442: optimize substr performance and fix ASAN global buffer overflow

HappenLee commented on code in PR #10442:
URL: https://github.com/apache/doris/pull/10442#discussion_r907002621


##########
be/src/vec/common/string_searcher.h:
##########
@@ -0,0 +1,860 @@
+// 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.
+// This file is copied from
+// https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/StringSearcher.h
+// and modified by Doris
+
+#pragma once
+
+#include <stdint.h>
+#include <string.h>
+
+#include <algorithm>
+#include <limits>
+#include <vector>
+
+#include "vec/common/string_utils/string_utils.h"
+
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
+
+#ifdef __SSE4_1__
+#include <smmintrin.h>
+#endif
+
+namespace doris {
+
+// namespace ErrorCodes
+// {
+//     extern const int BAD_ARGUMENTS;
+// }
+
+/** Variants for searching a substring in a string.
+  * In most cases, performance is less than Volnitsky (see Volnitsky.h).
+  */
+
+class StringSearcherBase {
+public:
+    bool force_fallback = false;
+#ifdef __SSE2__
+protected:
+    static constexpr auto n = sizeof(__m128i);
+    const int page_size = sysconf(_SC_PAGESIZE); //::getPageSize();
+
+    bool page_safe(const void* const ptr) const {
+        return ((page_size - 1) & reinterpret_cast<std::uintptr_t>(ptr)) <= page_size - n;
+    }
+#endif
+};
+
+/// Performs case-sensitive and case-insensitive search of UTF-8 strings
+template <bool CaseSensitive, bool ASCII>
+class StringSearcher;
+
+// comment out since it's not used in doris and UTF8 dependency is not easy to meet

Review Comment:
   we should delete unless comment codeļ¼Œ same of other code



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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