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

Showing Reported Size and Estimated Size in human readable format in UI #8199

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ const TenantPageDetails = ({ match }: RouteComponentProps<Props>) => {
</Grid>
<Tooltip title="Uncompressed size of all data segments" arrow placement="top-start">
<Grid item xs={2}>
<strong>Reported Size:</strong> {tableSummary.reportedSize}
<strong>Reported Size:</strong> {Utils.formatBytes(tableSummary.reportedSize)}
</Grid>
</Tooltip>
<Grid item xs={2}></Grid>
<Tooltip title="Estimated size of all data segments, in case any servers are not reachable for actual size" arrow placement="top-start">
<Grid item xs={2}>
<strong>Estimated Size: </strong>
{tableSummary.estimatedSize}
{Utils.formatBytes(tableSummary.estimatedSize)}
</Grid>
</Tooltip>
<Grid item xs={2}></Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ const getAllTableDetails = (tablesList) => {
} = result.data;
singleTableData.push(
tableName,
reportedSizeInBytes,
estimatedSizeInBytes
Utils.formatBytes(reportedSizeInBytes),
Utils.formatBytes(estimatedSizeInBytes)
);
} else if (index % 3 === 1) {
// response of getIdealState API
Expand Down
15 changes: 14 additions & 1 deletion pinot-controller/src/main/resources/app/utils/Utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,18 @@ const encodeString = (str: string) => {
return str;
}

const formatBytes = (bytes, decimals = 2) => {
if (bytes === 0) return '0 Bytes';

const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];

const i = Math.floor(Math.log(bytes) / Math.log(k));

return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}

export default {
sortArray,
tableFormat,
Expand All @@ -333,5 +345,6 @@ export default {
serialize,
navigateToPreviousPage,
syncTableSchemaData,
encodeString
encodeString,
formatBytes
};