Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use TIMERANGE and VERSION in HBASE

Shulou Source: shulou.com Published: 2022-06-01 02:24:48 10月04日 Update

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"

Tags: Face time version result example content that is analysis specialty small and medium information rich content history command multiple data article time more condition Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno Docker MySQL Shulou Information