@fluidframework/container-runtime 2.0.0-internal.5.4.2 → 2.0.0-internal.6.0.1
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 +71 -0
- package/dist/batchTracker.d.ts +2 -1
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.d.ts +4 -1
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +61 -26
- package/dist/blobManager.js.map +1 -1
- package/dist/connectionTelemetry.js +10 -2
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/containerRuntime.d.ts +26 -11
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +177 -123
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.js +8 -2
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.js +23 -24
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +20 -4
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +107 -53
- package/dist/dataStores.js.map +1 -1
- package/dist/gc/garbageCollection.js +17 -20
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.js +13 -11
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcHelpers.js +4 -6
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcSummaryStateTracker.js +4 -6
- package/dist/gc/gcSummaryStateTracker.js.map +1 -1
- package/dist/gc/gcTelemetry.d.ts.map +1 -1
- package/dist/gc/gcTelemetry.js +55 -37
- package/dist/gc/gcTelemetry.js.map +1 -1
- package/dist/id-compressor/idCompressor.js +49 -51
- package/dist/id-compressor/idCompressor.js.map +1 -1
- package/dist/id-compressor/idRange.js +2 -2
- package/dist/id-compressor/idRange.js.map +1 -1
- package/dist/id-compressor/sessionIdNormalizer.js +11 -16
- package/dist/id-compressor/sessionIdNormalizer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/opLifecycle/batchManager.js +10 -6
- package/dist/opLifecycle/batchManager.js.map +1 -1
- package/dist/opLifecycle/opCompressor.js +6 -1
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +11 -9
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opGroupingManager.js +13 -5
- package/dist/opLifecycle/opGroupingManager.js.map +1 -1
- package/dist/opLifecycle/opSplitter.js +10 -6
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.js +1 -2
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/opProperties.js +1 -2
- package/dist/opProperties.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +2 -2
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +22 -22
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/scheduleManager.js +14 -10
- package/dist/scheduleManager.js.map +1 -1
- package/dist/summary/orderedClientElection.d.ts +2 -1
- package/dist/summary/orderedClientElection.d.ts.map +1 -1
- package/dist/summary/orderedClientElection.js +17 -18
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/dist/summary/runningSummarizer.js +32 -38
- package/dist/summary/runningSummarizer.js.map +1 -1
- package/dist/summary/summarizer.js +4 -7
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerClientElection.js +5 -9
- package/dist/summary/summarizerClientElection.js.map +1 -1
- package/dist/summary/summarizerHeuristics.js +8 -12
- package/dist/summary/summarizerHeuristics.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNode.js +22 -15
- package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeUtils.js +2 -4
- package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeWithGc.js +17 -16
- package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/dist/summary/summaryCollection.js +3 -5
- package/dist/summary/summaryCollection.js.map +1 -1
- package/dist/summary/summaryFormat.js +1 -2
- package/dist/summary/summaryFormat.js.map +1 -1
- package/dist/summary/summaryGenerator.js +62 -20
- package/dist/summary/summaryGenerator.js.map +1 -1
- package/dist/summary/summaryManager.js +3 -5
- package/dist/summary/summaryManager.js.map +1 -1
- package/lib/batchTracker.d.ts +2 -1
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.d.ts +4 -1
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +61 -26
- package/lib/blobManager.js.map +1 -1
- package/lib/connectionTelemetry.js +10 -2
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/containerRuntime.d.ts +26 -11
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +177 -123
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.js +8 -2
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.js +23 -24
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +20 -4
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +107 -53
- package/lib/dataStores.js.map +1 -1
- package/lib/gc/garbageCollection.js +17 -20
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.js +13 -11
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcHelpers.js +4 -6
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcSummaryStateTracker.js +4 -6
- package/lib/gc/gcSummaryStateTracker.js.map +1 -1
- package/lib/gc/gcTelemetry.d.ts.map +1 -1
- package/lib/gc/gcTelemetry.js +55 -37
- package/lib/gc/gcTelemetry.js.map +1 -1
- package/lib/id-compressor/idCompressor.js +49 -51
- package/lib/id-compressor/idCompressor.js.map +1 -1
- package/lib/id-compressor/idRange.js +2 -2
- package/lib/id-compressor/idRange.js.map +1 -1
- package/lib/id-compressor/sessionIdNormalizer.js +11 -16
- package/lib/id-compressor/sessionIdNormalizer.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/opLifecycle/batchManager.js +10 -6
- package/lib/opLifecycle/batchManager.js.map +1 -1
- package/lib/opLifecycle/opCompressor.js +6 -1
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +11 -9
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opGroupingManager.js +13 -5
- package/lib/opLifecycle/opGroupingManager.js.map +1 -1
- package/lib/opLifecycle/opSplitter.js +10 -6
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.js +1 -2
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/opProperties.js +1 -2
- package/lib/opProperties.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +2 -2
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +22 -22
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/scheduleManager.js +14 -10
- package/lib/scheduleManager.js.map +1 -1
- package/lib/summary/orderedClientElection.d.ts +2 -1
- package/lib/summary/orderedClientElection.d.ts.map +1 -1
- package/lib/summary/orderedClientElection.js +17 -18
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/lib/summary/runningSummarizer.js +32 -38
- package/lib/summary/runningSummarizer.js.map +1 -1
- package/lib/summary/summarizer.js +4 -7
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerClientElection.js +5 -9
- package/lib/summary/summarizerClientElection.js.map +1 -1
- package/lib/summary/summarizerHeuristics.js +8 -12
- package/lib/summary/summarizerHeuristics.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNode.js +22 -15
- package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeUtils.js +2 -4
- package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeWithGc.js +17 -16
- package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/lib/summary/summaryCollection.js +3 -5
- package/lib/summary/summaryCollection.js.map +1 -1
- package/lib/summary/summaryFormat.js +1 -2
- package/lib/summary/summaryFormat.js.map +1 -1
- package/lib/summary/summaryGenerator.js +62 -20
- package/lib/summary/summaryGenerator.js.map +1 -1
- package/lib/summary/summaryManager.js +3 -5
- package/lib/summary/summaryManager.js.map +1 -1
- package/package.json +17 -17
- package/src/batchTracker.ts +2 -1
- package/src/blobManager.ts +43 -2
- package/src/containerRuntime.ts +74 -51
- package/src/dataStore.ts +7 -1
- package/src/dataStores.ts +95 -55
- package/src/gc/gcTelemetry.ts +1 -2
- package/src/index.ts +0 -1
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +12 -15
- package/src/summary/orderedClientElection.ts +2 -1
|
@@ -145,9 +145,8 @@ export class IdCompressor {
|
|
|
145
145
|
* it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.
|
|
146
146
|
*/
|
|
147
147
|
takeNextCreationRange() {
|
|
148
|
-
var _a;
|
|
149
148
|
const lastLocalInRange = -this.localIdCount;
|
|
150
|
-
const lastTakenNormalized =
|
|
149
|
+
const lastTakenNormalized = this.lastTakenLocalId ?? 0;
|
|
151
150
|
assert(lastLocalInRange <= lastTakenNormalized, 0x485 /* Inconsistent local ID state */);
|
|
152
151
|
let ids;
|
|
153
152
|
if (lastLocalInRange !== lastTakenNormalized) {
|
|
@@ -190,21 +189,20 @@ export class IdCompressor {
|
|
|
190
189
|
* @param range - the range of session-local IDs to finalize.
|
|
191
190
|
*/
|
|
192
191
|
finalizeCreationRange(range) {
|
|
193
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
194
192
|
const { sessionId } = range;
|
|
195
193
|
const isLocal = sessionId === this.localSessionId;
|
|
196
|
-
const session =
|
|
194
|
+
const session = this.sessions.get(sessionId) ?? this.createSession(sessionId);
|
|
197
195
|
const ids = getIds(range);
|
|
198
196
|
if (ids === undefined) {
|
|
199
197
|
return;
|
|
200
198
|
}
|
|
201
199
|
const { currentClusterDetails } = session;
|
|
202
|
-
const { cluster: currentCluster, clusterBase: currentBaseFinalId } = currentClusterDetails
|
|
200
|
+
const { cluster: currentCluster, clusterBase: currentBaseFinalId } = currentClusterDetails ?? {
|
|
203
201
|
cluster: undefined,
|
|
204
202
|
clusterBase: undefined,
|
|
205
203
|
};
|
|
206
204
|
const currentClusterExists = currentCluster !== undefined && currentBaseFinalId !== undefined;
|
|
207
|
-
const normalizedLastFinalizedLocal =
|
|
205
|
+
const normalizedLastFinalizedLocal = session.lastFinalizedLocalId ?? 0;
|
|
208
206
|
const { first: newFirstFinalizedLocal, last: newLastFinalizedLocal } = ids;
|
|
209
207
|
assert(newFirstFinalizedLocal === normalizedLastFinalizedLocal - 1, 0x489 /* Ranges finalized out of order. */);
|
|
210
208
|
// The total number of session-local IDs to finalize
|
|
@@ -216,7 +214,8 @@ export class IdCompressor {
|
|
|
216
214
|
let newBaseUuid;
|
|
217
215
|
if (currentClusterExists) {
|
|
218
216
|
if (isLocal) {
|
|
219
|
-
const lastKnownFinal =
|
|
217
|
+
const lastKnownFinal = this.sessionIdNormalizer.getLastFinalId() ??
|
|
218
|
+
fail("Cluster exists but normalizer does not have an entry for it.");
|
|
220
219
|
const lastAlignedFinalInCluster = (currentBaseFinalId +
|
|
221
220
|
Math.min(currentCluster.count + finalizeCount, currentCluster.capacity) -
|
|
222
221
|
1);
|
|
@@ -267,7 +266,7 @@ export class IdCompressor {
|
|
|
267
266
|
// actually finalized, because total order broadcast guarantees that any usage of those final IDs will be observed after
|
|
268
267
|
// the finalization of the ranges.
|
|
269
268
|
this.sessionIdNormalizer.registerFinalIdBlock(finalPivot, expansionAmount, currentCluster);
|
|
270
|
-
|
|
269
|
+
this.logger?.sendTelemetryEvent({
|
|
271
270
|
eventName: "RuntimeIdCompressor:ClusterExpansion",
|
|
272
271
|
sessionId: this.localSessionId,
|
|
273
272
|
previousCapacity,
|
|
@@ -283,7 +282,7 @@ export class IdCompressor {
|
|
|
283
282
|
newBaseUuid = incrementUuid(currentCluster.baseUuid, currentCluster.capacity);
|
|
284
283
|
currentCluster.count += remainingCapacity;
|
|
285
284
|
remainingCount -= remainingCapacity;
|
|
286
|
-
|
|
285
|
+
this.logger?.sendTelemetryEvent({
|
|
287
286
|
eventName: "RuntimeIdCompressor:OverfilledCluster",
|
|
288
287
|
sessionId: this.localSessionId,
|
|
289
288
|
});
|
|
@@ -293,7 +292,7 @@ export class IdCompressor {
|
|
|
293
292
|
// Session has never made a cluster, form a new one with the session UUID as the baseUuid
|
|
294
293
|
newBaseUuid = session.sessionUuid;
|
|
295
294
|
if (isLocal) {
|
|
296
|
-
|
|
295
|
+
this.logger?.sendTelemetryEvent({
|
|
297
296
|
eventName: "RuntimeIdCompressor:FirstCluster",
|
|
298
297
|
sessionId: this.localSessionId,
|
|
299
298
|
});
|
|
@@ -328,7 +327,7 @@ export class IdCompressor {
|
|
|
328
327
|
const usedCapacity = finalizeCount - remainingCount;
|
|
329
328
|
localIdPivot = (newFirstFinalizedLocal - usedCapacity);
|
|
330
329
|
if (isLocal) {
|
|
331
|
-
|
|
330
|
+
this.logger?.sendTelemetryEvent({
|
|
332
331
|
eventName: "RuntimeIdCompressor:NewCluster",
|
|
333
332
|
sessionId: this.localSessionId,
|
|
334
333
|
clusterCapacity: newCapacity,
|
|
@@ -374,7 +373,7 @@ export class IdCompressor {
|
|
|
374
373
|
(normalizedLastFinalizedLocal - overriddenLocal) -
|
|
375
374
|
1);
|
|
376
375
|
}
|
|
377
|
-
|
|
376
|
+
cluster.overrides ?? (cluster.overrides = new Map());
|
|
378
377
|
const inversionKey = IdCompressor.createInversionKey(override);
|
|
379
378
|
const existingIds = this.getExistingIdsForNewOverride(inversionKey, true);
|
|
380
379
|
let overrideForCluster;
|
|
@@ -442,11 +441,11 @@ export class IdCompressor {
|
|
|
442
441
|
}
|
|
443
442
|
}
|
|
444
443
|
if (isLocal) {
|
|
445
|
-
|
|
444
|
+
this.logger?.sendTelemetryEvent({
|
|
446
445
|
eventName: "RuntimeIdCompressor:IdCompressorStatus",
|
|
447
|
-
eagerFinalIdCount: eagerFinalIdCount - (
|
|
448
|
-
localIdCount: remainingCount + (
|
|
449
|
-
overridesCount:
|
|
446
|
+
eagerFinalIdCount: eagerFinalIdCount - (overrides?.length ?? 0),
|
|
447
|
+
localIdCount: remainingCount + (overrides?.length ?? 0),
|
|
448
|
+
overridesCount: overrides?.length ?? 0,
|
|
450
449
|
sessionId: this.localSessionId,
|
|
451
450
|
});
|
|
452
451
|
}
|
|
@@ -491,7 +490,6 @@ export class IdCompressor {
|
|
|
491
490
|
* Returns an existing ID associated with an override, or undefined if none exists.
|
|
492
491
|
*/
|
|
493
492
|
getExistingIdsForNewOverride(inversionKey, isFinalOverride) {
|
|
494
|
-
var _a;
|
|
495
493
|
const closestMatch = this.clustersAndOverridesInversion.getPairOrNextLower(inversionKey, reusedArray);
|
|
496
494
|
let numericOverride;
|
|
497
495
|
let stableOverride;
|
|
@@ -529,7 +527,9 @@ export class IdCompressor {
|
|
|
529
527
|
}
|
|
530
528
|
}
|
|
531
529
|
}
|
|
532
|
-
const override =
|
|
530
|
+
const override = numericOverride ??
|
|
531
|
+
stableOverride ??
|
|
532
|
+
(IdCompressor.isStableInversionKey(inversionKey) ? inversionKey : undefined);
|
|
533
533
|
if (override !== undefined) {
|
|
534
534
|
const sessionSpaceId = this.getCompressedIdForStableId(override);
|
|
535
535
|
if (sessionSpaceId !== undefined) {
|
|
@@ -557,8 +557,7 @@ export class IdCompressor {
|
|
|
557
557
|
* Helper for retrieving an override.
|
|
558
558
|
*/
|
|
559
559
|
static tryGetOverride(cluster, finalId) {
|
|
560
|
-
|
|
561
|
-
const override = (_a = cluster.overrides) === null || _a === void 0 ? void 0 : _a.get(finalId);
|
|
560
|
+
const override = cluster.overrides?.get(finalId);
|
|
562
561
|
if (override === undefined) {
|
|
563
562
|
return undefined;
|
|
564
563
|
}
|
|
@@ -603,15 +602,15 @@ export class IdCompressor {
|
|
|
603
602
|
const registeredLocal = sessionIdNormalizer.addLocalId();
|
|
604
603
|
assert(registeredLocal === newLocalId, 0x496 /* Session ID Normalizer produced unexpected local ID */);
|
|
605
604
|
if (eagerFinalId !== undefined) {
|
|
606
|
-
sessionIdNormalizer.addFinalIds(eagerFinalId, eagerFinalId, cluster
|
|
605
|
+
sessionIdNormalizer.addFinalIds(eagerFinalId, eagerFinalId, cluster ?? fail("No cluster when generating compressed ID"));
|
|
607
606
|
}
|
|
608
|
-
this.localOverrides.append(newLocalId, override
|
|
607
|
+
this.localOverrides.append(newLocalId, override ?? fail("Override must be defined"));
|
|
609
608
|
// Since the local ID was just created, it is in both session and op space
|
|
610
609
|
const compressionMapping = newLocalId;
|
|
611
610
|
this.clustersAndOverridesInversion.set(overrideInversionKey, compressionMapping);
|
|
612
611
|
}
|
|
613
612
|
else if (eagerFinalId !== undefined) {
|
|
614
|
-
sessionIdNormalizer.addFinalIds(eagerFinalId, eagerFinalId, cluster
|
|
613
|
+
sessionIdNormalizer.addFinalIds(eagerFinalId, eagerFinalId, cluster ?? fail("No cluster when generating compressed ID"));
|
|
615
614
|
return eagerFinalId;
|
|
616
615
|
}
|
|
617
616
|
else {
|
|
@@ -626,8 +625,7 @@ export class IdCompressor {
|
|
|
626
625
|
* @returns the UUID or override string associated with the compressed ID. Fails if the ID was not generated by this compressor.
|
|
627
626
|
*/
|
|
628
627
|
decompress(id) {
|
|
629
|
-
|
|
630
|
-
return (_a = this.tryDecompress(id)) !== null && _a !== void 0 ? _a : fail("Compressed ID was not generated by this compressor");
|
|
628
|
+
return this.tryDecompress(id) ?? fail("Compressed ID was not generated by this compressor");
|
|
631
629
|
}
|
|
632
630
|
/**
|
|
633
631
|
* Attempts to decompress a previously compressed ID into a UUID or override string.
|
|
@@ -635,7 +633,6 @@ export class IdCompressor {
|
|
|
635
633
|
* @returns the UUID or override string associated with the compressed ID, or undefined if the ID was not generated by this compressor.
|
|
636
634
|
*/
|
|
637
635
|
tryDecompress(id) {
|
|
638
|
-
var _a;
|
|
639
636
|
if (isFinalId(id)) {
|
|
640
637
|
const possibleCluster = this.getClusterForFinalId(id);
|
|
641
638
|
if (possibleCluster === undefined) {
|
|
@@ -667,7 +664,7 @@ export class IdCompressor {
|
|
|
667
664
|
// If this is a local ID with an override, then it must have been allocated on this machine and will be contained in
|
|
668
665
|
// `localOverrides`s. Otherwise, it is a sequential allocation from the session UUID and can simply be negated and
|
|
669
666
|
// added to that UUID to obtain the stable ID associated with it.
|
|
670
|
-
const localOverride =
|
|
667
|
+
const localOverride = this.localOverrides?.get(id);
|
|
671
668
|
return localOverride !== undefined
|
|
672
669
|
? localOverride
|
|
673
670
|
: stableIdFromNumericUuid(this.localSession.sessionUuid, idOffset - 1);
|
|
@@ -679,8 +676,7 @@ export class IdCompressor {
|
|
|
679
676
|
* @returns the `CompressedId` associated with `uncompressed`. Fails if it has not been previously compressed by this compressor.
|
|
680
677
|
*/
|
|
681
678
|
recompress(uncompressed) {
|
|
682
|
-
|
|
683
|
-
return (_a = this.tryRecompress(uncompressed)) !== null && _a !== void 0 ? _a : fail("No such string has ever been compressed");
|
|
679
|
+
return this.tryRecompress(uncompressed) ?? fail("No such string has ever been compressed");
|
|
684
680
|
}
|
|
685
681
|
/**
|
|
686
682
|
* Attempts to recompresses a decompressed ID, which could be a UUID or an override string.
|
|
@@ -695,7 +691,6 @@ export class IdCompressor {
|
|
|
695
691
|
* performance optimization.
|
|
696
692
|
*/
|
|
697
693
|
recompressInternal(uncompressed, uncompressedUuidNumeric) {
|
|
698
|
-
var _a, _b;
|
|
699
694
|
let numericUuid = uncompressedUuidNumeric;
|
|
700
695
|
const inversionKey = IdCompressor.createInversionKey(uncompressed);
|
|
701
696
|
const isStable = IdCompressor.isStableInversionKey(inversionKey);
|
|
@@ -706,7 +701,8 @@ export class IdCompressor {
|
|
|
706
701
|
if (key === inversionKey) {
|
|
707
702
|
return IdCompressor.isUnfinalizedOverride(compressionMapping)
|
|
708
703
|
? compressionMapping
|
|
709
|
-
:
|
|
704
|
+
: compressionMapping.associatedLocalId ??
|
|
705
|
+
compressionMapping.originalOverridingFinal;
|
|
710
706
|
}
|
|
711
707
|
}
|
|
712
708
|
else {
|
|
@@ -714,11 +710,11 @@ export class IdCompressor {
|
|
|
714
710
|
return undefined;
|
|
715
711
|
}
|
|
716
712
|
const { clusterBase: closestBaseFinalId, cluster: closestCluster } = compressionMapping;
|
|
717
|
-
numericUuid
|
|
713
|
+
numericUuid ?? (numericUuid = numericUuidFromStableId(inversionKey));
|
|
718
714
|
const uuidOffset = getPositiveDelta(numericUuid, closestCluster.baseUuid, closestCluster.count - 1);
|
|
719
715
|
if (uuidOffset !== undefined) {
|
|
720
716
|
let targetFinalId = (closestBaseFinalId + uuidOffset);
|
|
721
|
-
const override =
|
|
717
|
+
const override = closestCluster.overrides?.get(targetFinalId);
|
|
722
718
|
if (typeof override === "object") {
|
|
723
719
|
if (override.associatedLocalId !== undefined) {
|
|
724
720
|
return override.associatedLocalId;
|
|
@@ -733,7 +729,7 @@ export class IdCompressor {
|
|
|
733
729
|
}
|
|
734
730
|
if (isStable) {
|
|
735
731
|
// May have already computed the numeric UUID, so avoid recomputing if possible
|
|
736
|
-
const sessionSpaceId = this.getCompressedIdForStableId(numericUuid
|
|
732
|
+
const sessionSpaceId = this.getCompressedIdForStableId(numericUuid ?? inversionKey);
|
|
737
733
|
if (sessionSpaceId !== undefined) {
|
|
738
734
|
return sessionSpaceId;
|
|
739
735
|
}
|
|
@@ -746,7 +742,6 @@ export class IdCompressor {
|
|
|
746
742
|
* @returns the ID in op space.
|
|
747
743
|
*/
|
|
748
744
|
normalizeToOpSpace(id) {
|
|
749
|
-
var _a, _b, _c;
|
|
750
745
|
if (isFinalId(id)) {
|
|
751
746
|
return id;
|
|
752
747
|
}
|
|
@@ -765,7 +760,8 @@ export class IdCompressor {
|
|
|
765
760
|
const override = this.localOverrides.get(id);
|
|
766
761
|
if (override !== undefined) {
|
|
767
762
|
const inversionKey = IdCompressor.createInversionKey(override);
|
|
768
|
-
const compressionMapping =
|
|
763
|
+
const compressionMapping = this.clustersAndOverridesInversion.get(inversionKey) ??
|
|
764
|
+
fail("Bimap is malformed.");
|
|
769
765
|
return !IdCompressor.isClusterInfo(compressionMapping) &&
|
|
770
766
|
!IdCompressor.isUnfinalizedOverride(compressionMapping) &&
|
|
771
767
|
compressionMapping.associatedLocalId === id
|
|
@@ -773,9 +769,10 @@ export class IdCompressor {
|
|
|
773
769
|
: id;
|
|
774
770
|
}
|
|
775
771
|
const possibleFinal = this.sessionIdNormalizer.getFinalId(id);
|
|
776
|
-
return
|
|
772
|
+
return possibleFinal?.[0] ?? id;
|
|
777
773
|
}
|
|
778
|
-
const [correspondingFinal, cluster] =
|
|
774
|
+
const [correspondingFinal, cluster] = this.sessionIdNormalizer.getFinalId(id) ??
|
|
775
|
+
fail("Locally created cluster should be added to the map when allocated");
|
|
779
776
|
if (cluster.overrides) {
|
|
780
777
|
const override = cluster.overrides.get(correspondingFinal);
|
|
781
778
|
if (typeof override === "object" && override.originalOverridingFinal !== undefined) {
|
|
@@ -786,7 +783,6 @@ export class IdCompressor {
|
|
|
786
783
|
return correspondingFinal;
|
|
787
784
|
}
|
|
788
785
|
normalizeToSessionSpace(id, sessionIdIfLocal) {
|
|
789
|
-
var _a, _b, _c, _d;
|
|
790
786
|
if (isLocalId(id)) {
|
|
791
787
|
if (sessionIdIfLocal === undefined || sessionIdIfLocal === this.localSessionId) {
|
|
792
788
|
const localIndex = -id;
|
|
@@ -796,10 +792,12 @@ export class IdCompressor {
|
|
|
796
792
|
return id;
|
|
797
793
|
}
|
|
798
794
|
else {
|
|
799
|
-
const session =
|
|
795
|
+
const session = this.sessions.get(sessionIdIfLocal) ??
|
|
796
|
+
fail("No IDs have ever been finalized by the supplied session.");
|
|
800
797
|
const localCount = -id;
|
|
801
798
|
const numericUuid = incrementUuid(session.sessionUuid, localCount - 1);
|
|
802
|
-
return (
|
|
799
|
+
return (this.compressNumericUuid(numericUuid) ??
|
|
800
|
+
fail("ID is not known to this compressor."));
|
|
803
801
|
}
|
|
804
802
|
}
|
|
805
803
|
const normalizedId = this.sessionIdNormalizer.getSessionSpaceId(id);
|
|
@@ -808,8 +806,9 @@ export class IdCompressor {
|
|
|
808
806
|
}
|
|
809
807
|
// Check for a unified override finalized first by another session but to which the local session
|
|
810
808
|
// still has an associated local ID.
|
|
811
|
-
const [_, cluster] =
|
|
812
|
-
|
|
809
|
+
const [_, cluster] = this.getClusterForFinalId(id) ??
|
|
810
|
+
fail("Supplied final ID was not finalized by this compressor.");
|
|
811
|
+
const override = cluster.overrides?.get(id);
|
|
813
812
|
if (typeof override === "object" && override.associatedLocalId !== undefined) {
|
|
814
813
|
return override.associatedLocalId;
|
|
815
814
|
}
|
|
@@ -978,7 +977,6 @@ export class IdCompressor {
|
|
|
978
977
|
return true;
|
|
979
978
|
}
|
|
980
979
|
static idClustersEqual(a, b, checkSessionData = true, compareLocalState = true) {
|
|
981
|
-
var _a, _b;
|
|
982
980
|
const areEqual = numericUuidEquals(a.baseUuid, b.baseUuid) &&
|
|
983
981
|
a.capacity === b.capacity &&
|
|
984
982
|
a.count === b.count &&
|
|
@@ -986,7 +984,7 @@ export class IdCompressor {
|
|
|
986
984
|
IdCompressor.sessionDataEqual(a.session, b.session, false, compareLocalState)) &&
|
|
987
985
|
(a.overrides === undefined) === (b.overrides === undefined) &&
|
|
988
986
|
(a.overrides === undefined ||
|
|
989
|
-
compareMaps(
|
|
987
|
+
compareMaps(a.overrides ?? fail("Overrides must be defined"), b.overrides ?? fail("Overrides must be defined"), (overrideA, overrideB) => {
|
|
990
988
|
if (compareLocalState) {
|
|
991
989
|
if (typeof overrideA === "string" || typeof overrideB === "string") {
|
|
992
990
|
return overrideA === overrideB;
|
|
@@ -1010,7 +1008,6 @@ export class IdCompressor {
|
|
|
1010
1008
|
return areEqual;
|
|
1011
1009
|
}
|
|
1012
1010
|
serialize(withSession) {
|
|
1013
|
-
var _a, _b;
|
|
1014
1011
|
const serializedSessions = [];
|
|
1015
1012
|
const sessionIdToSessionIndex = new Map();
|
|
1016
1013
|
for (const [sessionId, session] of this.sessions) {
|
|
@@ -1028,7 +1025,8 @@ export class IdCompressor {
|
|
|
1028
1025
|
for (const [baseFinalId, cluster] of this.finalIdToCluster.entries()) {
|
|
1029
1026
|
const sessionId = stableIdFromNumericUuid(cluster.session.sessionUuid);
|
|
1030
1027
|
if (sessionId !== reservedSessionId) {
|
|
1031
|
-
const sessionIndex =
|
|
1028
|
+
const sessionIndex = sessionIdToSessionIndex.get(sessionId) ??
|
|
1029
|
+
fail("Session object contains wrong session numeric UUID");
|
|
1032
1030
|
const serializedCluster = [
|
|
1033
1031
|
sessionIndex,
|
|
1034
1032
|
cluster.capacity,
|
|
@@ -1080,7 +1078,7 @@ export class IdCompressor {
|
|
|
1080
1078
|
}
|
|
1081
1079
|
return serializedWithSession;
|
|
1082
1080
|
}
|
|
1083
|
-
|
|
1081
|
+
this.logger?.sendTelemetryEvent({
|
|
1084
1082
|
eventName: "RuntimeIdCompressor:SerializedIdCompressorSize",
|
|
1085
1083
|
size: JSON.stringify(serializedIdCompressor).length,
|
|
1086
1084
|
clusterCount: serializedIdCompressor.clusters.length,
|
|
@@ -1141,7 +1139,7 @@ export class IdCompressor {
|
|
|
1141
1139
|
baseUuid: incrementUuid(sessionUuid, currentIdCount),
|
|
1142
1140
|
session,
|
|
1143
1141
|
};
|
|
1144
|
-
const lastFinalizedNormalized = lastFinalizedLocalId
|
|
1142
|
+
const lastFinalizedNormalized = lastFinalizedLocalId ?? 0;
|
|
1145
1143
|
const clusterBase = compressor.nextClusterBaseFinalId;
|
|
1146
1144
|
session.lastFinalizedLocalId = (lastFinalizedNormalized - count);
|
|
1147
1145
|
session.currentClusterDetails = { clusterBase, cluster };
|
|
@@ -1195,8 +1193,8 @@ export class IdCompressor {
|
|
|
1195
1193
|
}
|
|
1196
1194
|
if (serializedLocalState !== undefined) {
|
|
1197
1195
|
compressor.sessionIdNormalizer = SessionIdNormalizer.deserialize(serializedLocalState.sessionNormalizer, (finalId) => {
|
|
1198
|
-
|
|
1199
|
-
|
|
1196
|
+
const [_, cluster] = compressor.finalIdToCluster.getPairOrNextLower(finalId) ??
|
|
1197
|
+
fail("Final in serialized normalizer was never created.");
|
|
1200
1198
|
return cluster;
|
|
1201
1199
|
});
|
|
1202
1200
|
}
|