PHOENIX-5720 Multiple scans on the same table region cause incorrect IndexTool counters
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java
index 3619d01..83c479a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java
@@ -440,13 +440,17 @@
long scanMaxTs = scan.getTimeRange().getMax();
byte[] keyPrefix = Bytes.toBytes(Long.toString(scanMaxTs));
byte[] regionName = Bytes.toBytes(region.getRegionInfo().getRegionNameAsString());
- byte[] rowKey = new byte[keyPrefix.length + regionName.length];
- // The row key for the result table is the max timestamp of the scan + the table region name
+ // The row key for the result table is the max timestamp of the scan + the table region name + scan start row
+ // + scan stop row
+ byte[] rowKey = new byte[keyPrefix.length + regionName.length + scan.getStartRow().length +
+ scan.getStopRow().length];
Bytes.putBytes(rowKey, 0, keyPrefix, 0, keyPrefix.length);
Bytes.putBytes(rowKey, keyPrefix.length, regionName, 0, regionName.length);
+ Bytes.putBytes(rowKey, keyPrefix.length + regionName.length, scan.getStartRow(), 0,
+ scan.getStartRow().length);
+ Bytes.putBytes(rowKey, keyPrefix.length + regionName.length + scan.getStartRow().length,
+ scan.getStopRow(), 0, scan.getStopRow().length);
Put put = new Put(rowKey);
- put.addColumn(RESULT_TABLE_COLUMN_FAMILY, IndexTool.SCAN_STOP_ROW_KEY_BYTES,
- scanMaxTs, scan.getStopRow());
put.addColumn(RESULT_TABLE_COLUMN_FAMILY, SCANNED_DATA_ROW_COUNT_BYTES,
scanMaxTs, Bytes.toBytes(Long.toString(verificationResult.scannedDataRowCount)));
put.addColumn(RESULT_TABLE_COLUMN_FAMILY, REBUILT_INDEX_ROW_COUNT_BYTES,
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
index 6dc71e2..c71c0ff 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
@@ -173,8 +173,6 @@
public final static byte[] INDEX_TABLE_TS_BYTES = Bytes.toBytes(INDEX_TABLE_TS);
public static String ERROR_MESSAGE = "Error";
public final static byte[] ERROR_MESSAGE_BYTES = Bytes.toBytes(ERROR_MESSAGE);
- public static String SCAN_STOP_ROW_KEY = "StopRowKey";
- public final static byte[] SCAN_STOP_ROW_KEY_BYTES = Bytes.toBytes(SCAN_STOP_ROW_KEY);
public static String SCANNED_DATA_ROW_COUNT = "ScannedDataRowCount";
public final static byte[] SCANNED_DATA_ROW_COUNT_BYTES = Bytes.toBytes(SCANNED_DATA_ROW_COUNT);
public static String REBUILT_INDEX_ROW_COUNT = "RebuiltIndexRowCount";