@itwin/imodel-transformer 2.0.0-dev.3 → 2.0.0-dev.5
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/lib/cjs/ECReferenceTypesCache.d.ts +3 -0
- package/lib/cjs/ECReferenceTypesCache.d.ts.map +1 -1
- package/lib/cjs/ECReferenceTypesCache.js +100 -36
- package/lib/cjs/ECReferenceTypesCache.js.map +1 -1
- package/lib/cjs/TransformerLoggerCategory.d.ts +2 -1
- package/lib/cjs/TransformerLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/TransformerLoggerCategory.js +1 -0
- package/lib/cjs/TransformerLoggerCategory.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,6 +22,9 @@ export declare class ECReferenceTypesCache {
|
|
|
22
22
|
private _propQualifierToRefType;
|
|
23
23
|
private _relClassNameEndToRefTypes;
|
|
24
24
|
private _initedSchemas;
|
|
25
|
+
private _rootBisClassCache;
|
|
26
|
+
private _relationshipInfoCache;
|
|
27
|
+
private _constraintClassCache;
|
|
25
28
|
private static bisRootClassToRefType;
|
|
26
29
|
private getRootBisClass;
|
|
27
30
|
private getAbstractConstraintClass;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECReferenceTypesCache.d.ts","sourceRoot":"","sources":["../../src/ECReferenceTypesCache.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACL,mBAAmB,EAEnB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAY5B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ECReferenceTypesCache.d.ts","sourceRoot":"","sources":["../../src/ECReferenceTypesCache.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACL,mBAAmB,EAEnB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAY5B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;;CAI7C;AAED;;;;;;;GAOG;AACH,qBAAa,qBAAqB;IAChC,uGAAuG;IACvG,OAAO,CAAC,uBAAuB,CAG3B;IACJ,OAAO,CAAC,0BAA0B,CAG9B;IACJ,OAAO,CAAC,cAAc,CAAgC;IAGtD,OAAO,CAAC,kBAAkB,CAA8B;IACxD,OAAO,CAAC,sBAAsB,CAA8C;IAC5E,OAAO,CAAC,qBAAqB,CAA8B;IAE3D,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAalC;YAEY,eAAe;YAmCf,0BAA0B;IAqBxC,8CAA8C;IACjC,sBAAsB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;YAuDtD,kBAAkB;YAalB,UAAU;YAwFV,mBAAmB;IA4D1B,iBAAiB,CACtB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,SAAS,GAAG,mBAAmB;IAS3B,sBAAsB,CAC3B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,SAAS,GAAG,WAAW;IAQnB,KAAK;CAQb"}
|
|
@@ -12,6 +12,7 @@ const core_bentley_1 = require("@itwin/core-bentley");
|
|
|
12
12
|
const core_common_1 = require("@itwin/core-common");
|
|
13
13
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
14
14
|
const assert = require("assert");
|
|
15
|
+
const TransformerLoggerCategory_1 = require("./TransformerLoggerCategory");
|
|
15
16
|
/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.
|
|
16
17
|
* @internal
|
|
17
18
|
*/
|
|
@@ -34,6 +35,10 @@ class ECReferenceTypesCache {
|
|
|
34
35
|
_propQualifierToRefType = new core_bentley_1.TupleKeyedMap();
|
|
35
36
|
_relClassNameEndToRefTypes = new core_bentley_1.TupleKeyedMap();
|
|
36
37
|
_initedSchemas = new Map();
|
|
38
|
+
// Performance optimization caches
|
|
39
|
+
_rootBisClassCache = new Map();
|
|
40
|
+
_relationshipInfoCache = new Map();
|
|
41
|
+
_constraintClassCache = new Map();
|
|
37
42
|
static bisRootClassToRefType = {
|
|
38
43
|
/* eslint-disable quote-props, @typescript-eslint/naming-convention */
|
|
39
44
|
Element: core_common_1.ConcreteEntityTypes.Element,
|
|
@@ -46,6 +51,11 @@ class ECReferenceTypesCache {
|
|
|
46
51
|
/* eslint-enable quote-props, @typescript-eslint/naming-convention */
|
|
47
52
|
};
|
|
48
53
|
async getRootBisClass(ecclass) {
|
|
54
|
+
const cacheKey = ecclass.fullName;
|
|
55
|
+
const cached = this._rootBisClassCache.get(cacheKey);
|
|
56
|
+
if (cached) {
|
|
57
|
+
return cached;
|
|
58
|
+
}
|
|
49
59
|
let bisRootForConstraint = ecclass;
|
|
50
60
|
await ecclass.traverseBaseClasses((baseClass) => {
|
|
51
61
|
// The depth first traversal will descend all the way to the root class before making any lateral traversal
|
|
@@ -64,21 +74,28 @@ class ECReferenceTypesCache {
|
|
|
64
74
|
assert(bisRootForConstraint.appliesTo !== undefined, "The referenced AppliesToEntityClass could not be found, how did it pass schema validation?");
|
|
65
75
|
bisRootForConstraint = await this.getRootBisClass(await bisRootForConstraint.appliesTo);
|
|
66
76
|
}
|
|
77
|
+
this._rootBisClassCache.set(cacheKey, bisRootForConstraint);
|
|
67
78
|
return bisRootForConstraint;
|
|
68
79
|
}
|
|
69
80
|
async getAbstractConstraintClass(constraint) {
|
|
81
|
+
const cacheKey = `${constraint.fullName}_${constraint.constraintClasses?.[0]?.fullName || "abstract"}`;
|
|
82
|
+
const cached = this._constraintClassCache.get(cacheKey);
|
|
83
|
+
if (cached) {
|
|
84
|
+
return cached;
|
|
85
|
+
}
|
|
70
86
|
// constraint classes must share a base so we can get the root from any of them, just use the first
|
|
71
87
|
const ecclass = await (constraint.constraintClasses?.[0] ||
|
|
72
88
|
constraint.abstractConstraint);
|
|
73
89
|
assert(ecclass !== undefined, "At least one constraint class or an abstract constraint must have been defined, the constraint is not valid");
|
|
90
|
+
this._constraintClassCache.set(cacheKey, ecclass);
|
|
74
91
|
return ecclass;
|
|
75
92
|
}
|
|
76
93
|
/** initialize from an imodel with metadata */
|
|
77
94
|
async initAllSchemasInIModel(imodel) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
95
|
+
let totalSchemaCount = 0;
|
|
96
|
+
let schemaCompletedCount = 0;
|
|
97
|
+
const initStartTime = performance.now();
|
|
98
|
+
const query = `
|
|
82
99
|
WITH RECURSIVE refs(SchemaId) AS (
|
|
83
100
|
SELECT ECInstanceId FROM ECDbMeta.ECSchemaDef WHERE Name='BisCore'
|
|
84
101
|
UNION ALL
|
|
@@ -91,16 +108,26 @@ class ECReferenceTypesCache {
|
|
|
91
108
|
JOIN ECDbMeta.ECSchemaDef s ON refs.SchemaId=s.ECInstanceId
|
|
92
109
|
-- ensure schema dependency order
|
|
93
110
|
ORDER BY s.ECInstanceId
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
`;
|
|
112
|
+
for await (const row of imodel.createQueryReader(query)) {
|
|
113
|
+
const schemaName = row.name;
|
|
114
|
+
const startTime = performance.now();
|
|
115
|
+
core_bentley_1.Logger.logInfo(TransformerLoggerCategory_1.TransformerLoggerCategory.ECReferenceTypesCache, `Loading schema: ${schemaName}`);
|
|
116
|
+
const schemaItemKey = new ecschema_metadata_1.SchemaKey(schemaName);
|
|
117
|
+
const schema = await imodel.schemaContext.getSchema(schemaItemKey);
|
|
118
|
+
if (schema) {
|
|
99
119
|
await this.considerInitSchema(schema);
|
|
120
|
+
const endTime = performance.now();
|
|
121
|
+
core_bentley_1.Logger.logInfo(TransformerLoggerCategory_1.TransformerLoggerCategory.ECReferenceTypesCache, `Completed schema: ${schemaName} in ${(endTime - startTime).toFixed(2)}ms`);
|
|
122
|
+
schemaCompletedCount++;
|
|
100
123
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
124
|
+
else {
|
|
125
|
+
core_bentley_1.Logger.logInfo(TransformerLoggerCategory_1.TransformerLoggerCategory.ECReferenceTypesCache, `Did not load schema: ${schemaName}`);
|
|
126
|
+
}
|
|
127
|
+
totalSchemaCount++;
|
|
128
|
+
}
|
|
129
|
+
const initEndTime = performance.now();
|
|
130
|
+
core_bentley_1.Logger.logInfo(TransformerLoggerCategory_1.TransformerLoggerCategory.ECReferenceTypesCache, `Schemas completed out of total: ${schemaCompletedCount} / ${totalSchemaCount} in ${(initEndTime - initStartTime).toFixed(2)}ms`);
|
|
104
131
|
}
|
|
105
132
|
async considerInitSchema(schema) {
|
|
106
133
|
if (this._initedSchemas.has(schema.name)) {
|
|
@@ -114,33 +141,66 @@ class ECReferenceTypesCache {
|
|
|
114
141
|
return this.initSchema(schema);
|
|
115
142
|
}
|
|
116
143
|
async initSchema(schema) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
144
|
+
const schemaNameLower = schema.name.toLowerCase();
|
|
145
|
+
// Pre-collect all items to reduce iterator overhead
|
|
146
|
+
const allItems = Array.from(schema.getItems());
|
|
147
|
+
const ecClasses = [];
|
|
148
|
+
const relationshipClasses = [];
|
|
149
|
+
// Single pass through items with type checking
|
|
150
|
+
for (const item of allItems) {
|
|
151
|
+
// eslint-disable-next-line @itwin/no-internal
|
|
152
|
+
if (!ecschema_metadata_1.ECClass.isECClass(item))
|
|
122
153
|
continue;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const relClass = await prop.relationshipClass;
|
|
127
|
-
const relInfo = await this.relInfoFromRelClass(relClass);
|
|
128
|
-
if (relInfo === undefined)
|
|
129
|
-
continue;
|
|
130
|
-
const navPropRefType = prop.direction === ecschema_metadata_1.StrengthDirection.Forward
|
|
131
|
-
? relInfo.target
|
|
132
|
-
: relInfo.source;
|
|
133
|
-
this._propQualifierToRefType.set([
|
|
134
|
-
schema.name.toLowerCase(),
|
|
135
|
-
ecclass.name.toLowerCase(),
|
|
136
|
-
prop.name.toLowerCase(),
|
|
137
|
-
], navPropRefType);
|
|
154
|
+
ecClasses.push(item);
|
|
155
|
+
if (item instanceof ecschema_metadata_1.RelationshipClass) {
|
|
156
|
+
relationshipClasses.push(item);
|
|
138
157
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
}
|
|
159
|
+
// Process relationship classes in parallel and populate global cache
|
|
160
|
+
const relInfoPromises = relationshipClasses.map(async (relClass) => {
|
|
161
|
+
const relInfo = await this.relInfoFromRelClass(relClass);
|
|
162
|
+
this._relationshipInfoCache.set(relClass.fullName, relInfo);
|
|
163
|
+
if (relInfo) {
|
|
164
|
+
this._relClassNameEndToRefTypes.set([schemaNameLower, relClass.name.toLowerCase()], relInfo);
|
|
143
165
|
}
|
|
166
|
+
return relInfo;
|
|
167
|
+
});
|
|
168
|
+
// Wait for all relationship info to be cached
|
|
169
|
+
await Promise.all(relInfoPromises);
|
|
170
|
+
// Process navigation properties with optimized batching
|
|
171
|
+
const propertyBatchSize = 25;
|
|
172
|
+
for (let i = 0; i < ecClasses.length; i += propertyBatchSize) {
|
|
173
|
+
const classBatch = ecClasses.slice(i, i + propertyBatchSize);
|
|
174
|
+
const classPromises = classBatch.map(async (ecclass) => {
|
|
175
|
+
const properties = await ecclass.getProperties();
|
|
176
|
+
if (!properties)
|
|
177
|
+
return;
|
|
178
|
+
const classNameLower = ecclass.name.toLowerCase();
|
|
179
|
+
// Efficiently filter navigation properties
|
|
180
|
+
const navProps = Array.from(properties).filter((prop) => prop.isNavigation());
|
|
181
|
+
if (navProps.length === 0)
|
|
182
|
+
return;
|
|
183
|
+
const navPropPromises = navProps.map(async (prop) => {
|
|
184
|
+
const relClass = await prop.relationshipClass;
|
|
185
|
+
// Use cached relation info
|
|
186
|
+
let relInfo = this._relationshipInfoCache.get(relClass.fullName);
|
|
187
|
+
if (relInfo === undefined &&
|
|
188
|
+
!this._relationshipInfoCache.has(relClass.fullName)) {
|
|
189
|
+
relInfo = await this.relInfoFromRelClass(relClass);
|
|
190
|
+
this._relationshipInfoCache.set(relClass.fullName, relInfo);
|
|
191
|
+
}
|
|
192
|
+
if (relInfo === undefined)
|
|
193
|
+
return;
|
|
194
|
+
const navPropRefType = prop.direction === ecschema_metadata_1.StrengthDirection.Forward
|
|
195
|
+
? // eslint-disable-next-line @itwin/no-internal
|
|
196
|
+
relInfo.target
|
|
197
|
+
: // eslint-disable-next-line @itwin/no-internal
|
|
198
|
+
relInfo.source;
|
|
199
|
+
this._propQualifierToRefType.set([schemaNameLower, classNameLower, prop.name.toLowerCase()], navPropRefType);
|
|
200
|
+
});
|
|
201
|
+
await Promise.all(navPropPromises);
|
|
202
|
+
});
|
|
203
|
+
await Promise.all(classPromises);
|
|
144
204
|
}
|
|
145
205
|
this._initedSchemas.set(schema.name, schema.schemaKey);
|
|
146
206
|
}
|
|
@@ -199,6 +259,10 @@ class ECReferenceTypesCache {
|
|
|
199
259
|
clear() {
|
|
200
260
|
this._initedSchemas.clear();
|
|
201
261
|
this._propQualifierToRefType.clear();
|
|
262
|
+
this._relClassNameEndToRefTypes.clear();
|
|
263
|
+
this._rootBisClassCache.clear();
|
|
264
|
+
this._relationshipInfoCache.clear();
|
|
265
|
+
this._constraintClassCache.clear();
|
|
202
266
|
}
|
|
203
267
|
}
|
|
204
268
|
exports.ECReferenceTypesCache = ECReferenceTypesCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECReferenceTypesCache.js","sourceRoot":"","sources":["../../src/ECReferenceTypesCache.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA8D;AAC9D,oDAI4B;AAC5B,gEASkC;AAClC,iCAAiC;AAGjC;;GAEG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAC5C;QACE,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC3D,CAAC;CACF;AAJD,kDAIC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C,WAAW,EAAE;YACxB,SAAS,CAAC,WAAW,EAAE;YACvB,QAAQ,CAAC,WAAW,EAAE;SACvB,CAAC,CAAC;IACL,CAAC;IAEM,sBAAsB,CAC3B,UAAkB,EAClB,SAAiB;QAEjB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,MAAM,IAAI,mBAAmB,EAAE,CAAC;QAC1E,OAAO,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC;YACzC,UAAU,CAAC,WAAW,EAAE;YACxB,SAAS,CAAC,WAAW,EAAE;SACxB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;;AA/OH,sDAgPC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { DbResult, TupleKeyedMap } from \"@itwin/core-bentley\";\nimport {\n ConcreteEntityTypes,\n IModelError,\n RelTypeInfo,\n} from \"@itwin/core-common\";\nimport {\n ECClass,\n Mixin,\n RelationshipClass,\n RelationshipConstraint,\n Schema,\n SchemaKey,\n SchemaLoader,\n StrengthDirection,\n} from \"@itwin/ecschema-metadata\";\nimport * as assert from \"assert\";\nimport { IModelDb } from \"@itwin/core-backend\";\n\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\n * @internal\n */\nexport class SchemaNotInCacheErr extends Error {\n public constructor() {\n super(\"Schema was not in cache, initialize that schema\");\n }\n}\n\n/**\n * A cache of the entity types referenced by navprops in ecchemas, as well as the source and target entity types of\n * The transformer needs the referenced type to determine how to resolve references.\n *\n * Using multiple of these usually performs redundant computation, for static schemas at least. A possible future optimization\n * would be to seed the computation from a global cache of non-dynamic schemas, but dynamic schemas can collide willy-nilly\n * @internal\n */\nexport class ECReferenceTypesCache {\n /** nesting based tuple map keyed by qualified property path tuple [schemaName, className, propName] */\n private _propQualifierToRefType = new TupleKeyedMap<\n [string, string, string],\n ConcreteEntityTypes\n >();\n private _relClassNameEndToRefTypes = new TupleKeyedMap<\n [string, string],\n RelTypeInfo\n >();\n private _initedSchemas = new Map<string, SchemaKey>();\n\n private static bisRootClassToRefType: Record<\n string,\n ConcreteEntityTypes | undefined\n > = {\n /* eslint-disable quote-props, @typescript-eslint/naming-convention */\n Element: ConcreteEntityTypes.Element,\n Model: ConcreteEntityTypes.Model,\n ElementAspect: ConcreteEntityTypes.ElementAspect,\n ElementRefersToElements: ConcreteEntityTypes.Relationship,\n ElementDrivesElement: ConcreteEntityTypes.Relationship,\n // code spec is technically a potential root class but it is ignored currently\n // see [ConcreteEntityTypes]($common)\n /* eslint-enable quote-props, @typescript-eslint/naming-convention */\n };\n\n private async getRootBisClass(ecclass: ECClass) {\n let bisRootForConstraint: ECClass = ecclass;\n await ecclass.traverseBaseClasses((baseClass) => {\n // The depth first traversal will descend all the way to the root class before making any lateral traversal\n // of mixin hierarchies, (or if the constraint is a mixin, it will traverse to the root of the mixin hierarchy)\n // Once we see that we've moved laterally, we can terminate early\n const isFirstTest = bisRootForConstraint === ecclass;\n const traversalSwitchedRootPath =\n baseClass.name !== bisRootForConstraint.baseClass?.name;\n const stillTraversingRootPath = isFirstTest || !traversalSwitchedRootPath;\n if (!stillTraversingRootPath) return true; // stop traversal early\n bisRootForConstraint = baseClass;\n return false;\n });\n // if the root class of the constraint was a mixin, use its AppliesToEntityClass\n if (bisRootForConstraint instanceof Mixin) {\n assert(\n bisRootForConstraint.appliesTo !== undefined,\n \"The referenced AppliesToEntityClass could not be found, how did it pass schema validation?\"\n );\n bisRootForConstraint = await this.getRootBisClass(\n await bisRootForConstraint.appliesTo\n );\n }\n return bisRootForConstraint;\n }\n\n private async getAbstractConstraintClass(\n constraint: RelationshipConstraint\n ): Promise<ECClass> {\n // constraint classes must share a base so we can get the root from any of them, just use the first\n const ecclass = await (constraint.constraintClasses?.[0] ||\n constraint.abstractConstraint);\n assert(\n ecclass !== undefined,\n \"At least one constraint class or an abstract constraint must have been defined, the constraint is not valid\"\n );\n return ecclass;\n }\n\n /** initialize from an imodel with metadata */\n public async initAllSchemasInIModel(imodel: IModelDb): Promise<void> {\n const schemaLoader = new SchemaLoader((name: string) =>\n imodel.getSchemaProps(name)\n );\n // Issue for `createQueryReader` reported: https://github.com/iTwin/itwinjs-core/issues/7984\n // eslint-disable-next-line @itwin/no-internal, @typescript-eslint/no-deprecated\n await imodel.withPreparedStatement(\n `\n WITH RECURSIVE refs(SchemaId) AS (\n SELECT ECInstanceId FROM ECDbMeta.ECSchemaDef WHERE Name='BisCore'\n UNION ALL\n SELECT sr.SourceECInstanceId\n FROM ECDbMeta.SchemaHasSchemaReferences sr\n JOIN refs ON sr.TargetECInstanceId = refs.SchemaId\n )\n SELECT DISTINCT s.Name as name\n FROM refs\n JOIN ECDbMeta.ECSchemaDef s ON refs.SchemaId=s.ECInstanceId\n -- ensure schema dependency order\n ORDER BY s.ECInstanceId\n `,\n async (stmt) => {\n let status: DbResult;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const schemaName = stmt.getValue(0).getString();\n const schema = schemaLoader.getSchema(schemaName);\n await this.considerInitSchema(schema);\n }\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n }\n );\n }\n\n private async considerInitSchema(schema: Schema): Promise<void> {\n if (this._initedSchemas.has(schema.name)) {\n const cachedSchemaKey = this._initedSchemas.get(schema.name);\n assert(cachedSchemaKey !== undefined);\n const incomingSchemaIsEqualOrOlder =\n schema.schemaKey.compareByVersion(cachedSchemaKey) <= 0;\n if (incomingSchemaIsEqualOrOlder) {\n return;\n }\n }\n return this.initSchema(schema);\n }\n\n private async initSchema(schema: Schema): Promise<void> {\n for (const ecclass of schema.getItems()) {\n if (!ECClass.isECClass(ecclass)) continue;\n const properties = await ecclass.getProperties();\n if (properties === undefined) continue;\n for (const prop of properties) {\n if (!prop.isNavigation()) continue;\n const relClass = await prop.relationshipClass;\n const relInfo = await this.relInfoFromRelClass(relClass);\n if (relInfo === undefined) continue;\n const navPropRefType =\n prop.direction === StrengthDirection.Forward\n ? relInfo.target\n : relInfo.source;\n this._propQualifierToRefType.set(\n [\n schema.name.toLowerCase(),\n ecclass.name.toLowerCase(),\n prop.name.toLowerCase(),\n ],\n navPropRefType\n );\n }\n\n if (ecclass instanceof RelationshipClass) {\n const relInfo = await this.relInfoFromRelClass(ecclass);\n if (relInfo)\n this._relClassNameEndToRefTypes.set(\n [schema.name.toLowerCase(), ecclass.name.toLowerCase()],\n relInfo\n );\n }\n }\n\n this._initedSchemas.set(schema.name, schema.schemaKey);\n }\n\n private async relInfoFromRelClass(\n ecclass: RelationshipClass\n ): Promise<RelTypeInfo | undefined> {\n assert(ecclass.source.constraintClasses !== undefined);\n assert(ecclass.target.constraintClasses !== undefined);\n const [\n [sourceClass, sourceRootBisClass],\n [targetClass, targetRootBisClass],\n ] = await Promise.all([\n this.getAbstractConstraintClass(ecclass.source).then(\n async (constraintClass) => [\n constraintClass,\n await this.getRootBisClass(constraintClass),\n ]\n ),\n this.getAbstractConstraintClass(ecclass.target).then(\n async (constraintClass) => [\n constraintClass,\n await this.getRootBisClass(constraintClass),\n ]\n ),\n ]);\n\n if (\n sourceRootBisClass.name === \"CodeSpec\" ||\n targetRootBisClass.name === \"CodeSpec\"\n )\n return undefined;\n const sourceType =\n ECReferenceTypesCache.bisRootClassToRefType[sourceRootBisClass.name];\n const targetType =\n ECReferenceTypesCache.bisRootClassToRefType[targetRootBisClass.name];\n if (\n (!sourceType &&\n sourceRootBisClass.customAttributes?.has(\"ECDbMap.QueryView\")) ||\n (!targetType &&\n targetRootBisClass.customAttributes?.has(\"ECDbMap.QueryView\"))\n ) {\n // ECView elements are not \"real\" data and transformer does not need to process them.\n // Relationships that point to ECView elements can only be used in ECViews so the mapping is not needed.\n return undefined;\n }\n\n const makeAssertMsg = (root: ECClass, cls: ECClass) =>\n [\n `An unknown root class '${root.fullName}' was encountered while populating`,\n `the nav prop reference type cache for ${cls.fullName}.`,\n \"This is a bug.\",\n ].join(\"\\n\");\n assert(\n sourceType !== undefined,\n makeAssertMsg(sourceRootBisClass, sourceClass)\n );\n assert(\n targetType !== undefined,\n makeAssertMsg(targetRootBisClass, targetClass)\n );\n return { source: sourceType, target: targetType };\n }\n\n public getNavPropRefType(\n schemaName: string,\n className: string,\n propName: string\n ): undefined | ConcreteEntityTypes {\n if (!this._initedSchemas.has(schemaName)) throw new SchemaNotInCacheErr();\n return this._propQualifierToRefType.get([\n schemaName.toLowerCase(),\n className.toLowerCase(),\n propName.toLowerCase(),\n ]);\n }\n\n public getRelationshipEndType(\n schemaName: string,\n className: string\n ): undefined | RelTypeInfo {\n if (!this._initedSchemas.has(schemaName)) throw new SchemaNotInCacheErr();\n return this._relClassNameEndToRefTypes.get([\n schemaName.toLowerCase(),\n className.toLowerCase(),\n ]);\n }\n\n public clear() {\n this._initedSchemas.clear();\n this._propQualifierToRefType.clear();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ECReferenceTypesCache.js","sourceRoot":"","sources":["../../src/ECReferenceTypesCache.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAsE;AACtE,oDAI4B;AAC5B,gEASkC;AAClC,iCAAiC;AAEjC,2EAAwE;AAExE;;GAEG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAC5C;QACE,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC3D,CAAC;CACF;AAJD,kDAIC;AAED;;;;;;;GAOG;AACH,MAAa,qBAAqB;IAChC,uGAAuG;IAC/F,uBAAuB,GAAG,IAAI,4BAAa,EAGhD,CAAC;IACI,0BAA0B,GAAG,IAAI,4BAAa,EAGnD,CAAC;IACI,cAAc,GAAG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iVC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { DbResult, Logger, TupleKeyedMap } from \"@itwin/core-bentley\";\nimport {\n ConcreteEntityTypes,\n IModelError,\n RelTypeInfo,\n} from \"@itwin/core-common\";\nimport {\n ECClass,\n Mixin,\n RelationshipClass,\n RelationshipConstraint,\n Schema,\n SchemaKey,\n SchemaLoader,\n StrengthDirection,\n} from \"@itwin/ecschema-metadata\";\nimport * as assert from \"assert\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\n\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\n * @internal\n */\nexport class SchemaNotInCacheErr extends Error {\n public constructor() {\n super(\"Schema was not in cache, initialize that schema\");\n }\n}\n\n/**\n * A cache of the entity types referenced by navprops in ecchemas, as well as the source and target entity types of\n * The transformer needs the referenced type to determine how to resolve references.\n *\n * Using multiple of these usually performs redundant computation, for static schemas at least. A possible future optimization\n * would be to seed the computation from a global cache of non-dynamic schemas, but dynamic schemas can collide willy-nilly\n * @internal\n */\nexport class ECReferenceTypesCache {\n /** nesting based tuple map keyed by qualified property path tuple [schemaName, className, propName] */\n private _propQualifierToRefType = new TupleKeyedMap<\n [string, string, string],\n ConcreteEntityTypes\n >();\n private _relClassNameEndToRefTypes = new TupleKeyedMap<\n [string, string],\n RelTypeInfo\n >();\n private _initedSchemas = new Map<string, SchemaKey>();\n\n // Performance optimization caches\n private _rootBisClassCache = new Map<string, ECClass>();\n private _relationshipInfoCache = new Map<string, RelTypeInfo | undefined>();\n private _constraintClassCache = new Map<string, ECClass>();\n\n private static bisRootClassToRefType: Record<\n string,\n ConcreteEntityTypes | undefined\n > = {\n /* eslint-disable quote-props, @typescript-eslint/naming-convention */\n Element: ConcreteEntityTypes.Element,\n Model: ConcreteEntityTypes.Model,\n ElementAspect: ConcreteEntityTypes.ElementAspect,\n ElementRefersToElements: ConcreteEntityTypes.Relationship,\n ElementDrivesElement: ConcreteEntityTypes.Relationship,\n // code spec is technically a potential root class but it is ignored currently\n // see [ConcreteEntityTypes]($common)\n /* eslint-enable quote-props, @typescript-eslint/naming-convention */\n };\n\n private async getRootBisClass(ecclass: ECClass) {\n const cacheKey = ecclass.fullName;\n const cached = this._rootBisClassCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n let bisRootForConstraint: ECClass = ecclass;\n await ecclass.traverseBaseClasses((baseClass) => {\n // The depth first traversal will descend all the way to the root class before making any lateral traversal\n // of mixin hierarchies, (or if the constraint is a mixin, it will traverse to the root of the mixin hierarchy)\n // Once we see that we've moved laterally, we can terminate early\n const isFirstTest = bisRootForConstraint === ecclass;\n const traversalSwitchedRootPath =\n baseClass.name !== bisRootForConstraint.baseClass?.name;\n const stillTraversingRootPath = isFirstTest || !traversalSwitchedRootPath;\n if (!stillTraversingRootPath) return true; // stop traversal early\n bisRootForConstraint = baseClass;\n return false;\n });\n // if the root class of the constraint was a mixin, use its AppliesToEntityClass\n if (bisRootForConstraint instanceof Mixin) {\n assert(\n bisRootForConstraint.appliesTo !== undefined,\n \"The referenced AppliesToEntityClass could not be found, how did it pass schema validation?\"\n );\n bisRootForConstraint = await this.getRootBisClass(\n await bisRootForConstraint.appliesTo\n );\n }\n\n this._rootBisClassCache.set(cacheKey, bisRootForConstraint);\n return bisRootForConstraint;\n }\n\n private async getAbstractConstraintClass(\n constraint: RelationshipConstraint\n ): Promise<ECClass> {\n const cacheKey = `${constraint.fullName}_${constraint.constraintClasses?.[0]?.fullName || \"abstract\"}`;\n const cached = this._constraintClassCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n // constraint classes must share a base so we can get the root from any of them, just use the first\n const ecclass = await (constraint.constraintClasses?.[0] ||\n constraint.abstractConstraint);\n assert(\n ecclass !== undefined,\n \"At least one constraint class or an abstract constraint must have been defined, the constraint is not valid\"\n );\n\n this._constraintClassCache.set(cacheKey, ecclass);\n return ecclass;\n }\n\n /** initialize from an imodel with metadata */\n public async initAllSchemasInIModel(imodel: IModelDb): Promise<void> {\n let totalSchemaCount = 0;\n let schemaCompletedCount = 0;\n\n const initStartTime = performance.now();\n\n const query = `\n WITH RECURSIVE refs(SchemaId) AS (\n SELECT ECInstanceId FROM ECDbMeta.ECSchemaDef WHERE Name='BisCore'\n UNION ALL\n SELECT sr.SourceECInstanceId\n FROM ECDbMeta.SchemaHasSchemaReferences sr\n JOIN refs ON sr.TargetECInstanceId = refs.SchemaId\n )\n SELECT DISTINCT s.Name as name\n FROM refs\n JOIN ECDbMeta.ECSchemaDef s ON refs.SchemaId=s.ECInstanceId\n -- ensure schema dependency order\n ORDER BY s.ECInstanceId\n `;\n\n for await (const row of imodel.createQueryReader(query)) {\n const schemaName = row.name;\n const startTime = performance.now();\n Logger.logInfo(\n TransformerLoggerCategory.ECReferenceTypesCache,\n `Loading schema: ${schemaName}`\n );\n const schemaItemKey = new SchemaKey(schemaName);\n const schema = await imodel.schemaContext.getSchema(schemaItemKey);\n if (schema) {\n await this.considerInitSchema(schema);\n const endTime = performance.now();\n Logger.logInfo(\n TransformerLoggerCategory.ECReferenceTypesCache,\n `Completed schema: ${schemaName} in ${(endTime - startTime).toFixed(2)}ms`\n );\n schemaCompletedCount++;\n } else {\n Logger.logInfo(\n TransformerLoggerCategory.ECReferenceTypesCache,\n `Did not load schema: ${schemaName}`\n );\n }\n\n totalSchemaCount++;\n }\n\n const initEndTime = performance.now();\n Logger.logInfo(\n TransformerLoggerCategory.ECReferenceTypesCache,\n `Schemas completed out of total: ${schemaCompletedCount} / ${totalSchemaCount} in ${(initEndTime - initStartTime).toFixed(2)}ms`\n );\n }\n\n private async considerInitSchema(schema: Schema): Promise<void> {\n if (this._initedSchemas.has(schema.name)) {\n const cachedSchemaKey = this._initedSchemas.get(schema.name);\n assert(cachedSchemaKey !== undefined);\n const incomingSchemaIsEqualOrOlder =\n schema.schemaKey.compareByVersion(cachedSchemaKey) <= 0;\n if (incomingSchemaIsEqualOrOlder) {\n return;\n }\n }\n return this.initSchema(schema);\n }\n\n private async initSchema(schema: Schema): Promise<void> {\n const schemaNameLower = schema.name.toLowerCase();\n\n // Pre-collect all items to reduce iterator overhead\n const allItems = Array.from(schema.getItems());\n const ecClasses: ECClass[] = [];\n const relationshipClasses: RelationshipClass[] = [];\n\n // Single pass through items with type checking\n for (const item of allItems) {\n // eslint-disable-next-line @itwin/no-internal\n if (!ECClass.isECClass(item)) continue;\n ecClasses.push(item);\n if (item instanceof RelationshipClass) {\n relationshipClasses.push(item);\n }\n }\n\n // Process relationship classes in parallel and populate global cache\n const relInfoPromises = relationshipClasses.map(async (relClass) => {\n const relInfo = await this.relInfoFromRelClass(relClass);\n this._relationshipInfoCache.set(relClass.fullName, relInfo);\n if (relInfo) {\n this._relClassNameEndToRefTypes.set(\n [schemaNameLower, relClass.name.toLowerCase()],\n relInfo\n );\n }\n return relInfo;\n });\n\n // Wait for all relationship info to be cached\n await Promise.all(relInfoPromises);\n\n // Process navigation properties with optimized batching\n const propertyBatchSize = 25;\n for (let i = 0; i < ecClasses.length; i += propertyBatchSize) {\n const classBatch = ecClasses.slice(i, i + propertyBatchSize);\n\n const classPromises = classBatch.map(async (ecclass) => {\n const properties = await ecclass.getProperties();\n if (!properties) return;\n\n const classNameLower = ecclass.name.toLowerCase();\n\n // Efficiently filter navigation properties\n const navProps = Array.from(properties).filter((prop) =>\n prop.isNavigation()\n );\n if (navProps.length === 0) return;\n\n const navPropPromises = navProps.map(async (prop) => {\n const relClass = await prop.relationshipClass;\n\n // Use cached relation info\n let relInfo = this._relationshipInfoCache.get(relClass.fullName);\n if (\n relInfo === undefined &&\n !this._relationshipInfoCache.has(relClass.fullName)\n ) {\n relInfo = await this.relInfoFromRelClass(relClass);\n this._relationshipInfoCache.set(relClass.fullName, relInfo);\n }\n\n if (relInfo === undefined) return;\n\n const navPropRefType =\n prop.direction === StrengthDirection.Forward\n ? // eslint-disable-next-line @itwin/no-internal\n relInfo.target\n : // eslint-disable-next-line @itwin/no-internal\n relInfo.source;\n\n this._propQualifierToRefType.set(\n [schemaNameLower, classNameLower, prop.name.toLowerCase()],\n navPropRefType\n );\n });\n\n await Promise.all(navPropPromises);\n });\n\n await Promise.all(classPromises);\n }\n\n this._initedSchemas.set(schema.name, schema.schemaKey);\n }\n\n private async relInfoFromRelClass(\n ecclass: RelationshipClass\n ): Promise<RelTypeInfo | undefined> {\n assert(ecclass.source.constraintClasses !== undefined);\n assert(ecclass.target.constraintClasses !== undefined);\n const [\n [sourceClass, sourceRootBisClass],\n [targetClass, targetRootBisClass],\n ] = await Promise.all([\n this.getAbstractConstraintClass(ecclass.source).then(\n async (constraintClass) => [\n constraintClass,\n await this.getRootBisClass(constraintClass),\n ]\n ),\n this.getAbstractConstraintClass(ecclass.target).then(\n async (constraintClass) => [\n constraintClass,\n await this.getRootBisClass(constraintClass),\n ]\n ),\n ]);\n\n if (\n sourceRootBisClass.name === \"CodeSpec\" ||\n targetRootBisClass.name === \"CodeSpec\"\n )\n return undefined;\n const sourceType =\n ECReferenceTypesCache.bisRootClassToRefType[sourceRootBisClass.name];\n const targetType =\n ECReferenceTypesCache.bisRootClassToRefType[targetRootBisClass.name];\n if (\n (!sourceType &&\n sourceRootBisClass.customAttributes?.has(\"ECDbMap.QueryView\")) ||\n (!targetType &&\n targetRootBisClass.customAttributes?.has(\"ECDbMap.QueryView\"))\n ) {\n // ECView elements are not \"real\" data and transformer does not need to process them.\n // Relationships that point to ECView elements can only be used in ECViews so the mapping is not needed.\n return undefined;\n }\n\n const makeAssertMsg = (root: ECClass, cls: ECClass) =>\n [\n `An unknown root class '${root.fullName}' was encountered while populating`,\n `the nav prop reference type cache for ${cls.fullName}.`,\n \"This is a bug.\",\n ].join(\"\\n\");\n assert(\n sourceType !== undefined,\n makeAssertMsg(sourceRootBisClass, sourceClass)\n );\n assert(\n targetType !== undefined,\n makeAssertMsg(targetRootBisClass, targetClass)\n );\n return { source: sourceType, target: targetType };\n }\n\n public getNavPropRefType(\n schemaName: string,\n className: string,\n propName: string\n ): undefined | ConcreteEntityTypes {\n if (!this._initedSchemas.has(schemaName)) throw new SchemaNotInCacheErr();\n return this._propQualifierToRefType.get([\n schemaName.toLowerCase(),\n className.toLowerCase(),\n propName.toLowerCase(),\n ]);\n }\n\n public getRelationshipEndType(\n schemaName: string,\n className: string\n ): undefined | RelTypeInfo {\n if (!this._initedSchemas.has(schemaName)) throw new SchemaNotInCacheErr();\n return this._relClassNameEndToRefTypes.get([\n schemaName.toLowerCase(),\n className.toLowerCase(),\n ]);\n }\n\n public clear() {\n this._initedSchemas.clear();\n this._propQualifierToRefType.clear();\n this._relClassNameEndToRefTypes.clear();\n this._rootBisClassCache.clear();\n this._relationshipInfoCache.clear();\n this._constraintClassCache.clear();\n }\n}\n"]}
|
|
@@ -22,6 +22,7 @@ export declare enum TransformerLoggerCategory {
|
|
|
22
22
|
/** The logger category used by the [IModelCloneContext]($transformer) class.
|
|
23
23
|
* @beta
|
|
24
24
|
*/
|
|
25
|
-
IModelCloneContext = "imodel-transformer.IModelCloneContext"
|
|
25
|
+
IModelCloneContext = "imodel-transformer.IModelCloneContext",
|
|
26
|
+
ECReferenceTypesCache = "imodel-transformer.ECReferenceTypesCache"
|
|
26
27
|
}
|
|
27
28
|
//# sourceMappingURL=TransformerLoggerCategory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransformerLoggerCategory.d.ts","sourceRoot":"","sources":["../../src/TransformerLoggerCategory.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;GAIG;AACH,oBAAY,yBAAyB;IACnC;;OAEG;IACH,cAAc,sCAAsC;IAEpD;;OAEG;IACH,cAAc,sCAAsC;IAEpD;;OAEG;IACH,iBAAiB,yCAAyC;IAE1D;;OAEG;IACH,kBAAkB,0CAA0C;
|
|
1
|
+
{"version":3,"file":"TransformerLoggerCategory.d.ts","sourceRoot":"","sources":["../../src/TransformerLoggerCategory.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;GAIG;AACH,oBAAY,yBAAyB;IACnC;;OAEG;IACH,cAAc,sCAAsC;IAEpD;;OAEG;IACH,cAAc,sCAAsC;IAEpD;;OAEG;IACH,iBAAiB,yCAAyC;IAE1D;;OAEG;IACH,kBAAkB,0CAA0C;IAE5D,qBAAqB,6CAA6C;CACnE"}
|
|
@@ -31,5 +31,6 @@ var TransformerLoggerCategory;
|
|
|
31
31
|
* @beta
|
|
32
32
|
*/
|
|
33
33
|
TransformerLoggerCategory["IModelCloneContext"] = "imodel-transformer.IModelCloneContext";
|
|
34
|
+
TransformerLoggerCategory["ECReferenceTypesCache"] = "imodel-transformer.ECReferenceTypesCache";
|
|
34
35
|
})(TransformerLoggerCategory || (exports.TransformerLoggerCategory = TransformerLoggerCategory = {}));
|
|
35
36
|
//# sourceMappingURL=TransformerLoggerCategory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransformerLoggerCategory.js","sourceRoot":"","sources":["../../src/TransformerLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;;GAIG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"TransformerLoggerCategory.js","sourceRoot":"","sources":["../../src/TransformerLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;;GAIG;AACH,IAAY,yBAsBX;AAtBD,WAAY,yBAAyB;IACnC;;OAEG;IACH,iFAAoD,CAAA;IAEpD;;OAEG;IACH,iFAAoD,CAAA;IAEpD;;OAEG;IACH,uFAA0D,CAAA;IAE1D;;OAEG;IACH,yFAA4D,CAAA;IAE5D,+FAAkE,CAAA;AACpE,CAAC,EAtBW,yBAAyB,yCAAzB,yBAAyB,QAsBpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\n/** Logger categories used by this package\n * @note All logger categories in this package start with the `imodel-transformer` prefix.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum TransformerLoggerCategory {\n /** The logger category used by the [IModelExporter]($transformer) class.\n * @beta\n */\n IModelExporter = \"imodel-transformer.IModelExporter\",\n\n /** The logger category used by the [IModelImporter]($transformer) class.\n * @beta\n */\n IModelImporter = \"imodel-transformer.IModelImporter\",\n\n /** The logger category used by the [IModelTransformer]($transformer) class.\n * @beta\n */\n IModelTransformer = \"imodel-transformer.IModelTransformer\",\n\n /** The logger category used by the [IModelCloneContext]($transformer) class.\n * @beta\n */\n IModelCloneContext = \"imodel-transformer.IModelCloneContext\",\n\n ECReferenceTypesCache = \"imodel-transformer.ECReferenceTypesCache\",\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/imodel-transformer",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.5",
|
|
4
4
|
"description": "API for exporting an iModel's parts and also importing them into another iModel",
|
|
5
5
|
"main": "lib/cjs/imodel-transformer.js",
|
|
6
6
|
"typings": "lib/cjs/imodel-transformer",
|