Re: [protobuf] GZip Stream examples

2011-03-09 Thread ksamdev
Well, I have to update the very first value, , after all messages are 
written. I do not know a priory how many messages will be stored. Therefore, 
I use fstream::fseekp(0) to move the write pointer before the file is closed 
and update the value. Of course, the number is written without optimizations 
with WriteLittleEndian32(...).

It does not seem I can do the same with Gzip. The number would be compressed 
differently depending on its value and therefore may have different length.

-- 
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.



Re: [protobuf] GZip Stream examples

2011-03-08 Thread Jason Hsueh
I don't think there are any problems with having a raw prefix, and just
wrapping GZipInputStream around the raw input stream after it's been read,
but that sounds pretty messy. It seems easier to just make the whole thing a
gzip stream - it can then also be easily read by other tools that use zlib.

On Tue, Mar 8, 2011 at 8:09 PM, ksamdev  wrote:

> Cool, it worked great.
>
> Can I mix Raw out and Gzip out in the file?
>
> Say, I'd like to write a raw number (4 bytes) at the beginning of the file
> and then add the message through the Gzip stream. Visually, my file would
> look like:
>
> .
>
> where first  - 4 bytes written with raw_out and the rest:
> GG - with Gzip Stream.
>
> Of course, the reading sequence would be:
>
> 1. read 
> 2. keep reading the rest G through Gzip Stream.
>
> --
> 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.
>

-- 
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.



Re: [protobuf] GZip Stream examples

2011-03-08 Thread ksamdev
Cool, it worked great.

Can I mix Raw out and Gzip out in the file?

Say, I'd like to write a raw number (4 bytes) at the beginning of the file 
and then add the message through the Gzip stream. Visually, my file would 
look like:

.

where first  - 4 bytes written with raw_out and the rest: 
GG - with Gzip Stream.

Of course, the reading sequence would be:

1. read 
2. keep reading the rest G through Gzip Stream.

-- 
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.



Re: [protobuf] GZip Stream examples

2011-03-08 Thread Jason Hsueh
You wrap GZipOutputStream around your underlying output stream, and use the
GZipOutputStream with CodedOutputStream instead:

On Tue, Mar 8, 2011 at 10:10 AM, ksamdev  wrote:

> Hi,
>
> Are there any examples on how to use GzipOUtputStream in ProtoBuf?
> I've manages so far combo:
>
>  _raw_out.reset(new
> ::google::protobuf::io::OstreamOutputStream(&_output));
>
_compressed_out.reset(new
::google::protobuf::io::GZipOutputStream(_raw_out.get()));

>  _coded_out.reset(new
> ::google::protobuf::io::CodedOutputStream(_compressed_out.get()));
>
> (both objects are boost::shared_pointer's).
>
> How am I supposed to use the GzipOutputStream here?
>
> thanks.
>
> --
> 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.
>

-- 
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] GZip Stream examples

2011-03-08 Thread ksamdev
Hi,

Are there any examples on how to use GzipOUtputStream in ProtoBuf?
I've manages so far combo:

 _raw_out.reset(new 
::google::protobuf::io::OstreamOutputStream(&_output));
 _coded_out.reset(new 
::google::protobuf::io::CodedOutputStream(_raw_out.get()));

(both objects are boost::shared_pointer's).

How am I supposed to use the GzipOutputStream here?

thanks.

-- 
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.