incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaron morton <aa...@thelastpickle.com>
Subject Re: CF metadata syntax for an array
Date Tue, 13 Nov 2012 10:08:55 GMT
> While this solves the problem for an array of 'primitive' types. What if I want an array
or collection of an arbitrary type like list<foo>, where foo is a user defined type?
Do you mean a custom Cassandra data type that sub classes AbstractType? I dont think CQL can
support those, I may be wrong though. 

If you mean a basic client side data type you could serialise it and store as a string or
byte buffer in a CQL collection. 

> What are the options to solve this type of array? 
...
> arbitrary type like list<foo>, 
Do you mean an array such as int[] or do you mean the equivalent of a java List<T> with
functions like remove that actually delete items and from the list?

If it's the former a CQL table such as below would work

CREATE TABLE vectors (
	vector_name text,
	index bigint,
	object_property_1 text,
	object_property_2 text,
	PRIMARY_KEY (vector_name, index)
);

The problem is, if you delete a element at (vector, index) the remaining indexes will be off.
 
If it's the later, a List<T>, then it depends a little on what features you want to
support. If you want a sorted list of objects the table is roughly the same

CREATE TABLE List (
	list_name text,
	sort_key bigint,
	object_property_1 text,
	object_property_2 text,
	PRIMARY_KEY (list_name, sort_key)
);

Hope that helps. 

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 13/11/2012, at 9:46 AM, Kevin Burton <rkevinburton@charter.net> wrote:

> While this solves the problem for an array of 'primitive' types. What if I want an array
or collection of an arbitrary type like list<foo>, where foo is a user defined type?
I am guessing that this cannot be done with 'collections'. What are the options to solve this
type of array?
> 
> On Nov 12, 2012, at 2:28 PM, aaron morton <aaron@thelastpickle.com> wrote:
> 
>> This may help http://www.datastax.com/dev/blog/cql3_collections
>> 
>>>  I have gotten as far as feeling a need to understand a ‘super-column’ 
>> You can happily ignore them.
>> 
>> 
>> Cheers
>> 
>> -----------------
>> Aaron Morton
>> Freelance Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>> 
>> On 12/11/2012, at 8:35 PM, Kevin Burton <rkevinburton@charter.net> wrote:
>> 
>>> I am sorry if this is an FAQ. But I was wondering what the syntax for describing
an array? I have gotten as far as feeling a need to understand a ‘super-column’ but I
fail after that. Once I have the metadata in place to describe an array how do I  insert data
into the array? Get data from the array? Thank you.
>>>  
>> 


Mime
View raw message