Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseDelimitedFrom and writeDelimitedTo only available in Java. #27

Open
cmacdonald opened this issue Mar 29, 2021 · 0 comments
Open

parseDelimitedFrom and writeDelimitedTo only available in Java. #27

cmacdonald opened this issue Mar 29, 2021 · 0 comments

Comments

@cmacdonald
Copy link
Member

We use message.writeDelimitedTo() in Java to write multiple messages into a stream. However, this function is only available in Java. See also https://www.datadoghq.com/blog/engineering/protobuf-parsing-in-python/

My replacement in Python:

def write_delimited(f, o):
  from google.protobuf.internal.encoder import _VarintBytes
  from google.protobuf.internal.decoder import _DecodeVarint32
  size = o.ByteSize()
  f.write(_VarintBytes(size))
  f.write(o.SerializeToString())
JMMackenzie added a commit that referenced this issue Apr 12, 2021
* Update README.md

A few simple documentation changes to the README.

* notes about  parseDelimitedFrom() and writeDelimitedTo() cf #27

* make a note about d-gaps and writeDelimitedTo

Co-authored-by: Craig Macdonald <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant