MCPcopy Create free account
hub / github.com/apache/kudu / pretty

Method pretty

java/kudu-client/src/main/java/org/apache/kudu/client/Bytes.java:904–935  ·  view source on GitHub ↗

Pretty-prints a byte array into a human-readable output buffer. @param outbuf The buffer where to write the output. @param array The (possibly null) array to pretty-print.

(final StringBuilder outbuf, final byte[] array)

Source from the content-addressed store, hash-verified

902 * @param array The (possibly {@code null}) array to pretty-print.
903 */
904 public static void pretty(final StringBuilder outbuf, final byte[] array) {
905 if (array == null) {
906 outbuf.append("null");
907 return;
908 }
909 int ascii = 0;
910 final int start_length = outbuf.length();
911 final int n = array.length;
912 outbuf.ensureCapacity(start_length + 1 + n + 1);
913 outbuf.append('"');
914 for (int i = 0; i < n; i++) {
915 final byte b = array[i];
916 if (' ' <= b && b <= '~') {
917 ascii++;
918 outbuf.append((char) b);
919 } else if (b == '\n') {
920 outbuf.append('\\').append('n');
921 } else if (b == '\t') {
922 outbuf.append('\\').append('t');
923 } else {
924 outbuf.append("\\x")
925 .append(HEX[(b >>> 4) & 0x0F])
926 .append(HEX[b & 0x0F]);
927 }
928 }
929 if (ascii < n / 2) {
930 outbuf.setLength(start_length);
931 outbuf.append(Arrays.toString(array));
932 } else {
933 outbuf.append('"');
934 }
935 }
936
937 /**
938 * Pretty-prints an array of byte arrays into a human-readable output buffer.

Callers 12

assertBytesEqualsMethod · 0.95
testBinaryColumnsMethod · 0.95
callMethod · 0.95
scanFinishedMethod · 0.95
toStringMethod · 0.95
toStringMethod · 0.95
deserializeMethod · 0.95
toStringMethod · 0.95
toStringMethod · 0.95
rowToStringMethod · 0.95
getPbFromBytesMethod · 0.95

Calls 4

getBytesMethod · 0.80
appendMethod · 0.45
lengthMethod · 0.45
toStringMethod · 0.45

Tested by 2

assertBytesEqualsMethod · 0.76
testBinaryColumnsMethod · 0.76