2

I have been testing table.put using java and python.

In java, you can write int or float values into a column. using happybase

table.put(line_item_key, {'allinone:quantity': quantity})

it bombs out with TypeError: object of type 'int' has no len()

Could this be true that happybase does not support write out anything other than string?

bhomass
  • 3,414
  • 8
  • 45
  • 75

2 Answers2

4

In Hbase, everything is byte array. No any fancy data type like int,string,float, double, etc. So whenever you want to insert in hbase table,first you need to convert into byte array. Then you can insert.

chandu kavar
  • 411
  • 1
  • 4
  • 13
1

You can also insert byte arrays into hbase using happybase with the python struct module.

import struct

quantity = struct.pack(">i", 1)
table.put(rowkey, {'allinone:quantity': quantity})

This will insert the binary representation in HBase.

rye
  • 487
  • 1
  • 5
  • 15