cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ono_matope <>
Subject Wide Row with some indexes in CQL3
Date Thu, 24 Oct 2013 06:59:49 GMT

In my new project, I want to create a wide row CF with indexes in CQL3.

In my project, users can store multipurpose data and backed to Cassandra.

For example, my Profile CF has some user-defined properties as wide row.
And users can add indexes on columns which they want.
Of cource, we can create such a CF easily on Thrift as below.

[default] create column family profile_thrift
  with comparator = 'UTF8Type'
  and default_validation_class = 'UTF8Type'
  and key_validation_class = 'UTF8Type';

[default] update column family profile_thrift with column_metadata =
        column_name : gender,
        validation_class : UTF8Type,
        index_type : 0,
        index_name : idx_gender

[default] get profile_thrift where gender='m';
RowKey: user002
=> (name=age, value=33, timestamp=1382524511829000)
=> (name=gender, value=m, timestamp=1382524519270000)
=> (name=name, value=bob, timestamp=1382524503605000)
RowKey: user003
=> (name=gender, value=m, timestamp=1382524887595000)
=> (name=hobby, value=driving, timestamp=1382524567386000)
=> (name=name, value=charlie, timestamp=1382524545710000)

2 Rows Returned.
Elapsed time: 39 msec(s).


But now, Thrift looks likely to obsoleted sooner or later and I hesitate to adopt it to new
project now.
 (cf. )

Although I don't have any idea how create such a table in CQL3.
I can create wide row tables with index in CQL3 on *ALL* columns of profile.
I think it's too much. 
So I want to index on *specified* column.

  id text,
  column text,
  value text,
  PRIMARY KEY (id, column)
CREATE INDEX idx_profile_val ON profile_CQL3 (value);

INSERT INTO profile_CQL3 (id,column,value) VALUES('user001', name','alice');
INSERT INTO profile_CQL3 (id,column,value) VALUES('user001','age','18');
INSERT INTO profile_CQL3 (id,column,value) VALUES('user001','gender','f');

INSERT INTO profile_CQL3 (id,column,value) VALUES('user002', name','bob');
INSERT INTO profile_CQL3 (id,column,value) VALUES('user002','age','33');
INSERT INTO profile_CQL3 (id,column,value) VALUES('user002','gender','m');

INSERT INTO profile_CQL3 (id,column,value) VALUES('user003', name','charlie');
INSERT INTO profile_CQL3 (id,column,value) VALUES('user003','hobby','driving')
INSERT INTO profile_CQL3 (id,column,value) VALUES('user003','gender','m');

select * from profile_CQL3 where value='m' and column='gender';

So, do you know some good way to do this on CQL3? or should I adopt Thrift in this project?

(User-profile is just a example. we would like to provide versatile datastore which have property
like this (i.e like thrift-api).)

View raw message