From 1ca4c006b8915afbbc12e76b3bd60ae92519b20d Mon Sep 17 00:00:00 2001 From: james Date: Mon, 29 Jun 2026 16:07:47 +0800 Subject: [PATCH 1/2] refactor: rm operator+ from StringRef Signed-off-by: james --- include/base/string_ref.h | 20 ++------------------ include/base/type.h | 3 +-- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/include/base/string_ref.h b/include/base/string_ref.h index 0b24c4d744b..23e2ed302bf 100644 --- a/include/base/string_ref.h +++ b/include/base/string_ref.h @@ -44,8 +44,8 @@ struct StringRef { ~StringRef() {} - const inline bool IsNull() const { return nullptr == data_; } - const std::string ToString() const { + inline bool IsNull() const { return nullptr == data_; } + std::string ToString() const { return size_ == 0 ? "" : std::string(data_, size_); } @@ -82,22 +82,6 @@ struct StringRef { const char* data_; }; -__attribute__((unused)) static const StringRef operator+(const StringRef& a, - const StringRef& b) { - StringRef str; - str.size_ = a.size_ + b.size_; - char* buffer = static_cast(malloc(str.size_ + 1)); - str.data_ = buffer; - if (a.size_ > 0) { - memcpy(buffer, a.data_, a.size_); - } - if (b.size_ > 0) { - memcpy(buffer + a.size_, b.data_, b.size_); - } - buffer[str.size_] = '\0'; - return str; -} - __attribute__((unused)) static std::ostream& operator<<(std::ostream& os, const StringRef& a) { os << a.ToString(); diff --git a/include/base/type.h b/include/base/type.h index 0500bcca809..3673d2d9a34 100644 --- a/include/base/type.h +++ b/include/base/type.h @@ -22,7 +22,6 @@ #include #include #include -#include namespace openmldb { namespace base { @@ -109,7 +108,7 @@ struct Date { } // | --- 16 bit -------------------------- | -- 8 bit ------------| --- 8 bit --------- | - // | year count since 1990 (starts from 0) | month(starts from 0) | day (starts from 1) | + // | year count since 1900 (starts from 0) | month(starts from 0) | day (starts from 1) | int32_t date_; friend std::ostream& operator<<(std::ostream& os, const Date& date) { From e053596b450d3af5170663341270e7897a2e8157 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 29 Jun 2026 16:19:52 +0800 Subject: [PATCH 2/2] fix: add vector include to test_udf Signed-off-by: james --- src/examples/test_udf.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/examples/test_udf.cc b/src/examples/test_udf.cc index f4c3bced6ca..fd18657bd98 100644 --- a/src/examples/test_udf.cc +++ b/src/examples/test_udf.cc @@ -16,6 +16,8 @@ #include "udf/openmldb_udf.h" +#include + extern "C" void cut2(::openmldb::base::UDFContext* ctx, ::openmldb::base::StringRef* input, ::openmldb::base::StringRef* output) { if (input == nullptr || output == nullptr) {