Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Humanize object size #4766

Closed
wants to merge 15 commits into from
Closed

Conversation

Cdaprod
Copy link

@Cdaprod Cdaprod commented Nov 19, 2023

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers
under the terms of the [Apache 2 license] (https://www.apache.org/licenses/LICENSE-2.0).
By creating this pull request I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 license.

Description

This PR introduces enhancements to stat.go in the MinIO mc tool, implementing humanized formatting for object counts in the mc stat command output. By adopting comma-separated values, this update significantly improves the readability of large numbers.

Furthermore, the stat_test.go file has been augmented to include comprehensive tests for these new formatting features. These tests rigorously verify that the humanized output adheres to the expected format across a range of scenarios.

Changes Summary

  • stat.go: Modified to apply humanized formatting using humanize.Comma.
  • stat_test.go: Added new test cases and assertions to validate the humanized output.

These changes aim to enhance the readability of the mc stat command output, particularly when dealing with large object counts.

Motivation and Context

When dealing with large object counts, it's easier for users to read and understand the numbers when they're formatted with commas. This change enhances the user experience by making the output of mc stat more accessible, especially when presenting large datasets.

How to test this PR?

  • Manual testing of the mc stat command with various bucket sizes to ensure the output is formatted correctly.
  • After performing manual testing, you can also ensure the functionality of the humanized output in mc stat using automated tests.

Manual Testing of mc stat

  • Build the mc tool with the updated stat.go.
  • Run mc stat on various buckets or objects.

Automated Testing

  • Run go test in the directory containing stat_test.go.

The tests should cover various scenarios and check if the humanized output is as expected for different object sizes.
These tests ensure that both the new functionality and existing features of the mc stat command work as intended.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Fixes a regression (If yes, please add commit-id or PR # here)
  • Unit tests added/updated
  • Internal documentation updated
  • Create a documentation update request here

Updated the 'mc stat' command's output to humanize the object sizes in
the histogram section. It improves readability by formatting large
numbers with commas.
Implemented the changes necessary for automated testing humanized
object count function
@Cdaprod Cdaprod closed this Nov 19, 2023
@Cdaprod Cdaprod deleted the humanize-object-size branch November 19, 2023 21:25
@Cdaprod Cdaprod restored the humanize-object-size branch November 19, 2023 21:26
@Cdaprod Cdaprod reopened this Nov 19, 2023
cmd/stat_test.go Outdated Show resolved Hide resolved
cmd/stat_test.go Outdated Show resolved Hide resolved
Cdaprod and others added 6 commits November 19, 2023 17:43
Created a function with large number for mock data at 1 billion.
- Refactor stat_test.go to improve readability and maintainability
- Update test cases to use struct literals for better clarity and
organization
Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment

cmd/stat.go Outdated Show resolved Hide resolved
Copy link
Author

@Cdaprod Cdaprod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it’s all caught up, let me know what anyone thinks.

Copy link
Author

@Cdaprod Cdaprod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@klauspost
Copy link
Contributor

@Cdaprod

Error: cmd/stat_test.go:43:2: expected operand, found '}'
Error: make: *** [Makefile:33: vet] Error 1
Error: Process completed with exit code 2.

@Cdaprod
Copy link
Author

Cdaprod commented Nov 28, 2023

I am adding bubbletea to the mc stat.go to give it a more appealing output.

@harshavardhana
Copy link
Member

Please resubmit when its ready @Cdaprod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants