/** * PAVI resources内存数据库 * @author guxiang * 整个页面共享一个内存数据库,原始resources对象统一存储在Map里面,用iter做tag,相同的iter传多个直接忽略不计。meta对象应该包含的是{ iter: number, time: number } * 最后的查询顺序是 resourceType (scalar, feature, histogram, heatmap) -> taskID -> tag -> iter -> value。 * TODO: option使用immutable.js进行优化,尽可能减轻数据处理的代价 * * 最终页面上需要用到的有3种x轴,其中iter应该使用value,time和relativeTime应该使用time类型 */ import { smoothData } from './delayFilterSmooth'; import echarts from 'echarts'; import { TrainingInfoSchema } from '../types'; import ScalarStore from '../stores/ScalarStore'; export type DBValue = { value: number; time: number; iter: number; }; export type XAxisType = 'relative' | 'time' | 'iter'; export type SeriesData = [number, number, DBValue, TrainingInfoSchema, string]; export interface WSResponse { Type: string; Timestamp: number; Content: T; } export interface TagSchema { dataKey: string; color?: string; title: string; multiplier?: number; } export type ScalarDBOnChangeFunc = (event: { type: 'init' | 'append'; taskID: string; tag: string; values: DBValue[]; }) => void; export declare const getSeriesID: (taskID: string, tag: string) => string; /** * 针对PAVI四种相似类型的数据设计的一个资源数据库 * echarts dataset 的 source 我们使用k-v式的声明,{ y1: v1, y2: v2, ... } */ export declare class ScalarDB { /** * 一类资源的所有数据都存储在这里,退出页面销毁 * 最终的结果里存一下iter,虽然是冗余的 */ private _dataMap; /** * 不同task的的开始时间,用于计算relativeTime */ private _startTime; get startTime(): { [taskID: string]: { [tag: string]: number; }; }; private _endTime; get endTime(): { [taskID: string]: { [tag: string]: number; }; }; private _startIter; get startIter(): { [taskID: string]: { [tag: string]: number; }; }; private _endIter; get endIter(): { [taskID: string]: { [tag: string]: number; }; }; /** * 最小值的指针集合 */ private _min; get min(): { [taskID: string]: { [tag: string]: DBValue; }; }; /** * 最大值的指针集合 */ private _max; get max(): { [taskID: string]: { [tag: string]: DBValue; }; }; getYAxis(isMetric: any): echarts.EChartOption.YAxis; getXAxis(xAxis: XAxisType, oneIter: boolean, isMetric: any): echarts.EChartOption.XAxis; getSeries(tasks: { id: string; name: string; }[], tags: TagSchema[], xAxis: XAxisType, smoothWeight: number, dataZoom: Parameters[2], scalarStore: typeof ScalarStore, isMetric: boolean): echarts.EChartOption.SeriesLine[]; getDataRange(tasks: { id: string; name: string; }[], tags: string[], xAxis: XAxisType): { x: { startValue: number; endValue: number; }; y: { startValue: number; endValue: number; }; }; /** * Event Handler 用于告知外部数据发生了变化 */ private _onChange; /** * 一次性向数据库里更新数据,重复就替换 * @param taskID * @param tag * @param data */ updateData(taskID: string, tag: string, payload: DBValue[]): void; /** * 向数据库里增加数据 * @param taskID * @param tag * @param data */ appendData(taskID: string, tag: string, payload: DBValue): void; /** * 获取当前dataset的所有tags信息 */ get tags(): unknown[]; /** * 根据x轴的值和x轴类型返回一个slice的summary信息,用于tooltip表格的展示 * @param axisValue * @param axisType */ static Summary(scalardb: ScalarDB, series: echarts.EChartOption.SeriesLine[], axisValue: number, scalarStore: typeof ScalarStore): { key: string; color: string; name: string; iter: number; time: string; relative: string; value: number; min: string; max: string; }[]; } /** * scalardb全局单例 */