Skip to content

Commit

Permalink
fix: rename DataStorage -> dataStore and some other renames.
Browse files Browse the repository at this point in the history
  • Loading branch information
100pah committed Aug 21, 2021
1 parent dd48619 commit f26ccae
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 104 deletions.
4 changes: 2 additions & 2 deletions src/chart/candlestick/candlestickLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { DimensionIndex, StageHandler, StageHandlerProgressParams } from '../../
import CandlestickSeriesModel from './CandlestickSeries';
import SeriesData from '../../data/SeriesData';
import { RectLike } from 'zrender/src/core/BoundingRect';
import DataStorage from '../../data/DataStorage';
import DataStore from '../../data/DataStore';

const LargeArr = typeof Float32Array !== 'undefined' ? Float32Array : Array;

Expand Down Expand Up @@ -206,7 +206,7 @@ const candlestickLayout: StageHandler = {
};

function getSign(
storage: DataStorage, dataIndex: number, openVal: number, closeVal: number, closeDimI: DimensionIndex
storage: DataStore, dataIndex: number, openVal: number, closeVal: number, closeDimI: DimensionIndex
): -1 | 1 {
let sign: -1 | 1;
if (openVal > closeVal) {
Expand Down
4 changes: 2 additions & 2 deletions src/chart/helper/createGraphFromNodeEdge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ export default function createGraphFromNodeEdge(
coordDimensions.concat(['value']);
}

const { dimList } = prepareSeriesDataSchema(nodes, {
const { dimensions } = prepareSeriesDataSchema(nodes, {
coordDimensions: coordDimensions,
encodeDefine: seriesModel.getEncode()
});
nodeData = new SeriesData(dimList, seriesModel);
nodeData = new SeriesData(dimensions, seriesModel);
nodeData.initData(nodes);
}

Expand Down
8 changes: 4 additions & 4 deletions src/chart/helper/createSeriesData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
EncodeDefaulter
} from '../../util/types';
import SeriesModel from '../../model/Series';
import DataStorage from '../../data/DataStorage';
import DataStore from '../../data/DataStore';
import SeriesDimensionDefine from '../../data/SeriesDimensionDefine';

function getCoordSysDimDefs(
Expand Down Expand Up @@ -148,10 +148,10 @@ function createSeriesData(
};
const schema = prepareSeriesDataSchema(source, createDimensionOptions);
const firstCategoryDimIndex = injectOrdinalMeta(
schema.dimList, opt.createInvertedIndices, coordSysInfo
schema.dimensions, opt.createInvertedIndices, coordSysInfo
);

const storage = !isOriginalSource ? sourceManager.getSharedDataStorage(schema) : null;
const storage = !isOriginalSource ? sourceManager.getSharedDataStore(schema) : null;

const stackCalculationInfo = enableDataStack(seriesModel, { schema, storage });

Expand All @@ -161,7 +161,7 @@ function createSeriesData(
const dimValueGetter =
firstCategoryDimIndex != null
&& isNeedCompleteOrdinalData(source)
? function (this: DataStorage, itemOpt: any, dimName: string, dataIndex: number, dimIndex: number) {
? function (this: DataStore, itemOpt: any, dimName: string, dataIndex: number, dimIndex: number) {
// Use dataIndex as ordinal value in categoryAxis
return dimIndex === firstCategoryDimIndex
? dataIndex
Expand Down
8 changes: 4 additions & 4 deletions src/chart/helper/createSeriesDataSimply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import prepareSeriesDataSchema, {CreateDimensionsParams} from '../../data/helper/createDimensions';
import prepareSeriesDataSchema, {PrepareSeriesDataSchemaParams} from '../../data/helper/createDimensions';
import SeriesData from '../../data/SeriesData';
import {extend, isArray} from 'zrender/src/core/util';
import SeriesModel from '../../model/Series';
Expand All @@ -34,7 +34,7 @@ import SeriesModel from '../../model/Series';
*/
export default function createSeriesDataSimply(
seriesModel: SeriesModel,
opt: CreateDimensionsParams | CreateDimensionsParams['coordDimensions'],
opt: PrepareSeriesDataSchemaParams | PrepareSeriesDataSchemaParams['coordDimensions'],
nameList?: string[]
): SeriesData {
opt = isArray(opt) && {
Expand All @@ -45,9 +45,9 @@ export default function createSeriesDataSimply(

const source = seriesModel.getSource();

const { dimList } = prepareSeriesDataSchema(source, opt as CreateDimensionsParams);
const { dimensions } = prepareSeriesDataSchema(source, opt as PrepareSeriesDataSchemaParams);

const list = new SeriesData(dimList, seriesModel);
const list = new SeriesData(dimensions, seriesModel);
list.initData(source, nameList);

return list;
Expand Down
4 changes: 2 additions & 2 deletions src/chart/themeRiver/ThemeRiverSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class ThemeRiverSeriesModel extends SeriesModel<ThemeRiverSeriesOption> {
}
}

const { dimList } = prepareSeriesDataSchema(data, {
const { dimensions } = prepareSeriesDataSchema(data, {
coordDimensions: ['single'],
dimensionsDefine: [
{
Expand All @@ -200,7 +200,7 @@ class ThemeRiverSeriesModel extends SeriesModel<ThemeRiverSeriesOption> {
}
});

const list = new SeriesData(dimList, this);
const list = new SeriesData(dimensions, this);
list.initData(data);

return list;
Expand Down
52 changes: 26 additions & 26 deletions src/data/DataStorage.ts → src/data/DataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const dataCtors = {
'time': CtorFloat64Array
} as const;

export type DataStorageDimensionType = keyof typeof dataCtors;
export type DataStoreDimensionType = keyof typeof dataCtors;

type DataTypedArray = Uint32Array | Int32Array | Uint16Array | Float64Array;
type DataTypedArrayConstructor = typeof Uint32Array | typeof Int32Array | typeof Uint16Array | typeof Float64Array;
Expand All @@ -72,18 +72,18 @@ type FilterCb = (...args: any) => boolean;
type MapCb = (...args: any) => ParsedValue | ParsedValue[];

export type DimValueGetter = (
this: DataStorage,
this: DataStore,
dataItem: any,
property: string,
dataIndex: number,
dimIndex: DimensionIndex
) => ParsedValue;

export interface DataStorageDimensionDefine {
export interface DataStoreDimensionDefine {
/**
* Default to be float.
*/
type?: DataStorageDimensionType;
type?: DataStoreDimensionType;

/**
* Only used in SOURCE_FORMAT_OBJECT_ROWS and SOURCE_FORMAT_KEYED_COLUMNS to retrieve value
Expand Down Expand Up @@ -129,7 +129,7 @@ function cloneChunk(originalChunk: DataValueChunk): DataValueChunk {
function prepareStorage(
storage: DataValueChunk[],
dimIdx: number,
dimType: DataStorageDimensionType,
dimType: DataStoreDimensionType,
end: number,
append?: boolean
): void {
Expand All @@ -154,9 +154,9 @@ function prepareStorage(
};

/**
* Basically, DataStorage API keep immutable.
* Basically, DataStore API keep immutable.
*/
class DataStorage {
class DataStore {
private _chunks: DataValueChunk[] = [];

private _provider: DataProvider;
Expand All @@ -173,7 +173,7 @@ class DataStorage {
private _count: number = 0;
private _rawCount: number = 0;

private _dimensions: DataStorageDimensionDefine[];
private _dimensions: DataStoreDimensionDefine[];
private _dimValueGetter: DimValueGetter;

private _calcDimNameToIdx = createHashMap<DimensionIndex, DimensionName>();
Expand All @@ -185,7 +185,7 @@ class DataStorage {
*/
initData(
provider: DataProvider,
inputDimensions: DataStorageDimensionDefine[],
inputDimensions: DataStoreDimensionDefine[],
dimValueGetter?: DimValueGetter
): void {
if (__DEV__) {
Expand Down Expand Up @@ -236,7 +236,7 @@ class DataStorage {
/**
* @caution Only used in dataStack.
*/
ensureCalculationDimension(dimName: DimensionName, type: DataStorageDimensionType): DimensionIndex {
ensureCalculationDimension(dimName: DimensionName, type: DataStoreDimensionType): DimensionIndex {
const calcDimNameToIdx = this._calcDimNameToIdx;
const dimensions = this._dimensions;

Expand Down Expand Up @@ -296,7 +296,7 @@ class DataStorage {
return ordinalMeta;
}

getDimensionProperty(dimIndex: DimensionIndex): DataStorageDimensionDefine['property'] {
getDimensionProperty(dimIndex: DimensionIndex): DataStoreDimensionDefine['property'] {
const item = this._dimensions[dimIndex];
return item && item.property;
}
Expand Down Expand Up @@ -648,7 +648,7 @@ class DataStorage {
filter(
dims: DimensionIndex[],
cb: FilterCb
): DataStorage {
): DataStore {
if (!this._count) {
return this;
}
Expand Down Expand Up @@ -706,7 +706,7 @@ class DataStorage {
* Select data in range. (For optimization of filter)
* (Manually inline code, support 5 million data filtering in data zoom.)
*/
selectRange(range: {[dimIdx: number]: [number, number]}): DataStorage {
selectRange(range: {[dimIdx: number]: [number, number]}): DataStore {
const newStore = this.clone();

const len = newStore._count;
Expand Down Expand Up @@ -836,7 +836,7 @@ class DataStorage {
/**
* Data mapping to a new List with given dimensions
*/
map(dims: DimensionIndex[], cb: MapCb): DataStorage {
map(dims: DimensionIndex[], cb: MapCb): DataStore {
// TODO only clone picked chunks.
const target = this.clone(dims);
this._updateDims(target, dims, cb);
Expand All @@ -851,7 +851,7 @@ class DataStorage {
}

private _updateDims(
target: DataStorage,
target: DataStore,
dims: DimensionIndex[],
cb: MapCb
) {
Expand Down Expand Up @@ -912,7 +912,7 @@ class DataStorage {
lttbDownSample(
valueDimension: DimensionIndex,
rate: number
): DataStorage {
): DataStore {
const target = this.clone([valueDimension], true);
const targetStorage = target._chunks;
const dimStore = targetStorage[valueDimension];
Expand Down Expand Up @@ -999,7 +999,7 @@ class DataStorage {
rate: number,
sampleValue: (frameValues: ArrayLike<ParsedValue>) => ParsedValueNumeric,
sampleIndex: (frameValues: ArrayLike<ParsedValue>, value: ParsedValueNumeric) => number
): DataStorage {
): DataStore {
const target = this.clone([dimension], true);
const targetStorage = target._chunks;

Expand Down Expand Up @@ -1168,8 +1168,8 @@ class DataStorage {
*
* @param clonedDims Determine which dims to clone. Will share the data if not specified.
*/
clone(clonedDims?: DimensionIndex[], ignoreIndices?: boolean): DataStorage {
const target = new DataStorage();
clone(clonedDims?: DimensionIndex[], ignoreIndices?: boolean): DataStore {
const target = new DataStore();
const chunks = this._chunks;
const clonedDimsMap = clonedDims && reduce(clonedDims, (obj, dimIdx) => {
obj[dimIdx] = true;
Expand All @@ -1194,7 +1194,7 @@ class DataStorage {
return target;
}

private _copyCommonProps(target: DataStorage): void {
private _copyCommonProps(target: DataStore): void {
target._count = this._count;
target._rawCount = this._rawCount;
target._provider = this._provider;
Expand All @@ -1204,7 +1204,7 @@ class DataStorage {
target._rawExtent = clone(this._rawExtent);
}

private _cloneIndices(): DataStorage['_indices'] {
private _cloneIndices(): DataStore['_indices'] {
if (this._indices) {
const Ctor = this._indices.constructor as DataArrayLikeConstructor;
let indices;
Expand Down Expand Up @@ -1240,7 +1240,7 @@ class DataStorage {
private static internalField = (function () {

function getDimValueSimply(
this: DataStorage, dataItem: any, property: string, dataIndex: number, dimIndex: number
this: DataStore, dataItem: any, property: string, dataIndex: number, dimIndex: number
): ParsedValue {
return parseDataValue(dataItem[dimIndex], this._dimensions[dimIndex]);
}
Expand All @@ -1250,15 +1250,15 @@ class DataStorage {
arrayRows: getDimValueSimply,

objectRows(
this: DataStorage, dataItem: any, property: string, dataIndex: number, dimIndex: number
this: DataStore, dataItem: any, property: string, dataIndex: number, dimIndex: number
): ParsedValue {
return parseDataValue(dataItem[property], this._dimensions[dimIndex]);
},

keyedColumns: getDimValueSimply,

original(
this: DataStorage, dataItem: any, property: string, dataIndex: number, dimIndex: number
this: DataStore, dataItem: any, property: string, dataIndex: number, dimIndex: number
): ParsedValue {
// Performance sensitive, do not use modelUtil.getDataItemValue.
// If dataItem is an plain object with no value field, the let `value`
Expand All @@ -1276,7 +1276,7 @@ class DataStorage {
},

typedArray: function (
this: DataStorage, dataItem: any, property: string, dataIndex: number, dimIndex: number
this: DataStore, dataItem: any, property: string, dataIndex: number, dimIndex: number
): ParsedValue {
return dataItem[dimIndex];
}
Expand All @@ -1286,4 +1286,4 @@ class DataStorage {
})();
}

export default DataStorage;
export default DataStore;
Loading

0 comments on commit f26ccae

Please sign in to comment.