Skip to content

Commit 9cde12d

Browse files
umar4569prady9
authored andcommitted
Fix byteToString where the byte value is > a petabyte
1 parent 0a66851 commit 9cde12d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/common/Logger.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ shared_ptr<logger> loggerFactory(string name) {
5252
}
5353

5454
string bytesToString(size_t bytes) {
55-
static array<const char *, 5> units{{"B", "KB", "MB", "GB", "TB"}};
55+
constexpr array<const char *, 7> units{
56+
{"B", "KB", "MB", "GB", "TB", "PB", "EB"}};
5657
size_t count = 0;
5758
double fbytes = static_cast<double>(bytes);
5859
size_t num_units = units.size();
5960
for (count = 0; count < num_units && fbytes > 1000.0f; count++) {
6061
fbytes *= (1.0f / 1024.0f);
6162
}
63+
if (count == units.size()) count--;
6264
return fmt::format("{:.3g} {}", fbytes, units[count]);
6365
}
6466
} // namespace common

0 commit comments

Comments
 (0)