1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.regionserver;
20
21 import java.io.IOException;
22 import java.util.List;
23 import java.util.NavigableSet;
24
25 import org.apache.hadoop.hbase.classification.InterfaceAudience;
26 import org.apache.hadoop.hbase.Cell;
27 import org.apache.hadoop.hbase.client.Scan;
28 import org.apache.hadoop.hbase.mob.MobUtils;
29
30
31
32
33
34
35 @InterfaceAudience.Private
36 public class ReversedMobStoreScanner extends ReversedStoreScanner {
37
38 private boolean cacheMobBlocks = false;
39 private boolean rawMobScan = false;
40 private boolean readEmptyValueOnMobCellMiss = false;
41 protected final HMobStore mobStore;
42
43 ReversedMobStoreScanner(Store store, ScanInfo scanInfo, Scan scan, NavigableSet<byte[]> columns,
44 long readPt) throws IOException {
45 super(store, scanInfo, scan, columns, readPt);
46 cacheMobBlocks = MobUtils.isCacheMobBlocks(scan);
47 rawMobScan = MobUtils.isRawMobScan(scan);
48 readEmptyValueOnMobCellMiss = MobUtils.isReadEmptyValueOnMobCellMiss(scan);
49 if (!(store instanceof HMobStore)) {
50 throw new IllegalArgumentException("The store " + store + " is not a HMobStore");
51 }
52 mobStore = (HMobStore) store;
53 }
54
55
56
57
58
59
60 @Override
61 public boolean next(List<Cell> outResult, ScannerContext ctx) throws IOException {
62 boolean result = super.next(outResult, ctx);
63 if (!rawMobScan) {
64
65 if (outResult.isEmpty()) {
66 return result;
67 }
68 long mobKVCount = 0;
69 long mobKVSize = 0;
70 for (int i = 0; i < outResult.size(); i++) {
71 Cell cell = outResult.get(i);
72 if (MobUtils.isMobReferenceCell(cell)) {
73 Cell mobCell = mobStore
74 .resolve(cell, cacheMobBlocks, readPt, readEmptyValueOnMobCellMiss);
75 mobKVCount++;
76 mobKVSize += mobCell.getValueLength();
77 outResult.set(i, mobCell);
78 }
79 }
80 mobStore.updateMobScanCellsCount(mobKVCount);
81 mobStore.updateMobScanCellsSize(mobKVSize);
82 }
83 return result;
84 }
85 }