Skip to content

Commit

Permalink
fix: rename to make name shorter.
Browse files Browse the repository at this point in the history
  • Loading branch information
100pah committed Aug 20, 2021
1 parent 6e0a254 commit 1e3f1ad
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 133 deletions.
2 changes: 1 addition & 1 deletion src/component/visualMap/VisualMapModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class VisualMapModel<Opts extends VisualMapOption = VisualMapOption> extends Com
const dimName = dimNames[i];
const dimInfo = data.getDimensionInfo(dimName);
if (!dimInfo.isCalculationCoord) {
return dimInfo.storageDimensionIndex;
return dimInfo.storeDimIndex;
}
}
}
Expand Down
79 changes: 40 additions & 39 deletions src/data/SeriesData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ type SeriesDimensionName = DimensionName;

const TRANSFERABLE_PROPERTIES = [
'hasItemOption', '_nameList', '_idList', '_invertedIndicesMap',
'_dimensionsSummary', 'userOutput',
'_dimSummary', 'userOutput',
'_rawData', '_dimValueGetter',
'_nameDimIdx', '_idDimIdx', '_nameRepeatCount'
];

const CLONE_PROPERTIES = [
'_approximateExtent'
];
Expand Down Expand Up @@ -164,9 +165,9 @@ class SeriesData<
readonly dimensions: SeriesDimensionName[];

// Infomation of each data dimension, like data type.
private _dimensionInfos: Record<SeriesDimensionName, SeriesDimensionDefine>;
private _dimInfos: Record<SeriesDimensionName, SeriesDimensionDefine>;

private _dimensionOmitted = false;
private _dimOmitted = false;
private _schema?: SeriesDataSchema;
/**
* @pending
Expand Down Expand Up @@ -222,7 +223,7 @@ class SeriesData<
// key: dim, value: extent
private _approximateExtent: Record<SeriesDimensionName, [number, number]> = {};

private _dimensionsSummary: DimensionSummary;
private _dimSummary: DimensionSummary;

private _invertedIndicesMap: Record<SeriesDimensionName, ArrayLike<number>>;

Expand Down Expand Up @@ -271,7 +272,7 @@ class SeriesData<
let assignStorageDimIdx = false;
if (isSeriesDataSchema(dimensionsInput)) {
dimensions = dimensionsInput.dimensionList;
this._dimensionOmitted = dimensionsInput.isDimensionOmitted();
this._dimOmitted = dimensionsInput.isDimensionOmitted();
this._schema = dimensionsInput;
}
else {
Expand Down Expand Up @@ -323,25 +324,25 @@ class SeriesData<
}

if (__DEV__) {
zrUtil.assert(assignStorageDimIdx || dimensionInfo.storageDimensionIndex >= 0);
zrUtil.assert(assignStorageDimIdx || dimensionInfo.storeDimIndex >= 0);
}
if (assignStorageDimIdx) {
dimensionInfo.storageDimensionIndex = i;
dimensionInfo.storeDimIndex = i;
}
}

this.dimensions = dimensionNames;
this._dimensionInfos = dimensionInfos;
this._dimInfos = dimensionInfos;
this._initGetDimensionInfo(needsHasOwn);

this.hostModel = hostModel;

this._invertedIndicesMap = invertedIndicesMap;

if (this._dimensionOmitted) {
if (this._dimOmitted) {
const dimIdxToName = this._dimIdxToName = zrUtil.createHashMap<DimensionName, DimensionIndex>();
zrUtil.each(dimensionNames, dimName => {
dimIdxToName.set(dimensionInfos[dimName].storageDimensionIndex, dimName);
dimIdxToName.set(dimensionInfos[dimName].storeDimIndex, dimName);
});
}
}
Expand Down Expand Up @@ -370,7 +371,7 @@ class SeriesData<
}
dimIdx = dim as DimensionIndex;

if (!this._dimensionOmitted) {
if (!this._dimOmitted) {
return this.dimensions[dimIdx];
}

Expand All @@ -381,7 +382,7 @@ class SeriesData<
return dimName;
}

const sourceDimDef = this._schema.getDimensionFromSource(dimIdx);
const sourceDimDef = this._schema.getSourceDim(dimIdx);
if (sourceDimDef) {
return sourceDimDef.name;
}
Expand All @@ -397,10 +398,10 @@ class SeriesData<
return dimIdx;
}

const dimInfo = this._getDimensionInfo(dim as DimensionName);
const dimInfo = this._getDimInfo(dim as DimensionName);
return dimInfo
? dimInfo.storageDimensionIndex
: this._dimensionOmitted
? dimInfo.storeDimIndex
: this._dimOmitted
? this._schema.getDimensionIndexFromSource(dim as DimensionName)
: -1;
}
Expand Down Expand Up @@ -430,8 +431,8 @@ class SeriesData<
|| (
dim != null
&& !isNaN(dim as any)
&& !this._getDimensionInfo(dim)
&& (!this._dimensionOmitted || this._schema.getDimensionIndexFromSource(dim) < 0)
&& !this._getDimInfo(dim)
&& (!this._dimOmitted || this._schema.getDimensionIndexFromSource(dim) < 0)
)
) {
return +dim;
Expand All @@ -456,18 +457,18 @@ class SeriesData<
*/
getDimensionInfo(dim: SeriesDimensionLoose): SeriesDimensionDefine {
// Do not clone, because there may be categories in dimInfo.
return this._getDimensionInfo(this.getDimension(dim));
return this._getDimInfo(this.getDimension(dim));
}

/**
* If `dimName` if from outside of `SeriesData`,
* use this method other than visit `this._dimensionInfos` directly.
* use this method other than visit `this._dimInfos` directly.
*/
private _getDimensionInfo: (dimName: SeriesDimensionName) => SeriesDimensionDefine;
private _getDimInfo: (dimName: SeriesDimensionName) => SeriesDimensionDefine;

private _initGetDimensionInfo(needsHasOwn: boolean): void {
const dimensionInfos = this._dimensionInfos;
this._getDimensionInfo = needsHasOwn
const dimensionInfos = this._dimInfos;
this._getDimInfo = needsHasOwn
? dimName => (dimensionInfos.hasOwnProperty(dimName) ? dimensionInfos[dimName] : undefined)
: dimName => dimensionInfos[dimName];
}
Expand All @@ -476,7 +477,7 @@ class SeriesData<
* concrete dimension name list on coord.
*/
getDimensionsOnCoord(): SeriesDimensionName[] {
return this._dimensionsSummary.dataDimsOnCoord.slice();
return this._dimSummary.dataDimsOnCoord.slice();
}

/**
Expand All @@ -488,7 +489,7 @@ class SeriesData<
mapDimension(coordDim: SeriesDimensionName): SeriesDimensionName;
mapDimension(coordDim: SeriesDimensionName, idx: number): SeriesDimensionName;
mapDimension(coordDim: SeriesDimensionName, idx?: number): SeriesDimensionName {
const dimensionsSummary = this._dimensionsSummary;
const dimensionsSummary = this._dimSummary;

if (idx == null) {
return dimensionsSummary.encodeFirstDimNotExtra[coordDim] as any;
Expand All @@ -499,7 +500,7 @@ class SeriesData<
}

mapDimensionsAll(coordDim: SeriesDimensionName): SeriesDimensionName[] {
const dimensionsSummary = this._dimensionsSummary;
const dimensionsSummary = this._dimSummary;
const dims = dimensionsSummary.encode[coordDim];
return (dims || []).slice();
}
Expand All @@ -524,7 +525,7 @@ class SeriesData<
): void {
let store: DataStorage;
const dimensions = this.dimensions;
const dimensionInfos = map(dimensions, this._getDimensionInfo, this);
const dimensionInfos = map(dimensions, this._getDimInfo, this);
if (data instanceof DataStorage) {
store = data;
}
Expand All @@ -548,8 +549,8 @@ class SeriesData<

// Cache summary info for fast visit. See "dimensionHelper".
// Needs to be initialized after store is prepared.
this._dimensionsSummary = summarizeDimensions(this, this._schema);
this.userOutput = this._dimensionsSummary.userOutput;
this._dimSummary = summarizeDimensions(this, this._schema);
this.userOutput = this._dimSummary.userOutput;
}

/**
Expand Down Expand Up @@ -595,9 +596,9 @@ class SeriesData<
const store = this._store;
const dimensions = this.dimensions;
for (let i = 0; i < dimensions.length; i++) {
const dimInfo = this._dimensionInfos[dimensions[i]];
const dimInfo = this._dimInfos[dimensions[i]];
if (dimInfo.ordinalMeta) {
store.collectOrdinalMeta(dimInfo.storageDimensionIndex, dimInfo.ordinalMeta);
store.collectOrdinalMeta(dimInfo.storeDimIndex, dimInfo.ordinalMeta);
}
}
}
Expand Down Expand Up @@ -762,9 +763,9 @@ class SeriesData<
*/
get(dim: SeriesDimensionName, idx: number): ParsedValue {
const store = this._store;
const dimInfo = this._dimensionInfos[dim];
const dimInfo = this._dimInfos[dim];
if (dimInfo) {
return store.get(dimInfo.storageDimensionIndex, idx);
return store.get(dimInfo.storeDimIndex, idx);
}
}

Expand All @@ -773,9 +774,9 @@ class SeriesData<
*/
getByRawIndex(dim: SeriesDimensionName, rawIdx: number): ParsedValue {
const store = this._store;
const dimInfo = this._dimensionInfos[dim];
const dimInfo = this._dimInfos[dim];
if (dimInfo) {
return store.getByRawIndex(dimInfo.storageDimensionIndex, rawIdx);
return store.getByRawIndex(dimInfo.storeDimIndex, rawIdx);
}
}

Expand Down Expand Up @@ -812,7 +813,7 @@ class SeriesData<
* Only check the coord dimensions.
*/
hasValue(idx: number): boolean {
const dataDimIndicesOnCoord = this._dimensionsSummary.dataDimIndicesOnCoord;
const dataDimIndicesOnCoord = this._dimSummary.dataDimIndicesOnCoord;
for (let i = 0, len = dataDimIndicesOnCoord.length; i < len; i++) {
// Ordinal type originally can be string or number.
// But when an ordinal type is used on coord, it can
Expand Down Expand Up @@ -1341,7 +1342,7 @@ class SeriesData<
list = new SeriesData(
this._schema
? this._schema
: map(this.dimensions, this._getDimensionInfo, this),
: map(this.dimensions, this._getDimInfo, this),
this.hostModel
);
}
Expand Down Expand Up @@ -1380,7 +1381,7 @@ class SeriesData<
prepareInvertedIndex = function (data: SeriesData): void {
const invertedIndicesMap = data._invertedIndicesMap;
zrUtil.each(invertedIndicesMap, function (invertedIndices, dim) {
const dimInfo = data._dimensionInfos[dim];
const dimInfo = data._dimInfos[dim];
// Currently, only dimensions that has ordinalMeta can create inverted indices.
const ordinalMeta = dimInfo.ordinalMeta;
const store = data._store;
Expand All @@ -1395,7 +1396,7 @@ class SeriesData<
}
for (let i = 0; i < store.count(); i++) {
// Only support the case that all values are distinct.
invertedIndices[store.get(dimInfo.storageDimensionIndex, i) as number] = i;
invertedIndices[store.get(dimInfo.storeDimIndex, i) as number] = i;
}
}
});
Expand Down Expand Up @@ -1437,7 +1438,7 @@ class SeriesData<
const list = new SeriesData(
original._schema
? original._schema
: map(original.dimensions, original._getDimensionInfo, original),
: map(original.dimensions, original._getDimInfo, original),
original.hostModel
);
// FIXME If needs stackedOn, value may already been stacked
Expand Down
4 changes: 2 additions & 2 deletions src/data/SeriesDimensionDefine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class SeriesDimensionDefine {
tooltip?: boolean;

/**
* This dimension maps to the the dimension in dataStorage by `storageDimensionIndex`.
* This dimension maps to the the dimension in dataStorage by `storeDimIndex`.
* Notice the facts:
* 1. When there are too many dimensions in storage, seriesData only save the
* used storage dimensions.
* 2. We use dimensionIndex but not name to reference storage dimension
* becuause the dataset dimension definition might has no name specified by users,
* or names in sereis dimension definition might be different from dataset.
*/
storageDimensionIndex?: number;
storeDimIndex?: number;

/**
* Which coordSys dimension this dimension mapped to.
Expand Down
Loading

0 comments on commit 1e3f1ad

Please sign in to comment.