aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me/lucko/spark/memory
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2018-11-03 14:28:42 +0000
committerLuck <git@lucko.me>2018-11-03 14:28:42 +0000
commit9e4c0edc47707fbcad34305b3cd723b08f1ab4d6 (patch)
tree354b34b04631f05b4732c82b59ee1fcdd965065b /spark-common/src/main/java/me/lucko/spark/memory
parenta235a054532c3d403f083be7662b7a796a309159 (diff)
downloadspark-9e4c0edc47707fbcad34305b3cd723b08f1ab4d6.tar.gz
spark-9e4c0edc47707fbcad34305b3cd723b08f1ab4d6.tar.bz2
spark-9e4c0edc47707fbcad34305b3cd723b08f1ab4d6.zip
Improve the type descriptor conversion in heap dump outputs
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/memory')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/memory/HeapDump.java39
1 files changed, 3 insertions, 36 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/memory/HeapDump.java b/spark-common/src/main/java/me/lucko/spark/memory/HeapDump.java
index dc8bfec..4007bad 100644
--- a/spark-common/src/main/java/me/lucko/spark/memory/HeapDump.java
+++ b/spark-common/src/main/java/me/lucko/spark/memory/HeapDump.java
@@ -22,6 +22,8 @@ package me.lucko.spark.memory;
import com.google.gson.stream.JsonWriter;
+import me.lucko.spark.util.TypeDescriptors;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
@@ -92,7 +94,7 @@ public class HeapDump {
Integer.parseInt(matcher.group(1)),
Integer.parseInt(matcher.group(2)),
Long.parseLong(matcher.group(3)),
- getFriendlyTypeName(matcher.group(4))
+ TypeDescriptors.getJavaType(matcher.group(4))
);
})
.filter(Objects::nonNull)
@@ -134,41 +136,6 @@ public class HeapDump {
return byteOut.toByteArray();
}
- private static String getPrimitiveTypeName(char character) {
- switch (character) {
- case 'B':
- return "byte";
- case 'C':
- return "char";
- case 'D':
- return "double";
- case 'F':
- return "float";
- case 'I':
- return "int";
- case 'J':
- return "long";
- case 'S':
- return "short";
- case 'V':
- return "void";
- case 'Z':
- return "boolean";
- default:
- throw new IllegalArgumentException();
- }
- }
-
- private static String getFriendlyTypeName(String internalDesc) {
- if (internalDesc.length() == 2 && internalDesc.charAt(0) == '[') {
- return getPrimitiveTypeName(internalDesc.charAt(1)) + " array";
- }
- if (internalDesc.startsWith("[L") && internalDesc.endsWith(";")) {
- return internalDesc.substring(2, internalDesc.length() - 1) + " array";
- }
- return internalDesc;
- }
-
public static final class Entry {
private final int order;
private final int instances;