views:

671

answers:

2

Assume the following data set:

id       age  city      phone
==       ===  ====      =====
alfred   30   london    3281283
jeff     43   sydney    2342734
joe      29   tokyo     1283881
kelly    54   new york  2394929
molly    20   london    1823881
rob      39   sydney    4928381

To get the following result set ..

id       age  phone
==       ===  =====
alfred   30   3281283
joe      29   1283881
molly    20   1823881

.. using SQL one would issue ..

SELECT id, age, phone FROM dataset WHERE id IN ('alfred', 'joe', 'molly');

What is the corresponding Cassandra API call that would yield the same result set in one command?

+3  A: 

you would do a multiget_slice w/ keys of alfred, joe, and molly, and SlicePredicate column_names of id, age, phone

jbellis
+1  A: 

A Cassandra equivalent could be modelled as described below:

Users = { //this is a ColumnFamily
  "alfred": { //this is the key to this Row inside the CF
     "age":"30",
     "city":"london",
     "phone":"3281283"
  }, // end row
  // more rows...
}

where "alfred" is your (row) key and the row has three columns; age, city and phone. (Omitted the timestamp field (for simplicity) for the three columns)

Schildmeijer