You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ja...@apache.org on 2022/08/26 13:07:26 UTC
[incubator-brpc] branch master updated: Fix override issue in pb
This is an automated email from the ASF dual-hosted git repository.
jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 86beca89 Fix override issue in pb
86beca89 is described below
commit 86beca89fe8b1c1dbf1f95b37c31d9b77630dde4
Author: gejun <ge...@bytedance.com>
AuthorDate: Fri Aug 26 21:07:11 2022 +0800
Fix override issue in pb
---
src/brpc/esp_message.h | 9 +++++----
src/brpc/memcache.h | 17 +++++++++--------
src/brpc/nshead_message.h | 9 +++++----
src/brpc/pb_compat.h | 34 ++++++++++++++++++++++++++++++++++
src/brpc/redis.h | 17 +++++++++--------
src/brpc/serialized_request.h | 9 +++++----
tools/rpc_press/json_loader.cpp | 4 +---
7 files changed, 68 insertions(+), 31 deletions(-)
diff --git a/src/brpc/esp_message.h b/src/brpc/esp_message.h
index 1c24707b..ce271d45 100644
--- a/src/brpc/esp_message.h
+++ b/src/brpc/esp_message.h
@@ -27,6 +27,7 @@
#include "brpc/esp_head.h"
#include "butil/iobuf.h"
#include "brpc/proto_base.pb.h"
+#include "brpc/pb_compat.h"
namespace brpc {
@@ -53,7 +54,7 @@ public:
// implements Message ----------------------------------------------
- EspMessage* New() const override;
+ EspMessage* New() const PB_319_OVERRIDE;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
EspMessage* New(::google::protobuf::Arena* arena) const override;
#endif
@@ -66,11 +67,11 @@ public:
int ByteSize() const;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) override;
+ ::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const override;
+ ::google::protobuf::io::CodedOutputStream* output) const PB_310_OVERRIDE;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(
- ::google::protobuf::uint8* output) const override;
+ ::google::protobuf::uint8* output) const PB_310_OVERRIDE;
int GetCachedSize() const override { return ByteSize(); }
protected:
diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h
index d0aaa542..a34ccd60 100644
--- a/src/brpc/memcache.h
+++ b/src/brpc/memcache.h
@@ -25,6 +25,7 @@
#include "butil/iobuf.h"
#include "butil/strings/string_piece.h"
#include "brpc/proto_base.pb.h"
+#include "brpc/pb_compat.h"
namespace brpc {
@@ -89,7 +90,7 @@ public:
const butil::IOBuf& raw_buffer() const { return _buf; }
// Protobuf methods.
- MemcacheRequest* New() const override;
+ MemcacheRequest* New() const PB_319_OVERRIDE;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
MemcacheRequest* New(::google::protobuf::Arena* arena) const override;
#endif
@@ -102,10 +103,10 @@ public:
int ByteSize() const;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) override;
+ ::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const override;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const override;
+ ::google::protobuf::io::CodedOutputStream* output) const PB_310_OVERRIDE;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PB_310_OVERRIDE;
int GetCachedSize() const override { return _cached_size_; }
static const ::google::protobuf::Descriptor* descriptor();
@@ -202,7 +203,7 @@ public:
// implements Message ----------------------------------------------
- MemcacheResponse* New() const override;
+ MemcacheResponse* New() const PB_319_OVERRIDE;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
MemcacheResponse* New(::google::protobuf::Arena* arena) const override;
#endif
@@ -215,10 +216,10 @@ public:
int ByteSize() const;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) override;
+ ::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const override;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const override;
+ ::google::protobuf::io::CodedOutputStream* output) const PB_310_OVERRIDE;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PB_310_OVERRIDE;
int GetCachedSize() const override { return _cached_size_; }
static const ::google::protobuf::Descriptor* descriptor();
diff --git a/src/brpc/nshead_message.h b/src/brpc/nshead_message.h
index ffa81e67..475d8ce8 100644
--- a/src/brpc/nshead_message.h
+++ b/src/brpc/nshead_message.h
@@ -23,6 +23,7 @@
#include "brpc/nshead.h" // nshead_t
#include "butil/iobuf.h" // IOBuf
#include "brpc/proto_base.pb.h"
+#include "brpc/pb_compat.h"
namespace brpc {
@@ -49,7 +50,7 @@ public:
// implements Message ----------------------------------------------
- NsheadMessage* New() const override;
+ NsheadMessage* New() const PB_319_OVERRIDE;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
NsheadMessage* New(::google::protobuf::Arena* arena) const override;
#endif
@@ -62,10 +63,10 @@ public:
int ByteSize() const;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) override;
+ ::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const override;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const override;
+ ::google::protobuf::io::CodedOutputStream* output) const PB_310_OVERRIDE;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PB_310_OVERRIDE;
int GetCachedSize() const override { return ByteSize(); }
protected:
diff --git a/src/brpc/pb_compat.h b/src/brpc/pb_compat.h
new file mode 100644
index 00000000..c9654b75
--- /dev/null
+++ b/src/brpc/pb_compat.h
@@ -0,0 +1,34 @@
+// 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.
+
+
+#ifndef BRPC_PB_COMPAT_H
+#define BRPC_PB_COMPAT_H
+
+#if GOOGLE_PROTOBUF_VERSION < 3019000
+# define PB_319_OVERRIDE override
+#else
+# define PB_319_OVERRIDE
+#endif
+
+#if GOOGLE_PROTOBUF_VERSION < 3010000
+# define PB_310_OVERRIDE override
+#else
+# define PB_310_OVERRIDE
+#endif
+
+#endif // BRPC_PB_COMPAT_H
diff --git a/src/brpc/redis.h b/src/brpc/redis.h
index 9abfbe95..035cf70a 100644
--- a/src/brpc/redis.h
+++ b/src/brpc/redis.h
@@ -31,6 +31,7 @@
#include "brpc/parse_result.h"
#include "brpc/callback.h"
#include "brpc/socket.h"
+#include "brpc/pb_compat.h"
namespace brpc {
@@ -107,7 +108,7 @@ public:
bool SerializeTo(butil::IOBuf* buf) const;
// Protobuf methods.
- RedisRequest* New() const override;
+ RedisRequest* New() const PB_319_OVERRIDE;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
RedisRequest* New(::google::protobuf::Arena* arena) const override;
#endif
@@ -120,10 +121,10 @@ public:
int ByteSize() const;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) override;
+ ::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const override;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const override;
+ ::google::protobuf::io::CodedOutputStream* output) const PB_310_OVERRIDE;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PB_310_OVERRIDE;
int GetCachedSize() const override { return _cached_size_; }
static const ::google::protobuf::Descriptor* descriptor();
@@ -180,7 +181,7 @@ public:
// implements Message ----------------------------------------------
- RedisResponse* New() const override;
+ RedisResponse* New() const PB_319_OVERRIDE;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
RedisResponse* New(::google::protobuf::Arena* arena) const override;
#endif
@@ -193,10 +194,10 @@ public:
int ByteSize() const;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) override;
+ ::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const override;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const override;
+ ::google::protobuf::io::CodedOutputStream* output) const PB_310_OVERRIDE;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PB_310_OVERRIDE;
int GetCachedSize() const override { return _cached_size_; }
static const ::google::protobuf::Descriptor* descriptor();
diff --git a/src/brpc/serialized_request.h b/src/brpc/serialized_request.h
index 02d83e32..6a02e5b2 100644
--- a/src/brpc/serialized_request.h
+++ b/src/brpc/serialized_request.h
@@ -22,6 +22,7 @@
#include <google/protobuf/message.h>
#include "butil/iobuf.h"
#include "brpc/proto_base.pb.h"
+#include "brpc/pb_compat.h"
namespace brpc {
@@ -43,7 +44,7 @@ public:
// implements Message ----------------------------------------------
- SerializedRequest* New() const override;
+ SerializedRequest* New() const PB_319_OVERRIDE;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
SerializedRequest* New(::google::protobuf::Arena* arena) const override;
#endif
@@ -61,11 +62,11 @@ protected:
private:
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) override;
+ ::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const override;
+ ::google::protobuf::io::CodedOutputStream* output) const PB_310_OVERRIDE;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(
- ::google::protobuf::uint8* output) const override;
+ ::google::protobuf::uint8* output) const PB_310_OVERRIDE;
void MergeFrom(const ::google::protobuf::Message& from) override;
void MergeFrom(const SerializedRequest& from);
void SharedCtor();
diff --git a/tools/rpc_press/json_loader.cpp b/tools/rpc_press/json_loader.cpp
index 9ca3877e..b338b711 100644
--- a/tools/rpc_press/json_loader.cpp
+++ b/tools/rpc_press/json_loader.cpp
@@ -76,9 +76,7 @@ bool JsonLoader::Reader::read_some() {
static bool possibly_valid_json(const butil::IOBuf& json) {
butil::IOBufAsZeroCopyInputStream it(json);
const void* data = NULL;
- int size = 0;
- int total_size = 0;
- for (; it.Next(&data, &size); total_size += size) {
+ for (int size = 0; it.Next(&data, &size); ) {
for (int i = 0; i < size; ++i) {
char c = ((const char*)data)[i];
if (!isspace(c) && c != '\n') {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org