cassandra - Astyanax getKey with compound key -


i run following code compound primary key.

column<string> result = keyspace.preparequery(cf_counter1)     .getkey(rowkey)     .getcolumn("column1")     .execute().getresult(); long countervalue = result.getlongvalue(); 

research seems show can string represents key (if it's not compound primary key). the documentation says of type k, alas, not experience java, , have no idea means. base type lots of stuff inherits from? if so, i'm not closer knowing getkey(k) needs in order handle compound key (am i?).

you need write class fits columns in data model. can give class astyanax in mutations or queries.

for example, if had data model this

   create table fishblogs (         userid varchar,         when timestamp,         fishtype varchar,         blog varchar,         image blob,         primary key (userid, when, fishtype)     ); 

you create class this:

   public class fishblog {       @component(ordinal = 0)       public long when;       @component(ordinal = 1)       public string fishtype;       @component(ordinal = 2)       public string field;        public fishblog() {       }    } 

when , fishtype form composite column key , represented fishblog class. userid row/partition key , can of simple "string" type.

have @ this blog explaining in great detail how insert data composite keys (where took example from).

hope helps.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -