efficient way to store 8-bit or 16-bit value?

2013-12-11 Thread onlinespending
What do people recommend I do to store a small binary value in a column? I’d 
rather not simply use a 32-bit int for a single byte value. Can I have a one 
byte blob? Or should I store it as a single character ASCII string? I imagine 
each is going to have the overhead of storing the length (or null termination 
in the case of a string). That overhead may be worse than simply using a 32-bit 
int.

Also is it possible to partition on a single character or substring of 
characters from a string (or a portion of a blob)? Something like:

CREATE TABLE test (
id text,
value blob,
PRIMARY KEY (string[0:1])
) 

Re: efficient way to store 8-bit or 16-bit value?

2013-12-11 Thread Andrey Ilinykh
Column metadata is about 20 bytes. So, there is no big difference if you
save 1 or 4 bytes.

Thank you,
  Andrey


On Wed, Dec 11, 2013 at 2:42 PM, onlinespending onlinespend...@gmail.comwrote:

 What do people recommend I do to store a small binary value in a column?
 I’d rather not simply use a 32-bit int for a single byte value. Can I have
 a one byte blob? Or should I store it as a single character ASCII string? I
 imagine each is going to have the overhead of storing the length (or null
 termination in the case of a string). That overhead may be worse than
 simply using a 32-bit int.

 Also is it possible to partition on a single character or substring of
 characters from a string (or a portion of a blob)? Something like:

 CREATE TABLE test (
 id text,
 value blob,
 PRIMARY KEY (string[0:1])
 )


Re: efficient way to store 8-bit or 16-bit value?

2013-12-11 Thread Aaron Morton
 What do people recommend I do to store a small binary value in a column? I’d 
 rather not simply use a 32-bit int for a single byte value. 
blob is a byte array
or you could use the varint, a variable length integer, but you probably want 
the blob. 

cheers

-
Aaron Morton
New Zealand
@aaronmorton

Co-Founder  Principal Consultant
Apache Cassandra Consulting
http://www.thelastpickle.com

On 12/12/2013, at 1:33 pm, Andrey Ilinykh ailin...@gmail.com wrote:

 Column metadata is about 20 bytes. So, there is no big difference if you save 
 1 or 4 bytes.
 
 Thank you,
   Andrey
 
 
 On Wed, Dec 11, 2013 at 2:42 PM, onlinespending onlinespend...@gmail.com 
 wrote:
 What do people recommend I do to store a small binary value in a column? I’d 
 rather not simply use a 32-bit int for a single byte value. Can I have a one 
 byte blob? Or should I store it as a single character ASCII string? I imagine 
 each is going to have the overhead of storing the length (or null termination 
 in the case of a string). That overhead may be worse than simply using a 
 32-bit int.
 
 Also is it possible to partition on a single character or substring of 
 characters from a string (or a portion of a blob)? Something like:
 
 CREATE TABLE test (
 id text,
 value blob,
 PRIMARY KEY (string[0:1])
 )