convert null terminator in ascii dump
Summary: The ASCII output is almost always useless to me as the first '\0' byte in the key or value causes it to stop printing. Since all characters are already surrounded by spaces, "\ 0" (how we display a backslash followed by a zero) and "\0" (how this PR displays a null terminator) are distinguishable. My assumption is the value of seeing all the bytes outweighs the value of the alignment we had before, where we always had one character followed by one space. Closes https://github.com/facebook/rocksdb/pull/3203 Differential Revision: D6428651 Pulled By: ajkr fbshipit-source-id: aafc978a51e9ea029cfe3e763e2bb0e1751b9ccf
This commit is contained in:
parent
c1ed005a21
commit
c85f8ccca3
@ -2423,11 +2423,19 @@ void BlockBasedTable::DumpKeyValue(const Slice& key, const Slice& value,
|
||||
std::string res_key(""), res_value("");
|
||||
char cspace = ' ';
|
||||
for (size_t i = 0; i < str_key.size(); i++) {
|
||||
if (str_key[i] == '\0') {
|
||||
res_key.append("\\0", 2);
|
||||
} else {
|
||||
res_key.append(&str_key[i], 1);
|
||||
}
|
||||
res_key.append(1, cspace);
|
||||
}
|
||||
for (size_t i = 0; i < str_value.size(); i++) {
|
||||
if (str_value[i] == '\0') {
|
||||
res_value.append("\\0", 2);
|
||||
} else {
|
||||
res_value.append(&str_value[i], 1);
|
||||
}
|
||||
res_value.append(1, cspace);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user