简体   繁体   中英

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM