gpt4 book ai didi

HBase:数据如何以排序方式写入 HFile?

转载 作者:行者123 更新时间:2023-12-05 01:02:25 28 4
gpt4 key购买 nike

我对 HFiles 有一个相当基本的怀疑。

当发起 put/insert 请求时,值首先写入 WAL,然后写入 memstore。 memstore 中的值以与 HFile 中相同的排序方式存储。一旦 memstore 已满,它就会被刷新到一个新的 HFile 中。

现在,我已经读到 HFile 按排序顺序存储数据,即连续的行键将彼此相邻 .

这是 100% 真的吗?

例如:我首先用 rowkeys 1 到 1000 写入行,rowkey 500 除外。假设 memstore 现在已满,因此它将创建一个新的 HFile,将其命名为 HFile1。现在,这个文件是不可变的。

现在,我将写行 1001 到 2000,然后我写行键 500。假设 memstore 已满并写入 HFile,称为 HFile2。

那么,事情是这样发生的吗?

如果是,则 rowkey 500 不在 HFile1 中,因此 HFiles 中的 rowkeys 没有排序。那么,原文加粗的说法正确吗?

那么,当读取发生时,读取是如何发生的呢?

最佳答案

HFile stores the data in sorted order i.e. the sequential rowkeys will be next to each other.

Is this 100% true?


是的,这是 100% 准确的。单个 HFile 中的 RowKeys 总是被排序。

I will write rows 1001 to 2000, then I write rowkey 500. Assume that the memstore is full and it writes to a HFile, call it HFile2.

So, is this how it happens?


是的,现在 500 到达第二个 HFile 的顶部。

If yes, then rowkey 500 is not in the HFile1, so the rowkeys in the HFiles are not in sorted order. So, is the original statement in bold correct?


是的,单个 HFile 中的行键总是被排序的。 HBase 定期执行 compactions它将合并多个 HFile 并将它们重写为单个 HFile,这个作为压缩结果的新 HFile 也被排序。

So, when a read happens, how does the read happen?


在读取时,如果存储有多个 HFile,HBase 将从所有 HFile 中读取该行(检查该行是否存在,如果已读取)以及 memstore。所以它可以得到最新的数据。
HBase Definitive Guide 对 HBase 读取路径的工作原理有很好的解释。

关于HBase:数据如何以排序方式写入 HFile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26696212/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com