Skip to content

Commit

Permalink
fix: other rename of data storage -> data store
Browse files Browse the repository at this point in the history
  • Loading branch information
100pah committed Aug 21, 2021
1 parent 136a97c commit afafc7b
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 104 deletions.
32 changes: 16 additions & 16 deletions src/chart/candlestick/candlestickLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ const candlestickLayout: StageHandler = {

function normalProgress(params: StageHandlerProgressParams, data: SeriesData) {
let dataIndex;
const storage = data.getStorage();
const store = data.getStore();
while ((dataIndex = params.next()) != null) {

const axisDimVal = storage.get(cDimI, dataIndex) as number;
const openVal = storage.get(openDimI, dataIndex) as number;
const closeVal = storage.get(closeDimI, dataIndex) as number;
const lowestVal = storage.get(lowestDimI, dataIndex) as number;
const highestVal = storage.get(highestDimI, dataIndex) as number;
const axisDimVal = store.get(cDimI, dataIndex) as number;
const openVal = store.get(openDimI, dataIndex) as number;
const closeVal = store.get(closeDimI, dataIndex) as number;
const lowestVal = store.get(lowestDimI, dataIndex) as number;
const highestVal = store.get(highestDimI, dataIndex) as number;

const ocLow = Math.min(openVal, closeVal);
const ocHigh = Math.max(openVal, closeVal);
Expand All @@ -110,7 +110,7 @@ const candlestickLayout: StageHandler = {
);

data.setItemLayout(dataIndex, {
sign: getSign(storage, dataIndex, openVal, closeVal, closeDimI),
sign: getSign(store, dataIndex, openVal, closeVal, closeDimI),
initBaseline: openVal > closeVal
? ocHighPoint[vDimIdx] : ocLowPoint[vDimIdx], // open point.
ends: ends,
Expand Down Expand Up @@ -172,22 +172,22 @@ const candlestickLayout: StageHandler = {
const tmpIn: number[] = [];
const tmpOut: number[] = [];
let dataIndex;
const storage = data.getStorage();
const store = data.getStore();

while ((dataIndex = params.next()) != null) {
const axisDimVal = storage.get(cDimI, dataIndex) as number;
const openVal = storage.get(openDimI, dataIndex) as number;
const closeVal = storage.get(closeDimI, dataIndex) as number;
const lowestVal = storage.get(lowestDimI, dataIndex) as number;
const highestVal = storage.get(highestDimI, dataIndex) as number;
const axisDimVal = store.get(cDimI, dataIndex) as number;
const openVal = store.get(openDimI, dataIndex) as number;
const closeVal = store.get(closeDimI, dataIndex) as number;
const lowestVal = store.get(lowestDimI, dataIndex) as number;
const highestVal = store.get(highestDimI, dataIndex) as number;

if (isNaN(axisDimVal) || isNaN(lowestVal) || isNaN(highestVal)) {
points[offset++] = NaN;
offset += 3;
continue;
}

points[offset++] = getSign(storage, dataIndex, openVal, closeVal, closeDimI);
points[offset++] = getSign(store, dataIndex, openVal, closeVal, closeDimI);

tmpIn[cDimIdx] = axisDimVal;

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

function getSign(
storage: DataStore, dataIndex: number, openVal: number, closeVal: number, closeDimI: DimensionIndex
store: DataStore, dataIndex: number, openVal: number, closeVal: number, closeDimI: DimensionIndex
): -1 | 1 {
let sign: -1 | 1;
if (openVal > closeVal) {
Expand All @@ -218,7 +218,7 @@ function getSign(
else {
sign = dataIndex > 0
// If close === open, compare with close of last record
? (storage.get(closeDimI, dataIndex - 1) <= closeVal ? 1 : -1)
? (store.get(closeDimI, dataIndex - 1) <= closeVal ? 1 : -1)
// No record of previous, set to be positive
: 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/chart/custom/CustomView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ function makeRenderItem(
*/
function value(dim?: DimensionLoose, dataIndexInside?: number): ParsedValue {
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
return data.getStorage().get(data.getDimensionIndex(dim || 0), dataIndexInside);
return data.getStore().get(data.getDimensionIndex(dim || 0), dataIndexInside);
}

/**
Expand All @@ -957,7 +957,7 @@ function makeRenderItem(
const dimInfo = data.getDimensionInfo(dim);
if (!dimInfo) {
const dimIndex = data.getDimensionIndex(dim);
return dimIndex >= 0 ? data.getStorage().get(dimIndex, dataIndexInside) : undefined;
return dimIndex >= 0 ? data.getStore().get(dimIndex, dataIndexInside) : undefined;
}
const val = data.get(dimInfo.name, dataIndexInside);
const ordinalMeta = dimInfo && dimInfo.ordinalMeta;
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 @@ -151,9 +151,9 @@ function createSeriesData(
schema.dimensions, opt.createInvertedIndices, coordSysInfo
);

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

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

const data = new SeriesData(schema, seriesModel);
data.setCalculationInfo(stackCalculationInfo);
Expand All @@ -171,8 +171,8 @@ function createSeriesData(

data.hasItemOption = false;
data.initData(
// Try to reuse the data storage in sourceManager if using dataset.
isOriginalSource ? source : storage,
// Try to reuse the data store in sourceManager if using dataset.
isOriginalSource ? source : store,
null,
dimValueGetter
);
Expand Down
2 changes: 1 addition & 1 deletion src/chart/radar/RadarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class RadarView extends ChartView {

const pathEmphasisState = symbolPath.ensureState('emphasis');
pathEmphasisState.style = zrUtil.clone(itemHoverStyle);
let defaultText = data.getStorage().get(data.getDimensionIndex(symbolPath.__dimIdx), idx);
let defaultText = data.getStore().get(data.getDimensionIndex(symbolPath.__dimIdx), idx);
(defaultText == null || isNaN(defaultText as number)) && (defaultText = '');

setLabelStyle(
Expand Down
3 changes: 0 additions & 3 deletions src/chart/sankey/SankeySeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ class SankeySeriesModel extends SeriesModel<SankeySeriesOption> {

/**
* Init a graph data structure from data in option series
*
* @param {Object} option the object used to config echarts view
* @return {module:echarts/data/SeriesData} storage initial data
*/
getInitialData(option: SankeySeriesOption, ecModel: GlobalModel) {
const links = option.edges || option.links;
Expand Down
2 changes: 0 additions & 2 deletions src/chart/tree/TreeSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ class TreeSeriesModel extends SeriesModel<TreeSeriesOption> {

/**
* Init a tree data structure from data in option series
* @param option the object used to config echarts view
* @return storage initial data
*/
getInitialData(option: TreeSeriesOption): SeriesData {

Expand Down
4 changes: 2 additions & 2 deletions src/component/dataZoom/AxisProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,14 @@ class AxisProxy {
}

if (filterMode === 'weakFilter') {
const storage = seriesData.getStorage();
const store = seriesData.getStore();
const dataDimIndices = zrUtil.map(dataDims, dim => seriesData.getDimensionIndex(dim), seriesData);
seriesData.filterSelf(function (dataIndex) {
let leftOut;
let rightOut;
let hasValue;
for (let i = 0; i < dataDims.length; i++) {
const value = storage.get(dataDimIndices[i], dataIndex) as number;
const value = store.get(dataDimIndices[i], dataIndex) as number;
const thisHasValue = !isNaN(value);
const thisLeftOut = value < valueWindow[0];
const thisRightOut = value > valueWindow[1];
Expand Down
2 changes: 1 addition & 1 deletion src/component/visualMap/ContinuousView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ class ContinuousView extends VisualMapView {
}

const data = dataModel.getData(ecData.dataType);
const value = data.getStorage().get(visualMapModel.getDataDimensionIndex(data), ecData.dataIndex) as number;
const value = data.getStore().get(visualMapModel.getDataDimensionIndex(data), ecData.dataIndex) as number;

if (!isNaN(value)) {
this._showIndicator(value, value);
Expand Down
25 changes: 12 additions & 13 deletions src/data/DataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const CtorUint16Array = typeof Uint16Array === UNDEFINED ? Array : Uint16
export const CtorInt32Array = typeof Int32Array === UNDEFINED ? Array : Int32Array;
export const CtorFloat64Array = typeof Float64Array === UNDEFINED ? Array : Float64Array;
/**
* Multi dimensional data storage
* Multi dimensional data store
*/
const dataCtors = {
'float': CtorFloat64Array,
Expand Down Expand Up @@ -99,7 +99,7 @@ export interface DataStoreDimensionDefine {
/**
* When using category axis.
* Category strings will be collected and stored in ordinalMeta.categories.
* And storage will store the index of categories.
* And store will store the index of categories.
*/
ordinalMeta?: OrdinalMeta,

Expand All @@ -126,8 +126,8 @@ function cloneChunk(originalChunk: DataValueChunk): DataValueChunk {
: new (Ctor as DataTypedArrayConstructor)(originalChunk as DataTypedArray);
}

function prepareStorage(
storage: DataValueChunk[],
function prepareStore(
store: DataValueChunk[],
dimIdx: number,
dimType: DataStoreDimensionType,
end: number,
Expand All @@ -136,7 +136,7 @@ function prepareStorage(
const DataCtor = dataCtors[dimType || 'float'];

if (append) {
const oldStore = storage[dimIdx];
const oldStore = store[dimIdx];
const oldLen = oldStore && oldStore.length;
if (!(oldLen === end)) {
const newStore = new DataCtor(end);
Expand All @@ -145,11 +145,11 @@ function prepareStorage(
for (let j = 0; j < oldLen; j++) {
newStore[j] = oldStore[j];
}
storage[dimIdx] = newStore;
store[dimIdx] = newStore;
}
}
else {
storage[dimIdx] = new DataCtor(end);
store[dimIdx] = new DataCtor(end);
}
};

Expand Down Expand Up @@ -223,7 +223,7 @@ class DataStore {
}

/**
* Caution: even when a `source` instance owned by a series, the created data storage
* Caution: even when a `source` instance owned by a series, the created data store
* may still be shared by different sereis (the source hash does not use all `source`
* props, see `sourceManager`). In this case, the `source` props that are not used in
* hash (like `source.dimensionDefine`) probably only belongs to a certain series and
Expand Down Expand Up @@ -325,7 +325,7 @@ class DataStore {
}

appendValues(values: any[][], minFillLen?: number): { start: number; end: number } {
const storage = this._chunks;
const chunks = this._chunks;
const dimensions = this._dimensions;
const dimLen = dimensions.length;
const rawExtent = this._rawExtent;
Expand All @@ -335,7 +335,7 @@ class DataStore {

for (let i = 0; i < dimLen; i++) {
const dim = dimensions[i];
prepareStorage(storage, i, dim.type, end, true);
prepareStore(chunks, i, dim.type, end, true);
}

const emptyDataItem: number[] = [];
Expand All @@ -347,7 +347,7 @@ class DataStore {
const val = defaultDimValueGetters.arrayRows.call(
this, values[sourceIdx] || emptyDataItem, dim.property, sourceIdx, dimIdx
) as ParsedValueNumeric;
(storage[dimIdx] as any)[idx] = val;
(chunks[dimIdx] as any)[idx] = val;

const dimRawExtent = rawExtent[dimIdx];
val < dimRawExtent[0] && (dimRawExtent[0] = val);
Expand Down Expand Up @@ -377,10 +377,9 @@ class DataStore {
if (!rawExtent[i]) {
rawExtent[i] = getInitialExtent();
}
prepareStorage(chunks, i, dim.type, end, append);
prepareStore(chunks, i, dim.type, end, append);
}


if (provider.fillStorage) {
provider.fillStorage(start, end, chunks, rawExtent);
}
Expand Down
2 changes: 1 addition & 1 deletion src/data/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ function createGraphDataProxyMixin<Host extends GraphEdge | GraphNode>(
*/
getValue(this: Host, dimension?: DimensionLoose): ParsedValue {
const data = this[hostName][dataName];
return data.getStorage().get(data.getDimensionIndex(dimension || 'value'), this.dataIndex);
return data.getStore().get(data.getDimensionIndex(dimension || 'value'), this.dataIndex);
},
// TODO: TYPE stricter type.
setVisual(this: Host, key: string | Dictionary<any>, value?: any) {
Expand Down
28 changes: 14 additions & 14 deletions src/data/SeriesData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ class SeriesData<
hostModel: HostModel
) {
let dimensions: SeriesDimensionDefineLoose[];
let assignStorageDimIdx = false;
let assignStoreDimIdx = false;
if (isSeriesDataSchema(dimensionsInput)) {
dimensions = dimensionsInput.dimensions;
this._dimOmitted = dimensionsInput.isDimensionOmitted();
this._schema = dimensionsInput;
}
else {
assignStorageDimIdx = true;
assignStoreDimIdx = true;
dimensions = dimensionsInput as SeriesDimensionDefineLoose[];
}

Expand Down Expand Up @@ -324,9 +324,9 @@ class SeriesData<
}

if (__DEV__) {
zrUtil.assert(assignStorageDimIdx || dimensionInfo.storeDimIndex >= 0);
zrUtil.assert(assignStoreDimIdx || dimensionInfo.storeDimIndex >= 0);
}
if (assignStorageDimIdx) {
if (assignStoreDimIdx) {
dimensionInfo.storeDimIndex = i;
}
}
Expand Down Expand Up @@ -359,7 +359,7 @@ class SeriesData<
*
* @notice Becuause of this reason, should better use `getDimensionIndex` instead, for examples:
* ```js
* const val = data.getStorage().get(data.getDimensionIndex(dim), dataIdx);
* const val = data.getStore().get(data.getDimensionIndex(dim), dataIdx);
* ```
*
* @return Concrete dim name.
Expand Down Expand Up @@ -389,7 +389,7 @@ class SeriesData<
}

/**
* Get dimension index in the storage. Return -1 if not found.
* Get dimension index in data store. Return -1 if not found.
* Can be used to index value from getRawValue.
*/
getDimensionIndex(dim: DimensionLoose): DimensionIndex {
Expand Down Expand Up @@ -509,13 +509,13 @@ class SeriesData<
return (dims || []).slice();
}

getStorage() {
getStore() {
return this._store;
}

/**
* Initialize from data
* @param data source or data or data storage.
* @param data source or data or data store.
* @param nameList The name of a datum is used on data diff and
* default label/tooltip.
* A name can be specified in encode.itemName,
Expand Down Expand Up @@ -567,7 +567,7 @@ class SeriesData<
/**
* Caution: Can be only called on raw data (before `this._indices` created).
* This method does not modify `rawData` (`dataProvider`), but only
* add values to storage.
* add values to store.
*
* The final count will be increased by `Math.max(values.length, names.length)`.
*
Expand Down Expand Up @@ -763,7 +763,7 @@ class SeriesData<
/**
* Get value. Return NaN if idx is out of range.
*
* @notice Should better to use `data.getStorage().get(dimIndex, dataIdx)` instead.
* @notice Should better to use `data.getStore().get(dimIndex, dataIdx)` instead.
*/
get(dim: SeriesDimensionName, idx: number): ParsedValue {
const store = this._store;
Expand All @@ -774,7 +774,7 @@ class SeriesData<
}

/**
* @notice Should better to use `data.getStorage().getByRawIndex(dimIndex, dataIdx)` instead.
* @notice Should better to use `data.getStore().getByRawIndex(dimIndex, dataIdx)` instead.
*/
getByRawIndex(dim: SeriesDimensionName, rawIdx: number): ParsedValue {
const store = this._store;
Expand Down Expand Up @@ -1066,7 +1066,7 @@ class SeriesData<
);

// If do shallow clone here, if there are too many stacked series,
// it still cost lots of memory, becuase `storage.dimensions` are not shared.
// it still cost lots of memory, becuase `_store.dimensions` are not shared.
// We should consider there probably be shallow clone happen in each sereis
// in consequent filter/map.
this._store.modify(
Expand Down Expand Up @@ -1136,8 +1136,8 @@ class SeriesData<
const thisList = this;

return new DataDiffer(
otherList ? otherList.getStorage().getIndices() : [],
this.getStorage().getIndices(),
otherList ? otherList.getStore().getIndices() : [],
this.getStore().getIndices(),
function (idx: number) {
return getId(otherList, idx);
},
Expand Down
Loading

0 comments on commit afafc7b

Please sign in to comment.