Skip to content

Commit 2b79635

Browse files
author
Ray Mattingly
committed
PR feedback: simplify scan serialization
1 parent d782683 commit 2b79635

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/OnlineLogRecord.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package org.apache.hadoop.hbase.client;
1919

20-
import java.io.IOException;
2120
import java.util.Optional;
2221
import org.apache.commons.lang3.builder.EqualsBuilder;
2322
import org.apache.commons.lang3.builder.HashCodeBuilder;
@@ -30,7 +29,6 @@
3029

3130
import org.apache.hbase.thirdparty.com.google.gson.Gson;
3231
import org.apache.hbase.thirdparty.com.google.gson.JsonObject;
33-
import org.apache.hbase.thirdparty.com.google.gson.JsonParser;
3432
import org.apache.hbase.thirdparty.com.google.gson.JsonSerializer;
3533

3634
/**
@@ -60,11 +58,7 @@ final public class OnlineLogRecord extends LogEntry {
6058
jsonObj.remove("multiServiceCalls");
6159
}
6260
if (slowLogPayload.getScan().isPresent()) {
63-
try {
64-
jsonObj.add("scan", JsonParser.parseString(slowLogPayload.getScan().get().toJSON()));
65-
} catch (IOException e) {
66-
LOG.warn("Failed to serialize scan {}", slowLogPayload.getScan().get(), e);
67-
}
61+
jsonObj.add("scan", gson.toJsonTree(slowLogPayload.getScan().get().toMap()));
6862
} else {
6963
jsonObj.remove("scan");
7064
}

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOnlineLogRecord.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ public void itSerializesScan() {
4444
+ " \"startRow\": \"\\\\x00\\\\x00\\\\x00{\",\n"
4545
+ " \"stopRow\": \"\\\\x00\\\\x00\\\\x01\\\\xC8\",\n" + " \"batch\": -1,\n"
4646
+ " \"cacheBlocks\": true,\n" + " \"totalColumns\": 0,\n"
47-
+ " \"maxResultSize\": \"-1\",\n" + " \"families\": {},\n" + " \"caching\": -1,\n"
48-
+ " \"maxVersions\": 1,\n" + " \"timeRange\": [\n" + " \"0\",\n"
49-
+ " \"9223372036854775807\"\n" + " ]\n" + " }\n" + "}";
47+
+ " \"maxResultSize\": -1,\n" + " \"families\": {},\n" + " \"caching\": -1,\n"
48+
+ " \"maxVersions\": 1,\n" + " \"timeRange\": [\n" + " 0,\n"
49+
+ " 9223372036854775807\n" + " ]\n" + " }\n" + "}";
5050
OnlineLogRecord o =
5151
new OnlineLogRecord(1, 2, 3, 4, 5, null, null, null, null, null, null, null, 6, 7, 0, scan);
5252
String actualOutput = o.toJsonPrettyPrint();
53+
System.out.println(actualOutput);
5354
Assert.assertEquals(actualOutput, expectedOutput);
5455
}
5556
}

0 commit comments

Comments
 (0)