Re: using dynamic cell names in CQL 3

2014-09-29 Thread Robert Coli
On Thu, Sep 25, 2014 at 6:13 AM, shahab shahab.mok...@gmail.com wrote:

 It seems that I was not clear in my question, I would like to store values
 in the column name, for example column.name would be event_name
 (temperature) and column-content would be the respective value (e.g.
 40.5) . And I need to know how the schema should look like in CQL 3


You cannot have dynamic column names, in the exact storage way you are
thinking of them, in CQL3.

You can have a simple E-A-V scheme which works more or less the same way.
It is less storage efficient, but you get the CQL interface. In the opinion
of the developers, this was an acceptable tradeoff. In most cases, it
probably is.

In other cases, I would recommend using thrift and actual dynamic
columns... except that I logically presume Thrift will be eventually be
deprecated. I am unable to recommend the use of a feature which I believe
will eventually be removed from the product.

=Rob


Re: using dynamic cell names in CQL 3

2014-09-29 Thread Andrew Cobley
Isn’t the correct way to do this in CQL3 to use sets and user defined types (in 
C* 2.1) ?:

create type sensorreading( date timestamp, name text, value int);
CREATE TABLE sensordata (
name text,
data setfrozen sensorreading,
PRIMARY KEY (name)
);

insert into keyspace2.sensordata (name, data) values ('1234', {{date:'2012-10-2 
12:10',name:'temp',value:4}});
update sensordata set data = data+{{date:'2012-10-2 
12:10',name:'humidity',value:30}} where name='1234';
update sensordata set data = data+{{date:'2012-10-2 
12:12:30',name:'temp',value:5}} where name='1234';
update sensordata set data = data+{{date:'2012-10-2 
12:12:30',name:'humidity',value:31}} where name='1234';

select * from sensordata;


Perhaps not what you are after, but may be a start ?

Andy



On 29 Sep 2014, at 20:56, Robert Coli 
rc...@eventbrite.commailto:rc...@eventbrite.com wrote:

On Thu, Sep 25, 2014 at 6:13 AM, shahab 
shahab.mok...@gmail.commailto:shahab.mok...@gmail.com wrote:
It seems that I was not clear in my question, I would like to store values in 
the column name, for example column.namehttp://column.name/ would be 
event_name (temperature) and column-content would be the respective value 
(e.g. 40.5) . And I need to know how the schema should look like in CQL 3

You cannot have dynamic column names, in the exact storage way you are thinking 
of them, in CQL3.

You can have a simple E-A-V scheme which works more or less the same way. It is 
less storage efficient, but you get the CQL interface. In the opinion of the 
developers, this was an acceptable tradeoff. In most cases, it probably is.

In other cases, I would recommend using thrift and actual dynamic columns... 
except that I logically presume Thrift will be eventually be deprecated. I am 
unable to recommend the use of a feature which I believe will eventually be 
removed from the product.

=Rob


The University of Dundee is a registered Scottish Charity, No: SC015096


Re: using dynamic cell names in CQL 3

2014-09-26 Thread Brice Dutheil
I’m not sure I understand correctly “for example column.name would be
event_name(temperature)“, what I gather however is that you have multiple
events that may or may not have certain properties, in your example I
believe you mean you want a CF for events with a type event_name that
contains a column temperature ?!

You can model it like that :

CREATE TABLE events (
  name text,
  metric text,
  value text,
  PRIMARY KEY (name, metric)
)

Where

   - name is the row key, for each kind (or name) of event
   - metric is the column name, aka the clustering key

For example when inserting

INSERT INTO events (name, metric, value) VALUES ('captor',
'temperature', '25 ºC');
INSERT INTO events (name, metric, value) VALUES ('captor', 'wind', '5 km/h');
INSERT INTO events (name, metric, value) VALUES ('captor',
'atmosphere', '1013 millibars');

INSERT INTO events (name, metric, value) VALUES ('cpu', 'temperature', '70 ºC');
INSERT INTO events (name, metric, value) VALUES ('cpu', 'frequency',
'1015,7 MHz');

You will have something like this :
  temperature atmosphere wind frequency   meteorologic 25 ºC 1013 millibars 5
km/h  cpu 70 ºC  1015,7 MHz

CQLSH represents each clustering key as row, which is not how the column
family is stored.

The model I give is just an example as you may want a to model differently
according to your use cases. And time probably is part of it. And will
probably be in the clustering key too.

Note that if you create wide rows and you have *a lot* of data, you may
want to bucket the CF per time period (month / week / day / etc).

HTH

— Brice

On Thu, Sep 25, 2014 at 3:13 PM, shahab shahab.mok...@gmail.com wrote:

Thanks,
 It seems that I was not clear in my question, I would like to store values
 in the column name, for example column.name would be event_name
 (temperature) and column-content would be the respective value (e.g.
 40.5) . And I need to know how the schema should look like in CQL 3

 best,
 /Shahab


 On Wed, Sep 24, 2014 at 1:49 PM, DuyHai Doan doanduy...@gmail.com wrote:

 Dynamic thing in Thrift ≈ clustering columns in CQL

 Can you give more details about your data model ?

 On Wed, Sep 24, 2014 at 1:11 PM, shahab shahab.mok...@gmail.com wrote:

 Hi,

 I  would like to define schema for a table where the column (cell) names
 are defined dynamically. Apparently there is a way to do this in Thrift (
 http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
 )

 but i couldn't find how i can do the same using CQL?

 Any resource/example that I can look at ?


 best,
 /Shahab



  ​


Re: using dynamic cell names in CQL 3

2014-09-25 Thread shahab
Thanks,
It seems that I was not clear in my question, I would like to store values
in the column name, for example column.name would be event_name
(temperature) and column-content would be the respective value (e.g.
40.5) . And I need to know how the schema should look like in CQL 3

best,
/Shahab


On Wed, Sep 24, 2014 at 1:49 PM, DuyHai Doan doanduy...@gmail.com wrote:

 Dynamic thing in Thrift ≈ clustering columns in CQL

 Can you give more details about your data model ?

 On Wed, Sep 24, 2014 at 1:11 PM, shahab shahab.mok...@gmail.com wrote:

 Hi,

 I  would like to define schema for a table where the column (cell) names
 are defined dynamically. Apparently there is a way to do this in Thrift (
 http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
 )

 but i couldn't find how i can do the same using CQL?

 Any resource/example that I can look at ?


 best,
 /Shahab





using dynamic cell names in CQL 3

2014-09-24 Thread shahab
Hi,

I  would like to define schema for a table where the column (cell) names
are defined dynamically. Apparently there is a way to do this in Thrift (
http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows)

but i couldn't find how i can do the same using CQL?

Any resource/example that I can look at ?


best,
/Shahab


Re: using dynamic cell names in CQL 3

2014-09-24 Thread DuyHai Doan
Dynamic thing in Thrift ≈ clustering columns in CQL

Can you give more details about your data model ?

On Wed, Sep 24, 2014 at 1:11 PM, shahab shahab.mok...@gmail.com wrote:

 Hi,

 I  would like to define schema for a table where the column (cell) names
 are defined dynamically. Apparently there is a way to do this in Thrift (
 http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
 )

 but i couldn't find how i can do the same using CQL?

 Any resource/example that I can look at ?


 best,
 /Shahab