开发者

Cassandra: Update multiple rows?

开发者 https://www.devze.com 2023-01-11 19:53 出处:网络
In mysql, I can do the following query, UPDATE mytable SET price = \'100\' WHERE manuf开发者_开发技巧acturer=\'22\'

In mysql, I can do the following query, UPDATE mytable SET price = '100' WHERE manuf开发者_开发技巧acturer='22'

Can this be done with cassandra?

Thanks!


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消