HBASE-26276 Allow HashTable/SyncTable to perform rawScan when comparing cells (#3673)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
(cherry-picked from commit ee632bdcae)
This commit is contained in:
Wellington Ramos Chevreuil 2021-09-10 16:26:10 +01:00 committed by Wellington Chevreuil
parent 1664f52066
commit 126f6bc520
1 changed files with 19 additions and 3 deletions

View File

@ -98,6 +98,7 @@ public class HashTable extends Configured implements Tool {
long startTime = 0;
long endTime = 0;
boolean ignoreTimestamps;
boolean rawScan;
List<ImmutableBytesWritable> partitions;
@ -136,6 +137,7 @@ public class HashTable extends Configured implements Tool {
if (endTime != 0) {
p.setProperty("endTimestamp", Long.toString(endTime));
}
p.setProperty("rawScan", Boolean.toString(rawScan));
try (OutputStreamWriter osw = new OutputStreamWriter(fs.create(path), Charsets.UTF_8)) {
p.store(osw, null);
@ -173,6 +175,11 @@ public class HashTable extends Configured implements Tool {
versions = Integer.parseInt(versionString);
}
String rawScanString = p.getProperty("rawScan");
if (rawScanString != null) {
rawScan = Boolean.parseBoolean(rawScanString);
}
String startTimeString = p.getProperty("startTimestamp");
if (startTimeString != null) {
startTime = Long.parseLong(startTimeString);
@ -207,6 +214,8 @@ public class HashTable extends Configured implements Tool {
scan.addFamily(Bytes.toBytes(fam));
}
}
scan.setRaw(rawScan);
return scan;
}
@ -304,6 +313,7 @@ public class HashTable extends Configured implements Tool {
if (versions >= 0) {
sb.append(", versions=").append(versions);
}
sb.append(", rawScan=").append(rawScan);
if (startTime != 0) {
sb.append("startTime=").append(startTime);
}
@ -476,7 +486,6 @@ public class HashTable extends Configured implements Tool {
private long batchSize = 0;
boolean ignoreTimestamps;
public ResultHasher() {
try {
digest = MessageDigest.getInstance("MD5");
@ -626,6 +635,7 @@ public class HashTable extends Configured implements Tool {
System.err.println(" Ignored if no starttime specified.");
System.err.println(" scanbatch scanner batch size to support intra row scans");
System.err.println(" versions number of cell versions to include");
System.err.println(" rawScan performs a raw scan (false if omitted)");
System.err.println(" families comma-separated list of families to include");
System.err.println(" ignoreTimestamps if true, ignores cell timestamps");
System.err.println(" when calculating hashes");
@ -707,6 +717,12 @@ public class HashTable extends Configured implements Tool {
continue;
}
final String rawScanArgKey = "--rawScan=";
if (cmd.startsWith(rawScanArgKey)) {
tableHash.rawScan = Boolean.parseBoolean(cmd.substring(rawScanArgKey.length()));
continue;
}
final String familiesArgKey = "--families=";
if (cmd.startsWith(familiesArgKey)) {
tableHash.families = cmd.substring(familiesArgKey.length());