@itwin/core-backend 5.12.0-dev.6 → 5.12.0-dev.7
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 +9 -1
- package/lib/cjs/ChangesetReader.d.ts +65 -23
- package/lib/cjs/ChangesetReader.d.ts.map +1 -1
- package/lib/cjs/ChangesetReader.js +162 -102
- package/lib/cjs/ChangesetReader.js.map +1 -1
- package/lib/cjs/ECDb.js +2 -2
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/IModelDb.js +2 -2
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/esm/ChangesetReader.d.ts +65 -23
- package/lib/esm/ChangesetReader.d.ts.map +1 -1
- package/lib/esm/ChangesetReader.js +163 -103
- package/lib/esm/ChangesetReader.js.map +1 -1
- package/lib/esm/ECDb.js +2 -2
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/IModelDb.js +2 -2
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +4 -4
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +725 -110
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/package.json +14 -14
|
@@ -24,14 +24,29 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
24
24
|
private static readonly defaultSpillThresholdInBytes;
|
|
25
25
|
private readonly _nativeReader;
|
|
26
26
|
private _rowOptions?;
|
|
27
|
+
private _batchSizeOverride?;
|
|
27
28
|
private _propFilter;
|
|
28
29
|
private _changeIndex;
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
/** Rows fetched in the most recent native batch call. */
|
|
31
|
+
private _cache;
|
|
32
|
+
/**
|
|
33
|
+
* Index of the current row in `_cache`.
|
|
34
|
+
* Equals `_cache.length` (i.e. out-of-bounds) when no row is active:
|
|
35
|
+
* initial state, after exhaustion, or after close().
|
|
36
|
+
*/
|
|
37
|
+
private _cacheIndex;
|
|
38
|
+
/** Cached result of the `inserted` getter for the current row. `undefined` when not yet computed or not applicable. */
|
|
39
|
+
private _cachedInserted;
|
|
40
|
+
/** Cached result of the `deleted` getter for the current row. `undefined` when not yet computed or not applicable. */
|
|
41
|
+
private _cachedDeleted;
|
|
33
42
|
/** The db used for EC schema resolution. */
|
|
34
43
|
readonly db: AnyDb;
|
|
44
|
+
/** Returns the active cached row, throwing if no row is current.
|
|
45
|
+
* @internal */
|
|
46
|
+
private get _currentRow();
|
|
47
|
+
/** Returns the batch size to use for native step() calls based on the active property filter.
|
|
48
|
+
* @internal */
|
|
49
|
+
private get _batchSize();
|
|
35
50
|
/**
|
|
36
51
|
* `true` when the current row belongs to an EC-mapped table.
|
|
37
52
|
* Valid only after a successful call to [[step]].
|
|
@@ -54,17 +69,21 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
54
69
|
*/
|
|
55
70
|
get isIndirectChange(): boolean;
|
|
56
71
|
/**
|
|
57
|
-
* Post-change (inserted or updated-new) EC instance,
|
|
72
|
+
* Post-change (inserted or updated-new) EC instance, computed lazily after each [[step]] call.
|
|
58
73
|
* `undefined` when the current row is a Delete or a non-EC table row or [[step]] returned false.
|
|
74
|
+
* For UPDATE,inserted instances indicate the new state of the instance after the change has been applied and
|
|
75
|
+
* deleted instances indicate the old state of the instance before the change has been applied.
|
|
76
|
+
* For INSERT, inserted instances indicate the new state of the instance after the change has been applied and deleted instances are undefined.
|
|
77
|
+
* For DELETE, deleted instances indicate the old state of the instance before the change has been applied and inserted instances are undefined.
|
|
59
78
|
* @beta
|
|
60
79
|
*/
|
|
61
|
-
inserted
|
|
80
|
+
get inserted(): ChangeInstance | undefined;
|
|
62
81
|
/**
|
|
63
|
-
* Pre-change (deleted or updated-old) EC instance,
|
|
82
|
+
* Pre-change (deleted or updated-old) EC instance, computed lazily after each [[step]] call.
|
|
64
83
|
* `undefined` when the current row is an Insert or a non-EC table row or [[step]] returned false.
|
|
65
84
|
* @beta
|
|
66
85
|
*/
|
|
67
|
-
deleted
|
|
86
|
+
get deleted(): ChangeInstance | undefined;
|
|
68
87
|
private constructor();
|
|
69
88
|
/** Map public RowFormatOptions to the native adaptor options.
|
|
70
89
|
* @internal */
|
|
@@ -73,8 +92,8 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
73
92
|
* Open a changeset file from disk.
|
|
74
93
|
* @param args.fileName Absolute path to the changeset file.
|
|
75
94
|
* @param args.db Database at or after the changeset's ending state, used for schema resolution.
|
|
76
|
-
* @param args.invert When `true`, invert all operations (Insert↔Delete).
|
|
77
|
-
* @param args.
|
|
95
|
+
* @param args.invert When `true`, invert all operations (Insert↔Delete, New↔Old).
|
|
96
|
+
* @param args.rowOptions Row adaptor options controlling how EC property values are formatted.
|
|
78
97
|
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
79
98
|
* @throws if the native layer fails to open the file.
|
|
80
99
|
* @beta
|
|
@@ -86,7 +105,8 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
86
105
|
* Concatenate multiple changeset files and read them as a single logical stream.
|
|
87
106
|
* @param args.changesetFiles Ordered list of changeset file paths.
|
|
88
107
|
* @param args.db Database with schema at or ahead of the last changeset.
|
|
89
|
-
* @param args.
|
|
108
|
+
* @param args.invert When `true`, invert all operations (Insert↔Delete, New↔Old).
|
|
109
|
+
* @param args.rowOptions Row adaptor options controlling how EC property values are formatted.
|
|
90
110
|
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
91
111
|
* @param args.spillThresholdInBytes When the total size of the changeset data in the change group exceeds this threshold (in bytes),
|
|
92
112
|
* the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
|
|
@@ -104,7 +124,8 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
104
124
|
* Read pending (not yet pushed) local changes from an open IModelDb.
|
|
105
125
|
* @param args.db Must be an [IModelDb]($backend) (not [ECDb]($backend)).
|
|
106
126
|
* @param args.includeInMemoryChanges Also include in-memory (not yet saved to disk) changes.
|
|
107
|
-
* @param args.
|
|
127
|
+
* @param args.invert When `true`, invert all operations (Insert↔Delete, New↔Old).
|
|
128
|
+
* @param args.rowOptions Row adaptor options controlling how EC property values are formatted.
|
|
108
129
|
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
109
130
|
* @param args.spillThresholdInBytes When the total size of all local un-pushed saved changes exceeds this threshold (in bytes),
|
|
110
131
|
* the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
|
|
@@ -122,7 +143,8 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
122
143
|
/**
|
|
123
144
|
* Read the in-memory (not yet saved to disk) changes of an open IModelDb.
|
|
124
145
|
* @param args.db Must be an [IModelDb]($backend).
|
|
125
|
-
* @param args.
|
|
146
|
+
* @param args.invert When `true`, invert all operations (Insert↔Delete, New↔Old).
|
|
147
|
+
* @param args.rowOptions Row adaptor options controlling how EC property values are formatted.
|
|
126
148
|
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
127
149
|
* @param args.spillThresholdInBytes When the total size of the in-memory (unsaved) change data exceeds this threshold (in bytes),
|
|
128
150
|
* the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
|
|
@@ -139,7 +161,8 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
139
161
|
* Read a single saved transaction by its id.
|
|
140
162
|
* @param args.db Must be an [IModelDb]($backend) ([ECDb]($backend) does not support transactions).
|
|
141
163
|
* @param args.txnId The id of the saved transaction to read.
|
|
142
|
-
* @param args.
|
|
164
|
+
* @param args.invert When `true`, invert all operations (Insert↔Delete, New↔Old).
|
|
165
|
+
* @param args.rowOptions Row adaptor options controlling how EC property values are formatted.
|
|
143
166
|
* @param args.propFilter Controls which properties are included. Defaults to `All`.
|
|
144
167
|
* @param args.spillThresholdInBytes When the total size of the transaction's change data exceeds this threshold (in bytes),
|
|
145
168
|
* the reader writes the data to a temporary file on disk and streams it from there instead of buffering everything in memory.
|
|
@@ -154,14 +177,33 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
154
177
|
txnId: Id64String;
|
|
155
178
|
spillThresholdInBytes?: number;
|
|
156
179
|
}): ChangesetReader;
|
|
180
|
+
/** Throws if [[step]] has already been called, preventing filter/mode changes mid-iteration.
|
|
181
|
+
* @internal */
|
|
182
|
+
private throwIfAlreadyStepped;
|
|
157
183
|
/** Handle errors that occur while auto closing the reader if there is also an error while opening the reader */
|
|
158
184
|
private handleCloseErrorWhileOpening;
|
|
185
|
+
/**
|
|
186
|
+
* Set the number of rows to fetch and cache while stepping.
|
|
187
|
+
* This is an advanced option that can be used to tune performance for large changesets.
|
|
188
|
+
* Increasing the batch size improves throughput at the cost of higher peak memory; decreasing it keeps memory consumption lower.
|
|
189
|
+
*
|
|
190
|
+
* Default batch sizes when `setBatchSize` is not called:
|
|
191
|
+
* - `InstanceKey` filter: **100**.
|
|
192
|
+
* - `BisCoreElement` filter (any `abbreviateBlobs` setting): **20**.
|
|
193
|
+
* - `All` filter, `abbreviateBlobs: false`: **5**.
|
|
194
|
+
* - `All` filter (blobs abbreviated or unset): **10**.
|
|
195
|
+
*
|
|
196
|
+
* @param batchSize Number of rows to fetch and cache while stepping. Must be a positive integer.
|
|
197
|
+
* @throws [[IModelError]] if [[step]] has already been called successfully, or if `batchSize` is not a positive integer.
|
|
198
|
+
* @beta
|
|
199
|
+
*/
|
|
200
|
+
setBatchSize(batchSize: number): void;
|
|
159
201
|
/**
|
|
160
202
|
* Restrict iteration to changes from the named SQLite tables.
|
|
161
203
|
* That means the rows for changes from other tables will be skipped entirely and won't be visible through the reader.
|
|
162
204
|
* @param tableNames SQLite table names to include.
|
|
163
205
|
* Note: Table names must be provided in the correct case for proper filtering.
|
|
164
|
-
* @throws if the native layer encounters an error while setting the filter.
|
|
206
|
+
* @throws if [[step]] has already been called and the reader successfully stepped at least once(i.e. returned true for a step() call) or if the native layer encounters an error while setting the filter.
|
|
165
207
|
* @beta
|
|
166
208
|
*/
|
|
167
209
|
setTableNameFilters(tableNames: Set<string>): void;
|
|
@@ -169,7 +211,7 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
169
211
|
* Restrict iteration to changes with the given operation types.
|
|
170
212
|
* That means the rows for changes with other operation types will be skipped entirely and won't be visible through the reader.
|
|
171
213
|
* @param ops Operations to include.
|
|
172
|
-
* @throws if the native layer encounters an error while setting the filter.
|
|
214
|
+
* @throws if [[step]] has already been called and the reader successfully stepped at least once(i.e. returned true for a step() call) or if the native layer encounters an error while setting the filter.
|
|
173
215
|
* @beta
|
|
174
216
|
*/
|
|
175
217
|
setOpCodeFilters(ops: Set<SqliteChangeOp>): void;
|
|
@@ -178,25 +220,25 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
178
220
|
* That means the rows for changes from other EC classes will be skipped entirely and won't be visible through the reader.
|
|
179
221
|
* @param classNames EC class names to include. The classNames should be in the full name format(i.e. "SchemaName:ClassName").
|
|
180
222
|
* Note: Schema names and class names must be provided in the correct case for proper filtering. Derived classes are not automatically included, so they must be specified explicitly if needed.
|
|
181
|
-
* @throws if the native layer encounters an error while setting the filter.
|
|
223
|
+
* @throws if [[step]] has already been called and the reader successfully stepped at least once(i.e. returned true for a step() call) or if the native layer encounters an error while setting the filter.
|
|
182
224
|
* @beta
|
|
183
225
|
*/
|
|
184
226
|
setClassNameFilters(classNames: Set<string>): void;
|
|
185
227
|
/**
|
|
186
228
|
* Remove the table-name filters
|
|
187
|
-
* @throws if the native layer encounters an error.
|
|
229
|
+
* @throws if [[step]] has already been called and the reader successfully stepped at least once(i.e. returned true for a step() call) or if the native layer encounters an error.
|
|
188
230
|
* @beta
|
|
189
231
|
*/
|
|
190
232
|
clearTableNameFilters(): void;
|
|
191
233
|
/**
|
|
192
234
|
* Remove the op-code filters
|
|
193
|
-
* @throws if the native layer encounters an error.
|
|
235
|
+
* @throws if [[step]] has already been called and the reader successfully stepped at least once(i.e. returned true for a step() call) or if the native layer encounters an error.
|
|
194
236
|
* @beta
|
|
195
237
|
*/
|
|
196
238
|
clearOpCodeFilters(): void;
|
|
197
239
|
/**
|
|
198
240
|
* Remove the class-name filters
|
|
199
|
-
* @throws if the native layer encounters an error.
|
|
241
|
+
* @throws if [[step]] has already been called and the reader successfully stepped at least once(i.e. returned true for a step() call) or if the native layer encounters an error.
|
|
200
242
|
* @beta
|
|
201
243
|
*/
|
|
202
244
|
clearClassNameFilters(): void;
|
|
@@ -215,7 +257,7 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
215
257
|
* exactly the schema that was in effect when the changeset was written.
|
|
216
258
|
*
|
|
217
259
|
* @see [[disableStrictMode]] — the default (lenient) behaviour.
|
|
218
|
-
* @throws if the native layer encounters an error.
|
|
260
|
+
* @throws if [[step]] has already been called and the reader successfully stepped at least once(i.e. returned true for a step() call) or if the native layer encounters an error.
|
|
219
261
|
* @beta
|
|
220
262
|
*/
|
|
221
263
|
enableStrictMode(): void;
|
|
@@ -230,12 +272,12 @@ export declare class ChangesetReader implements Disposable, ChangeSource {
|
|
|
230
272
|
* missing columns are silently ignored.
|
|
231
273
|
*
|
|
232
274
|
* @see [[enableStrictMode]] — throw on column-count mismatches instead.
|
|
233
|
-
* @throws if the native layer encounters an error.
|
|
275
|
+
* @throws if [[step]] has already been called and the reader successfully stepped at least once(i.e. returned true for a step() call) or if the native layer encounters an error.
|
|
234
276
|
* @beta
|
|
235
277
|
*/
|
|
236
278
|
disableStrictMode(): void;
|
|
237
279
|
/**
|
|
238
|
-
* Advance to the next change
|
|
280
|
+
* Advance to the next change.
|
|
239
281
|
* @returns `true` while positioned on a valid change; `false` when the stream is exhausted.
|
|
240
282
|
* @throws if the native layer encounters an error while reading or decoding
|
|
241
283
|
* the next change.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangesetReader.d.ts","sourceRoot":"","sources":["../../src/ChangesetReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"ChangesetReader.d.ts","sourceRoot":"","sources":["../../src/ChangesetReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAY,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAoC,MAAM,wBAAwB,CAAC;AAC7H,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOhE;;;;;;;;;;;;;;GAcG;AACH,qBAAa,eAAgB,YAAW,UAAU,EAAE,YAAY;IAC9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAoB;IACxE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA+E;IAE7G,OAAO,CAAC,WAAW,CAAC,CAAmB;IACvC,OAAO,CAAC,kBAAkB,CAAC,CAAS;IACpC,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,YAAY,CAAK;IACzB,yDAAyD;IACzD,OAAO,CAAC,MAAM,CAAyC;IACvD;;;;OAIG;IACH,OAAO,CAAC,WAAW,CAAK;IACxB,uHAAuH;IACvH,OAAO,CAAC,eAAe,CAAyC;IAChE,sHAAsH;IACtH,OAAO,CAAC,cAAc,CAAyC;IAE/D,4CAA4C;IAC5C,SAAgB,EAAE,EAAE,KAAK,CAAC;IAE1B;mBACe;IACf,OAAO,KAAK,WAAW,GAItB;IAED;mBACe;IACf,OAAO,KAAK,UAAU,GAMrB;IAED;;;;;OAKG;IACH,IAAW,SAAS,IAAI,OAAO,CAAgD;IAE/E;;;;;OAKG;IACH,IAAW,SAAS,IAAI,MAAM,CAAgD;IAE9E;;;;;OAKG;IACH,IAAW,gB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