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
24 import org.apache.hadoop.hbase.classification.InterfaceAudience;
25 import org.apache.hadoop.hbase.Cell;
26 import org.apache.hadoop.hbase.CellUtil;
27 import org.apache.hadoop.hbase.KeyValueUtil;
28 import org.apache.hadoop.hbase.client.Scan;
29 import org.apache.hadoop.hbase.regionserver.HRegion.RegionScannerImpl;
30
31
32
33
34
35 @InterfaceAudience.Private
36 class ReversedRegionScannerImpl extends RegionScannerImpl {
37
38
39
40
41
42
43
44 ReversedRegionScannerImpl(Scan scan,
45 List<KeyValueScanner> additionalScanners, HRegion region, boolean copyCellsFromSharedMem)
46 throws IOException {
47 region.super(scan, additionalScanners, region, copyCellsFromSharedMem);
48 }
49
50 @Override
51 protected void initializeKVHeap(List<KeyValueScanner> scanners,
52 List<KeyValueScanner> joinedScanners, HRegion region) throws IOException {
53 this.storeHeap = new ReversedKeyValueHeap(scanners, comparator);
54 if (!joinedScanners.isEmpty()) {
55 this.joinedHeap = new ReversedKeyValueHeap(joinedScanners,
56 comparator);
57 }
58 }
59
60 @Override
61 protected boolean isStopRow(Cell currentRowCell) {
62 return currentRowCell == null
63 || (super.stopRow != null && comparator.compareRows(currentRowCell, stopRow, 0,
64 stopRow.length) <= super.isScan);
65 }
66
67 @Override
68 protected boolean nextRow(ScannerContext scannerContext, Cell curRowCell)
69 throws IOException {
70 assert super.joinedContinuationRow == null : "Trying to go to next row during joinedHeap read.";
71 byte[] row = new byte[curRowCell.getRowLength()];
72 CellUtil.copyRowTo(curRowCell, row, 0);
73 this.storeHeap.seekToPreviousRow(KeyValueUtil.createFirstOnRow(row));
74 resetFilters();
75
76 if (this.region.getCoprocessorHost() != null) {
77 return this.region.getCoprocessorHost().postScannerFilterRow(this, curRowCell);
78 }
79 return true;
80 }
81
82 }