You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BigTable] Convert byte to int after table.read_row() call issue #2678
In [43]: struct.unpack('>Q', r.cells['stat']['asset'][0].value)
Out[43]: (1,)
however is it possible to conver the int/long values automatically to python type once read_row is called?
set_cell doesn't require mandatory conversion to bytes so you simply submit int, char values and they're converted automatically.
I think it's great for end developer to get actual 'python' value instead of bytes.
Maybe I'm missing something and it has it's own purpose?
@dmitry-saritasa Bigtable stores no metadata about the types being stored, so storing typed data and converting back to types isn't something we could infer without using a different backend. So unfortunately, this is an impossible feature for us to add.
If you'd like a way to specify a type and have it converted, we could look into serialization / deserialization helpers, but you can also roll your own. For example, you could convert integers directly to the bytes representing the digits, and this would be efficient storage-wise until you hit 99999999 (max int is 9223372036854775807 which has 19 digits, min is -9223372036854775808)
What you are looking for is the Datastore API, which stores typed data.
Please let me know if there are any other questions about this.
Activity
dmitry-saritasa commentedon Nov 4, 2016
first integer in row_key is value for field 'stat:asset', when I'm trying to obtain the value:
[-][Bi[/-][+][BigTable] Convert byte to int after table.read_row() call issue[/+]dmitry-saritasa commentedon Nov 4, 2016
I see, the answer is this
https://docs.python.org/3/library/struct.html
however is it possible to conver the int/long values automatically to python type once read_row is called?
set_cell doesn't require mandatory conversion to bytes so you simply submit int, char values and they're converted automatically.
I think it's great for end developer to get actual 'python' value instead of bytes.
Maybe I'm missing something and it has it's own purpose?
thanks,
Dmitry
dhermes commentedon Nov 4, 2016
@dmitry-saritasa Bigtable stores no metadata about the types being stored, so storing typed data and converting back to types isn't something we could infer without using a different backend. So unfortunately, this is an impossible feature for us to add.
If you'd like a way to specify a type and have it converted, we could look into serialization / deserialization helpers, but you can also roll your own. For example, you could convert integers directly to the bytes representing the digits, and this would be efficient storage-wise until you hit
99999999(max int is9223372036854775807which has 19 digits, min is-9223372036854775808)What you are looking for is the Datastore API, which stores typed data.
Please let me know if there are any other questions about this.
automl: add natural language text classification ga samples [(#2678)](G…