kadirozde commented on a change in pull request #737: PHOENIX-5773 Index tool
output tables should support multiple simulta…
URL: https://github.com/apache/phoenix/pull/737#discussion_r395449605
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java
##########
@@ -257,16 +258,29 @@ private void logToIndexToolResultTable() throws
IOException {
long scanMaxTs = scan.getTimeRange().getMax();
byte[] keyPrefix = Bytes.toBytes(Long.toString(scanMaxTs));
byte[] regionName =
Bytes.toBytes(region.getRegionInfo().getRegionNameAsString());
- // 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);
+ int targetOffset = 0;
+ // The row key for the result table : timestamp | index table name |
datable table region name |
+ // scan start row | scan stop row
+ byte[] rowKey = new byte[keyPrefix.length +
ROW_KEY_SEPARATOR_BYTE.length + indexHTable.getName().toBytes().length +
+ ROW_KEY_SEPARATOR_BYTE.length + regionName.length +
ROW_KEY_SEPARATOR_BYTE.length +
+ scan.getStartRow().length + ROW_KEY_SEPARATOR_BYTE.length +
scan.getStopRow().length];
+ Bytes.putBytes(rowKey, targetOffset, keyPrefix, 0, keyPrefix.length);
+ targetOffset += keyPrefix.length;
+ Bytes.putBytes(rowKey, targetOffset, ROW_KEY_SEPARATOR_BYTE, 0,
ROW_KEY_SEPARATOR_BYTE.length);
+ targetOffset += ROW_KEY_SEPARATOR_BYTE.length;
+ Bytes.putBytes(rowKey, targetOffset, indexHTable.getName().toBytes(),
0, indexHTable.getName().toBytes().length);
+ targetOffset += indexHTable.getName().toBytes().length;
+ Bytes.putBytes(rowKey, targetOffset, ROW_KEY_SEPARATOR_BYTE, 0,
ROW_KEY_SEPARATOR_BYTE.length);
+ targetOffset += ROW_KEY_SEPARATOR_BYTE.length;
+ Bytes.putBytes(rowKey, targetOffset, regionName, 0, regionName.length);
+ targetOffset += regionName.length;
+ Bytes.putBytes(rowKey, targetOffset, ROW_KEY_SEPARATOR_BYTE, 0,
ROW_KEY_SEPARATOR_BYTE.length);
+ targetOffset += ROW_KEY_SEPARATOR_BYTE.length;
+ Bytes.putBytes(rowKey, targetOffset, scan.getStartRow(), 0,
scan.getStartRow().length);
+ targetOffset += scan.getStartRow().length;
Review comment:
@gjacoby126, I am not sure what you are really asking. I did not say these
separators are for programs. I said they were just there to help humans. The
previous version did not have any separators. There were no requirement in this
jira to add such separators. I added them based on Priyank's suggestion as he
claimed it would improve debugging. If there is a requirement to parse the row
key to obtain subfields then we need to have a separate jira to implement that.
Please also note that the row key is constructed in a way to help debugging.
For example, the timestamp values are written as variable strings instead of
fixed-size long values. We need to redesign the row key and maybe to have two
versions of it, one for human and the other for programs. That deserves a
separate jira.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services