2010YOUY01 commented on code in PR #18734:
URL: https://github.com/apache/datafusion/pull/18734#discussion_r2536194892
##########
datafusion/execution/src/memory_pool/mod.rs:
##########
@@ -503,6 +503,56 @@ pub fn human_readable_size(size: usize) -> String {
format!("{value:.1} {unit}")
}
+/// Present count in human-readable form with K, M, B, T suffixes
+pub fn human_readable_count(count: usize) -> String {
+ let count = count as u64;
+ let (value, unit) = {
+ if count >= 1_000_000_000_000 {
+ (count as f64 / 1_000_000_000_000.0, " T")
+ } else if count >= 1_000_000_000 {
+ (count as f64 / 1_000_000_000.0, " B")
+ } else if count >= 1_000_000 {
+ (count as f64 / 1_000_000.0, " M")
+ } else if count >= 1_000 {
+ (count as f64 / 1_000.0, " K")
+ } else {
+ return count.to_string();
+ }
+ };
+
+ // Format with appropriate precision
+ // For values >= 100, show 1 decimal place (e.g., 123.4 K)
+ // For values < 100, show 2 decimal places (e.g., 10.12 K)
+ if value >= 100.0 {
Review Comment:
Good point, let's leave it to an optional follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]