@vizabi/reader-ddfcsv 4.1.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/reader-ddfcsv-polyfill.js +1 -16
- package/dist/reader-ddfcsv-polyfill.js.map +1 -1
- package/dist/reader-ddfcsv.js +7 -16
- package/dist/reader-ddfcsv.js.map +1 -1
- package/lib/src/ddf-csv.d.ts +1 -0
- package/lib/src/ddf-csv.js +31 -20
- package/lib/src/ddf-csv.js.map +1 -1
- package/lib/src/ddfcsv-error.js +1 -0
- package/lib/src/ddfcsv-error.js.map +1 -1
- package/lib/src/ddfcsv-reader.js +6 -5
- package/lib/src/ddfcsv-reader.js.map +1 -1
- package/lib/src/file-readers/backend-file-reader.js +1 -0
- package/lib/src/file-readers/backend-file-reader.js.map +1 -1
- package/lib/src/file-readers/github-path-adapter.js +1 -0
- package/lib/src/file-readers/github-path-adapter.js.map +1 -1
- package/lib/src/index.js +5 -4
- package/lib/src/index.js.map +1 -1
- package/lib/src/interfaces.d.ts +1 -0
- package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.d.ts +3 -2
- package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.js +35 -35
- package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.js.map +1 -1
- package/lib/src/resource-selection-optimizer/index.d.ts +1 -1
- package/lib/src/resource-selection-optimizer/index.js +3 -2
- package/lib/src/resource-selection-optimizer/index.js.map +1 -1
- package/lib-web/src/ddf-csv.d.ts +1 -0
- package/lib-web/src/ddf-csv.js +285 -388
- package/lib-web/src/ddf-csv.js.map +1 -1
- package/lib-web/src/ddfcsv-error.js +9 -12
- package/lib-web/src/ddfcsv-error.js.map +1 -1
- package/lib-web/src/ddfcsv-reader.js +84 -125
- package/lib-web/src/ddfcsv-reader.js.map +1 -1
- package/lib-web/src/file-readers/frontend-file-reader.js +14 -16
- package/lib-web/src/file-readers/frontend-file-reader.js.map +1 -1
- package/lib-web/src/file-readers/github-path-adapter.js +6 -5
- package/lib-web/src/file-readers/github-path-adapter.js.map +1 -1
- package/lib-web/src/index-web.js +6 -5
- package/lib-web/src/index-web.js.map +1 -1
- package/lib-web/src/interfaces.d.ts +1 -0
- package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.d.ts +3 -2
- package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.js +168 -347
- package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.js.map +1 -1
- package/lib-web/src/resource-selection-optimizer/index.d.ts +1 -1
- package/lib-web/src/resource-selection-optimizer/index.js +7 -6
- package/lib-web/src/resource-selection-optimizer/index.js.map +1 -1
- package/package.json +6 -4
- package/src/ddf-csv.ts +18 -12
- package/src/interfaces.ts +1 -0
- package/src/resource-selection-optimizer/in-clause-under-conjunction.ts +37 -38
- package/src/resource-selection-optimizer/index.ts +2 -2
- package/tsconfig-web.json +5 -2
- package/tsconfig.json +1 -1
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
exports.InClauseUnderConjunction = void 0;
|
|
4
|
+
const head = require("lodash.head");
|
|
5
|
+
const values = require("lodash.values");
|
|
6
|
+
const keys = require("lodash.keys");
|
|
7
|
+
const get = require("lodash.get");
|
|
8
|
+
const flattenDeep = require("lodash.flattendeep");
|
|
9
|
+
const isEmpty = require("lodash.isempty");
|
|
10
|
+
const startsWith = require("lodash.startswith");
|
|
11
|
+
const includes = require("lodash.includes");
|
|
12
|
+
const compact = require("lodash.compact");
|
|
13
|
+
const ddfcsv_error_1 = require("../ddfcsv-error");
|
|
14
|
+
const ddf_query_validator_1 = require("ddf-query-validator");
|
|
15
|
+
const Papa = require('papaparse');
|
|
16
|
+
const WHERE_KEYWORD = 'where';
|
|
17
|
+
const JOIN_KEYWORD = 'join';
|
|
18
|
+
const KEY_IN = '$in';
|
|
19
|
+
const KEY_NIN = '$nin';
|
|
20
|
+
const KEY_AND = '$and';
|
|
21
|
+
const KEY_OR = '$or';
|
|
22
|
+
const getFirstConditionClause = clause => head(values(clause));
|
|
23
|
+
const getFirstKey = obj => head(keys(obj));
|
|
24
|
+
const isOneKeyBased = obj => keys(obj).length === 1;
|
|
25
|
+
class InClauseUnderConjunction {
|
|
26
|
+
constructor(parent, queryParam, options) {
|
|
27
|
+
this.parent = parent;
|
|
27
28
|
this.options = options;
|
|
28
29
|
this.flow = {};
|
|
29
30
|
this.fileReader = options.fileReader;
|
|
@@ -32,372 +33,192 @@ var InClauseUnderConjunction = (function () {
|
|
|
32
33
|
this.datapackage = options.datapackage;
|
|
33
34
|
this.conceptsLookup = options.conceptsLookup;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
var _this = this;
|
|
36
|
+
isMatched() {
|
|
37
37
|
this.flow.joinObject = get(this.query, JOIN_KEYWORD);
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
case 1:
|
|
54
|
-
_b.trys.push([1, 3, , 4]);
|
|
55
|
-
this.fillResourceToFileHash();
|
|
56
|
-
this.collectProcessableClauses();
|
|
57
|
-
this.collectEntityFilesNames();
|
|
58
|
-
return [4, this.collectEntities()];
|
|
59
|
-
case 2:
|
|
60
|
-
data = _b.sent();
|
|
61
|
-
this.fillEntityValuesHash(data);
|
|
62
|
-
this.getFilesGroupsQueryClause();
|
|
63
|
-
result = this.getOptimalFilesGroup();
|
|
64
|
-
return [3, 4];
|
|
65
|
-
case 3:
|
|
66
|
-
err_1 = _b.sent();
|
|
67
|
-
error('wrong data processing', err_1);
|
|
68
|
-
return [2, []];
|
|
69
|
-
case 4:
|
|
70
|
-
debug('recommended files found', result);
|
|
71
|
-
return [2, result];
|
|
72
|
-
case 5:
|
|
73
|
-
message = "Plugin \"InClauseUnderConjunction\" is not matched!";
|
|
74
|
-
warning(message);
|
|
75
|
-
throw new ddfcsv_error_1.DdfCsvError(message, 'InClauseUnderConjunction plugin');
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
InClauseUnderConjunction.prototype.fillResourceToFileHash = function () {
|
|
81
|
-
this.flow.resourceToFile = get(this.datapackage, 'resources', []).reduce(function (hash, resource) {
|
|
82
|
-
hash.set(resource.name, resource.path);
|
|
83
|
-
return hash;
|
|
84
|
-
}, new Map());
|
|
85
|
-
return this;
|
|
86
|
-
};
|
|
87
|
-
InClauseUnderConjunction.prototype.collectProcessableClauses = function () {
|
|
88
|
-
var _this = this;
|
|
89
|
-
var e_1, _a, _b, _c;
|
|
90
|
-
var joinKeys = keys(this.flow.joinObject);
|
|
91
|
-
this.flow.processableClauses = [];
|
|
92
|
-
try {
|
|
93
|
-
for (var joinKeys_1 = tslib_1.__values(joinKeys), joinKeys_1_1 = joinKeys_1.next(); !joinKeys_1_1.done; joinKeys_1_1 = joinKeys_1.next()) {
|
|
94
|
-
var joinKey = joinKeys_1_1.value;
|
|
95
|
-
var where = get(this.flow.joinObject, joinKey + "." + WHERE_KEYWORD, {});
|
|
96
|
-
if (this.singleAndField(where)) {
|
|
97
|
-
(_b = this.flow.processableClauses).push.apply(_b, tslib_1.__spread(flattenDeep(where[KEY_AND].map(function (el) { return _this.getProcessableClauses(el); }))));
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
(_c = this.flow.processableClauses).push.apply(_c, tslib_1.__spread(this.getProcessableClauses(where)));
|
|
101
|
-
}
|
|
38
|
+
const relatedFeatures = compact(ddf_query_validator_1.featureDetectors.map(detector => detector(this.query, this.conceptsLookup)));
|
|
39
|
+
return this.query.from === "datapoints";
|
|
40
|
+
}
|
|
41
|
+
async getRecommendedFilesSet() {
|
|
42
|
+
const { debug, error, warning } = this.options.diagnostic.prepareDiagnosticFor('getRecommendedFilesSet');
|
|
43
|
+
if (this.isMatched()) {
|
|
44
|
+
debug('plugin matched');
|
|
45
|
+
let result;
|
|
46
|
+
try {
|
|
47
|
+
this.collectProcessableClauses();
|
|
48
|
+
this.collectEntityFilesNames();
|
|
49
|
+
const data = await this.collectEntities();
|
|
50
|
+
this.fillEntityValuesHash(data);
|
|
51
|
+
this.getFilesGroupsQueryClause();
|
|
52
|
+
result = this.getOptimalFilesGroup();
|
|
102
53
|
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
error('wrong data processing', err);
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
debug('recommended files found', result);
|
|
59
|
+
return result;
|
|
103
60
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
61
|
+
else {
|
|
62
|
+
const message = `Plugin "InClauseUnderConjunction" is not matched!`;
|
|
63
|
+
warning(message);
|
|
64
|
+
throw new ddfcsv_error_1.DdfCsvError(message, 'InClauseUnderConjunction plugin');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
collectProcessableClauses() {
|
|
68
|
+
const joinKeys = keys(this.flow.joinObject);
|
|
69
|
+
this.flow.processableClauses = [];
|
|
70
|
+
for (const joinKey of joinKeys) {
|
|
71
|
+
const where = get(this.flow.joinObject, `${joinKey}.${WHERE_KEYWORD}`, {});
|
|
72
|
+
if (this.singleAndField(where)) {
|
|
73
|
+
this.flow.processableClauses.push(...flattenDeep(where[KEY_AND].map(el => this.getProcessableClauses(el))));
|
|
74
|
+
}
|
|
75
|
+
else if (this.singleOrField(where)) {
|
|
76
|
+
this.flow.processableClauses.push(...flattenDeep(where[KEY_OR].map(el => this.getProcessableClauses(el))));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.flow.processableClauses.push(...this.getProcessableClauses(where));
|
|
108
80
|
}
|
|
109
|
-
finally { if (e_1) throw e_1.error; }
|
|
110
81
|
}
|
|
111
82
|
return this;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.flow.
|
|
83
|
+
}
|
|
84
|
+
collectEntityFilesNames() {
|
|
85
|
+
this.flow.entityFilesNames = new Set();
|
|
86
|
+
this.flow.entityResources = new Set();
|
|
116
87
|
this.flow.fileNameToPrimaryKeyHash = new Map();
|
|
117
|
-
|
|
118
|
-
for (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
for (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
for (var _h = tslib_1.__values(schemaResourceRecord.resources), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
127
|
-
var resourceName = _j.value;
|
|
128
|
-
var file = this.flow.resourceToFile.get(resourceName);
|
|
129
|
-
this.flow.entityFilesNames.push(file);
|
|
130
|
-
this.flow.fileNameToPrimaryKeyHash.set(file, primaryKey);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
134
|
-
finally {
|
|
135
|
-
try {
|
|
136
|
-
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
137
|
-
}
|
|
138
|
-
finally { if (e_4) throw e_4.error; }
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
144
|
-
finally {
|
|
145
|
-
try {
|
|
146
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
88
|
+
for (const schemaResourceRecord of this.datapackage.ddfSchema.entities) {
|
|
89
|
+
for (const clause of this.flow.processableClauses) {
|
|
90
|
+
const primaryKey = getFirstKey(clause);
|
|
91
|
+
if (head(schemaResourceRecord.primaryKey) === primaryKey) {
|
|
92
|
+
for (const resourceName of schemaResourceRecord.resources) {
|
|
93
|
+
const resource = this.options.resourcesLookup.get(resourceName);
|
|
94
|
+
this.flow.entityResources.add(resource);
|
|
95
|
+
this.flow.entityFilesNames.add(resource.path);
|
|
96
|
+
this.flow.fileNameToPrimaryKeyHash.set(resource.path, primaryKey);
|
|
147
97
|
}
|
|
148
|
-
finally { if (e_3) throw e_3.error; }
|
|
149
98
|
}
|
|
150
99
|
}
|
|
151
100
|
}
|
|
152
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
153
|
-
finally {
|
|
154
|
-
try {
|
|
155
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
156
|
-
}
|
|
157
|
-
finally { if (e_2) throw e_2.error; }
|
|
158
|
-
}
|
|
159
101
|
return this;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
Papa.parse(text, {
|
|
169
|
-
header: true,
|
|
170
|
-
skipEmptyLines: true,
|
|
171
|
-
complete: function (result) { return actResolve({ file: file, result: result }); },
|
|
172
|
-
error: function (error) { return actReject(error); }
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}); });
|
|
102
|
+
}
|
|
103
|
+
collectEntities() {
|
|
104
|
+
const self = this;
|
|
105
|
+
const actions = [...self.flow.entityResources].map(resource => {
|
|
106
|
+
return (resource.data || (resource.data = self.parent.loadFile(resource.path, self.options)))
|
|
107
|
+
.then(data => ({ result: data, file: resource.path }));
|
|
108
|
+
});
|
|
176
109
|
return Promise.all(actions);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
.
|
|
182
|
-
.map(function (key) { return key.replace(/^is--/, ''); })); };
|
|
110
|
+
}
|
|
111
|
+
fillEntityValuesHash(entitiesData) {
|
|
112
|
+
const getSubdomainsFromRecord = record => compact(keys(record)
|
|
113
|
+
.filter(key => startsWith(key, 'is--') && (record[key] === true))
|
|
114
|
+
.map(key => key.replace(/^is--/, '')));
|
|
183
115
|
this.flow.entityValueToFileHash = new Map();
|
|
184
116
|
this.flow.entityValueToDomainHash = new Map();
|
|
185
|
-
|
|
186
|
-
for (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
domainsForCurrentRecord.push(primaryKeyForThisFile);
|
|
196
|
-
}
|
|
197
|
-
this.flow.entityValueToDomainHash.set(primaryKeyCellValue, domainsForCurrentRecord);
|
|
198
|
-
this.flow.entityValueToFileHash.set(primaryKeyCellValue, entityFileDescriptor.file);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
202
|
-
finally {
|
|
203
|
-
try {
|
|
204
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
205
|
-
}
|
|
206
|
-
finally { if (e_6) throw e_6.error; }
|
|
207
|
-
}
|
|
117
|
+
for (const entityFileDescriptor of entitiesData) {
|
|
118
|
+
for (const entityRecord of entityFileDescriptor.result.data) {
|
|
119
|
+
const primaryKeyForThisFile = this.flow.fileNameToPrimaryKeyHash.get(entityFileDescriptor.file);
|
|
120
|
+
const domainsForCurrentRecord = [...getSubdomainsFromRecord(entityRecord)];
|
|
121
|
+
if (isEmpty(domainsForCurrentRecord)) {
|
|
122
|
+
domainsForCurrentRecord.push(primaryKeyForThisFile);
|
|
123
|
+
}
|
|
124
|
+
const primaryKeyCellValue = entityRecord[primaryKeyForThisFile] || entityRecord[domainsForCurrentRecord[0]];
|
|
125
|
+
this.flow.entityValueToDomainHash.set(primaryKeyCellValue, domainsForCurrentRecord);
|
|
126
|
+
this.flow.entityValueToFileHash.set(primaryKeyCellValue, entityFileDescriptor.file);
|
|
208
127
|
}
|
|
209
128
|
}
|
|
210
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
211
|
-
finally {
|
|
212
|
-
try {
|
|
213
|
-
if (entitiesData_1_1 && !entitiesData_1_1.done && (_a = entitiesData_1.return)) _a.call(entitiesData_1);
|
|
214
|
-
}
|
|
215
|
-
finally { if (e_5) throw e_5.error; }
|
|
216
|
-
}
|
|
217
129
|
return this;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
try {
|
|
226
|
-
for (var _b = tslib_1.__values(_this.flow.entityValueToDomainHash.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
227
|
-
var entityKey = _c.value;
|
|
228
|
-
if (!includes(entityValuesToExclude, entityKey)) {
|
|
229
|
-
result.push(entityKey);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
234
|
-
finally {
|
|
235
|
-
try {
|
|
236
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
130
|
+
}
|
|
131
|
+
getFilesGroupsQueryClause() {
|
|
132
|
+
const getEntitiesExcept = (entityValuesToExclude) => {
|
|
133
|
+
const result = [];
|
|
134
|
+
for (const entityKey of this.flow.entityValueToDomainHash.keys()) {
|
|
135
|
+
if (!includes(entityValuesToExclude, entityKey)) {
|
|
136
|
+
result.push(entityKey);
|
|
237
137
|
}
|
|
238
|
-
finally { if (e_14) throw e_14.error; }
|
|
239
138
|
}
|
|
240
139
|
return result;
|
|
241
140
|
};
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
for (
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
for (var _k = tslib_1.__values(this.datapackage.ddfSchema.datapoints), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
263
|
-
var schemaResourceRecord = _l.value;
|
|
264
|
-
try {
|
|
265
|
-
for (var _m = tslib_1.__values(schemaResourceRecord.resources), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
266
|
-
var resourceName = _o.value;
|
|
267
|
-
if (includes(schemaResourceRecord.primaryKey, entityByQuery)) {
|
|
268
|
-
filesGroupByClause.datapoints.add(this.flow.resourceToFile.get(resourceName));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
273
|
-
finally {
|
|
274
|
-
try {
|
|
275
|
-
if (_o && !_o.done && (_e = _m.return)) _e.call(_m);
|
|
276
|
-
}
|
|
277
|
-
finally { if (e_11) throw e_11.error; }
|
|
278
|
-
}
|
|
141
|
+
const filesGroupsByClause = new Map();
|
|
142
|
+
for (const clause of this.flow.processableClauses) {
|
|
143
|
+
const filesGroupByClause = {
|
|
144
|
+
entities: this.flow.entityFilesNames,
|
|
145
|
+
datapoints: new Set(),
|
|
146
|
+
concepts: new Set()
|
|
147
|
+
};
|
|
148
|
+
const firstConditionClause = getFirstConditionClause(clause);
|
|
149
|
+
const entityValuesFromClause = firstConditionClause[KEY_IN] || getEntitiesExcept(firstConditionClause[KEY_NIN]);
|
|
150
|
+
for (const entityValueFromClause of entityValuesFromClause) {
|
|
151
|
+
const entitiesByQuery = this.flow.entityValueToDomainHash.get(entityValueFromClause);
|
|
152
|
+
for (const entityByQuery of entitiesByQuery) {
|
|
153
|
+
for (const schemaResourceRecord of this.datapackage.ddfSchema.datapoints) {
|
|
154
|
+
for (const resourceName of schemaResourceRecord.resources) {
|
|
155
|
+
if (includes(schemaResourceRecord.primaryKey, entityByQuery)) {
|
|
156
|
+
const resource = this.options.resourcesLookup.get(resourceName);
|
|
157
|
+
const constraint = resource.constraints[entityByQuery];
|
|
158
|
+
if (constraint) {
|
|
159
|
+
if (constraint.includes(entityValueFromClause)) {
|
|
160
|
+
filesGroupByClause.datapoints.add(resource.path);
|
|
279
161
|
}
|
|
280
162
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
try {
|
|
284
|
-
if (_l && !_l.done && (_d = _k.return)) _d.call(_k);
|
|
285
|
-
}
|
|
286
|
-
finally { if (e_10) throw e_10.error; }
|
|
163
|
+
else {
|
|
164
|
+
filesGroupByClause.datapoints.add(resource.path);
|
|
287
165
|
}
|
|
288
166
|
}
|
|
289
167
|
}
|
|
290
|
-
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
291
|
-
finally {
|
|
292
|
-
try {
|
|
293
|
-
if (entitiesByQuery_1_1 && !entitiesByQuery_1_1.done && (_c = entitiesByQuery_1.return)) _c.call(entitiesByQuery_1);
|
|
294
|
-
}
|
|
295
|
-
finally { if (e_9) throw e_9.error; }
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
300
|
-
finally {
|
|
301
|
-
try {
|
|
302
|
-
if (entityValuesFromClause_1_1 && !entityValuesFromClause_1_1.done && (_b = entityValuesFromClause_1.return)) _b.call(entityValuesFromClause_1);
|
|
303
|
-
}
|
|
304
|
-
finally { if (e_8) throw e_8.error; }
|
|
305
|
-
}
|
|
306
|
-
try {
|
|
307
|
-
for (var _p = tslib_1.__values(this.datapackage.ddfSchema.concepts), _q = _p.next(); !_q.done; _q = _p.next()) {
|
|
308
|
-
var schemaResourceRecord = _q.value;
|
|
309
|
-
try {
|
|
310
|
-
for (var _r = tslib_1.__values(schemaResourceRecord.resources), _s = _r.next(); !_s.done; _s = _r.next()) {
|
|
311
|
-
var resourceName = _s.value;
|
|
312
|
-
filesGroupByClause.concepts.add(this.flow.resourceToFile.get(resourceName));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
316
|
-
finally {
|
|
317
|
-
try {
|
|
318
|
-
if (_s && !_s.done && (_g = _r.return)) _g.call(_r);
|
|
319
|
-
}
|
|
320
|
-
finally { if (e_13) throw e_13.error; }
|
|
321
|
-
}
|
|
322
168
|
}
|
|
323
169
|
}
|
|
324
|
-
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
325
|
-
finally {
|
|
326
|
-
try {
|
|
327
|
-
if (_q && !_q.done && (_f = _p.return)) _f.call(_p);
|
|
328
|
-
}
|
|
329
|
-
finally { if (e_12) throw e_12.error; }
|
|
330
|
-
}
|
|
331
|
-
filesGroupsByClause.set(clause, filesGroupByClause);
|
|
332
170
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (_j && !_j.done && (_a = _h.return)) _a.call(_h);
|
|
171
|
+
for (const schemaResourceRecord of this.datapackage.ddfSchema.concepts) {
|
|
172
|
+
for (const resourceName of schemaResourceRecord.resources) {
|
|
173
|
+
filesGroupByClause.concepts.add(this.options.resourcesLookup.get(resourceName).path);
|
|
174
|
+
}
|
|
338
175
|
}
|
|
339
|
-
|
|
176
|
+
filesGroupsByClause.set(clause, filesGroupByClause);
|
|
340
177
|
}
|
|
341
178
|
this.flow.filesGroupsByClause = filesGroupsByClause;
|
|
342
179
|
return this;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (!appropriateClauseKey || size < appropriateClauseSize) {
|
|
356
|
-
appropriateClauseKey = key;
|
|
357
|
-
appropriateClauseSize = size;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
362
|
-
finally {
|
|
363
|
-
try {
|
|
364
|
-
if (clauseKeys_1_1 && !clauseKeys_1_1.done && (_a = clauseKeys_1.return)) _a.call(clauseKeys_1);
|
|
180
|
+
}
|
|
181
|
+
getOptimalFilesGroup() {
|
|
182
|
+
const clauseKeys = this.flow.filesGroupsByClause.keys();
|
|
183
|
+
let appropriateClauseKey;
|
|
184
|
+
let appropriateClauseSize;
|
|
185
|
+
for (const key of clauseKeys) {
|
|
186
|
+
const size = this.flow.filesGroupsByClause.get(key).datapoints.size +
|
|
187
|
+
this.flow.filesGroupsByClause.get(key).entities.size +
|
|
188
|
+
this.flow.filesGroupsByClause.get(key).concepts.size;
|
|
189
|
+
if (!appropriateClauseKey || size < appropriateClauseSize) {
|
|
190
|
+
appropriateClauseKey = key;
|
|
191
|
+
appropriateClauseSize = size;
|
|
365
192
|
}
|
|
366
|
-
finally { if (e_15) throw e_15.error; }
|
|
367
193
|
}
|
|
368
194
|
if (!this.flow.filesGroupsByClause.get(appropriateClauseKey)) {
|
|
369
195
|
return [];
|
|
370
196
|
}
|
|
371
|
-
return
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
197
|
+
return [
|
|
198
|
+
...Array.from(this.flow.filesGroupsByClause.get(appropriateClauseKey).concepts),
|
|
199
|
+
...Array.from(this.flow.filesGroupsByClause.get(appropriateClauseKey).entities),
|
|
200
|
+
...Array.from(this.flow.filesGroupsByClause.get(appropriateClauseKey).datapoints)
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
getProcessableClauses(clause) {
|
|
204
|
+
const result = [];
|
|
205
|
+
const clauseKeys = keys(clause);
|
|
206
|
+
for (const key of clauseKeys) {
|
|
207
|
+
if (!startsWith(key, '$') && isOneKeyBased(clause[key])) {
|
|
208
|
+
const conditionKey = head(keys(clause[key]));
|
|
209
|
+
if (conditionKey === KEY_IN || conditionKey === KEY_NIN) {
|
|
210
|
+
result.push(clause);
|
|
385
211
|
}
|
|
386
212
|
}
|
|
387
213
|
}
|
|
388
|
-
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
389
|
-
finally {
|
|
390
|
-
try {
|
|
391
|
-
if (clauseKeys_2_1 && !clauseKeys_2_1.done && (_a = clauseKeys_2.return)) _a.call(clauseKeys_2);
|
|
392
|
-
}
|
|
393
|
-
finally { if (e_16) throw e_16.error; }
|
|
394
|
-
}
|
|
395
214
|
return result;
|
|
396
|
-
}
|
|
397
|
-
|
|
215
|
+
}
|
|
216
|
+
singleAndField(clause) {
|
|
398
217
|
return isOneKeyBased(clause) && !!get(clause, KEY_AND);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
218
|
+
}
|
|
219
|
+
singleOrField(clause) {
|
|
220
|
+
return isOneKeyBased(clause) && !!get(clause, KEY_OR);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
402
223
|
exports.InClauseUnderConjunction = InClauseUnderConjunction;
|
|
403
224
|
//# sourceMappingURL=in-clause-under-conjunction.js.map
|