Skip to content

Commit

Permalink
added read modify write
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Oct 6, 2023
1 parent f053125 commit 2943e06
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test_proxy/handlers/client_handler_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,20 @@ async def CheckAndMutateRow(self, request, **kwargs):

@client_handler.error_safe
async def ReadModifyWriteRow(self, request, **kwargs):
raise NotImplementedError()
from google.cloud.bigtable.row import AppendRow
table_id = request["table_name"].split("/")[-1]
instance = self.client.instance(self.instance_id)
table = instance.table(table_id)
row_key = request["row_key"]
new_row = AppendRow(row_key, table)
for rule_dict in request.get("rules", []):
qualifier = rule_dict["column_qualifier"]
family = rule_dict["family_name"]
if "append_value" in rule_dict:
new_row.append_cell_value(family, qualifier, rule_dict["append_value"])
else:
new_row.increment_cell_value(family, qualifier, rule_dict["increment_amount"])
return new_row.commit()

@client_handler.error_safe
async def SampleRowKeys(self, request, **kwargs):
Expand Down

0 comments on commit 2943e06

Please sign in to comment.