2016-09-30 1083 views
1

我想了解Hbase如何在内部处理来自文件的重复记录。 为了做到这一点,我在配置单元中创建了EXTERNAL表,并使用HBase特定的配置属性,如表属性,SERDE,列族。 我必须在列家族中创建HBase表,我也是这样做的。Hbase如何处理重复记录?

我已经从具有重复记录的源表执行插入覆盖到此HIVE表中。 通过重复记录我的意思是这样的,

ID | Name  | Surname 
1 | Ritesh  | Rai 
1 | RiteshKumar | Rai 

现在执行插入覆盖后,我问我的HIVE表ID为1,我得到的输出(第二个)

1  RiteshKumar   Rai 

我想到HBase如何决定哪一个更新?只是它只是按顺序写入数据。最后一条记录将被覆盖并视为最新记录?或者它是怎么回事?

在此先感谢。

问候, 戈文德

回答

2

你是在正确的轨道上!

row:column_family:column_qualifier:timestamp:value 

HBasedatamodel可以被看作是一个“多维地图”和每个单元值与时间戳(默认insertion_time)相关联的时间戳与每个单个值相关联,并且而不是整行(这使得几个很好的功能)!

在阅读时,默认情况下您将获得最新版本,除非您另行指定。默认情况下应该存储3 versions。 Hbase进行“合并读取”,它将返回每一行的最新单元格值。

请从您的HBase的壳试试这个(未发布之前真正的考验):

put ‘table_name’, ‘1’, ‘f:name’, ‘Ritesh’ 
put ‘table_name’, ‘1’, ‘f:surname’, ‘Rai’ 
put ‘table_name’, ‘1’, ‘f:name’, ‘RiteshKumar’ 
put ‘table_name’, ‘1’, ‘f:surname’, ‘Rai’ 
put ‘table_name’, ‘1’, ‘f:other’, ‘Some other stuff’ 

// Data on 'disk' (that might just be the memstore for now) will look like this: 
// 1:f:name:1234567890:‘Ritesh’ 
// 1:f:surname:1234567891:‘Rai’ 
// 1:f:name:1234567892:‘RiteshKumar’ 
// 1:f:surname:1234567893:‘Rai’ 
// 1:f:other:1234567894:‘Some other stuff’ 

// Now try... And you will get ‘RiteshKumar’, ‘Rai’, ‘Some other stuff’ 
get ‘table_name’, ‘1’ 

// To get the previous versions of the data use the following: 
get ‘table_name’, ‘1’, {COLUMN => ‘f’, VERSIONS => 2} 

不要忘了看一看的schema design

+0

的最佳实践是有可能得到以前在这种情况下的价值? –