Logic
Logic

Reputation: 2258

How to add multipule values in single column of hbase

I have Geo Co-ordinates to be saved in HBase, for a single point I'm saving with column names as latitude and longitude, but when I have a line instead of point,I'll have to save 6 Geo Co-ordinates into HBase. The no.of Geo Co-ordinates varies. So, how to save such data into HBase ?

Can anything be done with column name, column family or anything else in the schema ?

What I need is to save in same column latitude and longitude, it should have one value each for a point, 6 values each for a line and so on...

Upvotes: 1

Views: 92

Answers (1)

Columns in HBase can be dynamically generated, you don't have to specify them in a schema. Given that you can have:

  • columns longitude and latitude for points
  • columns cord1, cord2, ..., cord6 for lines

Another option is to always have columns longitude and latitude and format the values according to whether you have a point or a line. For instance, if your encoding has a fixed length of 4 bytes, you'd have

  • points:
    • longitude = [0xdeadbeef]
    • latitude = [0xbadcaffe]
  • lines:
    • longitude = [0xdeadbeef 0xcafebabe 0x000000]
    • latitude = [0xbadcaffe 0x111111 0xdeadbeef]

When querying the data you know whether it's a point or a line based on the length of the values or you could store a tag in another column.

Upvotes: 2

Related Questions