Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use TIMERANGE and VERSION in HBASE

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to use TIMERANGE and VERSION in HBASE. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

In HBase table creation, one version is specified by default (the default VERSION is 1 when creating the table). To retain multiple version information, you need to specify the number of versions when creating the table.

Eg.create 'scores', {NAME= >' course',VERSIONS= > 2}

First, create a table, and then add two records

Hbase (main): 079 scores', 0 > create 'scores', {NAME= >' course',VERSIONS= > 2}

0 row (s) in 0.9590 seconds

Hbase (main): 080 put 0 > scores','Tom','course:math','97'

0 row (s) in 0.0100 seconds

Hbase (main): 081 scan 0 > scores'

ROW COLUMN+CELL

Tom column=course:math, timestamp=1394097631387, value=97

1 row (s) in 0.0190 seconds

Hbase (main): 082 put 0 > scores','Tom','course:math','100'

0 row (s) in 0.0080 seconds

Hbase (main): 026 scan 0 > scores'

ROW COLUMN+CELL

Tom column=course:math, timestamp=1394097651029, value=100

1 row (s) in 0.0110 seconds

Hbase (main): 027scores', 0 > scan 'scores', {TIMERANGE= > [139409763138713 94097651029]}

ROW COLUMN+CELL

Tom column=course:math, timestamp=1394097631387, value=97

1 row (s) in 0.0210 seconds

Hbase (main): 028 scores', 0 > scan 'scores', {TIMERANGE= > [139409763138713 94097651030]}

ROW COLUMN+CELL

Tom column=course:math, timestamp=1394097651029, value=100

1 row (s) in 0.0100 seconds

As you can see from the above, the default result of HBASE scan is the record of the last timestamp, so how to scan both of them?

At this point, you can add VERSIONS as a constraint:

Hbase (main): 032scores', 0 > scan 'scores', {VERSIONS= > 2}

ROW COLUMN+CELL

Tom column=course:math, timestamp=1394097651029, value=100

Tom column=course:math, timestamp=1394097631387, value=97

1 row (s) in 0.0130 seconds

The above order has already scan out all this record.

Take a look at the following example:

Scan 'scores', {TIMERANGE= > [1394097631386, 1394097651029], VERSIONS= > 2}

ROW COLUMN+CELL

Tom column=course:math, timestamp=1394097631387, value=97

1 row (s) in 0.0130 seconds

There is only one scan record from the above results. You know, TIMERANGE means "> = start time and"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report