@akohn/dashql-react 0.0.0-stage → 0.0.20-dev.664.g9e89b805d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/NOTICE +66 -0
- package/README.md +46 -2
- package/dist/_virtual/_vite/preload-helper.js +100 -0
- package/dist/brand/brand.d.ts +13 -0
- package/dist/brand/brand.js +14 -0
- package/dist/brand/landing_backdrop.d.ts +56 -0
- package/dist/brand/landing_backdrop.js +1019 -0
- package/dist/brand/wobble_morph.d.ts +54 -0
- package/dist/brand/wobble_morph.js +439 -0
- package/dist/components/action_list.d.ts +31 -0
- package/dist/components/action_list.js +63 -0
- package/dist/components/action_list.module.js +11 -0
- package/dist/components/anchored_overlay.d.ts +28 -0
- package/dist/components/anchored_overlay.js +93 -0
- package/dist/components/button.d.ts +42 -0
- package/dist/components/button.js +97 -0
- package/dist/components/button.module.js +20 -0
- package/dist/components/button_group.d.ts +7 -0
- package/dist/components/button_group.js +18 -0
- package/dist/components/button_group.module.js +3 -0
- package/dist/components/card_placeholder.d.ts +9 -0
- package/dist/components/card_placeholder.js +39 -0
- package/dist/components/card_placeholder.module.js +6 -0
- package/dist/components/clipboard.d.ts +19 -0
- package/dist/components/clipboard.js +54 -0
- package/dist/components/data_table/computation_tables.d.ts +12 -0
- package/dist/components/data_table/computation_tables.js +42 -0
- package/dist/components/data_table/data_table.d.ts +38 -0
- package/dist/components/data_table/data_table.js +378 -0
- package/dist/components/data_table/data_table.module.js +41 -0
- package/dist/components/data_table/data_table_cell.d.ts +7 -0
- package/dist/components/data_table/data_table_cell.js +9 -0
- package/dist/components/data_table/data_table_cell_data.d.ts +21 -0
- package/dist/components/data_table/data_table_cell_data.js +99 -0
- package/dist/components/data_table/data_table_cell_header_name.d.ts +17 -0
- package/dist/components/data_table/data_table_cell_header_name.js +73 -0
- package/dist/components/data_table/data_table_cell_header_plots.d.ts +31 -0
- package/dist/components/data_table/data_table_cell_header_plots.js +122 -0
- package/dist/components/data_table/data_table_colors.d.ts +19 -0
- package/dist/components/data_table/data_table_colors.js +27 -0
- package/dist/components/data_table/data_table_column_resize.d.ts +21 -0
- package/dist/components/data_table/data_table_column_resize.js +121 -0
- package/dist/components/data_table/data_table_focus.d.ts +15 -0
- package/dist/components/data_table/data_table_focus.js +53 -0
- package/dist/components/data_table/data_table_layout.d.ts +18 -0
- package/dist/components/data_table/data_table_layout.js +103 -0
- package/dist/components/data_table/data_table_ordering.d.ts +9 -0
- package/dist/components/data_table/data_table_ordering.js +39 -0
- package/dist/components/data_table/data_table_portals.d.ts +9 -0
- package/dist/components/data_table/data_table_portals.js +29 -0
- package/dist/components/data_table/data_table_sticky_views.d.ts +34 -0
- package/dist/components/data_table/data_table_sticky_views.js +161 -0
- package/dist/components/data_table/data_table_window.d.ts +18 -0
- package/dist/components/data_table/data_table_window.js +118 -0
- package/dist/components/data_table/format_peek.d.ts +2 -0
- package/dist/components/data_table/format_peek.js +17 -0
- package/dist/components/data_table/histogram_bars.d.ts +36 -0
- package/dist/components/data_table/histogram_bars.js +100 -0
- package/dist/components/data_table/histogram_brush.d.ts +23 -0
- package/dist/components/data_table/histogram_brush.js +107 -0
- package/dist/components/data_table/histogram_cell.d.ts +19 -0
- package/dist/components/data_table/histogram_cell.js +325 -0
- package/dist/components/data_table/histogram_cell.module.js +9 -0
- package/dist/components/data_table/histogram_label.d.ts +1 -0
- package/dist/components/data_table/histogram_label.js +7 -0
- package/dist/components/data_table/memo_props.d.ts +1 -0
- package/dist/components/data_table/memo_props.js +17 -0
- package/dist/components/data_table/mostfrequent_cell.d.ts +17 -0
- package/dist/components/data_table/mostfrequent_cell.js +316 -0
- package/dist/components/data_table/mostfrequent_cell.module.js +10 -0
- package/dist/components/data_table/use_cross_filters.d.ts +14 -0
- package/dist/components/data_table/use_cross_filters.js +47 -0
- package/dist/components/deferred.d.ts +11 -0
- package/dist/components/deferred.js +41 -0
- package/dist/components/deferred.module.js +5 -0
- package/dist/components/error_boundary.d.ts +18 -0
- package/dist/components/error_boundary.js +15 -0
- package/dist/components/graph.module.js +15 -0
- package/dist/components/graph_port.d.ts +10 -0
- package/dist/components/graph_port.js +34 -0
- package/dist/components/inspector_overlay.d.ts +32 -0
- package/dist/components/inspector_overlay.js +72 -0
- package/dist/components/inspector_overlay.module.js +18 -0
- package/dist/components/json/json_arrow_symbol.d.ts +4 -0
- package/dist/components/json/json_arrow_symbol.js +25 -0
- package/dist/components/json/json_copy_button.d.ts +11 -0
- package/dist/components/json/json_copy_button.js +61 -0
- package/dist/components/json/json_ellipsis_symbol.d.ts +7 -0
- package/dist/components/json/json_ellipsis_symbol.js +11 -0
- package/dist/components/json/json_item_count.d.ts +5 -0
- package/dist/components/json/json_item_count.js +12 -0
- package/dist/components/json/json_key_name.d.ts +6 -0
- package/dist/components/json/json_key_name.js +40 -0
- package/dist/components/json/json_key_values.d.ts +12 -0
- package/dist/components/json/json_key_values.js +99 -0
- package/dist/components/json/json_literal.d.ts +8 -0
- package/dist/components/json/json_literal.js +140 -0
- package/dist/components/json/json_nested_close.d.ts +11 -0
- package/dist/components/json/json_nested_close.js +31 -0
- package/dist/components/json/json_nested_open.d.ts +18 -0
- package/dist/components/json/json_nested_open.js +150 -0
- package/dist/components/json/json_nested_state.d.ts +14 -0
- package/dist/components/json/json_nested_state.js +28 -0
- package/dist/components/json/json_tool_state.d.ts +18 -0
- package/dist/components/json/json_tool_state.js +46 -0
- package/dist/components/json/json_value.d.ts +10 -0
- package/dist/components/json/json_value.js +46 -0
- package/dist/components/json/json_view.d.ts +14 -0
- package/dist/components/json/json_view.js +37 -0
- package/dist/components/json/json_view.module.js +41 -0
- package/dist/components/json/json_view_state.d.ts +14 -0
- package/dist/components/json/json_view_state.js +32 -0
- package/dist/components/json/unique_key.d.ts +1 -0
- package/dist/components/json/unique_key.js +8 -0
- package/dist/components/keyvalue_list.d.ts +25 -0
- package/dist/components/keyvalue_list.js +106 -0
- package/dist/components/keyvalue_list.module.js +15 -0
- package/dist/components/name_input.d.ts +11 -0
- package/dist/components/name_input.js +51 -0
- package/dist/components/overlay.d.ts +53 -0
- package/dist/components/overlay.js +183 -0
- package/dist/components/overlay.module.js +32 -0
- package/dist/components/panel_resize_handle.d.ts +12 -0
- package/dist/components/panel_resize_handle.js +39 -0
- package/dist/components/portal.d.ts +8 -0
- package/dist/components/portal.js +53 -0
- package/dist/components/progress_bar.d.ts +7 -0
- package/dist/components/progress_bar.js +21 -0
- package/dist/components/progress_bar.module.js +3 -0
- package/dist/components/query_history_viewer.d.ts +33 -0
- package/dist/components/query_history_viewer.js +268 -0
- package/dist/components/query_history_viewer.module.js +7 -0
- package/dist/components/query_profile/engine_profile_view.d.ts +19 -0
- package/dist/components/query_profile/engine_profile_view.js +94 -0
- package/dist/components/query_profile/numeric_limits.d.ts +1 -0
- package/dist/components/query_profile/numeric_limits.js +2 -0
- package/dist/components/query_profile/profile_execution_controller.d.ts +14 -0
- package/dist/components/query_profile/profile_execution_controller.js +56 -0
- package/dist/components/query_profile/profile_fit.d.ts +24 -0
- package/dist/components/query_profile/profile_fit.js +22 -0
- package/dist/components/query_profile/profile_navigation.d.ts +3 -0
- package/dist/components/query_profile/profile_navigation.js +34 -0
- package/dist/components/query_profile/profile_scene.d.ts +64 -0
- package/dist/components/query_profile/profile_scene.js +422 -0
- package/dist/components/query_profile/query_profile_view.d.ts +44 -0
- package/dist/components/query_profile/query_profile_view.js +961 -0
- package/dist/components/query_profile/query_profile_view.module.js +23 -0
- package/dist/components/query_progress/query_profile_overlay.d.ts +7 -0
- package/dist/components/query_progress/query_profile_overlay.js +67 -0
- package/dist/components/query_progress/query_profile_overlay.module.js +6 -0
- package/dist/components/query_progress/query_progress_panel.d.ts +14 -0
- package/dist/components/query_progress/query_progress_panel.js +255 -0
- package/dist/components/query_progress/query_progress_panel.module.js +10 -0
- package/dist/components/query_result/cell_detail_overlay.d.ts +34 -0
- package/dist/components/query_result/cell_detail_overlay.js +277 -0
- package/dist/components/query_result/cell_detail_overlay.module.js +21 -0
- package/dist/components/query_result/query_result_action_menu.d.ts +12 -0
- package/dist/components/query_result/query_result_action_menu.js +62 -0
- package/dist/components/query_result/query_result_action_menu.module.js +2 -0
- package/dist/components/query_result/query_result_details.d.ts +17 -0
- package/dist/components/query_result/query_result_details.js +46 -0
- package/dist/components/query_result/query_result_details.module.js +5 -0
- package/dist/components/query_result/query_result_download_button.d.ts +8 -0
- package/dist/components/query_result/query_result_download_button.js +38 -0
- package/dist/components/query_result/query_result_header.d.ts +21 -0
- package/dist/components/query_result/query_result_header.js +71 -0
- package/dist/components/query_result/query_result_header.module.js +3 -0
- package/dist/components/query_result/query_result_search_controls.d.ts +12 -0
- package/dist/components/query_result/query_result_search_controls.js +141 -0
- package/dist/components/query_result/query_result_search_controls.module.js +7 -0
- package/dist/components/query_result/query_result_toolbar.d.ts +21 -0
- package/dist/components/query_result/query_result_toolbar.js +74 -0
- package/dist/components/query_result/result_table_overlay.d.ts +9 -0
- package/dist/components/query_result/result_table_overlay.js +73 -0
- package/dist/components/query_result/result_table_overlay.module.js +6 -0
- package/dist/components/query_result/use_query_result_search.d.ts +8 -0
- package/dist/components/query_result/use_query_result_search.js +28 -0
- package/dist/components/segmented_control.d.ts +58 -0
- package/dist/components/segmented_control.js +116 -0
- package/dist/components/segmented_control.module.js +17 -0
- package/dist/components/separator.d.ts +21 -0
- package/dist/components/separator.js +79 -0
- package/dist/components/separator.module.js +7 -0
- package/dist/components/size_observer.d.ts +7 -0
- package/dist/components/size_observer.js +57 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +14 -0
- package/dist/components/skeleton.module.js +2 -0
- package/dist/components/spinners.d.ts +8 -0
- package/dist/components/spinners.js +33 -0
- package/dist/components/spinners.module.js +8 -0
- package/dist/components/status_indicator.d.ts +36 -0
- package/dist/components/status_indicator.js +182 -0
- package/dist/components/status_indicator.module.js +3 -0
- package/dist/components/symbol_icon.d.ts +65 -0
- package/dist/components/symbol_icon.js +213 -0
- package/dist/components/tab_header.d.ts +11 -0
- package/dist/components/tab_header.js +55 -0
- package/dist/components/tab_header.module.js +7 -0
- package/dist/components/tag.d.ts +10 -0
- package/dist/components/tag.js +17 -0
- package/dist/components/tag.module.js +4 -0
- package/dist/components/text_field.d.ts +44 -0
- package/dist/components/text_field.js +159 -0
- package/dist/components/text_field.module.js +15 -0
- package/dist/components/text_input.d.ts +25 -0
- package/dist/components/text_input.js +90 -0
- package/dist/components/text_input.module.js +13 -0
- package/dist/components/text_input_action.d.ts +19 -0
- package/dist/components/text_input_action.js +33 -0
- package/dist/components/text_input_action.module.js +2 -0
- package/dist/components/toggle_switch.d.ts +7 -0
- package/dist/components/toggle_switch.js +22 -0
- package/dist/components/toggle_switch.module.js +6 -0
- package/dist/components/tooltip.d.ts +22 -0
- package/dist/components/tooltip.js +139 -0
- package/dist/components/tooltip.module.js +2 -0
- package/dist/components/tree_entry.d.ts +17 -0
- package/dist/components/tree_entry.js +48 -0
- package/dist/components/tree_entry.module.js +9 -0
- package/dist/components/value_list.d.ts +17 -0
- package/dist/components/value_list.js +70 -0
- package/dist/components/value_list.module.js +8 -0
- package/dist/components/vegalite_chart.d.ts +18 -0
- package/dist/components/vegalite_chart.js +151 -0
- package/dist/components/vegalite_chart.module.js +3 -0
- package/dist/components/vegalite_view.d.ts +27 -0
- package/dist/components/vegalite_view.js +248 -0
- package/dist/components/vegalite_view.module.js +5 -0
- package/dist/components/vertical_scroll_shadows.d.ts +14 -0
- package/dist/components/vertical_scroll_shadows.js +55 -0
- package/dist/components/vertical_scroll_shadows.module.js +5 -0
- package/dist/components/vertical_split.d.ts +15 -0
- package/dist/components/vertical_split.js +112 -0
- package/dist/components/vertical_split.module.js +5 -0
- package/dist/components/vertical_tabs.d.ts +36 -0
- package/dist/components/vertical_tabs.js +169 -0
- package/dist/components/vertical_tabs.module.js +23 -0
- package/dist/components/visualization/capped_rows.d.ts +9 -0
- package/dist/components/visualization/capped_rows.js +23 -0
- package/dist/components/visualization/capped_rows.module.js +3 -0
- package/dist/components/visualization/chart_download_button.d.ts +12 -0
- package/dist/components/visualization/chart_download_button.js +41 -0
- package/dist/components/visualization/kpi_view.d.ts +10 -0
- package/dist/components/visualization/kpi_view.js +215 -0
- package/dist/components/visualization/kpi_view.module.js +17 -0
- package/dist/components/visualization/markdown_view.d.ts +17 -0
- package/dist/components/visualization/markdown_view.js +154 -0
- package/dist/components/visualization/markdown_view.module.js +4 -0
- package/dist/components/visualization/result_rows.d.ts +17 -0
- package/dist/components/visualization/result_rows.js +82 -0
- package/dist/components/visualization/vegalite_preview.d.ts +8 -0
- package/dist/components/visualization/vegalite_preview.js +17 -0
- package/dist/components/visualization/vegalite_preview.module.js +2 -0
- package/dist/components/visualization/visualization_dispatch.d.ts +14 -0
- package/dist/components/visualization/visualization_dispatch.js +41 -0
- package/dist/components/visualization/visualization_panel.d.ts +10 -0
- package/dist/components/visualization/visualization_panel.js +37 -0
- package/dist/components/visualization/visualization_panel.module.js +3 -0
- package/dist/dom/anchored_position.d.ts +42 -0
- package/dist/dom/anchored_position.js +255 -0
- package/dist/dom/app_host.d.ts +6 -0
- package/dist/dom/app_host.js +13 -0
- package/dist/dom/calm_frames.d.ts +24 -0
- package/dist/dom/calm_frames.js +96 -0
- package/dist/dom/classnames.d.ts +8 -0
- package/dist/dom/classnames.js +20 -0
- package/dist/dom/download_file.d.ts +1 -0
- package/dist/dom/download_file.js +12 -0
- package/dist/dom/focus.d.ts +29 -0
- package/dist/dom/focus.js +84 -0
- package/dist/dom/graph_edges.d.ts +53 -0
- package/dist/dom/graph_edges.js +450 -0
- package/dist/dom/key_events.d.ts +9 -0
- package/dist/dom/key_events.js +33 -0
- package/dist/dom/media_query.d.ts +2 -0
- package/dist/dom/media_query.js +15 -0
- package/dist/dom/outside_click.d.ts +8 -0
- package/dist/dom/outside_click.js +32 -0
- package/dist/dom/rerender_ref.d.ts +2 -0
- package/dist/dom/rerender_ref.js +11 -0
- package/dist/dom/row_context_menu.d.ts +7 -0
- package/dist/dom/row_context_menu.js +32 -0
- package/dist/dom/scrollbar.d.ts +3 -0
- package/dist/dom/scrollbar.js +23 -0
- package/dist/format/format.d.ts +11 -0
- package/dist/format/format.js +72 -0
- package/dist/format/query_progress_format.d.ts +17 -0
- package/dist/format/query_progress_format.js +69 -0
- package/dist/format/time_format.d.ts +5 -0
- package/dist/format/time_format.js +45 -0
- package/dist/hooks.d.ts +71 -0
- package/dist/hooks.js +302 -0
- package/dist/host.d.ts +10 -0
- package/dist/host.js +12 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.js +6 -0
- package/dist/models/computation_model.d.ts +14 -0
- package/dist/models/computation_model.js +27 -0
- package/dist/models/query_model.d.ts +12 -0
- package/dist/models/query_model.js +27 -0
- package/dist/models/script_model.d.ts +17 -0
- package/dist/models/script_model.js +69 -0
- package/dist/style.css +4226 -0
- package/dist/svg_symbols.d.ts +2 -0
- package/dist/svg_symbols.js +2 -0
- package/dist/symbols.svg +1197 -0
- package/dist/theme/color_scheme.d.ts +4 -0
- package/dist/theme/color_scheme.js +28 -0
- package/dist/theme/xcode_palette.d.ts +22 -0
- package/dist/theme/xcode_palette.js +4 -0
- package/dist/theme/xcode_palettes.js +41 -0
- package/dist/utils/plan_engine.d.ts +2 -0
- package/dist/utils/plan_engine.js +13 -0
- package/dist/vegalite/vegalite_check.d.ts +1 -0
- package/dist/vegalite/vegalite_check.js +7 -0
- package/dist/vegalite/vegalite_crossfilter.d.ts +54 -0
- package/dist/vegalite/vegalite_crossfilter.js +187 -0
- package/dist/vegalite/vegalite_image.d.ts +16 -0
- package/dist/vegalite/vegalite_image.js +28 -0
- package/dist/vegalite/vegalite_loader.d.ts +7 -0
- package/dist/vegalite/vegalite_loader.js +15 -0
- package/dist/vegalite/vegalite_rows.d.ts +3 -0
- package/dist/vegalite/vegalite_rows.js +17 -0
- package/dist/vegalite/vegalite_theme.d.ts +11 -0
- package/dist/vegalite/vegalite_theme.js +125 -0
- package/fonts/InstrumentSans-Bold.ttf +0 -0
- package/fonts/InstrumentSans-Medium.ttf +0 -0
- package/fonts/InstrumentSans-OFL.txt +93 -0
- package/fonts/InstrumentSans-Regular.ttf +0 -0
- package/fonts/InstrumentSans-SemiBold.ttf +0 -0
- package/fonts/JetBrainsMono-Bold.ttf +0 -0
- package/fonts/JetBrainsMono-Medium.ttf +0 -0
- package/fonts/JetBrainsMono-OFL.txt +93 -0
- package/fonts/JetBrainsMono-Regular.ttf +0 -0
- package/fonts/JetBrainsMono-SemiBold.ttf +0 -0
- package/fonts/fonts.css +61 -0
- package/package.json +43 -4
- package/styles/colors.css +110 -0
- package/styles/flavors/dbcom.css +48 -0
- package/styles/tokens.css +192 -0
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
import { SymbolIcon, ZoomInIcon, ZoomOutIcon } from "../symbol_icon.js";
|
|
2
|
+
import { JsonView } from "../json/json_view.js";
|
|
3
|
+
import { ButtonSize, ButtonVariant, IconButton } from "../button.js";
|
|
4
|
+
import { ButtonGroup } from "../button_group.js";
|
|
5
|
+
import { SegmentedControl, SegmentedControlSize } from "../segmented_control.js";
|
|
6
|
+
import { AnchoredOverlay } from "../anchored_overlay.js";
|
|
7
|
+
import { AnchorAlignment, AnchorSide } from "../../dom/anchored_position.js";
|
|
8
|
+
import { OverlaySize } from "../overlay.js";
|
|
9
|
+
import { computeProfileFitTransform } from "./profile_fit.js";
|
|
10
|
+
import { ProfileExecutionController } from "./profile_execution_controller.js";
|
|
11
|
+
import { formatCompactBytes, formatCompactCount, formatElapsed, stat, workOf } from "../../format/query_progress_format.js";
|
|
12
|
+
import { findProfileOperatorInDirection } from "./profile_navigation.js";
|
|
13
|
+
import { PROFILE_OPERATOR_PORT_INPUT, PROFILE_OPERATOR_PORT_OUTPUT, estimateRelativeDifference, materializeProfileScene } from "./profile_scene.js";
|
|
14
|
+
import { controls, edge_legend, edge_legend_matched, edge_legend_scale, fragment, inspector, inspector_header, metric_controls, operator, operator_symbol, pipeline, status_progress, status_spinner, status_track, svg, view_buttons, view_controls, viewport } from "./query_profile_view.module.js";
|
|
15
|
+
import { crossEdge, crossEdgeHighlight, edge, edgeBadge, edgeBadgeLayer, edgeHighlight, edgeHighlightLayer, fragment as fragment$1, fragment_colors, node_frame } from "../graph.module.js";
|
|
16
|
+
import { GraphPort } from "../graph_port.js";
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { color, interpolateOrRd, interpolateRdBu, interpolateRdPu, select, zoom, zoomIdentity } from "d3";
|
|
20
|
+
import * as dashql from "@akohn/dashql";
|
|
21
|
+
import { ProfileExecutionState, isStatReported } from "@akohn/dashql/platform/query/profile_execution_state";
|
|
22
|
+
import { PROFILE_OPERATOR_ANNOTATION_WIDTH, createProfileLayoutConfig } from "@akohn/dashql/platform/query/profile_layout_config";
|
|
23
|
+
import { PROFILE_OPERATOR_SYMBOL_SIZE, getProfileOperatorSymbol, shouldRenderProfileOperatorSymbol } from "@akohn/dashql/platform/query/profile_operator_symbol";
|
|
24
|
+
/** The default zoom limits of the plan, a fit of a large plan lowers the minimum */
|
|
25
|
+
var PROFILE_MIN_ZOOM = .1;
|
|
26
|
+
var PROFILE_MAX_ZOOM = 4;
|
|
27
|
+
var FitIcon = SymbolIcon("focus_center_16");
|
|
28
|
+
var RotateIcon = SymbolIcon("rotate_16");
|
|
29
|
+
var PaintbrushIcon = SymbolIcon("paintbrush_16");
|
|
30
|
+
/**
|
|
31
|
+
* Measure the drawn plan in scene coordinates. Operators drawn as symbols are narrower than their layout, and the
|
|
32
|
+
* fragment contours and badges reach beyond it, so the layout bounds are only the fallback when nothing is drawn.
|
|
33
|
+
* The bounding box of the scene group excludes its own zoom transform.
|
|
34
|
+
*/
|
|
35
|
+
function measurePlanBounds(group, scene) {
|
|
36
|
+
try {
|
|
37
|
+
const box = group?.getBBox();
|
|
38
|
+
if (box != null && box.width > 0 && box.height > 0) return {
|
|
39
|
+
left: box.x,
|
|
40
|
+
top: box.y,
|
|
41
|
+
width: box.width,
|
|
42
|
+
height: box.height
|
|
43
|
+
};
|
|
44
|
+
} catch {}
|
|
45
|
+
return {
|
|
46
|
+
left: 0,
|
|
47
|
+
top: 0,
|
|
48
|
+
width: scene.width,
|
|
49
|
+
height: scene.height
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var EDGE_WIDTH = 2;
|
|
53
|
+
var STATUS_ICON_SIZE = 14;
|
|
54
|
+
var OPERATOR_ANNOTATION_MIN_WIDTH = 20;
|
|
55
|
+
var OPERATOR_ANNOTATION_HEIGHT = 16;
|
|
56
|
+
var OPERATOR_ANNOTATION_CHAR_WIDTH = 5.5;
|
|
57
|
+
var OPERATOR_ANNOTATION_PADDING = 8;
|
|
58
|
+
var ESTIMATE_APPROXIMATE_ROW_THRESHOLD = 100;
|
|
59
|
+
var EDGE_BADGE_BORDER = "var(--color_border_strong)";
|
|
60
|
+
var EDGE_HIGHLIGHT_COLOR = "var(--color_accent_emphasis)";
|
|
61
|
+
var EDGE_HIGHLIGHT_TEXT_COLOR = "var(--color_fg_on_emphasis)";
|
|
62
|
+
var PROFILE_ANNOTATION_MODES = [
|
|
63
|
+
{
|
|
64
|
+
mode: "status",
|
|
65
|
+
label: "Status"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
mode: "plain",
|
|
69
|
+
label: "Plain"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
mode: "rows",
|
|
73
|
+
label: "Rows"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
mode: "estimates",
|
|
77
|
+
label: "Estimates"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
mode: "accuracy",
|
|
81
|
+
label: "Accuracy"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
mode: "cpu",
|
|
85
|
+
label: "CPU"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
mode: "memory",
|
|
89
|
+
label: "Memory"
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
var SPILLED_BADGE_BORDER = "var(--color_attention_fg)";
|
|
93
|
+
function StatusIcons(props) {
|
|
94
|
+
const status = dashql.buffers.profile.ProfileExecutionStatus;
|
|
95
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
+
/* @__PURE__ */ jsx("g", {
|
|
97
|
+
"data-status-icon": status.UNKNOWN,
|
|
98
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
99
|
+
cx: 8,
|
|
100
|
+
cy: 8,
|
|
101
|
+
r: 3.5
|
|
102
|
+
})
|
|
103
|
+
}),
|
|
104
|
+
/* @__PURE__ */ jsx("g", {
|
|
105
|
+
"data-status-icon": status.PENDING,
|
|
106
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
107
|
+
cx: 8,
|
|
108
|
+
cy: 8,
|
|
109
|
+
r: 3.5
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ jsxs("g", {
|
|
113
|
+
"data-status-icon": status.RUNNING,
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsx("circle", {
|
|
116
|
+
className: status_track,
|
|
117
|
+
cx: 8,
|
|
118
|
+
cy: 8,
|
|
119
|
+
r: 6.5
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx("circle", {
|
|
122
|
+
cx: 8,
|
|
123
|
+
cy: 8,
|
|
124
|
+
r: 3.5
|
|
125
|
+
}),
|
|
126
|
+
props.progress == null ? /* @__PURE__ */ jsx("circle", {
|
|
127
|
+
className: status_spinner,
|
|
128
|
+
cx: 8,
|
|
129
|
+
cy: 8,
|
|
130
|
+
r: 6.5,
|
|
131
|
+
strokeDasharray: "12 88",
|
|
132
|
+
pathLength: 100
|
|
133
|
+
}) : /* @__PURE__ */ jsx("circle", {
|
|
134
|
+
className: status_progress,
|
|
135
|
+
cx: 8,
|
|
136
|
+
cy: 8,
|
|
137
|
+
r: 6.5,
|
|
138
|
+
pathLength: 100,
|
|
139
|
+
strokeDasharray: `${props.progress} 100`,
|
|
140
|
+
transform: "rotate(-90 8 8)",
|
|
141
|
+
"data-testid": "operator-progress"
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsx("g", {
|
|
146
|
+
"data-status-icon": status.SUCCEEDED,
|
|
147
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
148
|
+
fillRule: "evenodd",
|
|
149
|
+
d: "M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16Zm3.78-9.72a.75.75 0 0 0-1.06-1.06L6.75 9.19 5.28 7.72a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l4.5-4.5Z"
|
|
150
|
+
})
|
|
151
|
+
}),
|
|
152
|
+
/* @__PURE__ */ jsx("g", {
|
|
153
|
+
"data-status-icon": status.FAILED,
|
|
154
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
155
|
+
fillRule: "evenodd",
|
|
156
|
+
d: "M2.343 13.657A8 8 0 1 1 13.657 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.75.75 0 0 0-1.06 1.06L6.94 8 4.97 9.97a.75.75 0 1 0 1.06 1.06L8 9.06l1.97 1.97a.75.75 0 1 0 1.06-1.06L9.06 8l1.97-1.97a.75.75 0 1 0-1.06-1.06L8 6.94 6.03 4.97Z"
|
|
157
|
+
})
|
|
158
|
+
}),
|
|
159
|
+
/* @__PURE__ */ jsx("g", {
|
|
160
|
+
"data-status-icon": status.SKIPPED,
|
|
161
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
162
|
+
fillRule: "evenodd",
|
|
163
|
+
d: "M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm11.333-2.167a.825.825 0 0 0-1.166-1.166l-5.5 5.5a.825.825 0 0 0 1.166 1.166Z"
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
] });
|
|
167
|
+
}
|
|
168
|
+
function fragmentProgress(execution, fragment) {
|
|
169
|
+
const state = execution.fragments[fragment];
|
|
170
|
+
const work = workOf(state);
|
|
171
|
+
if (state == null || work == null) return null;
|
|
172
|
+
return { percent: state.status === dashql.buffers.profile.ProfileExecutionStatus.RUNNING ? Math.round(work.done / work.total * 100) : null };
|
|
173
|
+
}
|
|
174
|
+
function formatFragmentMetrics(state) {
|
|
175
|
+
if (state == null) return null;
|
|
176
|
+
const field = dashql.buffers.profile.ProfileStatsField;
|
|
177
|
+
const succeeded = state.status === dashql.buffers.profile.ProfileExecutionStatus.SUCCEEDED;
|
|
178
|
+
const text = [];
|
|
179
|
+
const description = [];
|
|
180
|
+
const rows = stat(state, field.TUPLES_IN, (s) => s.tuplesIn);
|
|
181
|
+
if (rows != null && (rows > 0 || succeeded)) {
|
|
182
|
+
text.push(`${formatCompactCount(rows)} rows`);
|
|
183
|
+
description.push(`${rows} rows`);
|
|
184
|
+
}
|
|
185
|
+
const bytes = stat(state, field.BYTES_IN, (s) => s.bytesIn);
|
|
186
|
+
if (bytes != null && bytes > 0) {
|
|
187
|
+
text.push(formatCompactBytes(bytes));
|
|
188
|
+
description.push(formatCompactBytes(bytes));
|
|
189
|
+
}
|
|
190
|
+
const cpu = stat(state, field.CPU_TIME, (s) => s.cpuTimeUs);
|
|
191
|
+
if (cpu != null && cpu > 0) {
|
|
192
|
+
text.push(`${formatElapsed(cpu / 1e3)} CPU`);
|
|
193
|
+
description.push(`${formatElapsed(cpu / 1e3)} CPU time`);
|
|
194
|
+
}
|
|
195
|
+
const work = workOf(state);
|
|
196
|
+
if (work != null && !succeeded) {
|
|
197
|
+
text.push(`${formatCompactCount(work.done)}/${formatCompactCount(work.total)} splits`);
|
|
198
|
+
description.push(`${work.done} of ${work.total} splits`);
|
|
199
|
+
}
|
|
200
|
+
return text.length === 0 ? null : {
|
|
201
|
+
text: text.join(" · "),
|
|
202
|
+
description: description.join(", ")
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function operatorProgress(execution, fragment) {
|
|
206
|
+
const percent = fragmentProgress(execution, fragment)?.percent ?? null;
|
|
207
|
+
return percent == null || percent === 0 ? null : percent;
|
|
208
|
+
}
|
|
209
|
+
function fragmentStatus(execution, fragment) {
|
|
210
|
+
switch (execution.fragments[fragment]?.status) {
|
|
211
|
+
case dashql.buffers.profile.ProfileExecutionStatus.PENDING: return "pending";
|
|
212
|
+
case dashql.buffers.profile.ProfileExecutionStatus.RUNNING: return "running";
|
|
213
|
+
case dashql.buffers.profile.ProfileExecutionStatus.SUCCEEDED: return "succeeded";
|
|
214
|
+
case dashql.buffers.profile.ProfileExecutionStatus.FAILED: return "failed";
|
|
215
|
+
case dashql.buffers.profile.ProfileExecutionStatus.SKIPPED: return "skipped";
|
|
216
|
+
default: return;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
var DEFAULT_DEPENDENCIES = { materializeProfileScene };
|
|
220
|
+
var PROFILE_EDGE_COLOR_SCHEME_RD_BU = (value) => interpolateRdBu(1 - value);
|
|
221
|
+
var PROFILE_EDGE_COLOR_SCHEME_RD_PU = interpolateRdPu;
|
|
222
|
+
var PROFILE_COST_COLOR_SCHEME_OR_RD = interpolateOrRd;
|
|
223
|
+
function contrastingTextColor(background) {
|
|
224
|
+
const rgb = color(background)?.rgb();
|
|
225
|
+
if (rgb == null) return "#000000";
|
|
226
|
+
const linear = [
|
|
227
|
+
rgb.r,
|
|
228
|
+
rgb.g,
|
|
229
|
+
rgb.b
|
|
230
|
+
].map((channel) => {
|
|
231
|
+
const value = channel / 255;
|
|
232
|
+
return value <= .04045 ? value / 12.92 : Math.pow((value + .055) / 1.055, 2.4);
|
|
233
|
+
});
|
|
234
|
+
return .2126 * linear[0] + .7152 * linear[1] + .0722 * linear[2] > .179 ? "#000000" : "#ffffff";
|
|
235
|
+
}
|
|
236
|
+
function formatRelativeDifference(difference) {
|
|
237
|
+
const percentage = Math.round(difference * 100);
|
|
238
|
+
if (percentage > 200) return ">200%";
|
|
239
|
+
if (percentage < -200) return "<-200%";
|
|
240
|
+
return `${percentage > 0 ? "+" : ""}${percentage}%`;
|
|
241
|
+
}
|
|
242
|
+
function formatEstimateSymbol(difference, absoluteDifference = Number.POSITIVE_INFINITY) {
|
|
243
|
+
if (difference === 0) return "=";
|
|
244
|
+
if (absoluteDifference <= ESTIMATE_APPROXIMATE_ROW_THRESHOLD) return "~";
|
|
245
|
+
if (difference <= -.5) return ">>";
|
|
246
|
+
if (difference <= -.1) return ">";
|
|
247
|
+
if (difference < 0) return "~";
|
|
248
|
+
if (difference < .1) return "~";
|
|
249
|
+
if (difference < .5) return "<";
|
|
250
|
+
return "<<";
|
|
251
|
+
}
|
|
252
|
+
function formatCpuShare(share) {
|
|
253
|
+
if (share === 0) return "0%";
|
|
254
|
+
if (share < .01) return "<1%";
|
|
255
|
+
return `${Math.round(share * 100)}%`;
|
|
256
|
+
}
|
|
257
|
+
function formatShortBytes(bytes) {
|
|
258
|
+
if (bytes < 1e3) return `${Math.round(bytes)}B`;
|
|
259
|
+
const units = [
|
|
260
|
+
"K",
|
|
261
|
+
"M",
|
|
262
|
+
"G",
|
|
263
|
+
"T",
|
|
264
|
+
"P"
|
|
265
|
+
];
|
|
266
|
+
let value = bytes / 1e3;
|
|
267
|
+
let unit = 0;
|
|
268
|
+
while (Number(value.toPrecision(2)) >= 1e3 && unit < units.length - 1) {
|
|
269
|
+
value /= 1e3;
|
|
270
|
+
unit += 1;
|
|
271
|
+
}
|
|
272
|
+
return `${Number(value.toPrecision(2))}${units[unit]}`;
|
|
273
|
+
}
|
|
274
|
+
var ROW_COUNT_FORMAT = new Intl.NumberFormat("en-US");
|
|
275
|
+
function formatRowCount(value) {
|
|
276
|
+
return ROW_COUNT_FORMAT.format(value);
|
|
277
|
+
}
|
|
278
|
+
function placeOperatorAnnotation(operator, input) {
|
|
279
|
+
return {
|
|
280
|
+
x: operator.rect.x - operator.rect.width / 2 + input.nodePaddingLeft,
|
|
281
|
+
y: operator.rect.y
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showProgress = false, controllerRef, autoFocus = false, fill = false, edgeRendering, onRotate, dependencies = DEFAULT_DEPENDENCIES }) {
|
|
285
|
+
const scene = React.useMemo(() => dependencies.materializeProfileScene(plan), [dependencies, plan]);
|
|
286
|
+
const ownController = React.useRef(null);
|
|
287
|
+
ownController.current ??= new ProfileExecutionController();
|
|
288
|
+
const controller = controllerRef?.current ?? ownController.current;
|
|
289
|
+
const viewportRef = React.useRef(null);
|
|
290
|
+
const svgRef = React.useRef(null);
|
|
291
|
+
const sceneRef = React.useRef(null);
|
|
292
|
+
const zoomRef = React.useRef(null);
|
|
293
|
+
const transformRef = React.useRef(zoomIdentity);
|
|
294
|
+
const [selection, setSelection] = React.useState(null);
|
|
295
|
+
const [inspectorOpen, setInspectorOpen] = React.useState(false);
|
|
296
|
+
const [selectedAnnotationMode, setAnnotationMode] = React.useState(null);
|
|
297
|
+
const [fragmentColors, setFragmentColors] = React.useState(false);
|
|
298
|
+
const operatorRefs = React.useRef(/* @__PURE__ */ new Map());
|
|
299
|
+
const [positionRevision, setPositionRevision] = React.useState(0);
|
|
300
|
+
const edgeColorScheme = edgeRendering?.colorScheme ?? PROFILE_EDGE_COLOR_SCHEME_RD_BU;
|
|
301
|
+
const rowColorScheme = edgeRendering?.rowColorScheme ?? PROFILE_EDGE_COLOR_SCHEME_RD_PU;
|
|
302
|
+
const costColorScheme = edgeRendering?.costColorScheme ?? PROFILE_COST_COLOR_SCHEME_OR_RD;
|
|
303
|
+
const edgeDifferenceColor = React.useCallback((difference) => edgeColorScheme(difference < 0 ? Math.max(0, (difference + 1) / 2) : Math.min(1, .5 + difference / 4)), [edgeColorScheme]);
|
|
304
|
+
const estimateLegendGradient = React.useMemo(() => Array.from({ length: 11 }, (_, index) => edgeColorScheme(1 - index / 10)).join(", "), [edgeColorScheme]);
|
|
305
|
+
const rowLegendGradient = React.useMemo(() => Array.from({ length: 11 }, (_, index) => rowColorScheme(index / 10)).join(", "), [rowColorScheme]);
|
|
306
|
+
const costLegendGradient = React.useMemo(() => Array.from({ length: 11 }, (_, index) => costColorScheme(index / 10)).join(", "), [costColorScheme]);
|
|
307
|
+
const actualRows = React.useMemo(() => scene.edges.map((edge) => {
|
|
308
|
+
const rows = execution.edgeRows(edge.slot, edge.childOperator);
|
|
309
|
+
return rows == null ? null : Number(rows);
|
|
310
|
+
}), [scene, execution]);
|
|
311
|
+
const annotationModes = React.useMemo(() => {
|
|
312
|
+
const field = dashql.buffers.profile.ProfileStatsField;
|
|
313
|
+
const hasActual = actualRows.some((rows) => rows != null);
|
|
314
|
+
const hasEstimate = scene.edges.some((edge) => edge.outputCardinalityEstimated != null);
|
|
315
|
+
const hasBoth = scene.edges.some((edge, index) => edge.outputCardinalityEstimated != null && actualRows[index] != null);
|
|
316
|
+
const reports = (stat) => scene.operators.some((operator) => {
|
|
317
|
+
const state = execution.operators[operator.id];
|
|
318
|
+
return state != null && isStatReported(state.stats, stat);
|
|
319
|
+
});
|
|
320
|
+
const available = {
|
|
321
|
+
status: showProgress,
|
|
322
|
+
plain: true,
|
|
323
|
+
rows: hasActual,
|
|
324
|
+
estimates: hasEstimate,
|
|
325
|
+
accuracy: hasBoth,
|
|
326
|
+
cpu: reports(field.CPU_TIME),
|
|
327
|
+
memory: reports(field.MEMORY_BYTES)
|
|
328
|
+
};
|
|
329
|
+
return PROFILE_ANNOTATION_MODES.filter(({ mode }) => available[mode]);
|
|
330
|
+
}, [
|
|
331
|
+
scene,
|
|
332
|
+
execution,
|
|
333
|
+
actualRows,
|
|
334
|
+
showProgress
|
|
335
|
+
]);
|
|
336
|
+
const offered = (mode) => annotationModes.some((m) => m.mode === mode);
|
|
337
|
+
const annotationMode = selectedAnnotationMode != null && offered(selectedAnnotationMode) ? selectedAnnotationMode : [
|
|
338
|
+
"status",
|
|
339
|
+
"rows",
|
|
340
|
+
"estimates"
|
|
341
|
+
].find(offered) ?? "plain";
|
|
342
|
+
const annotations = React.useMemo(() => {
|
|
343
|
+
const field = dashql.buffers.profile.ProfileStatsField;
|
|
344
|
+
const badge = (operator, text, background, description, border = null) => ({
|
|
345
|
+
...placeOperatorAnnotation(operator, scene.layoutConfig.input),
|
|
346
|
+
width: Math.min(PROFILE_OPERATOR_ANNOTATION_WIDTH, Math.max(OPERATOR_ANNOTATION_MIN_WIDTH, text.length * OPERATOR_ANNOTATION_CHAR_WIDTH + OPERATOR_ANNOTATION_PADDING)),
|
|
347
|
+
text,
|
|
348
|
+
background,
|
|
349
|
+
foreground: contrastingTextColor(background),
|
|
350
|
+
border,
|
|
351
|
+
description
|
|
352
|
+
});
|
|
353
|
+
switch (annotationMode) {
|
|
354
|
+
case "rows":
|
|
355
|
+
case "estimates":
|
|
356
|
+
case "accuracy": break;
|
|
357
|
+
case "cpu": {
|
|
358
|
+
const cpu = scene.operators.map((operator) => stat(execution.operators[operator.id], field.CPU_TIME, (s) => s.cpuTimeUs));
|
|
359
|
+
const total = cpu.reduce((sum, value) => sum + (value ?? 0), 0);
|
|
360
|
+
const max = cpu.reduce((maximum, value) => Math.max(maximum, value ?? 0), 0);
|
|
361
|
+
return scene.operators.flatMap((operator, index) => {
|
|
362
|
+
const value = cpu[index];
|
|
363
|
+
if (value == null) return [];
|
|
364
|
+
const share = total === 0 ? 0 : value / total;
|
|
365
|
+
return [{
|
|
366
|
+
operator: operator.id,
|
|
367
|
+
edge: null,
|
|
368
|
+
badge: badge(operator, formatCpuShare(share), costColorScheme(max === 0 ? 0 : value / max), `CPU ${formatElapsed(value / 1e3)}, ${formatCpuShare(share)} of the CPU time of all operators`)
|
|
369
|
+
}];
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
case "memory": {
|
|
373
|
+
const memory = scene.operators.map((operator) => stat(execution.operators[operator.id], field.MEMORY_BYTES, (s) => s.memoryBytes));
|
|
374
|
+
const max = memory.reduce((maximum, value) => Math.max(maximum, value ?? 0), 0);
|
|
375
|
+
return scene.operators.flatMap((operator, index) => {
|
|
376
|
+
const value = memory[index];
|
|
377
|
+
if (value == null) return [];
|
|
378
|
+
const spilledBytes = stat(execution.operators[operator.id], field.SPILLED_BYTES, (s) => s.spilledBytes) ?? 0;
|
|
379
|
+
return [{
|
|
380
|
+
operator: operator.id,
|
|
381
|
+
edge: null,
|
|
382
|
+
badge: badge(operator, formatShortBytes(value), costColorScheme(max === 0 ? 0 : value / max), `Memory ${formatCompactBytes(value)}${spilledBytes > 0 ? `, spilled ${formatCompactBytes(spilledBytes)} to disk` : ""}`, spilledBytes > 0 ? SPILLED_BADGE_BORDER : null)
|
|
383
|
+
}];
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
default: return [];
|
|
387
|
+
}
|
|
388
|
+
const maxRowValue = scene.edges.reduce((maximum, edge, edgeIndex) => Math.max(maximum, actualRows[edgeIndex] ?? 0, edge.outputCardinalityEstimated ?? 0), 0);
|
|
389
|
+
const rowScale = (rows) => maxRowValue === 0 ? 0 : Math.log1p(rows) / Math.log1p(maxRowValue);
|
|
390
|
+
return scene.edges.flatMap((edge, edgeIndex) => {
|
|
391
|
+
const child = scene.operators[edge.childOperator];
|
|
392
|
+
if (child == null || scene.operators[edge.parentOperator] == null) return [];
|
|
393
|
+
const actual = actualRows[edgeIndex];
|
|
394
|
+
const estimated = edge.outputCardinalityEstimated;
|
|
395
|
+
let annotation = null;
|
|
396
|
+
if (annotationMode === "rows" && actual != null) annotation = badge(child, formatCompactCount(actual), rowColorScheme(rowScale(actual)), `Actual rows ${formatRowCount(actual)}`);
|
|
397
|
+
else if (annotationMode === "estimates" && estimated != null) annotation = badge(child, formatCompactCount(estimated), rowColorScheme(rowScale(estimated)), `Estimated rows ${formatRowCount(Math.round(estimated))}`);
|
|
398
|
+
else if (annotationMode === "accuracy" && actual != null && estimated != null) {
|
|
399
|
+
const difference = estimateRelativeDifference(estimated, actual);
|
|
400
|
+
annotation = badge(child, formatEstimateSymbol(difference, Math.abs(actual - estimated)), edgeDifferenceColor(difference), `Actual rows ${formatRowCount(actual)}, estimated rows ${formatRowCount(Math.round(estimated))}, difference ${formatRelativeDifference(difference)}`);
|
|
401
|
+
}
|
|
402
|
+
return annotation == null ? [] : [{
|
|
403
|
+
operator: child.id,
|
|
404
|
+
edge,
|
|
405
|
+
badge: annotation
|
|
406
|
+
}];
|
|
407
|
+
});
|
|
408
|
+
}, [
|
|
409
|
+
scene,
|
|
410
|
+
execution,
|
|
411
|
+
actualRows,
|
|
412
|
+
annotationMode,
|
|
413
|
+
rowColorScheme,
|
|
414
|
+
costColorScheme,
|
|
415
|
+
edgeDifferenceColor
|
|
416
|
+
]);
|
|
417
|
+
const spilled = React.useMemo(() => annotationMode === "memory" && annotations.some((annotation) => annotation.badge.border != null), [annotationMode, annotations]);
|
|
418
|
+
const annotationWidths = React.useMemo(() => {
|
|
419
|
+
const widths = /* @__PURE__ */ new Map();
|
|
420
|
+
for (const annotation of annotations) widths.set(annotation.operator, annotation.badge.width);
|
|
421
|
+
return widths;
|
|
422
|
+
}, [annotations]);
|
|
423
|
+
const highlightedEdges = React.useMemo(() => {
|
|
424
|
+
const operatorId = selection?.operator.id;
|
|
425
|
+
return operatorId == null ? [] : scene.edges.filter((edge) => edge.childOperator === operatorId || edge.parentOperator === operatorId);
|
|
426
|
+
}, [scene.edges, selection?.operator.id]);
|
|
427
|
+
const highlightedEdgeSet = React.useMemo(() => new Set(highlightedEdges), [highlightedEdges]);
|
|
428
|
+
const highlightedCrossEdges = React.useMemo(() => {
|
|
429
|
+
const operatorId = selection?.operator.id;
|
|
430
|
+
return operatorId == null ? [] : scene.crossEdges.filter((edge) => edge.sourceOperator === operatorId || edge.targetOperator === operatorId);
|
|
431
|
+
}, [scene.crossEdges, selection?.operator.id]);
|
|
432
|
+
const highlightedOutputPortOperatorIds = React.useMemo(() => /* @__PURE__ */ new Set([...highlightedEdges.map((edge) => edge.childOperator), ...highlightedCrossEdges.map((edge) => edge.sourceOperator)]), [highlightedCrossEdges, highlightedEdges]);
|
|
433
|
+
const highlightedInputPortOperatorIds = React.useMemo(() => /* @__PURE__ */ new Set([...highlightedEdges.map((edge) => edge.parentOperator), ...highlightedCrossEdges.map((edge) => edge.targetOperator)]), [highlightedCrossEdges, highlightedEdges]);
|
|
434
|
+
const crossEdgeDescriptions = React.useMemo(() => {
|
|
435
|
+
const relationships = /* @__PURE__ */ new Map();
|
|
436
|
+
const add = (operatorId, relationship) => {
|
|
437
|
+
const existing = relationships.get(operatorId);
|
|
438
|
+
if (existing == null) relationships.set(operatorId, [relationship]);
|
|
439
|
+
else existing.push(relationship);
|
|
440
|
+
};
|
|
441
|
+
for (const edge of scene.crossEdges) {
|
|
442
|
+
add(edge.sourceOperator, `provides ${edge.kind} to ${scene.operators[edge.targetOperator]?.label ?? "operator"}`);
|
|
443
|
+
if (edge.targetOperator !== edge.sourceOperator) add(edge.targetOperator, `uses ${edge.kind} from ${scene.operators[edge.sourceOperator]?.label ?? "operator"}`);
|
|
444
|
+
}
|
|
445
|
+
const descriptions = /* @__PURE__ */ new Map();
|
|
446
|
+
for (const [operatorId, operatorRelationships] of relationships) descriptions.set(operatorId, `; ${operatorRelationships.join("; ")}`);
|
|
447
|
+
return descriptions;
|
|
448
|
+
}, [scene.crossEdges, scene.operators]);
|
|
449
|
+
React.useLayoutEffect(() => {
|
|
450
|
+
controller.reset(scene.operators.length, scene.pipelines.length);
|
|
451
|
+
controller.applyState(execution, scene.operators.map((operator) => operator.fragment));
|
|
452
|
+
if (controllerRef != null) controllerRef.current = controller;
|
|
453
|
+
return () => {
|
|
454
|
+
if (controllerRef != null) controllerRef.current = null;
|
|
455
|
+
};
|
|
456
|
+
}, [
|
|
457
|
+
controller,
|
|
458
|
+
controllerRef,
|
|
459
|
+
scene,
|
|
460
|
+
execution
|
|
461
|
+
]);
|
|
462
|
+
React.useLayoutEffect(() => {
|
|
463
|
+
if (autoFocus) viewportRef.current?.focus();
|
|
464
|
+
}, [autoFocus]);
|
|
465
|
+
const fit = React.useCallback((animate = false) => {
|
|
466
|
+
const viewport = viewportRef.current;
|
|
467
|
+
const svg = svgRef.current;
|
|
468
|
+
const behavior = zoomRef.current;
|
|
469
|
+
if (viewport == null || svg == null || behavior == null) return;
|
|
470
|
+
const bounds = measurePlanBounds(sceneRef.current, scene);
|
|
471
|
+
if (bounds.width <= 0 || bounds.height <= 0) return;
|
|
472
|
+
const { x, y, scale } = computeProfileFitTransform(bounds, viewport.clientWidth, viewport.clientHeight);
|
|
473
|
+
behavior.scaleExtent([Math.min(PROFILE_MIN_ZOOM, scale), PROFILE_MAX_ZOOM]);
|
|
474
|
+
const target = zoomIdentity.translate(x, y).scale(scale);
|
|
475
|
+
if (animate) select(svg).transition().duration(160).call(behavior.transform, target);
|
|
476
|
+
else select(svg).call(behavior.transform, target);
|
|
477
|
+
}, [scene]);
|
|
478
|
+
const inspectorVisibleRef = React.useRef(false);
|
|
479
|
+
inspectorVisibleRef.current = selection != null && inspectorOpen;
|
|
480
|
+
const positionRevisionFrame = React.useRef(null);
|
|
481
|
+
const schedulePositionRevision = React.useCallback(() => {
|
|
482
|
+
if (positionRevisionFrame.current != null) return;
|
|
483
|
+
positionRevisionFrame.current = requestAnimationFrame(() => {
|
|
484
|
+
positionRevisionFrame.current = null;
|
|
485
|
+
setPositionRevision((value) => value + 1);
|
|
486
|
+
});
|
|
487
|
+
}, []);
|
|
488
|
+
React.useEffect(() => () => {
|
|
489
|
+
if (positionRevisionFrame.current != null) {
|
|
490
|
+
cancelAnimationFrame(positionRevisionFrame.current);
|
|
491
|
+
positionRevisionFrame.current = null;
|
|
492
|
+
}
|
|
493
|
+
}, []);
|
|
494
|
+
React.useLayoutEffect(() => {
|
|
495
|
+
const svg = svgRef.current;
|
|
496
|
+
const viewport = viewportRef.current;
|
|
497
|
+
if (svg == null || viewport == null) return;
|
|
498
|
+
const behavior = zoom().extent(() => [[0, 0], [viewport.clientWidth, viewport.clientHeight]]).scaleExtent([PROFILE_MIN_ZOOM, PROFILE_MAX_ZOOM]).clickDistance(4).filter((event) => !event.button && !(event.target instanceof Element && event.target.closest("button"))).on("zoom", (event) => {
|
|
499
|
+
transformRef.current = event.transform;
|
|
500
|
+
sceneRef.current?.setAttribute("transform", event.transform.toString());
|
|
501
|
+
if (inspectorVisibleRef.current) schedulePositionRevision();
|
|
502
|
+
});
|
|
503
|
+
zoomRef.current = behavior;
|
|
504
|
+
select(svg).call(behavior).on("dblclick.zoom", null);
|
|
505
|
+
const observer = new ResizeObserver(() => fit());
|
|
506
|
+
observer.observe(viewport);
|
|
507
|
+
fit();
|
|
508
|
+
return () => {
|
|
509
|
+
observer.disconnect();
|
|
510
|
+
select(svg).on(".zoom", null);
|
|
511
|
+
zoomRef.current = null;
|
|
512
|
+
};
|
|
513
|
+
}, [fit, schedulePositionRevision]);
|
|
514
|
+
const zoomBy = React.useCallback((factor) => {
|
|
515
|
+
const svg = svgRef.current;
|
|
516
|
+
const behavior = zoomRef.current;
|
|
517
|
+
if (svg != null && behavior != null) select(svg).transition().duration(120).call(behavior.scaleBy, factor);
|
|
518
|
+
}, []);
|
|
519
|
+
const rotate = React.useMemo(() => onRotate == null ? null : () => {
|
|
520
|
+
setInspectorOpen(false);
|
|
521
|
+
setSelection(null);
|
|
522
|
+
onRotate();
|
|
523
|
+
}, [onRotate]);
|
|
524
|
+
const onKeyDown = React.useCallback((event) => {
|
|
525
|
+
if (event.key === "Escape" && inspectorOpen) {
|
|
526
|
+
setInspectorOpen(false);
|
|
527
|
+
event.preventDefault();
|
|
528
|
+
event.stopPropagation();
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
const targetIsViewport = event.target === viewportRef.current;
|
|
532
|
+
const targetIsOperator = event.target instanceof Element && event.target.matches("[data-plan-operator-id]");
|
|
533
|
+
if (!targetIsViewport && !targetIsOperator) return;
|
|
534
|
+
const direction = event.key === "ArrowLeft" ? "left" : event.key === "ArrowRight" ? "right" : event.key === "ArrowUp" ? "up" : event.key === "ArrowDown" ? "down" : null;
|
|
535
|
+
if (direction != null) {
|
|
536
|
+
const targetOperatorId = targetIsOperator ? Number(event.target.getAttribute("data-plan-operator-id")) : null;
|
|
537
|
+
const current = targetOperatorId == null ? selection?.operator ?? null : scene.operators.find((operator) => operator.id === targetOperatorId) ?? null;
|
|
538
|
+
const next = findProfileOperatorInDirection(scene.operators, scene.edges, current, direction, scene.leftToRight);
|
|
539
|
+
const anchor = next == null ? null : operatorRefs.current.get(next.id) ?? null;
|
|
540
|
+
if (next != null && anchor != null) {
|
|
541
|
+
setSelection({
|
|
542
|
+
operator: next,
|
|
543
|
+
anchor
|
|
544
|
+
});
|
|
545
|
+
setPositionRevision((value) => value + 1);
|
|
546
|
+
anchor.focus();
|
|
547
|
+
}
|
|
548
|
+
} else if (event.key === "+" || event.key === "=") zoomBy(1.25);
|
|
549
|
+
else if (event.key === "-") zoomBy(.8);
|
|
550
|
+
else if (event.key === "f") fit(true);
|
|
551
|
+
else if (event.key === "r" && rotate != null) rotate();
|
|
552
|
+
else return;
|
|
553
|
+
event.preventDefault();
|
|
554
|
+
event.stopPropagation();
|
|
555
|
+
}, [
|
|
556
|
+
fit,
|
|
557
|
+
inspectorOpen,
|
|
558
|
+
rotate,
|
|
559
|
+
scene.operators,
|
|
560
|
+
scene.edges,
|
|
561
|
+
scene.leftToRight,
|
|
562
|
+
selection?.operator,
|
|
563
|
+
zoomBy
|
|
564
|
+
]);
|
|
565
|
+
const selectionRef = React.useRef(selection);
|
|
566
|
+
selectionRef.current = selection;
|
|
567
|
+
const setOperatorAnchor = React.useCallback((operatorId, anchor) => {
|
|
568
|
+
if (anchor == null) operatorRefs.current.delete(operatorId);
|
|
569
|
+
else operatorRefs.current.set(operatorId, anchor);
|
|
570
|
+
}, []);
|
|
571
|
+
const onFocusOperator = React.useCallback((selected, anchor) => {
|
|
572
|
+
setSelection({
|
|
573
|
+
operator: selected,
|
|
574
|
+
anchor
|
|
575
|
+
});
|
|
576
|
+
}, []);
|
|
577
|
+
const onSelectOperator = React.useCallback((selected, anchor, toggle) => {
|
|
578
|
+
const previous = selectionRef.current;
|
|
579
|
+
setSelection({
|
|
580
|
+
operator: selected,
|
|
581
|
+
anchor
|
|
582
|
+
});
|
|
583
|
+
setPositionRevision((value) => value + 1);
|
|
584
|
+
setInspectorOpen((open) => toggle && previous?.operator.id === selected.id ? !open : true);
|
|
585
|
+
}, []);
|
|
586
|
+
const anchorRef = React.useMemo(() => ({ current: selection?.anchor ?? null }), [selection?.anchor]);
|
|
587
|
+
const legend = annotationMode === "rows" || annotationMode === "estimates" ? /* @__PURE__ */ jsx("div", {
|
|
588
|
+
className: edge_legend,
|
|
589
|
+
role: "img",
|
|
590
|
+
"data-testid": "plan-rows-legend",
|
|
591
|
+
"aria-label": "Badge color encodes row count from fewer rows on the left to more rows on the right",
|
|
592
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
593
|
+
className: edge_legend_scale,
|
|
594
|
+
children: [
|
|
595
|
+
/* @__PURE__ */ jsx("span", { children: "Fewer rows" }),
|
|
596
|
+
/* @__PURE__ */ jsx("span", { children: "More rows" }),
|
|
597
|
+
/* @__PURE__ */ jsx("i", {
|
|
598
|
+
"aria-hidden": "true",
|
|
599
|
+
style: { backgroundImage: `linear-gradient(to right, ${rowLegendGradient})` }
|
|
600
|
+
})
|
|
601
|
+
]
|
|
602
|
+
})
|
|
603
|
+
}) : annotationMode === "cpu" || annotationMode === "memory" ? /* @__PURE__ */ jsx("div", {
|
|
604
|
+
className: edge_legend,
|
|
605
|
+
role: "img",
|
|
606
|
+
"data-testid": `plan-${annotationMode}-legend`,
|
|
607
|
+
"aria-label": annotationMode === "cpu" ? "Badges show the share of the CPU time of all operators, the color goes from none on the left to the operator with the most CPU time on the right" : `Badges show the memory of an operator, the color goes from none on the left to the operator with the most memory on the right${spilled ? ", an orange border marks an operator that spilled to disk" : ""}`,
|
|
608
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
609
|
+
className: edge_legend_scale,
|
|
610
|
+
children: [
|
|
611
|
+
/* @__PURE__ */ jsx("span", { children: annotationMode === "cpu" ? "Less CPU" : "Less memory" }),
|
|
612
|
+
/* @__PURE__ */ jsx("span", { children: annotationMode === "cpu" ? "More CPU" : "More memory" }),
|
|
613
|
+
/* @__PURE__ */ jsx("i", {
|
|
614
|
+
"aria-hidden": "true",
|
|
615
|
+
style: { backgroundImage: `linear-gradient(to right, ${costLegendGradient})` }
|
|
616
|
+
}),
|
|
617
|
+
spilled && /* @__PURE__ */ jsx("span", {
|
|
618
|
+
className: "dashql_edge_legend_note_IVlaV2",
|
|
619
|
+
style: { borderColor: SPILLED_BADGE_BORDER },
|
|
620
|
+
children: "Spilled to disk"
|
|
621
|
+
})
|
|
622
|
+
]
|
|
623
|
+
})
|
|
624
|
+
}) : annotationMode === "accuracy" ? /* @__PURE__ */ jsx("div", {
|
|
625
|
+
className: edge_legend,
|
|
626
|
+
role: "img",
|
|
627
|
+
"data-testid": "plan-accuracy-legend",
|
|
628
|
+
"aria-label": "Badge color compares actual rows with estimates: red on the left means underestimated, the center means matched, and blue on the right means overestimated; differences are capped at 200 percent",
|
|
629
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
630
|
+
className: edge_legend_scale,
|
|
631
|
+
children: [
|
|
632
|
+
/* @__PURE__ */ jsx("span", { children: "Underestimated" }),
|
|
633
|
+
/* @__PURE__ */ jsx("span", { children: "Overestimated" }),
|
|
634
|
+
/* @__PURE__ */ jsx("i", {
|
|
635
|
+
"aria-hidden": "true",
|
|
636
|
+
"data-testid": "plan-legend-gradient",
|
|
637
|
+
style: { backgroundImage: `linear-gradient(to right, ${estimateLegendGradient})` }
|
|
638
|
+
}),
|
|
639
|
+
/* @__PURE__ */ jsx("span", {
|
|
640
|
+
className: edge_legend_matched,
|
|
641
|
+
children: "Matched"
|
|
642
|
+
})
|
|
643
|
+
]
|
|
644
|
+
})
|
|
645
|
+
}) : null;
|
|
646
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
647
|
+
ref: viewportRef,
|
|
648
|
+
className: viewport,
|
|
649
|
+
"data-fill": fill || void 0,
|
|
650
|
+
role: "region",
|
|
651
|
+
"aria-label": `Query execution plan with ${scene.operators.length} operators`,
|
|
652
|
+
tabIndex: 0,
|
|
653
|
+
onKeyDown,
|
|
654
|
+
"data-electron-drag-region": "false",
|
|
655
|
+
children: [
|
|
656
|
+
/* @__PURE__ */ jsx("svg", {
|
|
657
|
+
ref: svgRef,
|
|
658
|
+
className: svg,
|
|
659
|
+
onClick: (event) => {
|
|
660
|
+
if (event.target === svgRef.current) {
|
|
661
|
+
setSelection(null);
|
|
662
|
+
setInspectorOpen(false);
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
children: /* @__PURE__ */ jsxs("g", {
|
|
666
|
+
ref: sceneRef,
|
|
667
|
+
children: [
|
|
668
|
+
/* @__PURE__ */ jsx("g", { children: scene.fragments.map((fragment$2, fragmentIndex) => {
|
|
669
|
+
const progress = showProgress ? fragmentProgress(execution, fragment$2.id) : null;
|
|
670
|
+
const metrics = showProgress ? formatFragmentMetrics(execution.fragments[fragment$2.id]) : null;
|
|
671
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
672
|
+
className: fragment_colors,
|
|
673
|
+
"data-color": fragmentColors ? fragmentIndex % 6 : "neutral",
|
|
674
|
+
role: "img",
|
|
675
|
+
"aria-label": `Fragment ${fragment$2.id + 1}${metrics == null ? "" : `, ${metrics.description}`}, containing operators: ${fragment$2.operatorIds.map((operatorId) => scene.operators[operatorId]?.label).filter((label) => label != null).join(", ")}`,
|
|
676
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
677
|
+
className: `${fragment$1} ${fragment}`,
|
|
678
|
+
d: fragment$2.path,
|
|
679
|
+
"data-status": fragmentStatus(execution, fragment$2.id)
|
|
680
|
+
}), progress?.percent != null && /* @__PURE__ */ jsx("path", {
|
|
681
|
+
className: "dashql_fragment_progress_vdNNB-",
|
|
682
|
+
d: fragment$2.path,
|
|
683
|
+
pathLength: 100,
|
|
684
|
+
strokeDasharray: `${progress.percent} 100`,
|
|
685
|
+
"data-testid": "fragment-progress"
|
|
686
|
+
})]
|
|
687
|
+
}, fragment$2.id);
|
|
688
|
+
}) }),
|
|
689
|
+
/* @__PURE__ */ jsx("g", { children: scene.pipelines.map((pipeline$1) => /* @__PURE__ */ jsx("path", {
|
|
690
|
+
ref: (path) => controller.registerPipeline(pipeline$1.id, path),
|
|
691
|
+
className: pipeline,
|
|
692
|
+
d: pipeline$1.path,
|
|
693
|
+
"aria-hidden": "true"
|
|
694
|
+
}, pipeline$1.id)) }),
|
|
695
|
+
/* @__PURE__ */ jsx("g", {
|
|
696
|
+
"aria-hidden": "true",
|
|
697
|
+
children: scene.edges.map((edge$1) => /* @__PURE__ */ jsx("path", {
|
|
698
|
+
className: edge,
|
|
699
|
+
d: edge$1.path,
|
|
700
|
+
style: { strokeWidth: EDGE_WIDTH },
|
|
701
|
+
"data-plan-edge-id": edge$1.id.toString()
|
|
702
|
+
}, edge$1.id.toString()))
|
|
703
|
+
}),
|
|
704
|
+
/* @__PURE__ */ jsx("g", {
|
|
705
|
+
"aria-hidden": "true",
|
|
706
|
+
children: scene.crossEdges.map((edge) => /* @__PURE__ */ jsx("path", {
|
|
707
|
+
className: crossEdge,
|
|
708
|
+
"data-kind": edge.kind,
|
|
709
|
+
d: edge.path
|
|
710
|
+
}, edge.id.toString()))
|
|
711
|
+
}),
|
|
712
|
+
/* @__PURE__ */ jsxs("g", {
|
|
713
|
+
className: edgeHighlightLayer,
|
|
714
|
+
"aria-hidden": "true",
|
|
715
|
+
children: [highlightedEdges.map((edge) => /* @__PURE__ */ jsx("path", {
|
|
716
|
+
className: edgeHighlight,
|
|
717
|
+
d: edge.path,
|
|
718
|
+
style: { strokeWidth: EDGE_WIDTH },
|
|
719
|
+
"data-plan-edge-highlight-id": edge.id.toString()
|
|
720
|
+
}, `edge-${edge.id}`)), highlightedCrossEdges.map((edge) => /* @__PURE__ */ jsx("path", {
|
|
721
|
+
className: crossEdgeHighlight,
|
|
722
|
+
d: edge.path,
|
|
723
|
+
"data-plan-cross-edge-highlight-id": edge.id.toString()
|
|
724
|
+
}, `cross-edge-${edge.id}`))]
|
|
725
|
+
}),
|
|
726
|
+
/* @__PURE__ */ jsx("g", { children: scene.operators.map((operator) => /* @__PURE__ */ jsx(ProfileOperatorNode, {
|
|
727
|
+
operator,
|
|
728
|
+
scene,
|
|
729
|
+
showStatus: showProgress && annotationMode === "status",
|
|
730
|
+
annotationWidth: showProgress && annotationMode === "status" ? STATUS_ICON_SIZE : annotationWidths.get(operator.id) ?? 0,
|
|
731
|
+
progress: showProgress ? operatorProgress(execution, operator.fragment) : null,
|
|
732
|
+
selected: selection?.operator.id === operator.id,
|
|
733
|
+
highlightedOutputPort: highlightedOutputPortOperatorIds.has(operator.id),
|
|
734
|
+
highlightedInputPort: highlightedInputPortOperatorIds.has(operator.id),
|
|
735
|
+
expanded: inspectorOpen && selection?.operator.id === operator.id,
|
|
736
|
+
controller,
|
|
737
|
+
relationshipDescription: crossEdgeDescriptions.get(operator.id) ?? "",
|
|
738
|
+
setAnchor: setOperatorAnchor,
|
|
739
|
+
onFocus: onFocusOperator,
|
|
740
|
+
onSelect: onSelectOperator
|
|
741
|
+
}, operator.id)) }),
|
|
742
|
+
/* @__PURE__ */ jsx("g", {
|
|
743
|
+
className: edgeBadgeLayer,
|
|
744
|
+
children: annotations.map(({ operator, edge, badge }) => {
|
|
745
|
+
const highlighted = edge != null ? highlightedEdgeSet.has(edge) : selection?.operator.id === operator;
|
|
746
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
747
|
+
className: edgeBadge,
|
|
748
|
+
transform: `translate(${badge.x}, ${badge.y})`,
|
|
749
|
+
role: "img",
|
|
750
|
+
"aria-label": badge.description,
|
|
751
|
+
"data-plan-edge-badge-id": edge?.id.toString(),
|
|
752
|
+
"data-plan-operator-badge-id": edge == null ? operator.toString() : void 0,
|
|
753
|
+
"data-spilled": badge.border != null || void 0,
|
|
754
|
+
"data-highlighted": highlighted || void 0,
|
|
755
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
756
|
+
x: 0,
|
|
757
|
+
y: -8,
|
|
758
|
+
width: badge.width,
|
|
759
|
+
height: OPERATOR_ANNOTATION_HEIGHT,
|
|
760
|
+
rx: OPERATOR_ANNOTATION_HEIGHT / 2,
|
|
761
|
+
fill: badge.background,
|
|
762
|
+
strokeWidth: badge.border != null ? 1.5 : void 0,
|
|
763
|
+
style: {
|
|
764
|
+
fill: highlighted ? EDGE_HIGHLIGHT_COLOR : void 0,
|
|
765
|
+
stroke: highlighted ? EDGE_HIGHLIGHT_COLOR : badge.border ?? EDGE_BADGE_BORDER
|
|
766
|
+
}
|
|
767
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
768
|
+
x: badge.width / 2,
|
|
769
|
+
fill: badge.foreground,
|
|
770
|
+
style: highlighted ? { fill: EDGE_HIGHLIGHT_TEXT_COLOR } : void 0,
|
|
771
|
+
children: badge.text
|
|
772
|
+
})]
|
|
773
|
+
}, edge != null ? `edge-${edge.id}` : `operator-${operator}`);
|
|
774
|
+
})
|
|
775
|
+
})
|
|
776
|
+
]
|
|
777
|
+
})
|
|
778
|
+
}),
|
|
779
|
+
/* @__PURE__ */ jsxs("div", {
|
|
780
|
+
className: metric_controls,
|
|
781
|
+
children: [scene.leftToRight && legend, /* @__PURE__ */ jsxs("div", {
|
|
782
|
+
className: view_controls,
|
|
783
|
+
children: [/* @__PURE__ */ jsx(SegmentedControl, {
|
|
784
|
+
"aria-label": "Plan annotations",
|
|
785
|
+
size: SegmentedControlSize.Tiny,
|
|
786
|
+
onChange: (index) => setAnnotationMode(annotationModes[index].mode),
|
|
787
|
+
children: annotationModes.map(({ mode, label }) => /* @__PURE__ */ jsx(SegmentedControl.Button, {
|
|
788
|
+
"data-testid": `plan-annotation-${mode}`,
|
|
789
|
+
selected: annotationMode === mode,
|
|
790
|
+
children: label
|
|
791
|
+
}, mode))
|
|
792
|
+
}), /* @__PURE__ */ jsxs(ButtonGroup, {
|
|
793
|
+
className: view_buttons,
|
|
794
|
+
"aria-label": "Plan view controls",
|
|
795
|
+
children: [rotate != null && /* @__PURE__ */ jsx(IconButton, {
|
|
796
|
+
variant: ButtonVariant.Default,
|
|
797
|
+
size: ButtonSize.Tiny,
|
|
798
|
+
"aria-label": scene.leftToRight ? "Rotate plan to top-down" : "Rotate plan to left-to-right",
|
|
799
|
+
"data-testid": "plan-rotate",
|
|
800
|
+
onClick: rotate,
|
|
801
|
+
children: /* @__PURE__ */ jsx(RotateIcon, { size: 12 })
|
|
802
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
803
|
+
variant: ButtonVariant.Default,
|
|
804
|
+
size: ButtonSize.Tiny,
|
|
805
|
+
"aria-label": "Color the fragments",
|
|
806
|
+
"aria-pressed": fragmentColors,
|
|
807
|
+
"data-testid": "plan-fragment-colors",
|
|
808
|
+
onClick: () => setFragmentColors((value) => !value),
|
|
809
|
+
children: /* @__PURE__ */ jsx(PaintbrushIcon, { size: 12 })
|
|
810
|
+
})]
|
|
811
|
+
})]
|
|
812
|
+
})]
|
|
813
|
+
}),
|
|
814
|
+
!scene.leftToRight && legend,
|
|
815
|
+
/* @__PURE__ */ jsxs(ButtonGroup, {
|
|
816
|
+
className: controls,
|
|
817
|
+
"aria-label": "Plan zoom controls",
|
|
818
|
+
children: [
|
|
819
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
820
|
+
variant: ButtonVariant.Default,
|
|
821
|
+
size: ButtonSize.Small,
|
|
822
|
+
"aria-label": "Zoom in",
|
|
823
|
+
onClick: () => zoomBy(1.25),
|
|
824
|
+
children: /* @__PURE__ */ jsx(ZoomInIcon, { size: 12 })
|
|
825
|
+
}),
|
|
826
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
827
|
+
variant: ButtonVariant.Default,
|
|
828
|
+
size: ButtonSize.Small,
|
|
829
|
+
"aria-label": "Zoom out",
|
|
830
|
+
onClick: () => zoomBy(.8),
|
|
831
|
+
children: /* @__PURE__ */ jsx(ZoomOutIcon, { size: 12 })
|
|
832
|
+
}),
|
|
833
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
834
|
+
variant: ButtonVariant.Default,
|
|
835
|
+
size: ButtonSize.Small,
|
|
836
|
+
"aria-label": "Fit plan",
|
|
837
|
+
onClick: () => fit(true),
|
|
838
|
+
children: /* @__PURE__ */ jsx(FitIcon, { size: 12 })
|
|
839
|
+
})
|
|
840
|
+
]
|
|
841
|
+
}),
|
|
842
|
+
/* @__PURE__ */ jsx(AnchoredOverlay, {
|
|
843
|
+
renderAnchor: null,
|
|
844
|
+
anchorRef,
|
|
845
|
+
open: selection != null && inspectorOpen,
|
|
846
|
+
onClose: () => setInspectorOpen(false),
|
|
847
|
+
side: scene.leftToRight ? AnchorSide.OutsideTop : AnchorSide.OutsideRight,
|
|
848
|
+
align: AnchorAlignment.Center,
|
|
849
|
+
anchorOffset: 8,
|
|
850
|
+
width: OverlaySize.L,
|
|
851
|
+
maxHeight: OverlaySize.L,
|
|
852
|
+
positionRevision,
|
|
853
|
+
children: /* @__PURE__ */ jsxs("section", {
|
|
854
|
+
className: inspector,
|
|
855
|
+
"data-testid": "plan-operator-inspector",
|
|
856
|
+
"aria-label": `${selection?.operator.label ?? "Operator"} properties`,
|
|
857
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
858
|
+
className: inspector_header,
|
|
859
|
+
"data-single-line": selection?.operator.typeName == null || selection.operator.typeName === selection.operator.label,
|
|
860
|
+
children: [/* @__PURE__ */ jsx("strong", { children: selection?.operator.label }), selection?.operator.typeName != null && selection.operator.typeName !== selection.operator.label && /* @__PURE__ */ jsx("span", { children: selection.operator.typeName })]
|
|
861
|
+
}), selection != null && /* @__PURE__ */ jsx(JsonView, {
|
|
862
|
+
className: "dashql_inspector_json_R3jZmm",
|
|
863
|
+
value: selection.operator.properties,
|
|
864
|
+
collapsed: 2,
|
|
865
|
+
shortenTextAfterLength: 100
|
|
866
|
+
})]
|
|
867
|
+
})
|
|
868
|
+
})
|
|
869
|
+
]
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
var ProfileOperatorNode = React.memo(function ProfileOperatorNode(props) {
|
|
873
|
+
const { operator: operator$1, scene, setAnchor: setOperatorAnchor } = props;
|
|
874
|
+
const setAnchor = React.useCallback((anchor) => setOperatorAnchor(operator$1.id, anchor), [setOperatorAnchor, operator$1.id]);
|
|
875
|
+
const x = operator$1.rect.x - operator$1.rect.width / 2;
|
|
876
|
+
const y = operator$1.rect.y - operator$1.rect.height / 2;
|
|
877
|
+
const input = scene.layoutConfig.input;
|
|
878
|
+
const regionStart = input.nodePaddingLeft + (props.annotationWidth > 0 ? props.annotationWidth + input.iconMarginRight : 0);
|
|
879
|
+
const regionEnd = operator$1.rect.width - input.nodePaddingRight;
|
|
880
|
+
const symbolName = shouldRenderProfileOperatorSymbol(operator$1.kind, operator$1.typeName, operator$1.label) ? getProfileOperatorSymbol(operator$1.kind) : null;
|
|
881
|
+
const OperatorSymbol = symbolName != null ? SymbolIcon(symbolName) : null;
|
|
882
|
+
const activate = (event) => {
|
|
883
|
+
if ("key" in event && event.key !== "Enter" && event.key !== " ") return;
|
|
884
|
+
if ("key" in event) event.preventDefault();
|
|
885
|
+
event.stopPropagation();
|
|
886
|
+
props.onSelect(operator$1, event.currentTarget, "key" in event);
|
|
887
|
+
};
|
|
888
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
889
|
+
ref: setAnchor,
|
|
890
|
+
className: operator,
|
|
891
|
+
"data-selected": props.selected,
|
|
892
|
+
"data-highlighted-output-port": props.highlightedOutputPort,
|
|
893
|
+
"data-highlighted-input-port": props.highlightedInputPort,
|
|
894
|
+
"data-plan-operator-id": operator$1.id,
|
|
895
|
+
transform: `translate(${x}, ${y})`,
|
|
896
|
+
role: "button",
|
|
897
|
+
tabIndex: 0,
|
|
898
|
+
"aria-label": `${operator$1.label}${props.relationshipDescription}, show properties`,
|
|
899
|
+
"aria-expanded": props.expanded,
|
|
900
|
+
onClick: activate,
|
|
901
|
+
onFocus: (event) => props.onFocus(operator$1, event.currentTarget),
|
|
902
|
+
onKeyDown: activate,
|
|
903
|
+
children: [
|
|
904
|
+
/* @__PURE__ */ jsx("rect", {
|
|
905
|
+
className: node_frame,
|
|
906
|
+
width: operator$1.rect.width,
|
|
907
|
+
height: operator$1.rect.height,
|
|
908
|
+
rx: 6,
|
|
909
|
+
ry: 6,
|
|
910
|
+
"data-plan-operator-frame": true
|
|
911
|
+
}),
|
|
912
|
+
props.showStatus && /* @__PURE__ */ jsx("g", {
|
|
913
|
+
ref: (slot) => props.controller.registerOperator(operator$1.id, slot),
|
|
914
|
+
className: "dashql_status_0_ceA-",
|
|
915
|
+
transform: `translate(${input.nodePaddingLeft}, ${(input.nodeHeight - STATUS_ICON_SIZE) / 2})`,
|
|
916
|
+
"aria-hidden": "true",
|
|
917
|
+
children: /* @__PURE__ */ jsx("g", {
|
|
918
|
+
transform: `scale(${STATUS_ICON_SIZE / 16})`,
|
|
919
|
+
children: /* @__PURE__ */ jsx(StatusIcons, { progress: props.progress })
|
|
920
|
+
})
|
|
921
|
+
}),
|
|
922
|
+
OperatorSymbol != null ? /* @__PURE__ */ jsx("g", {
|
|
923
|
+
className: operator_symbol,
|
|
924
|
+
transform: `translate(${(regionStart + regionEnd - PROFILE_OPERATOR_SYMBOL_SIZE) / 2}, ${(input.nodeHeight - PROFILE_OPERATOR_SYMBOL_SIZE) / 2})`,
|
|
925
|
+
"aria-hidden": "true",
|
|
926
|
+
children: /* @__PURE__ */ jsx(OperatorSymbol, { size: PROFILE_OPERATOR_SYMBOL_SIZE })
|
|
927
|
+
}) : /* @__PURE__ */ jsx("text", {
|
|
928
|
+
x: (regionStart + regionEnd) / 2,
|
|
929
|
+
y: input.nodeHeight / 2 + 5,
|
|
930
|
+
children: operator$1.displayLabel
|
|
931
|
+
}),
|
|
932
|
+
(operator$1.ports & 1) !== 0 && (scene.leftToRight ? /* @__PURE__ */ jsx(GraphPort, {
|
|
933
|
+
x: 0,
|
|
934
|
+
y: operator$1.rect.height / 2,
|
|
935
|
+
side: "left",
|
|
936
|
+
highlighted: props.highlightedOutputPort,
|
|
937
|
+
"data-plan-port": "output"
|
|
938
|
+
}) : /* @__PURE__ */ jsx(GraphPort, {
|
|
939
|
+
x: operator$1.rect.width / 2,
|
|
940
|
+
y: 0,
|
|
941
|
+
side: "top",
|
|
942
|
+
highlighted: props.highlightedOutputPort,
|
|
943
|
+
"data-plan-port": "output"
|
|
944
|
+
})),
|
|
945
|
+
(operator$1.ports & 2) !== 0 && (scene.leftToRight ? /* @__PURE__ */ jsx(GraphPort, {
|
|
946
|
+
x: operator$1.rect.width,
|
|
947
|
+
y: operator$1.rect.height / 2,
|
|
948
|
+
side: "right",
|
|
949
|
+
highlighted: props.highlightedInputPort,
|
|
950
|
+
"data-plan-port": "input"
|
|
951
|
+
}) : /* @__PURE__ */ jsx(GraphPort, {
|
|
952
|
+
x: operator$1.rect.width / 2,
|
|
953
|
+
y: operator$1.rect.height,
|
|
954
|
+
side: "bottom",
|
|
955
|
+
highlighted: props.highlightedInputPort,
|
|
956
|
+
"data-plan-port": "input"
|
|
957
|
+
}))
|
|
958
|
+
]
|
|
959
|
+
});
|
|
960
|
+
});
|
|
961
|
+
export { PROFILE_COST_COLOR_SCHEME_OR_RD, PROFILE_EDGE_COLOR_SCHEME_RD_BU, PROFILE_EDGE_COLOR_SCHEME_RD_PU, PROFILE_OPERATOR_PORT_INPUT, PROFILE_OPERATOR_PORT_OUTPUT, QueryProfileView, computeProfileFitTransform, createProfileLayoutConfig, formatCpuShare, formatEstimateSymbol, formatFragmentMetrics, formatShortBytes, materializeProfileScene, placeOperatorAnnotation };
|