我对HFiles有一个相当基本的疑问.
当启动put/insert请求时,该值首先写入WAL,然后写入memstore.memstore中的值以与HFile中相同的排序方式存储.一旦memstore满了,它就会被刷新到一个新的HFile中.
现在,我已经读过HFile以排序顺序存储数据,即顺序rowkeys将彼此相邻.
这100%是真的吗?
例如:我首先使用rowkeys 1到1000写行,但rowkey 500除外.假设memstore现已满,因此它将创建一个新的HFile,称之为HFile1.现在,这个文件是不可变的.
现在,我将写行1001到2000,然后我写rowkey 500.假设memstore已满并写入HFile,称之为HFile2.
那么,这是怎么回事?
如果是,则rowkey 500不在HFile1中,因此HFiles中的rowkeys不按排序顺序排列.那么,粗体的原始陈述是否正确?
因此,当读取发生时,读取是如何发生的?
我希望在 Pig 中实现以下功能。我有一组这样的样本记录。
请注意,EffectiveDate 列有时为空,并且对于相同的 CustomerID 也不同。
现在,作为输出,我希望每个 CustomerID 有一条记录,其中 EffectiveDate 是 MAX。因此,对于上面的示例,我希望记录突出显示,如下所示。
我目前使用 PIG 的方式是这样的:
customerdata = LOAD 'customerdata' AS (CustomerID:chararray, CustomerName:chararray, Age:int, Gender:chararray, EffectiveDate:chararray);
--Group customer data by CustomerID
customerdata_grpd = GROUP customerdata BY CustomerID;
--From the grouped data, generate one record per CustomerID that has the maximum EffectiveDate.
customerdata_maxdate = FOREACH customerdata_grpd GENERATE group as CustID, MAX(customerdata.EffectiveDate) as MaxDate;
--Join the above with the original data so that we get the other details like CustomerName, Age etc. …Run Code Online (Sandbox Code Playgroud)