HBase物理存储
HBase表中的所有行都按照行键的字典序排列,如下图所示。
物理存储就是把逻辑模型中一个行进行分割,并按列族存储。HBase物理存储方式如下表所示。
Row Key(行键) | 时 间 戳 | 列族Contents |
---|---|---|
com.zdsoft.www | t6 | Contents.html=“<html>…” |
t5 | Contents.html=“<html>…” | |
t3 | Contents.html=“<html>…” | |
Row Key(行键) | 时间戳 | 列族contents |
com.zdsoft.www | t9 | anchor:zdsoft.com=“zdsoft” |
t8 | anchor:zdsoft.com=“zdsoft.com” | |
Row Key(行键) | 时间戳 | 列族contents |
com.zdsoft.www | t6 | Mime:type=“text/html” |
从表分析来看,表中空值是不会被存储的,时间t8的“Contents:html”将返回null,时间t9的“Contents:html”将返回null,时间戳t3的“anchor:zdsoft.com”将返回null。如果没有指明时间戳,那么返回指定列的最新数据值,并且最新的数据值在表格中也是最先找到的,它们是按时间降序排列的,如果查询“Contents:”而不指明时间戳,将返回t6的时刻表;如果查询“anchor:”而不指明时间戳,将返回的是t8时刻的数据。这种存储方式还有一个优势:可以随时向表中的任何一个列族添加新列,而不必事先声明。
学员评价