- 浏览: 171509 次
- 性别:
- 来自: 武汉
文章分类
最新评论
-
boz.lee:
不错, 好多地方因为这里而出错
全局变量和局部变量在内存里的区别 -
issllx:
看到此文后对iteye深表遗憾
Yahoo S4 -
wohenshuaiba:
请问你有这个的代码吗?
k均值聚类(K-means) -
yxwang0615:
大神:
apr-1.3.3.tar.bz2
apr-util- ...
log4cxx编译方法 -
yxwang0615:
比csdn上的说的清楚干练,早看到这个就好了,我编了一天
p ...
log4cxx编译方法
This page describes some commonly-used design patterns for dealing with Protocol Buffers. You can also send design and usage questions to the Protocol Buffers discussion group. If you want to write multiple messages to a single file or stream, it is up to you to keep track of where one message ends and the next begins. The Protocol Buffer wire format is not self-delimiting, so protocol buffer parsers cannot determine where a message ends on their own. The easiest way to solve this problem is to write the size of each message before you write the message itself. When you read the messages back in, you read the size, then read the bytes into a separate buffer, then parse from that buffer. (If you want to avoid copying bytes to a separate buffer, check out the Protocol Buffers are not designed to handle large messages. As a general rule of thumb, if you are dealing in messages larger than a megabyte each, it may be time to consider an alternate strategy. That said, Protocol Buffers are great for handling individual messages within a large data set. Usually, large data sets are really just a collection of small pieces, where each small piece may be a structured piece of data. Even though Protocol Buffers cannot handle the entire set at once, using Protocol Buffers to encode each piece greatly simplifies your problem: now all you need is to handle a set of byte strings rather than a set of structures. Protocol Buffers do not include any built-in support for large data sets because different situations call for different solutions. Sometimes a simple list of records will do while other times you may want something more like a database. Each solution should be developed as a separate library, so that only those who need it need to pay the costs. You may sometimes want to send a message that could be one of several different types. However, protocol buffer parsers cannot necessarily determine the type of a message based on the contents alone. So how do you make sure that the recipient application knows how to decode your message? One solution is to create a wrapper message that has one optional field for each possible message type. For example, if you have message types You may also want to have an enum field that identifies which message is filled in, so that you can If you have a very large number of possible types, listing every one of them in your container type may be unwieldy. Instead, you should consider using extensions: Note that you can use the Protocol Buffers do not contain descriptions of their own types. Thus, given only a raw message without the corresponding However, note that the contents of a .proto file can itself be represented using protocol buffers. The file By using classes like All that said, the reason that this functionality is not included in the Protocol Buffer library is because we have never had a use for it inside Google.Techniques
Streaming Multiple Messages
CodedInputStream
class (in both C++ and Java) which can be told to limit reads to a certain number of bytes.)Large Data Sets
Union Types
Foo
, Bar
, and Baz
, you can combine them with a type like:message OneMessage {
// One of the following will be filled in.
optional Foo foo = 1;
optional Bar bar = 2;
optional Baz baz = 3;
}
switch
on it:message OneMessage {
enum Type { FOO = 1; BAR = 2; BAZ = 3; }
// Identifies which field is filled in.
required Type type = 1;
// One of the following will be filled in.
optional Foo foo = 2;
optional Bar bar = 3;
optional Baz baz = 4;
}
message OneMessage {
extensions 100 to max;
}
// Elsewhere...
extend OneMessage {
optional Foo foo_ext = 100;
optional Bar bar_ext = 101;
optional Baz baz_ext = 102;
}
ListFields
reflection method (in C++, Java, and Python) to get a list of all fields present in the message, including extensions. You might use this as part of a scheme for registering handlers for diverse message types.Self-describing Messages
.proto
file defining its type, it is difficult to extract any useful data.src/google/protobuf/descriptor.proto
in the source code package defines the message types involved. protoc
can output a FileDescriptorSet
– which represents a set of .proto files – using the --descriptor_set_out
option. With this, you could define a self-describing protocol message like so:message SelfDescribingMessage {
// Set of .proto files which define the type.
required FileDescriptorSet proto_files = 1;
// Name of the message type. Must be defined by one of the files in
// proto_files.
required string type_name = 2;
// The message data.
required bytes message_data = 3;
}
DynamicMessage
(available in C++ and Java), you can then write tools which can manipulate SelfDescribingMessage
s.
发表评论
-
小对象的分配技术
2011-03-21 12:01 1466小对象分配技术是Loki提高效率的有效途径,Loki里广 ... -
Protocol Buffer Basics: C++
2010-12-07 10:38 1036Protocol Buffer Basics: C++ ... -
Encoding of Protocol Buffers Developer Guide
2010-12-07 10:37 941Encoding A Simple Message ... -
Style Guide of Protocol Buffers Developer Guide
2010-12-07 10:36 786Style Guide This document pr ... -
Language Guide of Protocol Buffers Developer Guide
2010-12-07 10:34 1049Language Guide Defining A M ... -
Overview of Protocol Buffers Developer Guide
2010-12-07 10:31 683Developer Guide Welcome to t ... -
字节序
2010-12-01 21:03 953这几天又开始做网络方面的应用了,既然是网络编程,字节序肯定 ... -
全局变量和局部变量在内存里的区别
2010-11-09 21:55 2222一、预备知识—程序的内存分配 一个由c/C++编译 ... -
JobFlow要继续考虑的问题
2010-09-17 22:35 938小记: 1.把作业队列的概念扩展为作业池JobPool,提供 ... -
C++单例不可继承
2010-09-17 17:24 1490C++语言和单例的特性决定了单例不可继承。 单例有如下几项要 ... -
C++静态成员与静态成员函数小结
2010-09-16 15:48 1055类中的静态成员真是个让人爱恨交加的特性。我决定好好总结一下静态 ... -
log4cxx编译方法
2010-09-08 10:30 19991、下载http://logging.apache.o ... -
优秀的框架工具
2010-09-08 10:13 1139zookeeper Hadoop的子项目,可靠地分布式小文件 ... -
关于auto_ptr的忠告
2010-08-26 16:21 9211.auto_ptr不能用于数组,因为它调用的是delet ... -
snprintf与strncpy效率对比
2010-07-20 09:31 1583一直以为strncpy效率优于snprintf. 无意中在网上 ... -
用Valgrind查找内存泄漏和无效内存访问
2010-07-20 09:29 1958Valgrind是x86架构Linux上的多重用途代码剖析和内 ... -
头文件互包含于名字空间的相关问题
2010-07-17 20:27 1057c/c++里面头文件的使用 ... -
C++库介绍
2010-04-02 16:30 1522基础类1、 Dinkumware C++ ... -
C++中头文件相互包含的几点问题
2010-04-02 16:29 1029一、类嵌套的疑问 C++ ...
相关推荐
Protocol Buffers是Google开发的一种数据序列化协议,用于结构化数据的序列化,可以视为一种跨平台、跨语言的数据交换格式。它允许开发者定义数据结构,然后生成代码以轻松地在各种数据流之间读写这些数据。Protocol...
**Google Protocol Buffers**,简称Protobuf,是Google开发的一种数据序列化协议,它能够将结构化的数据序列化,可用于数据存储、通信协议等方面。它提供了比XML更小、更快、更简单的替代方案,可以用于各种编程语言...
Protocol Buffers 2.4.1 jar
在Google Protocol Buffers(简称Protobuf)中,它是一种数据序列化协议,允许你定义数据结构,然后在各种数据交换格式之间转换。这些数据结构可以是消息类型,它们被存储在.proto文件中。以下是关于Protobuf语言...
Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats. Latest ...
Google Protocol Buffers 是一种轻便高效的结构化数据存储格式,可以用于结构化数据串行化,或者说序列化。它很适合做数据存储或 RPC 数据交换格式。可用于通讯协议、数据存储等领域的语言无关、平台无关、可扩展的...
中文翻译Google Protocol Buffers中文教程中文翻译Google Protocol Buffers中文教程中文翻译Google Protocol Buffers中文教程中文翻译Google Protocol Buffers中文教程
基于Java的Protocol Buffers研究 本文将介绍Protocol Buffers的基本原理和使用方法,并对其进行深入分析。Protocol Buffers是一种高效的消息数据定义和处理方式,能够跨语言使用,具有足够的结构化能力,同时也具有...
标题中的"ProtocolBuffers-2.2.0-Source (1).tar.gz"指的是谷歌的Protocol Buffers(简称protobuf)的2.2.0版本源代码压缩包,它以.tar.gz格式打包,这是一种常见的Linux和macOS下的文件压缩方式。这个压缩包可能是...
Protocol Buffers Java开发包(protobuf-java-2.3.0.jar)
Google.ProtocolBuffers.dll类库
**Google.ProtocolBuffers详解** Google.Protocol Buffers(简称protobuf)是由Google开发的一种数据序列化协议,它提供了一种高效、灵活且跨平台的方式来序列化结构化数据。Protocol Buffers类似于XML和JSON,但其...
基于Protocol Buffers的配置下发接口适配与应用 Protocol Buffers是Google公司开发的开源数据编码方式,具有诸多优势。该技术可以应用于网管配置下发接口,实现高效、可靠的数据交换。下面是基于Protocol Buffers的...
This project contains the implementation of Protocol Buffers for Delphi. From the project was implemented limited functionality necessary for a specific project. At that time, I do not see any sense ...
在Swift编程中,Protocol Buffers(简称Protobuf)和JSON都是常见的数据序列化格式,用于在应用程序之间交换结构化数据。Protocol Buffers提供了一种高效、跨语言的序列化机制,而JSON则是一种轻量级的文本数据交换...
**Protocol Buffers简介** Protocol Buffers(简称protobuf)是由Google开发的一种数据序列化协议,它是一种高效、灵活且跨平台的通信数据格式。这个技术允许开发者定义数据结构,然后生成对应的编码和解码代码,...
protocolbuffer(以下简称PB)是google 的一种数据交换的格式,它独立于语言,独立于平台。google 提供了多种语言的实现,如:java、c#、c++、javascript、go 、python、ruby和php等,每一种实现都包含了相应语言的...
在"Protocol Buffers for Objective C.zip"这个压缩包中,我们可以期待找到与在Objective-C中使用Protocol Buffers相关的资源,这可能包括库文件、示例代码、教程文档等。尽管具体的文件列表(sss)没有给出详细内容...