[protobuf] Re: Issue 262 in protobuf: FileOutputStream::Flush wrongfully flushes entire buffer (not just used bytes)

2011-02-22 Thread protobuf

Updates:
Status: WorkingAsIntended

Comment #1 on issue 262 by tempo...@gmail.com: FileOutputStream::Flush  
wrongfully flushes entire buffer (not just used bytes)

http://code.google.com/p/protobuf/issues/detail?id=262

You need to destroy the CodedOutputStream before flushing the  
FileOutputStream.  While the CodedOutputStream is active it owns the  
underlying stream and you should not try to manipulate it separately.


--
You received this message because you are subscribed to the Google Groups Protocol 
Buffers group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Re: Issue 262 in protobuf: FileOutputStream::Flush wrongfully flushes entire buffer (not just used bytes)

2011-02-22 Thread protobuf


Comment #3 on issue 262 by ken...@google.com: FileOutputStream::Flush  
wrongfully flushes entire buffer (not just used bytes)

http://code.google.com/p/protobuf/issues/detail?id=262

The intended usage is that you construct a new CodedOutputStream on the  
stack for every message you write.  It is cheap to construct and destroy.


The same is true for reading.  You should construct a new CodedInputStream  
for each message you read.  Otherwise you're likely to hit the 64MB message  
size limit, which probably shouldn't apply to multi-message streams.


--
You received this message because you are subscribed to the Google Groups Protocol 
Buffers group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Re: Issue 262 in protobuf: FileOutputStream::Flush wrongfully flushes entire buffer (not just used bytes)

2011-02-22 Thread protobuf


Comment #2 on issue 262 by gno...@gmail.com: FileOutputStream::Flush  
wrongfully flushes entire buffer (not just used bytes)

http://code.google.com/p/protobuf/issues/detail?id=262

Fair enough, but this means that a single instance of a CodedOutputStream  
cannot be used over a streaming socket (which is how I got to this) because  
nothing is written to the socket unless:

1. the buffer fills up; or
2. the owning CodedOutputStream is destroyed
and simply calling Flush() on the FileOutputStream will write to the socket  
more than intended.


So for streaming a CodedOutputStream must be created and destroyed over the  
FileOutputStream for each message. Not so great, especially when for  
reading you don't have to do this (so you get asymmetric code for reading  
vs. writing)


Maybe a Flush() for CodedOutputStream isn't a bad idea?

Thanks for the clarification.

--
You received this message because you are subscribed to the Google Groups Protocol 
Buffers group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.