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

What is the difference between a specified version and an unspecified version of the HBase creation table

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces what is the difference between the specified version and the unspecified version of the HBase creation table. It is very detailed and has a certain reference value. Interested friends must read it!

The version of the table created by HBase is not specified [the default VERSION is 1.]

Create 'mytable', {NAME = >' colfam1'}

Add three pieces of data to 'mytable':

Put 'mytable','001','colfam1','1@'

Put 'mytable','001','colfam1','1%'

Put 'mytable','001','colfam1','1&'

Put 'mytable','001','colfam1','1*'

Data in scan 'mytable' [only the latest data can be viewed by default. If you want to view multiple versions, you need to specify]

The last record I saw.

Did you specify the version when looking for it, or did you see the last record? Although VERSIONS is added, the result of get is 1; this is because the default VERSION is 1. 0 when building the table.

You can modify VERSIONS:alter 'member', {NAME= >' info','VERSIONS'= > 2}

Analysis: related to the number of reserved versions specified when the table is created

HBase create table specified version: (add VERSIONS= > 3, you can find historical data, but you must add VERSIONS when you create the table, otherwise it will be invalid)

Create 'mytable', {NAME = >' colfam1', VERSIONS = > 5 minutes = >'3'}

Put 'mytable','001','colfam1','1@'

Put 'mytable','001','colfam1','1%'

Put 'mytable','001','colfam1','jhl'

Put 'mytable','001','colfam1','hjf'

Get 'mytable','001', {COLUMN = >' colfam1',VERSIONS = > 3}

Get 'mytable','001', {COLUMN = >' colfam1',VERSIONS = > 5}

Summary: 1. To preserve the history of the column families of a table: specify version information on the current column

{COLUMN = > 'colfam1',VERSIONS = > 5}

2.scan table is always the record that scans to the largest version of each row of the table.

For more information, api explains:

Gets is actually implemented on the basis of Scan. You can refer to the following discussion in detail. Get can also be described as Scan.

By default, if you do not specify a version, the most recent version of Cell will be returned when you use the Get operation (the Cell may be newly written, but there is no guarantee). The default action can be modified as follows:

See Get.setMaxVersions () if you want to return more than two versions of the handle

If you want to return more than the most recent version, see Get.setTimeRange ()

The latest version of the query should be less than or equal to the given value, which means that the given 'most recent' value can be a point in time. You can use 0 to the time you want to set it, and set max versions to 1.

5.8.1.2. Default Get example

The following Get operation will only get the latest version.

Get get = new Get (Bytes.toBytes ("row1")); Result r = htable.get (get); byte [] b = r.getValue (Bytes.toBytes ("cf"), Bytes.toBytes ("attr")); / / returns current version of value5.8.1.3. Contains an example of the version of Get

The following Get operation will get the last three versions.

Get get = new Get (Bytes.toBytes ("row1")); get.setMaxVersions (3); / / will return last 3 versions of row Result r = htable.get (get); byte [] b = r.getValue (Bytes.toBytes ("cf"), Bytes.toBytes ("attr")); / / returns current version of value List kv = r.getColumn (Bytes.toBytes ("cf"), Bytes.toBytes ("attr")) / / returns all versions of this column above is all the content of the article "what is the difference between the specified version and the unspecified version of the HBase creation table?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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