20.概念视图
你可以从Jim R. Wilson写的Understanding HBase and BigTable博文中读到一个对HBase数据模型很好理解的解释。另外一个好的描述是Amandeep Khurana的Introduction to Basic Schema Design。
它可能可以帮助你读到不同的方面,以此让你获得一个对HBase模式设计的更好的理解。链接的文章覆盖了这部分信息的相同范围。
下面这个例子是对BigTable论文的第2頁的表进行了轻微的修改的形式。有一个表叫做webtable,它包含两行(com.cnn.www和com.example.www)和三个列簇(contents,anchor,和people)。在这个例子中,对于第一行(com.cnn.www),anchor包含两列(anchor:cssnsi.com,anchor:my.look.ca)和包含一个列(contents:html)的contents。这个例子包含了5个row key为com.cnn.www的版本,和1个row key为com.example.www的版本,列修饰符contents:html包含了网站的整个html,anchor列簇的修饰符含有該行出现的外部站点及文本,即超链接的文本和链接地址。列簇people表示与站点相关的人。
列名 按照惯例,一个列名由它的列簇的前缀和一个修饰符组成。例如,列contents:html是由列簇contents和修饰符html构成。列簇和列修饰符由冒号(:)分隔开来。
Table 4. 表webtable
Row Key | Time Stamp | ColumnFamily contents | ColumnFamily anchor | ColumnFamily people |
---|---|---|---|---|
"com.cnn.www" | t9 | anchor:cnnsi.com = "CNN" | ||
"com.cnn.www" | t8 | anchor:my.look.ca = "CNN.com" | ||
"com.cnn.www" | t6 | contents:html = “...” | ||
"com.cnn.www" | t5 | contents:html = "..." | ||
"com.cnn.www" | t3 | contents:html = "..." |
在HBase里,表里的Cell要么实际存在,要么为空且不占用空间。这就使得HBase变得“稀疏”。表格的方式不是查看HBase数据的唯一或最准确的方式。以下使用多维Map呈现了同样的信息。这只是为了描述为目的的一个模拟,可能不是非常准确。
{
"com.cnn.www": {
contents: {
t6: contents:html: "<html>..."
t5: contents:html: "<html>..."
t3: contents:html: "<html>..."
}
anchor: {
t9: anchor:cnnsi.com = "CNN"
t8: anchor:my.look.ca = "CNN.com"
}
people: {}
}
"com.example.www": {
contents: {
t5: contents:html: "<html>..."
}
anchor: {}
people: {
t5: people:author: "John Doe"
}
}
}