Closed
Description
Is it possible to append additional rows with the existing 'rowkey' in Bigtable?
it seems when I call
from operator import itemgetter
import random
def get_row_key(record, template):
attrs = itemgetter(*template)
vals = attrs(record)
return '#'.join((str(v) for v in vals)
# main
record = dict(
user=random.randint(10, 1000),
viewability=30,
developer=1,
advertiser=2,
campaign=3,
game=4,
spot=5,
asset=6,
sex='m',
age=50,
browser='chrome',
browser_ver='55',
os='android',
os_ver='5.0',
mobile=True,
desktop=False,
country='us',
ip_addr='127.0.0.1',
created=1478218018,
tick_size=5,
session='aaaa'
is_generic=False
)
# pattern used in itemgetter
rowkey = ('asset', 'created', 'advertiser')
row = table.row(get_row_key(record, pattern))
for column, val in record.items():
row.set_cell('stat', column, val)
row.commit()
so if I run code against the same record 3 times (which will produce the same rowkey for the row) I only get a single row. It seems 1st row is inserted, and then 2nd and 3rd mutate the same row. How to make it append? (OR row_key HAS TO BE UNIQUE?)
thanks,
Dmitry