This is an automated email from the ASF dual-hosted git repository.
chihsuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new a5340758034 HDDS-17693. Fix heatmap hiding keys with very low read
counts (#11924)
a5340758034 is described below
commit a53407580348fe49b6398818e02084adbf3f808f
Author: Andy Huang <[email protected]>
AuthorDate: Wed Nov 11 17:17:19 2026 +0800
HDDS-17693. Fix heatmap hiding keys with very low read counts (#11924)
---
.../heatmap/HeatmapLowReadCounts.test.tsx | 95 ++++++++++++++++++++++
.../src/__tests__/heatmap/HeatmapPlot.test.tsx | 8 +-
.../src/v2/components/plots/heatmapPlot.tsx | 7 +-
.../src/v2/pages/heatmap/heatmap.tsx | 5 +-
.../src/views/heatMap/heatMapConfiguration.tsx | 9 +-
.../ozone-recon-web/src/views/heatMap/heatmap.tsx | 7 +-
6 files changed, 116 insertions(+), 15 deletions(-)
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/HeatmapLowReadCounts.test.tsx
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/HeatmapLowReadCounts.test.tsx
new file mode 100644
index 00000000000..59e774ef66d
--- /dev/null
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/HeatmapLowReadCounts.test.tsx
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import React from 'react';
+import { cleanup, render, waitFor } from '@testing-library/react';
+import Heatmap from '@/v2/pages/heatmap/heatmap';
+import HeatmapPlot from '@/v2/components/plots/heatmapPlot';
+import { Heatmap as LegacyHeatmap } from '@/views/heatMap/heatmap';
+import HeatMapConfiguration from '@/views/heatMap/heatMapConfiguration';
+import { useApiData } from '@/v2/hooks/useAPIData.hook';
+
+const { chart } = vi.hoisted(() => ({ chart: vi.fn() }));
+vi.mock('ag-charts-react', () => ({
+ AgChartsReact: (props: any) => { chart(props.options); return null; }
+}));
+vi.mock('@/v2/hooks/useAPIData.hook', () => ({ useApiData: vi.fn() }));
+
+const leaf = (color?: number) => ({
+ label: 'cold-key', path: '/vol/bucket/cold-key', size: 256, accessCount: 1,
+ ...(color === undefined ? {} : { color })
+});
+const tree = (child: any) => ({
+ label: 'bucket', path: '/vol/bucket', size: 512,
+ minAccessCount: 1, maxAccessCount: 5000,
+ children: [child, { ...leaf(1), label: 'hot-key', accessCount: 5000 }]
+});
+
+afterEach(() => { cleanup(); vi.clearAllMocks(); });
+
+describe.each([undefined, 0, 0.002])('heatmap leaf with color %s', color => {
+ test('v2 gives the leaf a visible area without sizing the group', async ()
=> {
+ const data = tree(leaf(color));
+ vi.mocked(useApiData).mockReturnValue({ data } as any);
+ render(<Heatmap />);
+ await waitFor(() => expect((data.children[0] as
any).normalizedSize).toBeGreaterThan(0));
+ expect(data.children[0].color).toBe(color ?? 0);
+ expect(data.children[1].color).toBe(1);
+ expect((data as any).normalizedSize).toBeUndefined();
+ });
+
+ test('legacy gives the leaf a visible area and includes it in size bounds',
() => {
+ const page = new LegacyHeatmap({ location: {} } as any);
+ const data = tree(leaf(color));
+ data.children[0].size = 128;
+ expect(page.minmax(data)).toEqual([128, 256]);
+ page.updateSize(data);
+ expect((data.children[0] as any).normalizedSize).toBeGreaterThan(0);
+ expect(data.children[0].color).toBe(color ?? 0);
+ expect(data.children[1].color).toBe(1);
+ expect((data as any).normalizedSize).toBeUndefined();
+ });
+
+ test.each(['v2', 'legacy'])('%s only drills into groups', version => {
+ const onClick = vi.fn();
+ const data = tree(leaf(color));
+ render(version === 'v2'
+ ? <HeatmapPlot data={data as any} onClick={onClick} colorScheme={[]}
entityType='key' />
+ : <HeatMapConfiguration data={[data] as any} onClick={onClick}
colorScheme={[]} />);
+ const click = chart.mock.calls[chart.mock.calls.length -
1][0].series[0].listeners.nodeClick;
+ click({ datum: data.children[0] });
+ expect(onClick).not.toHaveBeenCalled();
+ click({ datum: data });
+ expect(onClick).toHaveBeenCalledWith('/vol/bucket');
+ });
+});
+
+test.each(['v2', 'legacy'])('%s preserves zero-size handling for leaves with
empty children', async version => {
+ const hidden = { ...leaf(), size: 0, accessCount: 0, children: [] };
+ const visible = { ...leaf(), size: 0, children: [] };
+ const data = { ...tree(hidden), children: [hidden, visible] };
+ if (version === 'v2') {
+ vi.mocked(useApiData).mockReturnValue({ data } as any);
+ render(<Heatmap />);
+ await waitFor(() => expect((hidden as any).normalizedSize).toBe(0));
+ } else {
+ new LegacyHeatmap({ location: {} } as any).updateSize(data);
+ }
+ expect((hidden as any).normalizedSize).toBe(0);
+ expect((visible as any).normalizedSize).toBe(1);
+});
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/HeatmapPlot.test.tsx
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/HeatmapPlot.test.tsx
index f5ac06bb7e5..1bb69b4e1ce 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/HeatmapPlot.test.tsx
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/HeatmapPlot.test.tsx
@@ -85,7 +85,13 @@ describe('HeatmapPlot nodeClick', () => {
/>
);
- invokeNodeClick({ label: 'vol1', path: '/vol1', size: 512, maxAccessCount:
100 });
+ invokeNodeClick({
+ label: 'vol1',
+ path: '/vol1',
+ size: 512,
+ maxAccessCount: 100,
+ children: [{ label: 'demo-key', size: 512, accessCount: 100, color: 1 }],
+ });
expect(onClick).toHaveBeenCalledTimes(1);
expect(onClick).toHaveBeenCalledWith('/vol1');
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/plots/heatmapPlot.tsx
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/plots/heatmapPlot.tsx
index a58a7704dac..3e81390bb6d 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/plots/heatmapPlot.tsx
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/plots/heatmapPlot.tsx
@@ -131,10 +131,9 @@ const HeatmapPlot: React.FC<HeatmapPlotProps> = ({
nodeClick: (event) => {
var data = event.datum;
// Leaf level box should not call API
- if (!data.color)
- if (data.path) {
- onClick(data.path);
- }
+ if (data.children?.length && data.path) {
+ onClick(data.path);
+ }
},
},
}
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/heatmap/heatmap.tsx
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/heatmap/heatmap.tsx
index 3649ed12775..408fcb60488 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/heatmap/heatmap.tsx
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/heatmap/heatmap.tsx
@@ -148,8 +148,9 @@ const Heatmap: React.FC<{}> = () => {
const updateSize = (obj: HeatmapResponse | HeatmapChild) => {
//Normalize Size so other blocks also get visualized if size is large in
bytes minimize and if size is too small make it big
- // it will only apply on leaf level as checking color property
- if (obj.hasOwnProperty('size') && obj.hasOwnProperty('color')) {
+ // Apply only to leaves, including those whose zero color is omitted by
the API.
+ if (obj.hasOwnProperty('size') && !('children' in obj &&
obj.children?.length)) {
+ (obj as HeatmapChild).color = (obj as HeatmapChild).color ?? 0;
// hide block at key,volume,bucket level if size accessCount and
maxAccessCount are zero apply normalized size only for leaf level
if ((obj as HeatmapChild)?.size === 0 && (obj as
HeatmapChild)?.accessCount === 0) {
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/heatMap/heatMapConfiguration.tsx
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/heatMap/heatMapConfiguration.tsx
index 00c313b706f..d964db634ce 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/heatMap/heatMapConfiguration.tsx
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/heatMap/heatMapConfiguration.tsx
@@ -94,11 +94,10 @@ export default class HeatMapConfiguration extends
React.Component<IHeatmapConfig
nodeClick: (event) => {
var data = event.datum;
// Leaf level box should not call API
- if (!data.color)
- if (data.path) {
- console.log('Path', data.path);
- this.props.onClick(data.path);
- }
+ if (data.children?.length && data.path) {
+ console.log('Path', data.path);
+ this.props.onClick(data.path);
+ }
},
},
}],
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/heatMap/heatmap.tsx
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/heatMap/heatmap.tsx
index fb5b9c51264..a3527820cb9 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/heatMap/heatmap.tsx
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/heatMap/heatmap.tsx
@@ -224,7 +224,7 @@ export class Heatmap extends React.Component<Record<string,
object>, ITreeState>
if (obj.hasOwnProperty('children')) {
obj.children.forEach((child: any) => this.minmax(child))
};
- if (obj.hasOwnProperty('size') && obj.hasOwnProperty('color')) {
+ if (obj.hasOwnProperty('size') && !('children' in obj &&
obj.children?.length)) {
minSize = Math.min(minSize, obj.size);
maxSize = Math.max(maxSize, obj.size);
}
@@ -233,8 +233,9 @@ export class Heatmap extends React.Component<Record<string,
object>, ITreeState>
updateSize = (obj: any) => {
//Normalize Size so other blocks also get visualized if size is large in
bytes minimize and if size is too small make it big
- // it will only apply on leaf level as checking color property
- if (obj.hasOwnProperty('size') && obj.hasOwnProperty('color')) {
+ // Apply only to leaves, including those whose zero color is omitted by
the API.
+ if (obj.hasOwnProperty('size') && !('children' in obj &&
obj.children?.length)) {
+ obj.color = obj.color ?? 0;
// hide block at key,volume,bucket level if size accessCount and
maxAccessCount are zero apply normalized size only for leaf level
if (obj && obj.size === 0 && obj.accessCount === 0) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]