Writing to a boost gzip filter stream

64 views
Skip to first unread message

emyrj...@gmail.com

unread,
Jul 20, 2020, 12:08:12 AM7/20/20
to Cap'n Proto
Hi,

I have an application that is currently using gzipped tab seperated fields file. The fields are a mix of strings and ints (it's the lstat info for every file in a filesystem). To store the full path in this file I base64 encode it so that the TSV format doesn't break when paths contain unprintable characters. I load this into a clickhouse database for reporting. Having to do base64 decoding in clickhouse is a pain and slows down the queries.
I want to switch my lstap collector to output capnp messages to avoid having to use base64 encoding. I currently use the boost gzip filter streams to do on the fly compression for my tsv lines. I'd like to do the same with capnp messages but it seems the only way to write to a file is using file descriptors. How can I write messages to a boost::io::filtering_ostream ?

Many thanks,

Emyr

Kenton Varda

unread,
Jul 20, 2020, 8:06:36 PM7/20/20
to emyrj...@gmail.com, Cap'n Proto
Hi Emyr,

You can use capnp::writeMessage() to write to any kind of stream.


This function writes to a `kj::OutputStream`, which is an abstract interface that you can implement any way you want. It only has a couple methods:


(capnp::writeMessage() always calls the second version of write(), which takes an array of byte arrays, to write the entire message all at once.)

In fact, there's even already an implementation of kj::OutputStream that gzip-compresses the output:


So you don't even need to use boost for that.

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/7b25d572-414e-481a-a9e8-587b6ed522fco%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages