Skip to content

Commit

Permalink
Remove table v1
Browse files Browse the repository at this point in the history
Change-Id: Ie1d2ac43d161f713f1cb8705ba1a0042cb542421
  • Loading branch information
Alexander Timin committed Aug 15, 2024
1 parent 91aed5b commit 405c843
Show file tree
Hide file tree
Showing 28 changed files with 584 additions and 2,020 deletions.
15 changes: 11 additions & 4 deletions ui/src/common/empty_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
autosaveConfigStore,
recordTargetStore,
} from '../frontend/record_config';
import {SqlTables} from '../frontend/widgets/sql/table/well_known_sql_tables';

import {NonSerializableState, State, STATE_VERSION} from './state';

Expand Down Expand Up @@ -58,19 +57,27 @@ export function createEmptyNonSerializableState(): NonSerializableState {
pivotTable: {
queryResult: null,
selectedPivots: [
{kind: 'regular', table: SqlTables.slice.name, column: 'name'},
{
kind: 'regular',
table: '_slice_with_thread_and_process_info',
column: 'name',
},
],
selectedAggregations: [
{
aggregationFunction: 'SUM',
column: {kind: 'regular', table: SqlTables.slice.name, column: 'dur'},
column: {
kind: 'regular',
table: '_slice_with_thread_and_process_info',
column: 'dur',
},
sortDirection: 'DESC',
},
{
aggregationFunction: 'SUM',
column: {
kind: 'regular',
table: SqlTables.slice.name,
table: '_slice_with_thread_and_process_info',
column: 'thread_dur',
},
},
Expand Down
4 changes: 2 additions & 2 deletions ui/src/core_plugins/chrome_tasks/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {SqlTableDescription} from '../../frontend/widgets/sql/table2/state';
import {SqlTableDescription} from '../../frontend/widgets/sql/table/table_description';
import {
ArgSetColumnSet,
DurationColumn,
SliceIdColumn,
StandardColumn,
TimestampColumn,
} from '../../frontend/widgets/sql/table2/well_known_columns';
} from '../../frontend/widgets/sql/table/well_known_columns';

export const chromeTasksTable: SqlTableDescription = {
imports: ['chrome.tasks'],
Expand Down
2 changes: 1 addition & 1 deletion ui/src/frontend/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {THREAD_STATE_TRACK_KIND} from '../core/track_kinds';
import {DisposableStack} from '../base/disposable_stack';
import {addSqlTableTab} from './sql_table_tab';
import {getThreadInfo} from '../trace_processor/sql_utils/thread';
import {SqlTables} from './widgets/sql/table2/well_known_sql_tables';
import {SqlTables} from './widgets/sql/table/well_known_sql_tables';

function renderPermalink(): m.Children {
const hash = globals.permalinkHash;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/frontend/charts/histogram/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {Engine} from '../../../public';
import {DetailsShell} from '../../../widgets/details_shell';
import {VegaView} from '../../../widgets/vega_view';
import {BottomTab, NewBottomTabArgs} from '../../bottom_tab';
import {Filter, filterTitle} from '../../widgets/sql/table2/column';
import {Filter, filterTitle} from '../../widgets/sql/table/column';

import {HistogramState} from './state';

Expand Down
2 changes: 1 addition & 1 deletion ui/src/frontend/pivot_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {ReorderableCell, ReorderableCellGroup} from './reorderable_cells';
import {AttributeModalHolder} from './tables/attribute_modal_holder';
import {DurationWidget} from './widgets/duration';
import {addSqlTableTab} from './sql_table_tab';
import {SqlTables} from './widgets/sql/table2/well_known_sql_tables';
import {SqlTables} from './widgets/sql/table/well_known_sql_tables';

interface PathItem {
tree: PivotTree;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/frontend/slice_args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {TreeNode} from '../widgets/tree';
import {Arg} from '../trace_processor/sql_utils/args';
import {globals} from './globals';
import {addSqlTableTab} from './sql_table_tab';
import {SqlTables} from './widgets/sql/table2/well_known_sql_tables';
import {SqlTables} from './widgets/sql/table/well_known_sql_tables';

// Renders slice arguments (key/value pairs) as a subtree.
export function renderArguments(engine: Engine, args: Arg[]): m.Children {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/frontend/slice_details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import {addSqlTableTab} from './sql_table_tab';
import {DurationWidget} from './widgets/duration';
import {renderProcessRef} from './widgets/process';
import {SqlTables} from './widgets/sql/table2/well_known_sql_tables';
import {SqlTables} from './widgets/sql/table/well_known_sql_tables';
import {renderThreadRef} from './widgets/thread';
import {Timestamp} from './widgets/timestamp';

Expand Down
7 changes: 4 additions & 3 deletions ui/src/frontend/sql_table_tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import {Popup, PopupPosition} from '../widgets/popup';
import {BottomTab, NewBottomTabArgs} from './bottom_tab';
import {AddDebugTrackMenu} from './debug_tracks/add_debug_track_menu';
import {getEngine} from './get_engine';
import {Filter} from './widgets/sql/table2/column';
import {SqlTableDescription, SqlTableState} from './widgets/sql/table2/state';
import {SqlTable} from './widgets/sql/table2/table';
import {Filter} from './widgets/sql/table/column';
import {SqlTableState} from './widgets/sql/table/state';
import {SqlTable} from './widgets/sql/table/table';
import {SqlTableDescription} from './widgets/sql/table/table_description';

interface SqlTableTabConfig {
table: SqlTableDescription;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/frontend/thread_slice_details_tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {DurationWidget} from './widgets/duration';
import {addSqlTableTab} from './sql_table_tab';
import {SliceRef} from './widgets/slice';
import {BasicTable} from '../widgets/basic_table';
import {SqlTables} from './widgets/sql/table2/well_known_sql_tables';
import {SqlTables} from './widgets/sql/table/well_known_sql_tables';

interface ContextMenuItem {
name: string;
Expand Down
71 changes: 26 additions & 45 deletions ui/src/frontend/widgets/sql/table/argument_selector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 The Android Open Source Project
// Copyright (C) 2024 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,73 +15,54 @@
import m from 'mithril';

import {raf} from '../../../../core/raf_scheduler';
import {Engine} from '../../../../trace_processor/engine';
import {STR} from '../../../../trace_processor/query_result';
import {
constraintsToQueryPrefix,
constraintsToQuerySuffix,
SQLConstraints,
} from '../../../../trace_processor/sql_utils';
import {FilterableSelect} from '../../../../widgets/select';
import {Spinner} from '../../../../widgets/spinner';

import {argColumn} from './column';
import {ArgSetIdColumn} from './table_description';
import {
TableColumn,
tableColumnId,
TableColumnSet,
TableManager,
} from './column';

const MAX_ARGS_TO_DISPLAY = 15;

interface ArgumentSelectorAttrs {
engine: Engine;
argSetId: ArgSetIdColumn;
tableName: string;
constraints: SQLConstraints;
// List of aliases for existing columns by the table.
alreadySelectedColumns: Set<string>;
onArgumentSelected: (argument: string) => void;
tableManager: TableManager;
columnSet: TableColumnSet;
alreadySelectedColumnIds: Set<string>;
onArgumentSelected: (column: TableColumn) => void;
}

// A widget which allows the user to select a new argument to display.
// Dinamically queries Trace Processor to find the relevant set of arg_set_ids
// and which args are present in these arg sets.
// This class is responsible for rendering a menu which allows user to select which column out of ColumnSet to add.
export class ArgumentSelector
implements m.ClassComponent<ArgumentSelectorAttrs>
{
argList?: string[];
columns?: {[key: string]: TableColumn};

constructor({attrs}: m.Vnode<ArgumentSelectorAttrs>) {
this.load(attrs);
}

private async load(attrs: ArgumentSelectorAttrs) {
const queryResult = await attrs.engine.query(`
-- Encapsulate the query in a CTE to avoid clashes between filters
-- and columns of the 'args' table.
WITH arg_sets AS (
${constraintsToQueryPrefix(attrs.constraints)}
SELECT DISTINCT ${attrs.tableName}.${attrs.argSetId.name} as arg_set_id
FROM ${attrs.tableName}
${constraintsToQuerySuffix(attrs.constraints)}
)
SELECT
DISTINCT args.key as key
FROM arg_sets
JOIN args USING (arg_set_id)
`);
this.argList = [];
const it = queryResult.iter({key: STR});
for (; it.valid(); it.next()) {
const arg = argColumn(attrs.tableName, attrs.argSetId, it.key);
if (attrs.alreadySelectedColumns.has(arg.alias)) continue;
this.argList.push(it.key);
}
const potentialColumns = await attrs.columnSet.discover(attrs.tableManager);
this.columns = Object.fromEntries(
potentialColumns
.filter(
({column}) =>
!attrs.alreadySelectedColumnIds.has(tableColumnId(column)),
)
.map(({key, column}) => [key, column]),
);
raf.scheduleFullRedraw();
}

view({attrs}: m.Vnode<ArgumentSelectorAttrs>) {
if (this.argList === undefined) return m(Spinner);
const columns = this.columns;
if (columns === undefined) return m(Spinner);
return m(FilterableSelect, {
values: this.argList,
onSelected: (value: string) => attrs.onArgumentSelected(value),
values: Object.keys(columns),
onSelected: (value: string) => attrs.onArgumentSelected(columns[value]),
maxDisplayedItems: MAX_ARGS_TO_DISPLAY,
autofocusInput: true,
});
Expand Down
Loading

0 comments on commit 405c843

Please sign in to comment.