MCPcopy Create free account
hub / github.com/apache/impala / ToDebugString

Method ToDebugString

be/src/kudu/util/slice.cc:42–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42std::string Slice::ToDebugString(size_t max_len) const {
43 size_t bytes_to_print = size_;
44 bool abbreviated = false;
45 if (max_len != 0 && bytes_to_print > max_len) {
46 bytes_to_print = max_len;
47 abbreviated = true;
48 }
49
50 int size = 0;
51 for (int i = 0; i < bytes_to_print; i++) {
52 if (!isgraph(data_[i])) {
53 size += 4;
54 } else {
55 size++;
56 }
57 }
58 if (abbreviated) {
59 size += 20; // extra padding
60 }
61
62 std::string ret;
63 ret.reserve(size);
64 for (int i = 0; i < bytes_to_print; i++) {
65 if (!isgraph(data_[i])) {
66 StringAppendF(&ret, "\\x%02x", data_[i] & 0xff);
67 } else {
68 ret.push_back(data_[i]);
69 }
70 }
71 if (abbreviated) {
72 StringAppendF(&ret, "...<%zd bytes total>", size_);
73 }
74 return ret;
75}
76
77bool IsAllZeros(const Slice& s) {
78 // Walk a pointer through the slice instead of using s[i]

Callers 8

ParseMessageFunction · 0.45
DoAddMethod · 0.45
DoSendTwoStringsMethod · 0.45
DoPushStringsMethod · 0.45
HexDumpMethod · 0.45
TestRoundTripFunction · 0.45
slice.hFile · 0.45
UncompressMethod · 0.45

Calls 3

StringAppendFFunction · 0.85
reserveMethod · 0.80
push_backMethod · 0.80

Tested by 4

DoAddMethod · 0.36
DoSendTwoStringsMethod · 0.36
DoPushStringsMethod · 0.36
TestRoundTripFunction · 0.36