override parseData()

in frontend/app/components/chart/default_data_provider.ts [104:152]


  override parseData(data: SimpleDataTable) {
    const rowWithReplicaGroups: DataTableRow[] = [];

    if (!data || !data.cols || !data.rows) return;

    // Set the column index member variables.
    for (let i = 0; i < data.cols.length; i++) {
      if (data.cols[i].id === 'category') this.opCategoryIndex = i;
      if (data.cols[i].id === 'operation') this.hloOpNameIndex = i;
      if (data.cols[i].id === 'total_self_time') this.selfTimeIndex = i;
    }

    if (this.opCategoryIndex === undefined ||
        this.hloOpNameIndex === undefined || this.selfTimeIndex === undefined) {
      return;
    }

    // Filter through rows whose hloOpName string has the field
    // 'replica_groups'. Set the value for the hloOpName to only be the
    // 'replica_groups={{...}}' string. This allows computing metrics grouped by
    // replica groups.
    for (const row of data.rows) {
      if (row?.c) {
        const hloOpName = row.c[this.hloOpNameIndex].v;

        if (typeof hloOpName !== 'string') return;

        const hasReplicaGroup =
            hloOpName.match(/replica_groups={({(\d,?)+},?)*}/);

        if (hasReplicaGroup !== null) {
          const newRow = {c: [...row.c]};
          newRow.c[this.hloOpNameIndex] = {v: hasReplicaGroup[0]};
          rowWithReplicaGroups.push(newRow);
        }
      }
    }

    // Create a set of the categories of communication HLO ops.
    this.communicationOps.clear();
    for (const row of rowWithReplicaGroups) {
      if (row?.c) {
        this.communicationOps.add(row.c[this.opCategoryIndex].v);
      }
    }

    this.dataTable = new google.visualization.DataTable(
        {cols: data.cols, rows: rowWithReplicaGroups, p: data.p});
  }