Read And Modify on same transaction - Bigtable

爱⌒轻易说出口 提交于 2019-12-11 07:34:20

问题


I building a coupon system and I use bigtable.

My schema has two column - Customer ID, Coupon code

I would like to query the table to check if the customer already exists and if true to return the code and if it doesn't, modify the customer id cell with the id and to return back the code.

I saw there is an option to do it in Bigtable ReadModifyWriteRow operator or with CheckAndMutateRow but I not found any references.


回答1:


Google has API documentation for Bigtable and Python available here. This shows you all the available methods and the source code that they refer to, so you can easily and more effectively use and understand the usage.

ReadModifyWriteRow appends as bytes or increments data in an existing cell in a row.

CheckAndMutateRow checks if a filter matched and then applies 2 sets of mutations. These are “true mutations” and “false mutations”.

You can use if statements in order to achieve the usage that you wish.

You can read about CheckAndMutateRow conditional requests, and there are also code samples available.



来源:https://stackoverflow.com/questions/57914718/read-and-modify-on-same-transaction-bigtable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!