Industrial
Industrial

Reputation: 42758

Cassandra: Update multiple rows?

In mysql, I can do the following query, UPDATE mytable SET price = '100' WHERE manufacturer='22'

Can this be done with cassandra?

Thanks!

Upvotes: 1

Views: 3292

Answers (1)

Schildmeijer
Schildmeijer

Reputation: 20946

For that you will need to maintain your own index in a separate column family (you need a way to find all products (product ids) that are manufactured by a certatin manufacturer. When you have all the product ids doing a batch mutation is simple). E.g

 ManufacturerToProducts = { // this is a ColumnFamily
     '22': { // this is the key to this Row inside the CF
        // now we have an infinite # of columns in this row
       'prod_1': "prod_1",  //for simplicity I'm only showing the value (but in reality the values in the map are the entire Column.)
       'prod_1911' : null         
      },  // end row
      '23': {   // this is the key to another row in the CF
         // now we have another infinite # of columns in this row
        'prod_1492': null,
      },
    }

(disclaimer: thanks Arin for the annotation used above)

Upvotes: 3

Related Questions