You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "dombizita (via GitHub)" <gi...@apache.org> on 2023/05/15 15:40:43 UTC

[GitHub] [ozone] dombizita commented on a diff in pull request #4665: HDDS-7812. Recon UI: Add visualization for container size distribution.

dombizita commented on code in PR #4665:
URL: https://github.com/apache/ozone/pull/4665#discussion_r1194012239


##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/insights/insights.tsx:
##########
@@ -36,10 +37,17 @@ interface IFileCountResponse {
   count: number;
 }
 
+interface IContainerCountResponse {
+  containerSize: number;
+  count: number;
+}
+
 interface IInsightsState {
   isLoading: boolean;
   fileCountsResponse: IFileCountResponse[];
+  containerCountResponse: IContainerCountResponse[];
   plotData: Plotly.Data[];
+  containerData: Plotly.Data[];

Review Comment:
   as we are having both container and file count size task now, we should rename the previous variable, so it is easier to understand it. 
   ```suggestion
     fileCountData: Plotly.Data[];
     containerCountData: Plotly.Data[];
   ```



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/insights/insights.tsx:
##########
@@ -155,12 +165,45 @@ export class Insights extends React.Component<Record<string, object>, IInsightsS
         const lowerbound = upperboundPower > 10 ? size(2 ** (upperboundPower - 1)) : size(0);
         return `${lowerbound} - ${upperbound}`;
       });
+      
+      const xyConatainerCountMap: Map<number, number> = containerCountResponse.reduce(

Review Comment:
   ```suggestion
         const xyContainerCountMap: Map<number, number> = containerCountResponse.reduce(
   ```



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/insights/insights.tsx:
##########
@@ -155,12 +165,45 @@ export class Insights extends React.Component<Record<string, object>, IInsightsS
         const lowerbound = upperboundPower > 10 ? size(2 ** (upperboundPower - 1)) : size(0);
         return `${lowerbound} - ${upperbound}`;
       });
+      
+      const xyConatainerCountMap: Map<number, number> = containerCountResponse.reduce(
+        (map: Map<number, number>, current) => {
+          const fileSize = current.containerSize;
+          const oldCount = map.has(fileSize) ? map.get(fileSize)! : 0;
+          map.set(fileSize, oldCount + current.count);
+          return map;
+        }, new Map<number, number>());
+      // Calculate the previous power of 2 to find the lower bound of the range
+      // Ex: for 2048, the lower bound is 1024
+      const xContainerCountValues = Array.from(xyConatainerCountMap.keys()).map(value => {
+        const upperbound = size(value);
+        const upperboundPower = Math.log2(value);
+        // For 1024 which is 2^10, the lowerbound is 0, since we start binning
+        // after 2^10
+        const lowerbound = upperboundPower > 10 ? size(2 ** (upperboundPower - 1)) : size(0);
+        return `${lowerbound} - ${upperbound}`;
+      });
+
+      let keysize = [];
+      keysize = Array.from(xyConatainerCountMap.keys()).map(value => {
+        return (size(value) );
+      });
+
       this.setState({
         plotData: [{
           type: 'bar',
           x: xValues,
           y: Array.from(xyMap.values()),

Review Comment:
   ```suggestion
             y: Array.from(xyFileCountMap.values()),
   ```



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/insights/insights.tsx:
##########
@@ -215,69 +264,107 @@ export class Insights extends React.Component<Record<string, object>, IInsightsS
 
   render() {
     const {plotData, isLoading, selectedBuckets, volumeOptions,
-      selectedVolumes, fileCountsResponse, bucketOptions, isBucketSelectionDisabled} = this.state;
+      selectedVolumes, fileCountsResponse, bucketOptions, isBucketSelectionDisabled, containerCountResponse, containerData} = this.state;
     return (
       <div className='insights-container'>
         <div className='page-header'>
           Insights
         </div>
+       
         <div className='content-div'>
-          {isLoading ? <span><Icon type='loading'/> Loading...</span> :
-            ((fileCountsResponse && fileCountsResponse.length > 0) ?
-              <div>
-                <Row>
-                  <Col xs={24} xl={18}>
-                    <Row>
-                      <Col>
-                        <div className='filter-block'>
-                          <h4>Volumes</h4>
-                          <MultiSelect
-                            allowSelectAll
-                            isMulti
-                            className='multi-select-container'
-                            options={volumeOptions}
-                            closeMenuOnSelect={false}
-                            hideSelectedOptions={false}
-                            value={selectedVolumes}
-                            allOption={allVolumesOption}
-                            onChange={this.handleVolumeChange}
-                          />
-                        </div>
-                        <div className='filter-block'>
-                          <h4>Buckets</h4>
-                          <MultiSelect
-                            allowSelectAll
-                            isMulti
-                            className='multi-select-container'
-                            options={bucketOptions}
-                            closeMenuOnSelect={false}
-                            hideSelectedOptions={false}
-                            value={selectedBuckets}
-                            allOption={allBucketsOption}
-                            isDisabled={isBucketSelectionDisabled}
-                            onChange={this.handleBucketChange}
-                          />
-                        </div>
-                      </Col>
-                    </Row>
-                  </Col>
-                </Row>
-                <Row>
-                  <Col>
-                    <Plot
-                      data={plotData}
-                      layout={
-                        {
-                          width: 800,
-                          height: 600,
-                          title: 'File Size Distribution',
-                          showlegend: true
-                        }
-                      }/>
-                  </Col>
-                </Row>
-              </div> :
-              <div>No data to visualize file size distribution. Add files to Ozone to see a visualization on file size distribution.</div>)}
+          <Tabs defaultActiveKey='1'>
+            <TabPane key='1' tab={`File Size`}>
+              {
+                <div className='content-div'>
+                  {isLoading ? <span><Icon type='loading'/> Loading...</span> :
+                    ((fileCountsResponse && fileCountsResponse.length > 0) ?
+                      <div>
+                        <Row>
+                          <Col xs={24} xl={18}>
+                            <Row>
+                              <Col>
+                                <div className='filter-block'>
+                                  <h4>Volumes</h4>
+                                  <MultiSelect
+                                    allowSelectAll
+                                    isMulti
+                                    className='multi-select-container'
+                                    options={volumeOptions}
+                                    closeMenuOnSelect={false}
+                                    hideSelectedOptions={false}
+                                    value={selectedVolumes}
+                                    allOption={allVolumesOption}
+                                    onChange={this.handleVolumeChange}
+                                  />
+                                </div>
+                                <div className='filter-block'>
+                                  <h4>Buckets</h4>
+                                  <MultiSelect
+                                    allowSelectAll
+                                    isMulti
+                                    className='multi-select-container'
+                                    options={bucketOptions}
+                                    closeMenuOnSelect={false}
+                                    hideSelectedOptions={false}
+                                    value={selectedBuckets}
+                                    allOption={allBucketsOption}
+                                    isDisabled={isBucketSelectionDisabled}
+                                    onChange={this.handleBucketChange}
+                                  />
+                                </div>
+                              </Col>
+                            </Row>
+                          </Col>
+                        </Row>
+                        <Row>
+                          <Col>
+                            <Plot
+                              data={plotData}
+                              layout={
+                                {
+                                  width: 800,
+                                  height: 600,
+                                  title: 'File Size Distribution',
+                                  showlegend: false
+                                }
+                              } />
+                          </Col>
+                        </Row>
+                      </div> :
+                      <div>No data to visualize file size distribution. Add files to Ozone to see a visualization on file size distribution.</div>)}
+                </div>
+              }
+            </TabPane>
+            <TabPane key='2' tab={`Container Size`}>
+              {
+                <div className='content-div'>
+                  {isLoading ? <span><Icon type='loading'/> Loading...</span> :
+                    ((containerCountResponse && containerCountResponse.length > 0) ?
+                      <div>
+                        <Row>
+                          <Col>
+                            <Plot
+                              data={containerData}
+                              layout={
+                                {
+                                  width: 850,
+                                  height: 750,
+                                  font: {
+                                    family: 'Roboto, sans-serif',
+                                    size: 15
+                                  },
+                                  title: 'Container Size Distribution',
+                                  showlegend: true
+                                }
+                              }/>
+                          </Col>
+                        </Row>
+                      </div> :
+                      <div>No data to visualize Container size distribution. Add files to Ozone to see a visualization on Container size distribution.</div>)}

Review Comment:
   ```suggestion
                         <div>No data to visualize container size distribution. Add files to Ozone to see a visualization on container size distribution.</div>)}
   ```



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/insights/insights.tsx:
##########
@@ -155,12 +165,45 @@ export class Insights extends React.Component<Record<string, object>, IInsightsS
         const lowerbound = upperboundPower > 10 ? size(2 ** (upperboundPower - 1)) : size(0);
         return `${lowerbound} - ${upperbound}`;
       });
+      
+      const xyConatainerCountMap: Map<number, number> = containerCountResponse.reduce(
+        (map: Map<number, number>, current) => {
+          const fileSize = current.containerSize;
+          const oldCount = map.has(fileSize) ? map.get(fileSize)! : 0;
+          map.set(fileSize, oldCount + current.count);
+          return map;
+        }, new Map<number, number>());
+      // Calculate the previous power of 2 to find the lower bound of the range
+      // Ex: for 2048, the lower bound is 1024
+      const xContainerCountValues = Array.from(xyConatainerCountMap.keys()).map(value => {
+        const upperbound = size(value);
+        const upperboundPower = Math.log2(value);
+        // For 1024 which is 2^10, the lowerbound is 0, since we start binning
+        // after 2^10
+        const lowerbound = upperboundPower > 10 ? size(2 ** (upperboundPower - 1)) : size(0);
+        return `${lowerbound} - ${upperbound}`;
+      });
+
+      let keysize = [];
+      keysize = Array.from(xyConatainerCountMap.keys()).map(value => {
+        return (size(value) );
+      });
+
       this.setState({
         plotData: [{
           type: 'bar',
           x: xValues,

Review Comment:
   ```suggestion
             x: xFileCountValues,
   ```



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/insights/insights.tsx:
##########
@@ -155,12 +165,45 @@ export class Insights extends React.Component<Record<string, object>, IInsightsS
         const lowerbound = upperboundPower > 10 ? size(2 ** (upperboundPower - 1)) : size(0);
         return `${lowerbound} - ${upperbound}`;
       });
+      
+      const xyConatainerCountMap: Map<number, number> = containerCountResponse.reduce(
+        (map: Map<number, number>, current) => {
+          const fileSize = current.containerSize;

Review Comment:
   ```suggestion
             const containerSize = current.containerSize;
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org