【源码】protobuf 中各个压缩(Serialize)、解压缩

io::ZeroCopyInputStream* input);

// Parse a protocol buffer from a file descriptor. If successful, the entire

// input will be consumed.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromFileDescriptor(

int file_descriptor);

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromFileDescriptor(

int file_descriptor);

// Parse a protocol buffer from a C++ istream. If successful, the entire

// input will be consumed.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromIstream(std::istream* input);

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromIstream(

std::istream* input);

// Read a protocol buffer from the given zero-copy input stream, expecting

// the message to be exactly “size” bytes long. If successful, exactly

// this many bytes will have been consumed from the input.

bool MergePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input,

int size);

// Like ParseFromBoundedZeroCopyStream(), but accepts messages that are

// missing required fields.

bool MergeFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input, int size);

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromBoundedZeroCopyStream(

io::ZeroCopyInputStream* input, int size);

// Like ParseFromBoundedZeroCopyStream(), but accepts messages that are

// missing required fields.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromBoundedZeroCopyStream(

io::ZeroCopyInputStream* input, int size);

// Parses a protocol buffer contained in a string. Returns true on success.

// This function takes a string in the (non-human-readable) binary wire

// format, matching the encoding output by MessageLite::SerializeToString().

// If you’d like to convert a human-readable string into a protocol buffer

// object, see google::protobuf::TextFormat::ParseFromString().

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromString(ConstStringParam data);

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromString(

ConstStringParam data);

// Parse a protocol buffer contained in an array of bytes.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromArray(const void* data,

int size);

PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromArray(const void* data,

int size);

// Reads a protocol buffer from the stream and merges it into this

// Message. Singular fields read from the what is

// already in the Message and repeated fields are appended to those

// already present.

//

// It is the responsibility of the caller to call input->LastTagWas()

// (for groups) or input->ConsumedEntireMessage() (for non-groups) after

// this returns to verify that the message’s end was delimited correctly.

//

// ParseFromCodedStream() is implemented as Clear() followed by

// MergeFromCodedStream().

bool MergeFromCodedStream(io::CodedInputStream* input);

// Like MergeFromCodedStream(), but succeeds even if required fields are

// missing in the input.

//

// MergeFromCodedStream() is just implemented as MergePartialFromCodedStream()

// followed by IsInitialized().

bool MergePartialFromCodedStream(io::CodedInputStream* input);

// Merge a protocol buffer contained in a string.

bool MergeFromString(ConstStringParam data);


Serialization


Methods for serializing in protocol buffer format. Most of these are just simple wrappers around ByteSize() and SerializeWithCachedSizes().

// Write a protocol buffer of this message to the given output. Returns

// false on a write error. If the message is missing required fields,

// this may GOOGLE_CHECK-fail.

bool SerializeToCodedStream(io::CodedOutputStream* output) const;

bool SerializePartialToCodedStream(io::CodedOutputStream* output) const;

// Write the message to the given zero-copy output stream. All required

// fields must be set.

bool SerializeToZeroCopyStream(io::ZeroCopyOutputStream* output) const;

bool SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream* output) const;

// Serialize the message and store it in the given string. All required

// fields must be set.

bool SerializeToString(std::string* output) const;

bool SerializePartialToString(std::string* output) const;

// Serialize the message and store it in the given byte array. All required

// fields must be set.

bool SerializeToArray(void* data, int size) const;

bool SerializePartialToArray(void* data, int size) const;

// Make a string encoding the message. Is equivalent to calling

// SerializeToString() on a string and using that. Returns the empty

// string if SerializeToString() would have returned an error.

// Note: If you intend to generate many such strings, you may

// reduce heap fragmentation by instead re-using the same string

// object with calls to SerializeToString().

std::string SerializeAsString() const;

std::string SerializePartialAsString() const;

// Serialize the message and write it to the given file descriptor. All

// required fields must be set.

bool SerializeToFileDescriptor(int file_descriptor) const;

bool SerializePartialToFileDescriptor(int file_descriptor) const;

Ending

Tip:由于文章篇幅有限制,下面还有20个关于MySQL的问题,我都复盘整理成一份pdf文档了,后面的内容我就把剩下的问题的目录展示给大家看一下

如果觉得有帮助不妨【转发+点赞+关注】支持我,后续会为大家带来更多的技术类文章以及学习类文章!(阿里对MySQL底层实现以及索引实现问的很多)

吃透后这份pdf,你同样可以跟面试官侃侃而谈MySQL。其实像阿里p7岗位的需求也没那么难(但也不简单),扎实的Java基础+无短板知识面+对某几个开源技术有深度学习+阅读过源码+算法刷题,这一套下来p7岗差不多没什么问题,还是希望大家都能拿到高薪offer吧。

学习类文章!**(阿里对MySQL底层实现以及索引实现问的很多)

[外链图片转存中…(img-ZjO1LsFH-1714159667507)]

[外链图片转存中…(img-nfqqTW7u-1714159667508)]

吃透后这份pdf,你同样可以跟面试官侃侃而谈MySQL。其实像阿里p7岗位的需求也没那么难(但也不简单),扎实的Java基础+无短板知识面+对某几个开源技术有深度学习+阅读过源码+算法刷题,这一套下来p7岗差不多没什么问题,还是希望大家都能拿到高薪offer吧。

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

  • 21
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值