Is it possible to decode a compressed blob using a cqlsh query?

168 Views Asked by At

I am saving blob in cassandra by converting a text into a compressed blob using erlang function 'term_to_binary'. https://www.erlang.org/doc/man/erlang.html#term_to_binary-2

Is there a way to decode the above compressed blob to original text using a cqlsh query?

1

There are 1 best solutions below

0
erszcz On

You can convert the blob back to an Erlang term with binary_to_term, but it cannot be done in cqlsh, it has to be done in Erlang/Elixir on the application level.

If you want to read from the database using a language which doesn't have binary_to_term, then you might be interested in BERT which is almost 100% compatible with Erlang Term Format and has libraries for Javascript and Ruby.

Alternatively, any other serialisation format like Piqi, JSON, XML etc would work.