apache / accumulo-proxy

Apache Accumulo Proxy
https://accumulo.apache.org
Apache License 2.0
9 stars 19 forks source link

examples or support for writing non-string values #26

Closed knackjax closed 3 years ago

knackjax commented 3 years ago

Code suggests adding non-string values using Accumulo Proxy do not work since Thrift is defaulted to String value.

https://github.com/apache/accumulo-proxy/blob/5df2f8c5017e5a8395316d928828c10f59cbe8c2/src/main/python/accumulo/ttypes.py#L514

Is there a way or examples to insert Date/Integer types into Accumulo Proxy using python?

Example, if you replace values in basic_client.py, you will get a runtime error.

row1 = {'a':[ColumnUpdate('a','a',value=1), ColumnUpdate('b','b',value=2]}
ctubbsii commented 3 years ago

@knackjax Accumulo works with arbitrary byte arrays. If you want to store anything more complex than arbitrary bytes, you must encode them into a byte array somehow.

The code you linked is auto-generated Thrift code. Thrift has a type system. Accumulo uses the binary type for this value field, as you can see here: https://github.com/apache/accumulo-proxy/blob/5df2f8c5017e5a8395316d928828c10f59cbe8c2/src/main/thrift/proxy.thrift#L55

Based on your example and the code you linked, it appears that Thrift uses strings to represent this binary type in python, so you will need to encode your complex objects into a python string using a mechanism of your choosing.