19072950d6affd90fcd89d908c6a0b51eb04d25f65e1cedcdb4fbb872fa467bef8cdc0aabf8453953091323b49b6568c570780858d6d303198826f79ec4754 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import { DatasetModel } from '../../component/dataset/install.js';
  2. import SeriesModel from '../../model/Series.js';
  3. import { Source } from '../Source.js';
  4. import DataStore from '../DataStore.js';
  5. import { SeriesDataSchema } from './SeriesDataSchema.js';
  6. /**
  7. * [REQUIREMENT_MEMO]:
  8. * (0) `metaRawOption` means `dimensions`/`sourceHeader`/`seriesLayoutBy` in raw option.
  9. * (1) Keep support the feature: `metaRawOption` can be specified both on `series` and
  10. * `root-dataset`. Them on `series` has higher priority.
  11. * (2) Do not support to set `metaRawOption` on a `non-root-dataset`, because it might
  12. * confuse users: whether those props indicate how to visit the upstream source or visit
  13. * the transform result source, and some transforms has nothing to do with these props,
  14. * and some transforms might have multiple upstream.
  15. * (3) Transforms should specify `metaRawOption` in each output, just like they can be
  16. * declared in `root-dataset`.
  17. * (4) At present only support visit source in `SERIES_LAYOUT_BY_COLUMN` in transforms.
  18. * That is for reducing complexity in transfroms.
  19. * PENDING: Whether to provide transposition transform?
  20. *
  21. * [IMPLEMENTAION_MEMO]:
  22. * "sourceVisitConfig" are calculated from `metaRawOption` and `data`.
  23. * They will not be calculated until `source` is about to be visited (to prevent from
  24. * duplicate calcuation). `source` is visited only in series and input to transforms.
  25. *
  26. * [DIMENSION_INHERIT_RULE]:
  27. * By default the dimensions are inherited from ancestors, unless a transform return
  28. * a new dimensions definition.
  29. * Consider the case:
  30. * ```js
  31. * dataset: [{
  32. * source: [ ['Product', 'Sales', 'Prise'], ['Cookies', 321, 44.21], ...]
  33. * }, {
  34. * transform: { type: 'filter', ... }
  35. * }]
  36. * dataset: [{
  37. * dimension: ['Product', 'Sales', 'Prise'],
  38. * source: [ ['Cookies', 321, 44.21], ...]
  39. * }, {
  40. * transform: { type: 'filter', ... }
  41. * }]
  42. * ```
  43. * The two types of option should have the same behavior after transform.
  44. *
  45. *
  46. * [SCENARIO]:
  47. * (1) Provide source data directly:
  48. * ```js
  49. * series: {
  50. * encode: {...},
  51. * dimensions: [...]
  52. * seriesLayoutBy: 'row',
  53. * data: [[...]]
  54. * }
  55. * ```
  56. * (2) Series refer to dataset.
  57. * ```js
  58. * series: [{
  59. * encode: {...}
  60. * // Ignore datasetIndex means `datasetIndex: 0`
  61. * // and the dimensions defination in dataset is used
  62. * }, {
  63. * encode: {...},
  64. * seriesLayoutBy: 'column',
  65. * datasetIndex: 1
  66. * }]
  67. * ```
  68. * (3) dataset transform
  69. * ```js
  70. * dataset: [{
  71. * source: [...]
  72. * }, {
  73. * source: [...]
  74. * }, {
  75. * // By default from 0.
  76. * transform: { type: 'filter', config: {...} }
  77. * }, {
  78. * // Piped.
  79. * transform: [
  80. * { type: 'filter', config: {...} },
  81. * { type: 'sort', config: {...} }
  82. * ]
  83. * }, {
  84. * id: 'regressionData',
  85. * fromDatasetIndex: 1,
  86. * // Third-party transform
  87. * transform: { type: 'ecStat:regression', config: {...} }
  88. * }, {
  89. * // retrieve the extra result.
  90. * id: 'regressionFormula',
  91. * fromDatasetId: 'regressionData',
  92. * fromTransformResult: 1
  93. * }]
  94. * ```
  95. */
  96. export declare class SourceManager {
  97. private _sourceHost;
  98. private _sourceList;
  99. private _storeList;
  100. private _upstreamSignList;
  101. private _versionSignBase;
  102. private _dirty;
  103. constructor(sourceHost: DatasetModel | SeriesModel);
  104. /**
  105. * Mark dirty.
  106. */
  107. dirty(): void;
  108. private _setLocalSource;
  109. /**
  110. * For detecting whether the upstream source is dirty, so that
  111. * the local cached source (in `_sourceList`) should be discarded.
  112. */
  113. private _getVersionSign;
  114. /**
  115. * Always return a source instance. Otherwise throw error.
  116. */
  117. prepareSource(): void;
  118. private _createSource;
  119. private _applyTransform;
  120. private _isDirty;
  121. /**
  122. * @param sourceIndex By defualt 0, means "main source".
  123. * Most cases there is only one source.
  124. */
  125. getSource(sourceIndex?: number): Source;
  126. /**
  127. *
  128. * Get a data store which can be shared across series.
  129. * Only available for series.
  130. *
  131. * @param seriesDimRequest Dimensions that are generated in series.
  132. * Should have been sorted by `storeDimIndex` asc.
  133. */
  134. getSharedDataStore(seriesDimRequest: SeriesDataSchema): DataStore;
  135. private _innerGetDataStore;
  136. /**
  137. * PEDING: Is it fast enough?
  138. * If no upstream, return empty array.
  139. */
  140. private _getUpstreamSourceManagers;
  141. private _getSourceMetaRawOption;
  142. }
  143. export declare function disableTransformOptionMerge(datasetModel: DatasetModel): void;