How to store a blob inside cassandra column family - size intially decided as <= 10 mb

2,338 views
Skip to first unread message

Shouvanik Haldar

unread,
Aug 10, 2012, 1:49:58 PM8/10/12
to hector...@googlegroups.com
Hi,

I have still not lucky in inserting a blob inside cassandra database column family. Does anybody know how to do it? My requirement is that I have to insert a blob (e.g. a image file) inside a column family and retrieve that blob value using the row key.

Regards,
Shouvanik

Shouvanik Haldar

unread,
Aug 10, 2012, 4:47:55 PM8/10/12
to hector...@googlegroups.com
I have found a work around. I am reading contents into a ByteArrayOutputStream and saving inside cassandra db. And retrieving the value back using FileOutputStream object. But this is limited to use if file size is less that <=10 mb. I know that cassandra does not encourage storing Blobs directly inside database column families.

I will push for using pointers that store location info and keep the files at some other place. My question is, do we have some repository that fits well with cassandra, so that this sort of communication can take place.? Any answer is highly appreciated.

Shouvanik

Nate McCall

unread,
Aug 10, 2012, 5:31:59 PM8/10/12
to hector...@googlegroups.com
The folks at DataStax have built their entire hadoop file system
implementation around storing binary data in cassandra. Yes it is
possible and done correctly will be extremely performant. Download the
trial version of DataStax Enterprise and run through the tutorials
then take a look at the column families created.

The general approach is to chunk data into smaller fixed size columns.
Maybe use composites on the column names to get creative with
checksums, file size information and similar, depending on your use
case.

When the slides from the Cassandra summit are posted (should be pretty
soon) Jonathan's keynote actually has a picture of the data model they
use (which is tuned for large HDFS blocks, but should still give you
some good ideas) with some additional contextual information.

pravat

unread,
Oct 13, 2012, 3:56:46 AM10/13/12
to hector...@googlegroups.com
@Shouvanik]


can u please share your coding to store the blob(image file ) into cassandra database.
its urgent.
if anybody  help me please to solve this issue

thanks in advance
pravat

sweety Bittu

unread,
Oct 13, 2012, 11:37:06 PM10/13/12
to hector...@googlegroups.com
I think you can try with BytesType as validator and persist as Bytes.

Kalyan Babu

unread,
Jan 30, 2013, 4:11:14 AM1/30/13
to hector...@googlegroups.com

Hi ,Shouvanik Haldar
           can u please give some code sample for storing a blob or image in Cassandra database,It is is very urgent for me...Thanks for ur reply.....

Thanks,
kalyan



Shane Perry

unread,
Jan 30, 2013, 10:47:20 AM1/30/13
to hector...@googlegroups.com
Convert your blob/image to a byte array and store using the template
system (see http://hector-client.github.com/hector/build/html/content/getting_started.html#update)
> --
> You received this message because you are subscribed to the Google Groups
> "hector-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hector-users...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Víctor Hugo Oliveira Molinar

unread,
Jan 31, 2013, 9:50:52 PM1/31/13
to hector...@googlegroups.com
Im currently persisting thrift objects by serializing it to byte array.
That works since my objects are never too heavy.
Reply all
Reply to author
Forward
0 new messages