You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/07/13 08:40:27 UTC
[echarts] branch dataset-perf updated: refact(data): share source
instance with dataset
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch dataset-perf
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/dataset-perf by this push:
new bf059ad refact(data): share source instance with dataset
bf059ad is described below
commit bf059adc227b329a99921bfd01bea96fe9b4bc67
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Jul 13 16:39:23 2021 +0800
refact(data): share source instance with dataset
to reduce the cost of source dimension parse
---
src/data/helper/sourceManager.ts | 48 +++++++++++++++++++++++-----------------
test/runTest/blacklist.js | 4 +++-
2 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/src/data/helper/sourceManager.ts b/src/data/helper/sourceManager.ts
index b1f4f63..8790bd7 100644
--- a/src/data/helper/sourceManager.ts
+++ b/src/data/helper/sourceManager.ts
@@ -142,6 +142,8 @@ export class SourceManager {
private _versionSignBase = 0;
+ private _dirty = true;
+
constructor(sourceHost: DatasetModel | SeriesModel) {
this._sourceHost = sourceHost;
}
@@ -152,6 +154,7 @@ export class SourceManager {
dirty() {
this._setLocalSource([], []);
this._storeList = [];
+ this._dirty = true;
}
private _setLocalSource(
@@ -182,11 +185,13 @@ export class SourceManager {
// cache the result source to prevent from repeating transform.
if (this._isDirty()) {
this._createSource();
+ this._dirty = false;
}
}
private _createSource(): void {
this._setLocalSource([], []);
+
const sourceHost = this._sourceHost;
const upSourceMgrList = this._getUpstreamSourceManagers();
@@ -219,28 +224,24 @@ export class SourceManager {
// See [REQUIREMENT_MEMO], merge settings on series and parent dataset if it is root.
const newMetaRawOption = this._getSourceMetaRawOption();
- const upMetaRawOption = upSource ? upSource.metaRawOption : null;
- const seriesLayoutBy = retrieve2(
- newMetaRawOption.seriesLayoutBy,
- upMetaRawOption ? upMetaRawOption.seriesLayoutBy : null
- );
- const sourceHeader = retrieve2(
- newMetaRawOption.sourceHeader,
- upMetaRawOption ? upMetaRawOption.sourceHeader : null
- );
+ const upMetaRawOption = upSource ? upSource.metaRawOption : {} as SourceMetaRawOption;
+ const seriesLayoutBy = retrieve2(newMetaRawOption.seriesLayoutBy, upMetaRawOption.seriesLayoutBy) || null;
+ const sourceHeader = retrieve2(newMetaRawOption.sourceHeader, upMetaRawOption.sourceHeader) || null;
// Note here we should not use `upSource.dimensionsDefine`. Consider the case:
// `upSource.dimensionsDefine` is detected by `seriesLayoutBy: 'column'`,
// but series need `seriesLayoutBy: 'row'`.
- const dimensions = retrieve2(
- newMetaRawOption.dimensions,
- upMetaRawOption ? upMetaRawOption.dimensions : null
- );
-
- resultSourceList = [createSource(
+ const dimensions = retrieve2(newMetaRawOption.dimensions, upMetaRawOption.dimensions);
+
+ // We share source with dataset as much as possible
+ // to avoid extra memroy cost of high dimensional data.
+ const needsCreateSource = seriesLayoutBy !== upMetaRawOption.seriesLayoutBy
+ || !!sourceHeader !== !!upMetaRawOption.sourceHeader
+ || dimensions;
+ resultSourceList = needsCreateSource ? [createSource(
data,
{ seriesLayoutBy, sourceHeader, dimensions },
sourceFormat
- )];
+ )] : [];
}
else {
const datasetModel = sourceHost as DatasetModel;
@@ -326,8 +327,7 @@ export class SourceManager {
}
private _isDirty(): boolean {
- const sourceList = this._sourceList;
- if (!sourceList.length) {
+ if (this._dirty) {
return true;
}
@@ -350,8 +350,16 @@ export class SourceManager {
* @param sourceIndex By defualt 0, means "main source".
* Most cases there is only one source.
*/
- getSource(sourceIndex?: number) {
- return this._sourceList[sourceIndex || 0];
+ getSource(sourceIndex?: number): Source {
+ sourceIndex = sourceIndex || 0;
+ const source = this._sourceList[sourceIndex];
+ if (!source) {
+ // Series may share source instance with dataset.
+ const upSourceMgrList = this._getUpstreamSourceManagers();
+ return upSourceMgrList[0]
+ && upSourceMgrList[0].getSource(sourceIndex);
+ }
+ return source;
}
/**
diff --git a/test/runTest/blacklist.js b/test/runTest/blacklist.js
index ba638ed..3bedb0c 100644
--- a/test/runTest/blacklist.js
+++ b/test/runTest/blacklist.js
@@ -39,7 +39,9 @@ module.exports.blacklist = [
// This case will have timeout
'visualMap-performance1.html',
- 'lines-stream-not-large.html'
+ 'lines-stream-not-large.html',
+
+ 'dataset-performance.html'
];
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org