Skip to content

Commit e7f806b

Browse files
authored
Showing Reported Size and Estimated Size in human readable format in UI (#8199)
1 parent bad7106 commit e7f806b

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

pinot-controller/src/main/resources/app/pages/TenantDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,14 @@ const TenantPageDetails = ({ match }: RouteComponentProps<Props>) => {
468468
</Grid>
469469
<Tooltip title="Uncompressed size of all data segments" arrow placement="top-start">
470470
<Grid item xs={2}>
471-
<strong>Reported Size:</strong> {tableSummary.reportedSize}
471+
<strong>Reported Size:</strong> {Utils.formatBytes(tableSummary.reportedSize)}
472472
</Grid>
473473
</Tooltip>
474474
<Grid item xs={2}></Grid>
475475
<Tooltip title="Estimated size of all data segments, in case any servers are not reachable for actual size" arrow placement="top-start">
476476
<Grid item xs={2}>
477477
<strong>Estimated Size: </strong>
478-
{tableSummary.estimatedSize}
478+
{Utils.formatBytes(tableSummary.estimatedSize)}
479479
</Grid>
480480
</Tooltip>
481481
<Grid item xs={2}></Grid>

pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ const getAllTableDetails = (tablesList) => {
422422
} = result.data;
423423
singleTableData.push(
424424
tableName,
425-
reportedSizeInBytes,
426-
estimatedSizeInBytes
425+
Utils.formatBytes(reportedSizeInBytes),
426+
Utils.formatBytes(estimatedSizeInBytes)
427427
);
428428
} else if (index % 3 === 1) {
429429
// response of getIdealState API

pinot-controller/src/main/resources/app/utils/Utils.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,18 @@ const encodeString = (str: string) => {
324324
return str;
325325
}
326326

327+
const formatBytes = (bytes, decimals = 2) => {
328+
if (bytes === 0) return '0 Bytes';
329+
330+
const k = 1024;
331+
const dm = decimals < 0 ? 0 : decimals;
332+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
333+
334+
const i = Math.floor(Math.log(bytes) / Math.log(k));
335+
336+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
337+
}
338+
327339
export default {
328340
sortArray,
329341
tableFormat,
@@ -333,5 +345,6 @@ export default {
333345
serialize,
334346
navigateToPreviousPage,
335347
syncTableSchemaData,
336-
encodeString
348+
encodeString,
349+
formatBytes
337350
};

0 commit comments

Comments
 (0)