@fluidframework/container-runtime 2.0.0-internal.6.1.1 → 2.0.0-internal.6.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 +39 -0
- package/README.md +4 -3
- package/dist/batchTracker.d.ts +1 -1
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js +5 -4
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.d.ts +4 -21
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +119 -185
- package/dist/blobManager.js.map +1 -1
- package/dist/connectionTelemetry.d.ts.map +1 -1
- package/dist/connectionTelemetry.js +13 -12
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/containerRuntime.d.ts +99 -16
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +380 -242
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.d.ts.map +1 -1
- package/dist/dataStore.js +4 -5
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts +2 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +40 -41
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.d.ts +1 -2
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/dataStoreContexts.js +7 -8
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/dataStoreRegistry.js +2 -2
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +23 -25
- package/dist/dataStores.js.map +1 -1
- package/dist/deltaManagerProxyBase.d.ts +1 -1
- package/dist/deltaManagerProxyBase.js +2 -2
- package/dist/deltaManagerProxyBase.js.map +1 -1
- package/dist/deltaScheduler.js +6 -6
- package/dist/deltaScheduler.js.map +1 -1
- package/dist/error.d.ts +14 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +21 -0
- package/dist/error.js.map +1 -0
- package/dist/gc/garbageCollection.d.ts +4 -6
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +26 -25
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.d.ts.map +1 -1
- package/dist/gc/gcConfigs.js +5 -3
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +4 -2
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcHelpers.js +7 -7
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcSummaryStateTracker.d.ts +4 -7
- package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
- package/dist/gc/gcSummaryStateTracker.js +15 -52
- package/dist/gc/gcSummaryStateTracker.js.map +1 -1
- package/dist/gc/gcTelemetry.d.ts.map +1 -1
- package/dist/gc/gcTelemetry.js +2 -0
- package/dist/gc/gcTelemetry.js.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.js +4 -4
- package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/dist/gc/index.d.ts +1 -1
- package/dist/gc/index.d.ts.map +1 -1
- package/dist/gc/index.js +1 -2
- package/dist/gc/index.js.map +1 -1
- package/dist/id-compressor/appendOnlySortedMap.d.ts +8 -30
- package/dist/id-compressor/appendOnlySortedMap.d.ts.map +1 -1
- package/dist/id-compressor/appendOnlySortedMap.js +26 -68
- package/dist/id-compressor/appendOnlySortedMap.js.map +1 -1
- package/dist/id-compressor/finalSpace.d.ts +29 -0
- package/dist/id-compressor/finalSpace.d.ts.map +1 -0
- package/dist/id-compressor/finalSpace.js +62 -0
- package/dist/id-compressor/finalSpace.js.map +1 -0
- package/dist/id-compressor/idCompressor.d.ts +25 -250
- package/dist/id-compressor/idCompressor.d.ts.map +1 -1
- package/dist/id-compressor/idCompressor.js +387 -1150
- package/dist/id-compressor/idCompressor.js.map +1 -1
- package/dist/id-compressor/identifiers.d.ts +32 -0
- package/dist/id-compressor/identifiers.d.ts.map +1 -0
- package/dist/id-compressor/identifiers.js +15 -0
- package/dist/id-compressor/identifiers.js.map +1 -0
- package/dist/id-compressor/index.d.ts +5 -6
- package/dist/id-compressor/index.d.ts.map +1 -1
- package/dist/id-compressor/index.js +20 -26
- package/dist/id-compressor/index.js.map +1 -1
- package/dist/id-compressor/persistanceUtilities.d.ts +22 -0
- package/dist/id-compressor/persistanceUtilities.d.ts.map +1 -0
- package/dist/id-compressor/persistanceUtilities.js +43 -0
- package/dist/id-compressor/persistanceUtilities.js.map +1 -0
- package/dist/id-compressor/sessionSpaceNormalizer.d.ts +46 -0
- package/dist/id-compressor/sessionSpaceNormalizer.d.ts.map +1 -0
- package/dist/id-compressor/sessionSpaceNormalizer.js +80 -0
- package/dist/id-compressor/sessionSpaceNormalizer.js.map +1 -0
- package/dist/id-compressor/sessions.d.ts +115 -0
- package/dist/id-compressor/sessions.d.ts.map +1 -0
- package/dist/id-compressor/sessions.js +305 -0
- package/dist/id-compressor/sessions.js.map +1 -0
- package/dist/id-compressor/utilities.d.ts +49 -0
- package/dist/id-compressor/utilities.d.ts.map +1 -0
- package/dist/id-compressor/utilities.js +166 -0
- package/dist/id-compressor/utilities.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/opLifecycle/opCompressor.js +5 -5
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +11 -10
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opGroupingManager.js +3 -3
- package/dist/opLifecycle/opGroupingManager.js.map +1 -1
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
- package/dist/opLifecycle/opSplitter.js +14 -15
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +1 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +16 -17
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +11 -5
- package/dist/opLifecycle/remoteMessageProcessor.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 +12 -5
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +36 -23
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/scheduleManager.d.ts.map +1 -1
- package/dist/scheduleManager.js +23 -23
- package/dist/scheduleManager.js.map +1 -1
- package/dist/summary/index.d.ts +3 -3
- package/dist/summary/index.d.ts.map +1 -1
- package/dist/summary/index.js +2 -1
- package/dist/summary/index.js.map +1 -1
- package/dist/summary/orderedClientElection.d.ts +2 -3
- package/dist/summary/orderedClientElection.d.ts.map +1 -1
- package/dist/summary/orderedClientElection.js +8 -8
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/dist/summary/runWhileConnectedCoordinator.js +3 -3
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/summary/runningSummarizer.d.ts +27 -4
- package/dist/summary/runningSummarizer.d.ts.map +1 -1
- package/dist/summary/runningSummarizer.js +246 -74
- package/dist/summary/runningSummarizer.js.map +1 -1
- package/dist/summary/summarizer.d.ts +6 -5
- package/dist/summary/summarizer.d.ts.map +1 -1
- package/dist/summary/summarizer.js +73 -69
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerClientElection.d.ts +2 -2
- package/dist/summary/summarizerClientElection.d.ts.map +1 -1
- package/dist/summary/summarizerClientElection.js +2 -2
- package/dist/summary/summarizerClientElection.js.map +1 -1
- package/dist/summary/summarizerHeuristics.js +2 -2
- package/dist/summary/summarizerHeuristics.js.map +1 -1
- package/dist/summary/summarizerNode/index.d.ts +1 -1
- package/dist/summary/summarizerNode/index.d.ts.map +1 -1
- package/dist/summary/summarizerNode/index.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNode.d.ts +5 -14
- package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
- package/dist/summary/summarizerNode/summarizerNode.js +32 -109
- package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +6 -30
- package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +0 -11
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeWithGc.js +5 -88
- package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/dist/summary/summarizerTypes.d.ts +38 -25
- package/dist/summary/summarizerTypes.d.ts.map +1 -1
- package/dist/summary/summarizerTypes.js.map +1 -1
- package/dist/summary/summaryCollection.d.ts +2 -3
- package/dist/summary/summaryCollection.d.ts.map +1 -1
- package/dist/summary/summaryCollection.js +9 -8
- package/dist/summary/summaryCollection.js.map +1 -1
- package/dist/summary/summaryFormat.js +2 -2
- package/dist/summary/summaryFormat.js.map +1 -1
- package/dist/summary/summaryGenerator.d.ts +10 -4
- package/dist/summary/summaryGenerator.d.ts.map +1 -1
- package/dist/summary/summaryGenerator.js +52 -48
- package/dist/summary/summaryGenerator.js.map +1 -1
- package/dist/summary/summaryManager.d.ts +7 -6
- package/dist/summary/summaryManager.d.ts.map +1 -1
- package/dist/summary/summaryManager.js +30 -22
- package/dist/summary/summaryManager.js.map +1 -1
- package/lib/batchTracker.d.ts +1 -1
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js +3 -2
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.d.ts +4 -21
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +91 -157
- package/lib/blobManager.js.map +1 -1
- package/lib/connectionTelemetry.d.ts.map +1 -1
- package/lib/connectionTelemetry.js +2 -1
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/containerRuntime.d.ts +99 -16
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +332 -192
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.d.ts.map +1 -1
- package/lib/dataStore.js +2 -3
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts +2 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +3 -4
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.d.ts +1 -2
- package/lib/dataStoreContexts.d.ts.map +1 -1
- package/lib/dataStoreContexts.js +1 -2
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/dataStoreRegistry.js +1 -1
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +2 -4
- package/lib/dataStores.js.map +1 -1
- package/lib/deltaManagerProxyBase.d.ts +1 -1
- package/lib/deltaManagerProxyBase.js +1 -1
- package/lib/deltaManagerProxyBase.js.map +1 -1
- package/lib/deltaScheduler.js +1 -1
- package/lib/deltaScheduler.js.map +1 -1
- package/lib/error.d.ts +14 -0
- package/lib/error.d.ts.map +1 -0
- package/lib/error.js +17 -0
- package/lib/error.js.map +1 -0
- package/lib/gc/garbageCollection.d.ts +4 -6
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +26 -25
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.d.ts.map +1 -1
- package/lib/gc/gcConfigs.js +3 -1
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +4 -2
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcHelpers.js +1 -1
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcSummaryStateTracker.d.ts +4 -7
- package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
- package/lib/gc/gcSummaryStateTracker.js +16 -53
- package/lib/gc/gcSummaryStateTracker.js.map +1 -1
- package/lib/gc/gcTelemetry.d.ts.map +1 -1
- package/lib/gc/gcTelemetry.js +2 -0
- package/lib/gc/gcTelemetry.js.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.js +1 -1
- package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/lib/gc/index.d.ts +1 -1
- package/lib/gc/index.d.ts.map +1 -1
- package/lib/gc/index.js +1 -1
- package/lib/gc/index.js.map +1 -1
- package/lib/id-compressor/appendOnlySortedMap.d.ts +8 -30
- package/lib/id-compressor/appendOnlySortedMap.d.ts.map +1 -1
- package/lib/id-compressor/appendOnlySortedMap.js +25 -66
- package/lib/id-compressor/appendOnlySortedMap.js.map +1 -1
- package/lib/id-compressor/finalSpace.d.ts +29 -0
- package/lib/id-compressor/finalSpace.d.ts.map +1 -0
- package/lib/id-compressor/finalSpace.js +58 -0
- package/lib/id-compressor/finalSpace.js.map +1 -0
- package/lib/id-compressor/idCompressor.d.ts +25 -250
- package/lib/id-compressor/idCompressor.d.ts.map +1 -1
- package/lib/id-compressor/idCompressor.js +382 -1139
- package/lib/id-compressor/idCompressor.js.map +1 -1
- package/lib/id-compressor/identifiers.d.ts +32 -0
- package/lib/id-compressor/identifiers.d.ts.map +1 -0
- package/lib/id-compressor/identifiers.js +11 -0
- package/lib/id-compressor/identifiers.js.map +1 -0
- package/lib/id-compressor/index.d.ts +5 -6
- package/lib/id-compressor/index.d.ts.map +1 -1
- package/lib/id-compressor/index.js +5 -6
- package/lib/id-compressor/index.js.map +1 -1
- package/lib/id-compressor/persistanceUtilities.d.ts +22 -0
- package/lib/id-compressor/persistanceUtilities.d.ts.map +1 -0
- package/lib/id-compressor/persistanceUtilities.js +34 -0
- package/lib/id-compressor/persistanceUtilities.js.map +1 -0
- package/lib/id-compressor/sessionSpaceNormalizer.d.ts +46 -0
- package/lib/id-compressor/sessionSpaceNormalizer.d.ts.map +1 -0
- package/lib/id-compressor/sessionSpaceNormalizer.js +76 -0
- package/lib/id-compressor/sessionSpaceNormalizer.js.map +1 -0
- package/lib/id-compressor/sessions.d.ts +115 -0
- package/lib/id-compressor/sessions.d.ts.map +1 -0
- package/lib/id-compressor/sessions.js +290 -0
- package/lib/id-compressor/sessions.js.map +1 -0
- package/lib/id-compressor/utilities.d.ts +49 -0
- package/lib/id-compressor/utilities.d.ts.map +1 -0
- package/lib/id-compressor/utilities.js +148 -0
- package/lib/id-compressor/utilities.js.map +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/opLifecycle/opCompressor.js +3 -3
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +2 -1
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opGroupingManager.js +1 -1
- package/lib/opLifecycle/opGroupingManager.js.map +1 -1
- package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
- package/lib/opLifecycle/opSplitter.js +2 -3
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +1 -0
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +7 -8
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +12 -6
- package/lib/opLifecycle/remoteMessageProcessor.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 +12 -5
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +21 -8
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/scheduleManager.d.ts.map +1 -1
- package/lib/scheduleManager.js +3 -3
- package/lib/scheduleManager.js.map +1 -1
- package/lib/summary/index.d.ts +3 -3
- package/lib/summary/index.d.ts.map +1 -1
- package/lib/summary/index.js +1 -1
- package/lib/summary/index.js.map +1 -1
- package/lib/summary/orderedClientElection.d.ts +2 -3
- package/lib/summary/orderedClientElection.d.ts.map +1 -1
- package/lib/summary/orderedClientElection.js +3 -3
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/lib/summary/runWhileConnectedCoordinator.js +1 -1
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/summary/runningSummarizer.d.ts +27 -4
- package/lib/summary/runningSummarizer.d.ts.map +1 -1
- package/lib/summary/runningSummarizer.js +240 -68
- package/lib/summary/runningSummarizer.js.map +1 -1
- package/lib/summary/summarizer.d.ts +6 -5
- package/lib/summary/summarizer.d.ts.map +1 -1
- package/lib/summary/summarizer.js +69 -65
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerClientElection.d.ts +2 -2
- package/lib/summary/summarizerClientElection.d.ts.map +1 -1
- package/lib/summary/summarizerClientElection.js +1 -1
- package/lib/summary/summarizerClientElection.js.map +1 -1
- package/lib/summary/summarizerHeuristics.js +1 -1
- package/lib/summary/summarizerHeuristics.js.map +1 -1
- package/lib/summary/summarizerNode/index.d.ts +1 -1
- package/lib/summary/summarizerNode/index.d.ts.map +1 -1
- package/lib/summary/summarizerNode/index.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNode.d.ts +5 -14
- package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
- package/lib/summary/summarizerNode/summarizerNode.js +16 -93
- package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +6 -30
- package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +0 -11
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeWithGc.js +3 -86
- package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/lib/summary/summarizerTypes.d.ts +38 -25
- package/lib/summary/summarizerTypes.d.ts.map +1 -1
- package/lib/summary/summarizerTypes.js.map +1 -1
- package/lib/summary/summaryCollection.d.ts +2 -3
- package/lib/summary/summaryCollection.d.ts.map +1 -1
- package/lib/summary/summaryCollection.js +2 -1
- package/lib/summary/summaryCollection.js.map +1 -1
- package/lib/summary/summaryFormat.js +1 -1
- package/lib/summary/summaryFormat.js.map +1 -1
- package/lib/summary/summaryGenerator.d.ts +10 -4
- package/lib/summary/summaryGenerator.d.ts.map +1 -1
- package/lib/summary/summaryGenerator.js +46 -42
- package/lib/summary/summaryGenerator.js.map +1 -1
- package/lib/summary/summaryManager.d.ts +7 -6
- package/lib/summary/summaryManager.d.ts.map +1 -1
- package/lib/summary/summaryManager.js +26 -18
- package/lib/summary/summaryManager.js.map +1 -1
- package/package.json +30 -29
- package/src/batchTracker.ts +3 -2
- package/src/blobManager.ts +105 -185
- package/src/connectionTelemetry.ts +2 -1
- package/src/containerRuntime.ts +481 -267
- package/src/dataStore.ts +2 -3
- package/src/dataStoreContext.ts +5 -8
- package/src/dataStoreContexts.ts +2 -4
- package/src/dataStoreRegistry.ts +1 -1
- package/src/dataStores.ts +4 -7
- package/src/deltaManagerProxyBase.ts +1 -1
- package/src/deltaScheduler.ts +1 -1
- package/src/error.ts +18 -0
- package/src/gc/garbageCollection.ts +39 -41
- package/src/gc/gcConfigs.ts +4 -2
- package/src/gc/gcDefinitions.ts +4 -6
- package/src/gc/gcHelpers.ts +1 -1
- package/src/gc/gcSummaryStateTracker.ts +19 -65
- package/src/gc/gcTelemetry.ts +2 -0
- package/src/gc/gcUnreferencedStateTracker.ts +1 -1
- package/src/gc/index.ts +0 -1
- package/src/id-compressor/appendOnlySortedMap.ts +26 -87
- package/src/id-compressor/finalSpace.ts +67 -0
- package/src/id-compressor/idCompressor.ts +456 -1681
- package/src/id-compressor/identifiers.ts +42 -0
- package/src/id-compressor/index.ts +11 -20
- package/src/id-compressor/persistanceUtilities.ts +58 -0
- package/src/id-compressor/sessionSpaceNormalizer.ts +83 -0
- package/src/id-compressor/sessions.ts +405 -0
- package/src/id-compressor/utilities.ts +187 -0
- package/src/index.ts +7 -1
- package/src/opLifecycle/opCompressor.ts +3 -3
- package/src/opLifecycle/opDecompressor.ts +2 -1
- package/src/opLifecycle/opGroupingManager.ts +1 -1
- package/src/opLifecycle/opSplitter.ts +4 -4
- package/src/opLifecycle/outbox.ts +14 -11
- package/src/opLifecycle/remoteMessageProcessor.ts +19 -6
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +50 -29
- package/src/scheduleManager.ts +6 -4
- package/src/summary/index.ts +4 -3
- package/src/summary/orderedClientElection.ts +8 -5
- package/src/summary/runWhileConnectedCoordinator.ts +1 -1
- package/src/summary/runningSummarizer.ts +273 -97
- package/src/summary/summarizer.ts +23 -12
- package/src/summary/summarizerClientElection.ts +2 -2
- package/src/summary/summarizerHeuristics.ts +1 -1
- package/src/summary/summarizerNode/index.ts +1 -2
- package/src/summary/summarizerNode/summarizerNode.ts +23 -145
- package/src/summary/summarizerNode/summarizerNodeUtils.ts +7 -38
- package/src/summary/summarizerNode/summarizerNodeWithGc.ts +3 -123
- package/src/summary/summarizerTypes.ts +40 -25
- package/src/summary/summaryCollection.ts +3 -3
- package/src/summary/summaryFormat.ts +1 -1
- package/src/summary/summaryGenerator.ts +52 -55
- package/src/summary/summaryManager.ts +36 -13
- package/dist/id-compressor/idRange.d.ts +0 -11
- package/dist/id-compressor/idRange.d.ts.map +0 -1
- package/dist/id-compressor/idRange.js +0 -29
- package/dist/id-compressor/idRange.js.map +0 -1
- package/dist/id-compressor/numericUuid.d.ts +0 -59
- package/dist/id-compressor/numericUuid.d.ts.map +0 -1
- package/dist/id-compressor/numericUuid.js +0 -325
- package/dist/id-compressor/numericUuid.js.map +0 -1
- package/dist/id-compressor/sessionIdNormalizer.d.ts +0 -138
- package/dist/id-compressor/sessionIdNormalizer.d.ts.map +0 -1
- package/dist/id-compressor/sessionIdNormalizer.js +0 -483
- package/dist/id-compressor/sessionIdNormalizer.js.map +0 -1
- package/dist/id-compressor/utils.d.ts +0 -57
- package/dist/id-compressor/utils.d.ts.map +0 -1
- package/dist/id-compressor/utils.js +0 -90
- package/dist/id-compressor/utils.js.map +0 -1
- package/dist/id-compressor/uuidUtilities.d.ts +0 -28
- package/dist/id-compressor/uuidUtilities.d.ts.map +0 -1
- package/dist/id-compressor/uuidUtilities.js +0 -104
- package/dist/id-compressor/uuidUtilities.js.map +0 -1
- package/lib/id-compressor/idRange.d.ts +0 -11
- package/lib/id-compressor/idRange.d.ts.map +0 -1
- package/lib/id-compressor/idRange.js +0 -25
- package/lib/id-compressor/idRange.js.map +0 -1
- package/lib/id-compressor/numericUuid.d.ts +0 -59
- package/lib/id-compressor/numericUuid.d.ts.map +0 -1
- package/lib/id-compressor/numericUuid.js +0 -315
- package/lib/id-compressor/numericUuid.js.map +0 -1
- package/lib/id-compressor/sessionIdNormalizer.d.ts +0 -138
- package/lib/id-compressor/sessionIdNormalizer.d.ts.map +0 -1
- package/lib/id-compressor/sessionIdNormalizer.js +0 -479
- package/lib/id-compressor/sessionIdNormalizer.js.map +0 -1
- package/lib/id-compressor/utils.d.ts +0 -57
- package/lib/id-compressor/utils.d.ts.map +0 -1
- package/lib/id-compressor/utils.js +0 -79
- package/lib/id-compressor/utils.js.map +0 -1
- package/lib/id-compressor/uuidUtilities.d.ts +0 -28
- package/lib/id-compressor/uuidUtilities.d.ts.map +0 -1
- package/lib/id-compressor/uuidUtilities.js +0 -96
- package/lib/id-compressor/uuidUtilities.js.map +0 -1
- package/src/id-compressor/idRange.ts +0 -35
- package/src/id-compressor/numericUuid.ts +0 -383
- package/src/id-compressor/sessionIdNormalizer.ts +0 -609
- package/src/id-compressor/utils.ts +0 -114
- package/src/id-compressor/uuidUtilities.ts +0 -120
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
|
6
|
-
import { assert } from "@fluidframework/common-utils";
|
|
7
|
-
import { compareFiniteNumbers, compareFiniteNumbersReversed, fail } from "./utils";
|
|
8
|
-
import { AppendOnlyDoublySortedMap } from "./appendOnlySortedMap";
|
|
9
|
-
/**
|
|
10
|
-
* Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.
|
|
11
|
-
* The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such
|
|
12
|
-
* that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.
|
|
13
|
-
* Below is an example to illustrate how various mappings can arise:
|
|
14
|
-
*
|
|
15
|
-
* ```
|
|
16
|
-
* +- Creation Index
|
|
17
|
-
* / +- Locals
|
|
18
|
-
* / / +- Finals
|
|
19
|
-
* / / /
|
|
20
|
-
* ---+-----+----
|
|
21
|
-
* 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.
|
|
22
|
-
* 1 | -2 | 1 -|
|
|
23
|
-
* 2 | | 2 -|
|
|
24
|
-
* 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.
|
|
25
|
-
* 4 | | 4 -|
|
|
26
|
-
* 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.
|
|
27
|
-
* 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.
|
|
28
|
-
* 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.
|
|
29
|
-
* 8 | | 13
|
|
30
|
-
* 9 | | 14
|
|
31
|
-
* 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* Note that in this example, some IDs (those at indices 2, 3, 4, 6, 8, and 9) have no local form. The ID at index 10 has no final form.
|
|
35
|
-
* These kinds of "gaps" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,
|
|
36
|
-
* which depends on receiving an ack/sequence number from the server. Given this context, "session space" can be thought of as:
|
|
37
|
-
*
|
|
38
|
-
* ```
|
|
39
|
-
* for each index in the range of IDs created by a session:
|
|
40
|
-
* the local form if it exists, otherwise the final form
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and
|
|
44
|
-
* final space) is uninterrupted by "gaps" and can be compactly represented by a (first, last) pair and is easily binary searched for
|
|
45
|
-
* normalization between local and final space.
|
|
46
|
-
*/
|
|
47
|
-
export class SessionIdNormalizer {
|
|
48
|
-
constructor(expensiveAsserts = false) {
|
|
49
|
-
this.expensiveAsserts = expensiveAsserts;
|
|
50
|
-
this.nextLocalId = -1;
|
|
51
|
-
this.idRanges = new AppendOnlyDoublySortedMap(compareFiniteNumbersReversed, ([_, finalRanges]) => {
|
|
52
|
-
if (finalRanges !== undefined) {
|
|
53
|
-
const first = getFirstRange(finalRanges);
|
|
54
|
-
return extractFirstFinalFromRange(first);
|
|
55
|
-
}
|
|
56
|
-
return Number.POSITIVE_INFINITY;
|
|
57
|
-
}, compareFiniteNumbers);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Converts the final ID to its session-space representation.
|
|
61
|
-
* This will be the corresponding local if a local form exists, and `finalId` otherwise.
|
|
62
|
-
*/
|
|
63
|
-
getSessionSpaceId(finalId) {
|
|
64
|
-
const localRange = this.idRanges.getPairOrNextLowerByValue(finalId);
|
|
65
|
-
if (localRange !== undefined) {
|
|
66
|
-
const [firstLocal, [lastLocal, finalRanges]] = localRange;
|
|
67
|
-
const finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);
|
|
68
|
-
if (finalRange !== undefined) {
|
|
69
|
-
const [alignedLocal, [firstFinal, lastFinal]] = finalRange;
|
|
70
|
-
if (finalId <= lastFinal) {
|
|
71
|
-
const localRangeDelta = alignedLocal - lastLocal;
|
|
72
|
-
const finalDelta = finalId - firstFinal;
|
|
73
|
-
if (finalDelta <= localRangeDelta) {
|
|
74
|
-
return (alignedLocal - finalDelta);
|
|
75
|
-
}
|
|
76
|
-
// `finalId` was an eagerly generated final ID
|
|
77
|
-
return finalId;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Converts the local ID to its corresponding final ID, if one exists.
|
|
85
|
-
*/
|
|
86
|
-
getFinalId(localId) {
|
|
87
|
-
const localRange = this.idRanges.getPairOrNextLower(localId) ??
|
|
88
|
-
fail("Local ID was never recorded with this normalizer.");
|
|
89
|
-
const [firstLocal, [lastLocal, finalRanges]] = localRange;
|
|
90
|
-
if (localId < lastLocal) {
|
|
91
|
-
fail("Local ID was never recorded with this normalizer.");
|
|
92
|
-
}
|
|
93
|
-
const finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);
|
|
94
|
-
if (finalRange !== undefined) {
|
|
95
|
-
const [alignedLocal, [firstFinal, lastFinal, rangeObject]] = finalRange;
|
|
96
|
-
const rangeDelta = lastFinal - firstFinal;
|
|
97
|
-
const localDelta = alignedLocal - localId;
|
|
98
|
-
if (localDelta <= rangeDelta) {
|
|
99
|
-
// Local is within a range segment that has a corresponding final
|
|
100
|
-
return [(firstFinal + localDelta), rangeObject];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Returns the index of the local ID corresponding to the supplied final ID in the total range of IDs created by the session,
|
|
107
|
-
* if the ID was created by the session for this `SessionIdNormalizer`.
|
|
108
|
-
*/
|
|
109
|
-
getCreationIndex(finalId) {
|
|
110
|
-
const localRange = this.idRanges.getPairOrNextLowerByValue(finalId);
|
|
111
|
-
if (localRange !== undefined) {
|
|
112
|
-
const [firstLocal, [_, finalRanges]] = localRange;
|
|
113
|
-
const finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);
|
|
114
|
-
if (finalRange !== undefined) {
|
|
115
|
-
const [alignedLocal, [firstFinal, lastFinal]] = finalRange;
|
|
116
|
-
if (finalId <= lastFinal) {
|
|
117
|
-
const finalDelta = finalId - firstFinal;
|
|
118
|
-
return -alignedLocal - 1 + finalDelta;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Returns the session-space ID at the supplied creation index, if one exists.
|
|
126
|
-
*/
|
|
127
|
-
getIdByCreationIndex(index) {
|
|
128
|
-
const localByIndex = -(index + 1);
|
|
129
|
-
const localRange = this.idRanges.getPairOrNextLower(localByIndex);
|
|
130
|
-
if (localRange === undefined) {
|
|
131
|
-
return undefined;
|
|
132
|
-
}
|
|
133
|
-
const [firstLocal, [lastLocal, finalRanges]] = localRange;
|
|
134
|
-
if (localByIndex >= lastLocal) {
|
|
135
|
-
return localByIndex;
|
|
136
|
-
}
|
|
137
|
-
const finalRange = getPairOrNextLower(firstLocal, finalRanges, localByIndex) ??
|
|
138
|
-
fail("Final ranges not aligned with owning local range.");
|
|
139
|
-
const [alignedLocal, [firstFinal, lastFinal]] = finalRange;
|
|
140
|
-
const localDelta = alignedLocal - localByIndex;
|
|
141
|
-
const finalId = firstFinal + localDelta;
|
|
142
|
-
if (finalId <= lastFinal) {
|
|
143
|
-
// `finalId` was an eagerly generated final ID
|
|
144
|
-
return finalId;
|
|
145
|
-
}
|
|
146
|
-
return undefined;
|
|
147
|
-
}
|
|
148
|
-
static makeFinalRangesMap() {
|
|
149
|
-
return new AppendOnlyDoublySortedMap(compareFiniteNumbersReversed, extractFirstFinalFromRange, compareFiniteNumbers);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Returns the last final ID known to this normalizer.
|
|
153
|
-
*/
|
|
154
|
-
getLastFinalId() {
|
|
155
|
-
const lastIndex = this.idRanges.size - 1;
|
|
156
|
-
const secondToLast = Math.max(0, lastIndex - 1);
|
|
157
|
-
for (let i = lastIndex; i >= secondToLast; i--) {
|
|
158
|
-
const localRange = this.idRanges.getAtIndex(i);
|
|
159
|
-
if (localRange !== undefined) {
|
|
160
|
-
const finalRanges = localRange[1][1];
|
|
161
|
-
if (finalRanges !== undefined) {
|
|
162
|
-
return getLastRange(finalRanges)[1];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return undefined;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Registers and returns the next ID in local space with this normalizer. An example:
|
|
170
|
-
*
|
|
171
|
-
* Locals: [-1, -2, X, X]
|
|
172
|
-
* Finals: [ 0, 1, 2, 3]
|
|
173
|
-
* In this scenario, a call to this method would generate and return -5.
|
|
174
|
-
*/
|
|
175
|
-
addLocalId() {
|
|
176
|
-
const localId = this.nextLocalId--;
|
|
177
|
-
const lastLocalRange = this.idRanges.last();
|
|
178
|
-
if (lastLocalRange !== undefined) {
|
|
179
|
-
const lastLocal = lastLocalRange[1][0];
|
|
180
|
-
if (localId === lastLocal - 1) {
|
|
181
|
-
// New local simply expands the last local range tracked
|
|
182
|
-
lastLocalRange[1][0] = localId;
|
|
183
|
-
return localId;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (this.expensiveAsserts) {
|
|
187
|
-
if (lastLocalRange === undefined) {
|
|
188
|
-
assert(localId === -1, 0x49e /* Local ID space must start at -1. */);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
const [firstLocal, [_, finalRanges]] = lastLocalRange;
|
|
192
|
-
let finalDelta = 0;
|
|
193
|
-
for (const [__, [firstFinal, lastFinal]] of entries(firstLocal, finalRanges)) {
|
|
194
|
-
finalDelta += lastFinal - firstFinal + 1;
|
|
195
|
-
}
|
|
196
|
-
assert(localId === firstLocal - finalDelta, 0x49f /* Local ID space must be contiguous. */);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
this.idRanges.append(localId, [localId, undefined]);
|
|
200
|
-
return localId;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Registers one or more final IDs with this normalizer.
|
|
204
|
-
* If there are any local IDs at the tip of session-space that do not have a corresponding final, they will be registered (aligned)
|
|
205
|
-
* starting with the first of those. Otherwise, will be registered as the next ID in session space in creation order.
|
|
206
|
-
*
|
|
207
|
-
* An example:
|
|
208
|
-
* Locals: [-1, -2, X, -4]
|
|
209
|
-
* Finals: [ 0, 1, 2, X]
|
|
210
|
-
* Calling `addFinalIds` with first === last === 5 results in the following:
|
|
211
|
-
* Locals: [-1, -2, X, -4]
|
|
212
|
-
* Finals: [ 0, 1, 2, 5]
|
|
213
|
-
* Subsequently calling `addFinalIds` with first === last === 6 results in the following:
|
|
214
|
-
* Locals: [-1, -2, X, -4, X]
|
|
215
|
-
* Finals: [ 0, 1, 2, 5, 6]
|
|
216
|
-
*
|
|
217
|
-
* Non-contiguous final IDs (i.e. the first final after a "gap" in final space) must always correspond to a local ID. For example,
|
|
218
|
-
* in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a
|
|
219
|
-
* non-contiguous final ID without a local form:
|
|
220
|
-
* Locals: [-1, -2, X, -4, X]
|
|
221
|
-
* Finals: [ 0, 1, 2, 5, 9]
|
|
222
|
-
*
|
|
223
|
-
* ^final ID 9 is not contiguous and does not have a corresponding local ID
|
|
224
|
-
*/
|
|
225
|
-
addFinalIds(firstFinal, lastFinal, rangeObject) {
|
|
226
|
-
assert(lastFinal >= firstFinal, 0x5ae /* Malformed normalization range. */);
|
|
227
|
-
const [firstLocal, finalRangesObj] = this.idRanges.last() ?? fail("Final IDs must be added to an existing local range.");
|
|
228
|
-
const [lastLocal, finalRanges] = finalRangesObj;
|
|
229
|
-
let nextLocal;
|
|
230
|
-
if (finalRanges === undefined) {
|
|
231
|
-
finalRangesObj[1] = [firstFinal, lastFinal, rangeObject];
|
|
232
|
-
nextLocal = Math.min(this.nextLocalId, firstLocal - (lastFinal - firstFinal) - 1);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
const [firstAlignedLocal, lastAlignedLocal, lastAlignedFinal, lastFinalRange] = this.getAlignmentOfLastRange(firstLocal, finalRanges);
|
|
236
|
-
nextLocal = Math.min(this.nextLocalId, lastAlignedLocal - (lastFinal - firstFinal) - 2);
|
|
237
|
-
if (firstFinal === lastAlignedFinal + 1) {
|
|
238
|
-
lastFinalRange[1] = lastFinal;
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
const alignedLocal = (lastAlignedLocal - 1);
|
|
242
|
-
let rangeMap;
|
|
243
|
-
if (isSingleRange(finalRanges)) {
|
|
244
|
-
// Convert the single range to a range collection
|
|
245
|
-
rangeMap = SessionIdNormalizer.makeFinalRangesMap();
|
|
246
|
-
rangeMap.append(firstAlignedLocal, lastFinalRange);
|
|
247
|
-
finalRangesObj[1] = rangeMap;
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
rangeMap = finalRanges;
|
|
251
|
-
}
|
|
252
|
-
rangeMap.append(alignedLocal, [firstFinal, lastFinal, rangeObject]);
|
|
253
|
-
assert(alignedLocal >= lastLocal, 0x4a0 /* Gaps in final space must align to a local. */);
|
|
254
|
-
}
|
|
255
|
-
if (this.expensiveAsserts) {
|
|
256
|
-
this.idRanges.assertValid();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
this.nextLocalId = nextLocal;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Alerts the normalizer to the existence of a block of final IDs that are *allocated* (but may not be entirely used).
|
|
263
|
-
*
|
|
264
|
-
* The normalizer may have unaligned (unfinalized) local IDs; any such outstanding locals will be eagerly aligned with
|
|
265
|
-
* as many finals from the registered block as possible.
|
|
266
|
-
*
|
|
267
|
-
* It is important to register blocks via this method as soon as they are created for future eager final generations to be utilized, as such
|
|
268
|
-
* generation is dependant on the normalizer being up-to-date with which local IDs have been aligned with finals. If, for instance,
|
|
269
|
-
* a block of finals is not immediately registered with the normalizer and there are outstanding locals that would have aligned with them,
|
|
270
|
-
* those locals will not be finalized until their creation range is finalized, which could be later if the block was created by an earlier
|
|
271
|
-
* creation range's finalization but is large enough to span them both. In this scenario, no eager finals can be generated until the second
|
|
272
|
-
* creation range is finalized.
|
|
273
|
-
*
|
|
274
|
-
* A usage example:
|
|
275
|
-
* Locals: [-1, -2, X, -4, -5, -6]
|
|
276
|
-
* Finals: [ 0, 1, 2, X, X, X]
|
|
277
|
-
* Calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 10 results in the following:
|
|
278
|
-
* Locals: [-1, -2, X, -4, -5, -6]
|
|
279
|
-
* Finals: [ 0, 1, 2, 5, 6, 7]
|
|
280
|
-
* Instead calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 2 results in the following:
|
|
281
|
-
* Locals: [-1, -2, X, -4, -5, -6]
|
|
282
|
-
* Finals: [ 0, 1, 2, 5, 6, X]
|
|
283
|
-
*
|
|
284
|
-
*/
|
|
285
|
-
registerFinalIdBlock(firstFinalInBlock, count, rangeObject) {
|
|
286
|
-
assert(count >= 1, 0x5af /* Malformed normalization block. */);
|
|
287
|
-
const [firstLocal, [lastLocal, finalRanges]] = this.idRanges.last() ??
|
|
288
|
-
fail("Final ID block should not be registered before any locals.");
|
|
289
|
-
let unalignedLocalCount;
|
|
290
|
-
if (finalRanges === undefined) {
|
|
291
|
-
unalignedLocalCount = firstLocal - lastLocal + 1;
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
const [_, lastAlignedLocal] = this.getAlignmentOfLastRange(firstLocal, finalRanges);
|
|
295
|
-
unalignedLocalCount = lastAlignedLocal - lastLocal;
|
|
296
|
-
}
|
|
297
|
-
assert(unalignedLocalCount > 0, 0x51b /* Final ID block should not be registered without an existing local range. */);
|
|
298
|
-
const lastFinal = (firstFinalInBlock +
|
|
299
|
-
Math.min(unalignedLocalCount, count) -
|
|
300
|
-
1);
|
|
301
|
-
this.addFinalIds(firstFinalInBlock, lastFinal, rangeObject);
|
|
302
|
-
}
|
|
303
|
-
getAlignmentOfLastRange(firstLocal, finalRanges) {
|
|
304
|
-
const isSingle = isSingleRange(finalRanges);
|
|
305
|
-
let lastFinalRange;
|
|
306
|
-
let firstAlignedLocal;
|
|
307
|
-
if (isSingle) {
|
|
308
|
-
firstAlignedLocal = firstLocal;
|
|
309
|
-
lastFinalRange = finalRanges;
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
[firstAlignedLocal, lastFinalRange] =
|
|
313
|
-
finalRanges.last() ?? fail("Map should be non-empty.");
|
|
314
|
-
}
|
|
315
|
-
const [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;
|
|
316
|
-
const lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);
|
|
317
|
-
return [
|
|
318
|
-
firstAlignedLocal,
|
|
319
|
-
lastAlignedLocal,
|
|
320
|
-
lastAlignedFinal,
|
|
321
|
-
lastFinalRange,
|
|
322
|
-
];
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Returns an enumerable of all session-space IDs known to this normalizer, in creation order.
|
|
326
|
-
*/
|
|
327
|
-
*[Symbol.iterator]() {
|
|
328
|
-
for (const [firstLocal, [lastLocal, finalRanges]] of this.idRanges.entries()) {
|
|
329
|
-
for (let i = firstLocal; i >= lastLocal; i--) {
|
|
330
|
-
yield i;
|
|
331
|
-
}
|
|
332
|
-
if (finalRanges !== undefined) {
|
|
333
|
-
// Safe to get only the last final range, as all others must have corresponding locals (see `addFinalIds` docs)
|
|
334
|
-
let lastFinalRange;
|
|
335
|
-
let alignedLocal;
|
|
336
|
-
if (isSingleRange(finalRanges)) {
|
|
337
|
-
alignedLocal = firstLocal;
|
|
338
|
-
lastFinalRange = finalRanges;
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
[alignedLocal, lastFinalRange] =
|
|
342
|
-
finalRanges.last() ?? fail("Map should be non-empty.");
|
|
343
|
-
}
|
|
344
|
-
const [firstFinal, lastFinal] = lastFinalRange;
|
|
345
|
-
const localRangeDelta = alignedLocal - lastLocal;
|
|
346
|
-
for (let i = firstFinal + localRangeDelta + 1; i <= lastFinal; i++) {
|
|
347
|
-
yield i;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
serialize() {
|
|
353
|
-
const serialized = {
|
|
354
|
-
localRanges: [],
|
|
355
|
-
nextLocalId: this.nextLocalId,
|
|
356
|
-
};
|
|
357
|
-
const localRanges = serialized.localRanges;
|
|
358
|
-
for (const [firstLocal, finalRanges] of this.idRanges.entries()) {
|
|
359
|
-
const [lastLocal, finalRangesTable] = finalRanges;
|
|
360
|
-
if (finalRangesTable !== undefined) {
|
|
361
|
-
const serializedFinalRanges = [];
|
|
362
|
-
for (const [alignedLocal, [firstFinal, lastFinal]] of entries(firstLocal, finalRangesTable)) {
|
|
363
|
-
serializedFinalRanges.push([alignedLocal, firstFinal, lastFinal]);
|
|
364
|
-
}
|
|
365
|
-
localRanges.push([firstLocal, lastLocal, serializedFinalRanges]);
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
localRanges.push([firstLocal, lastLocal]);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
return serialized;
|
|
372
|
-
}
|
|
373
|
-
static deserialize(serialized, getRangeObject) {
|
|
374
|
-
const normalizer = new SessionIdNormalizer();
|
|
375
|
-
const { idRanges } = normalizer;
|
|
376
|
-
for (const [firstLocal, lastLocal, serializedFinalRanges] of serialized.localRanges) {
|
|
377
|
-
let finalRanges;
|
|
378
|
-
if (serializedFinalRanges !== undefined) {
|
|
379
|
-
assert(serializedFinalRanges.length !== 0, 0x4a1 /* Empty range should not be reified. */);
|
|
380
|
-
if (serializedFinalRanges.length === 1) {
|
|
381
|
-
const [_, firstFinal, lastFinal] = serializedFinalRanges[0];
|
|
382
|
-
finalRanges = [firstFinal, lastFinal, getRangeObject(firstFinal)];
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
finalRanges = SessionIdNormalizer.makeFinalRangesMap();
|
|
386
|
-
for (const [alignedLocal, firstFinal, lastFinal] of serializedFinalRanges) {
|
|
387
|
-
finalRanges.append(alignedLocal, [
|
|
388
|
-
firstFinal,
|
|
389
|
-
lastFinal,
|
|
390
|
-
getRangeObject(firstFinal),
|
|
391
|
-
]);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
idRanges.append(firstLocal, [lastLocal, finalRanges]);
|
|
396
|
-
}
|
|
397
|
-
normalizer.nextLocalId = serialized.nextLocalId;
|
|
398
|
-
return normalizer;
|
|
399
|
-
}
|
|
400
|
-
equals(other, compareRangeObjects = (a, b) => a === b) {
|
|
401
|
-
return (this.nextLocalId === other.nextLocalId &&
|
|
402
|
-
this.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {
|
|
403
|
-
const [lastLocalA, finalRangesA] = localRangeA;
|
|
404
|
-
const [lastLocalB, finalRangesB] = localRangeB;
|
|
405
|
-
if (finalRangesA === undefined || finalRangesB === undefined) {
|
|
406
|
-
return finalRangesA === finalRangesB;
|
|
407
|
-
}
|
|
408
|
-
const rangeEquals = (finalRangeA, finalRangeB) => {
|
|
409
|
-
const [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;
|
|
410
|
-
const [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;
|
|
411
|
-
return (firstFinalA === firstFinalB &&
|
|
412
|
-
lastFinalA === lastFinalB &&
|
|
413
|
-
compareRangeObjects(rangeObjectA, rangeObjectB));
|
|
414
|
-
};
|
|
415
|
-
if (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {
|
|
416
|
-
if (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
419
|
-
return rangeEquals(finalRangesA, finalRangesB);
|
|
420
|
-
}
|
|
421
|
-
return lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);
|
|
422
|
-
}));
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
function isSingleRange(ranges) {
|
|
426
|
-
return Array.isArray(ranges);
|
|
427
|
-
}
|
|
428
|
-
function getLastRange(finalRanges) {
|
|
429
|
-
if (isSingleRange(finalRanges)) {
|
|
430
|
-
return finalRanges;
|
|
431
|
-
}
|
|
432
|
-
return (finalRanges.last() ?? fail("Map must be non-empty"))[1];
|
|
433
|
-
}
|
|
434
|
-
function getFirstRange(finalRanges) {
|
|
435
|
-
if (isSingleRange(finalRanges)) {
|
|
436
|
-
return finalRanges;
|
|
437
|
-
}
|
|
438
|
-
return (finalRanges.first() ?? fail("Map must be non-empty"))[1];
|
|
439
|
-
}
|
|
440
|
-
function extractFirstFinalFromRange(finalRange) {
|
|
441
|
-
return finalRange[0];
|
|
442
|
-
}
|
|
443
|
-
function getPairOrNextLowerByValue(firstLocal, finalRanges, finalId) {
|
|
444
|
-
if (finalRanges === undefined) {
|
|
445
|
-
return undefined;
|
|
446
|
-
}
|
|
447
|
-
if (isSingleRange(finalRanges)) {
|
|
448
|
-
if (finalId < finalRanges[0]) {
|
|
449
|
-
return undefined;
|
|
450
|
-
}
|
|
451
|
-
return [firstLocal, finalRanges];
|
|
452
|
-
}
|
|
453
|
-
return finalRanges.getPairOrNextLowerByValue(finalId);
|
|
454
|
-
}
|
|
455
|
-
function getPairOrNextLower(firstLocal, finalRanges, localId) {
|
|
456
|
-
if (finalRanges === undefined) {
|
|
457
|
-
return undefined;
|
|
458
|
-
}
|
|
459
|
-
if (isSingleRange(finalRanges)) {
|
|
460
|
-
if (localId > firstLocal) {
|
|
461
|
-
return undefined;
|
|
462
|
-
}
|
|
463
|
-
return [firstLocal, finalRanges];
|
|
464
|
-
}
|
|
465
|
-
return finalRanges.getPairOrNextLower(localId);
|
|
466
|
-
}
|
|
467
|
-
function* entries(firstLocal, finalRanges) {
|
|
468
|
-
if (finalRanges !== undefined) {
|
|
469
|
-
if (isSingleRange(finalRanges)) {
|
|
470
|
-
yield [firstLocal, finalRanges];
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
for (const range of finalRanges.entries()) {
|
|
474
|
-
yield range;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
//# sourceMappingURL=sessionIdNormalizer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessionIdNormalizer.js","sourceRoot":"","sources":["../../src/id-compressor/sessionIdNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8DAA8D;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAOtD,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,IAAI,EAAW,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,OAAO,mBAAmB;IAkB/B,YAAoC,mBAAmB,KAAK;QAAxB,qBAAgB,GAAhB,gBAAgB,CAAQ;QAjBpD,gBAAW,GAAsB,CAAC,CAAsB,CAAC;QAChD,aAAQ,GAIrB,IAAI,yBAAyB,CAChC,4BAA4B,EAC5B,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,EAAE;YACpB,IAAI,WAAW,KAAK,SAAS,EAAE;gBAC9B,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC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,OAAO,GAAG,UAAU,EAAE;YACzB,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,QAAQ,CAAC,CAAC,OAAO,CAChB,UAA6B,EAC7B,WAAkD;IAElD,IAAI,WAAW,KAAK,SAAS,EAAE;QAC9B,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE;YAC/B,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;SAChC;aAAM;YACN,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE;gBAC1C,MAAM,KAAK,CAAC;aACZ;SACD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/restrict-plus-operands */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tFinalCompressedId,\n\tLocalCompressedId,\n\tSessionSpaceCompressedId,\n\tSerializedSessionIdNormalizer,\n} from \"@fluidframework/runtime-definitions\";\nimport { compareFiniteNumbers, compareFiniteNumbersReversed, fail, Mutable } from \"./utils\";\nimport { AppendOnlyDoublySortedMap } from \"./appendOnlySortedMap\";\n\n/**\n * Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.\n * The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such\n * that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.\n * Below is an example to illustrate how various mappings can arise:\n *\n * ```\n * +- Creation Index\n * / +- Locals\n * / / +- Finals\n * / / /\n * ---+-----+----\n * 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.\n * 1 | -2 | 1 -|\n * 2 | | 2 -|\n * 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.\n * 4 | | 4 -|\n * 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.\n * 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.\n * 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.\n * 8 | | 13\n * 9 | | 14\n * 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.\n * ```\n *\n * Note that in this example, some IDs (those at indices 2, 3, 4, 6, 8, and 9) have no local form. The ID at index 10 has no final form.\n * These kinds of \"gaps\" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,\n * which depends on receiving an ack/sequence number from the server. Given this context, \"session space\" can be thought of as:\n *\n * ```\n * for each index in the range of IDs created by a session:\n * \tthe local form if it exists, otherwise the final form\n * ```\n *\n * This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and\n * final space) is uninterrupted by \"gaps\" and can be compactly represented by a (first, last) pair and is easily binary searched for\n * normalization between local and final space.\n */\nexport class SessionIdNormalizer<TRangeObject> {\n\tprivate nextLocalId: LocalCompressedId = -1 as LocalCompressedId;\n\tprivate readonly idRanges: AppendOnlyDoublySortedMap<\n\t\tLocalCompressedId,\n\t\t[lastLocal: LocalCompressedId, finalRanges: FinalRanges<TRangeObject> | undefined],\n\t\tFinalCompressedId\n\t> = new AppendOnlyDoublySortedMap(\n\t\tcompareFiniteNumbersReversed,\n\t\t([_, finalRanges]) => {\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\tconst first = getFirstRange(finalRanges);\n\t\t\t\treturn extractFirstFinalFromRange(first);\n\t\t\t}\n\t\t\treturn Number.POSITIVE_INFINITY as FinalCompressedId;\n\t\t},\n\t\tcompareFiniteNumbers,\n\t);\n\n\tpublic constructor(private readonly expensiveAsserts = false) {}\n\n\t/**\n\t * Converts the final ID to its session-space representation.\n\t * This will be the corresponding local if a local form exists, and `finalId` otherwise.\n\t */\n\tpublic getSessionSpaceId(finalId: FinalCompressedId): SessionSpaceCompressedId | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\tif (finalDelta <= localRangeDelta) {\n\t\t\t\t\t\treturn (alignedLocal - finalDelta) as LocalCompressedId;\n\t\t\t\t\t}\n\t\t\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Converts the local ID to its corresponding final ID, if one exists.\n\t */\n\tpublic getFinalId(localId: LocalCompressedId): [FinalCompressedId, TRangeObject] | undefined {\n\t\tconst localRange =\n\t\t\tthis.idRanges.getPairOrNextLower(localId) ??\n\t\t\tfail(\"Local ID was never recorded with this normalizer.\");\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localId < lastLocal) {\n\t\t\tfail(\"Local ID was never recorded with this normalizer.\");\n\t\t}\n\t\tconst finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);\n\t\tif (finalRange !== undefined) {\n\t\t\tconst [alignedLocal, [firstFinal, lastFinal, rangeObject]] = finalRange;\n\t\t\tconst rangeDelta = lastFinal - firstFinal;\n\t\t\tconst localDelta = alignedLocal - localId;\n\t\t\tif (localDelta <= rangeDelta) {\n\t\t\t\t// Local is within a range segment that has a corresponding final\n\t\t\t\treturn [(firstFinal + localDelta) as FinalCompressedId, rangeObject];\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the index of the local ID corresponding to the supplied final ID in the total range of IDs created by the session,\n\t * if the ID was created by the session for this `SessionIdNormalizer`.\n\t */\n\tpublic getCreationIndex(finalId: FinalCompressedId): number | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [_, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\treturn -alignedLocal - 1 + finalDelta;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the session-space ID at the supplied creation index, if one exists.\n\t */\n\tpublic getIdByCreationIndex(index: number): SessionSpaceCompressedId | undefined {\n\t\tconst localByIndex = -(index + 1) as LocalCompressedId;\n\t\tconst localRange = this.idRanges.getPairOrNextLower(localByIndex);\n\t\tif (localRange === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localByIndex >= lastLocal) {\n\t\t\treturn localByIndex;\n\t\t}\n\t\tconst finalRange =\n\t\t\tgetPairOrNextLower(firstLocal, finalRanges, localByIndex) ??\n\t\t\tfail(\"Final ranges not aligned with owning local range.\");\n\n\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\tconst localDelta = alignedLocal - localByIndex;\n\t\tconst finalId = firstFinal + localDelta;\n\t\tif (finalId <= lastFinal) {\n\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate static makeFinalRangesMap<TRangeObject>(): FinalRangesMap<TRangeObject> {\n\t\treturn new AppendOnlyDoublySortedMap(\n\t\t\tcompareFiniteNumbersReversed,\n\t\t\textractFirstFinalFromRange,\n\t\t\tcompareFiniteNumbers,\n\t\t);\n\t}\n\n\t/**\n\t * Returns the last final ID known to this normalizer.\n\t */\n\tpublic getLastFinalId(): FinalCompressedId | undefined {\n\t\tconst lastIndex = this.idRanges.size - 1;\n\t\tconst secondToLast = Math.max(0, lastIndex - 1);\n\t\tfor (let i = lastIndex; i >= secondToLast; i--) {\n\t\t\tconst localRange = this.idRanges.getAtIndex(i);\n\t\t\tif (localRange !== undefined) {\n\t\t\t\tconst finalRanges = localRange[1][1];\n\t\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t\treturn getLastRange(finalRanges)[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Registers and returns the next ID in local space with this normalizer. An example:\n\t *\n\t * Locals: [-1, -2, X, X]\n\t * Finals: [ 0, 1, 2, 3]\n\t * In this scenario, a call to this method would generate and return -5.\n\t */\n\tpublic addLocalId(): LocalCompressedId {\n\t\tconst localId = this.nextLocalId-- as LocalCompressedId;\n\t\tconst lastLocalRange = this.idRanges.last();\n\t\tif (lastLocalRange !== undefined) {\n\t\t\tconst lastLocal = lastLocalRange[1][0];\n\t\t\tif (localId === lastLocal - 1) {\n\t\t\t\t// New local simply expands the last local range tracked\n\t\t\t\tlastLocalRange[1][0] = localId;\n\t\t\t\treturn localId;\n\t\t\t}\n\t\t}\n\n\t\tif (this.expensiveAsserts) {\n\t\t\tif (lastLocalRange === undefined) {\n\t\t\t\tassert(localId === -1, 0x49e /* Local ID space must start at -1. */);\n\t\t\t} else {\n\t\t\t\tconst [firstLocal, [_, finalRanges]] = lastLocalRange;\n\t\t\t\tlet finalDelta = 0;\n\t\t\t\tfor (const [__, [firstFinal, lastFinal]] of entries(firstLocal, finalRanges)) {\n\t\t\t\t\tfinalDelta += lastFinal - firstFinal + 1;\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tlocalId === firstLocal - finalDelta,\n\t\t\t\t\t0x49f /* Local ID space must be contiguous. */,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tthis.idRanges.append(localId, [localId, undefined]);\n\t\treturn localId;\n\t}\n\n\t/**\n\t * Registers one or more final IDs with this normalizer.\n\t * If there are any local IDs at the tip of session-space that do not have a corresponding final, they will be registered (aligned)\n\t * starting with the first of those. Otherwise, will be registered as the next ID in session space in creation order.\n\t *\n\t * An example:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, X]\n\t * Calling `addFinalIds` with first === last === 5 results in the following:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, 5]\n\t * Subsequently calling `addFinalIds` with first === last === 6 results in the following:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 6]\n\t *\n\t * Non-contiguous final IDs (i.e. the first final after a \"gap\" in final space) must always correspond to a local ID. For example,\n\t * in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a\n\t * non-contiguous final ID without a local form:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 9]\n\t *\n\t * ^final ID 9 is not contiguous and does not have a corresponding local ID\n\t */\n\tpublic addFinalIds(\n\t\tfirstFinal: FinalCompressedId,\n\t\tlastFinal: FinalCompressedId,\n\t\trangeObject: TRangeObject,\n\t): void {\n\t\tassert(lastFinal >= firstFinal, 0x5ae /* Malformed normalization range. */);\n\t\tconst [firstLocal, finalRangesObj] =\n\t\t\tthis.idRanges.last() ?? fail(\"Final IDs must be added to an existing local range.\");\n\t\tconst [lastLocal, finalRanges] = finalRangesObj;\n\t\tlet nextLocal: LocalCompressedId;\n\t\tif (finalRanges === undefined) {\n\t\t\tfinalRangesObj[1] = [firstFinal, lastFinal, rangeObject];\n\t\t\tnextLocal = Math.min(\n\t\t\t\tthis.nextLocalId,\n\t\t\t\tfirstLocal - (lastFinal - firstFinal) - 1,\n\t\t\t) as LocalCompressedId;\n\t\t} else {\n\t\t\tconst [firstAlignedLocal, lastAlignedLocal, lastAlignedFinal, lastFinalRange] =\n\t\t\t\tthis.getAlignmentOfLastRange(firstLocal, finalRanges);\n\t\t\tnextLocal = Math.min(\n\t\t\t\tthis.nextLocalId,\n\t\t\t\tlastAlignedLocal - (lastFinal - firstFinal) - 2,\n\t\t\t) as LocalCompressedId;\n\t\t\tif (firstFinal === lastAlignedFinal + 1) {\n\t\t\t\tlastFinalRange[1] = lastFinal;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = (lastAlignedLocal - 1) as LocalCompressedId;\n\t\t\t\tlet rangeMap: FinalRangesMap<TRangeObject>;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\t// Convert the single range to a range collection\n\t\t\t\t\trangeMap = SessionIdNormalizer.makeFinalRangesMap();\n\t\t\t\t\trangeMap.append(firstAlignedLocal, lastFinalRange);\n\t\t\t\t\tfinalRangesObj[1] = rangeMap;\n\t\t\t\t} else {\n\t\t\t\t\trangeMap = finalRanges;\n\t\t\t\t}\n\t\t\t\trangeMap.append(alignedLocal, [firstFinal, lastFinal, rangeObject]);\n\t\t\t\tassert(\n\t\t\t\t\talignedLocal >= lastLocal,\n\t\t\t\t\t0x4a0 /* Gaps in final space must align to a local. */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this.expensiveAsserts) {\n\t\t\t\tthis.idRanges.assertValid();\n\t\t\t}\n\t\t}\n\n\t\tthis.nextLocalId = nextLocal;\n\t}\n\n\t/**\n\t * Alerts the normalizer to the existence of a block of final IDs that are *allocated* (but may not be entirely used).\n\t *\n\t * The normalizer may have unaligned (unfinalized) local IDs; any such outstanding locals will be eagerly aligned with\n\t * as many finals from the registered block as possible.\n\t *\n\t * It is important to register blocks via this method as soon as they are created for future eager final generations to be utilized, as such\n\t * generation is dependant on the normalizer being up-to-date with which local IDs have been aligned with finals. If, for instance,\n\t * a block of finals is not immediately registered with the normalizer and there are outstanding locals that would have aligned with them,\n\t * those locals will not be finalized until their creation range is finalized, which could be later if the block was created by an earlier\n\t * creation range's finalization but is large enough to span them both. In this scenario, no eager finals can be generated until the second\n\t * creation range is finalized.\n\t *\n\t * A usage example:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, X, X, X]\n\t * Calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 10 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, 7]\n\t * Instead calling `registerFinalIdBlock` with firstFinalInBlock === 5 and count === 2 results in the following:\n\t * Locals: [-1, -2, X, -4, -5, -6]\n\t * Finals: [ 0, 1, 2, 5, 6, X]\n\t *\n\t */\n\tpublic registerFinalIdBlock(\n\t\tfirstFinalInBlock: FinalCompressedId,\n\t\tcount: number,\n\t\trangeObject: TRangeObject,\n\t): void {\n\t\tassert(count >= 1, 0x5af /* Malformed normalization block. */);\n\t\tconst [firstLocal, [lastLocal, finalRanges]] =\n\t\t\tthis.idRanges.last() ??\n\t\t\tfail(\"Final ID block should not be registered before any locals.\");\n\t\tlet unalignedLocalCount: number;\n\t\tif (finalRanges === undefined) {\n\t\t\tunalignedLocalCount = firstLocal - lastLocal + 1;\n\t\t} else {\n\t\t\tconst [_, lastAlignedLocal] = this.getAlignmentOfLastRange(firstLocal, finalRanges);\n\t\t\tunalignedLocalCount = lastAlignedLocal - lastLocal;\n\t\t}\n\t\tassert(\n\t\t\tunalignedLocalCount > 0,\n\t\t\t0x51b /* Final ID block should not be registered without an existing local range. */,\n\t\t);\n\t\tconst lastFinal = (firstFinalInBlock +\n\t\t\tMath.min(unalignedLocalCount, count) -\n\t\t\t1) as FinalCompressedId;\n\t\tthis.addFinalIds(firstFinalInBlock, lastFinal, rangeObject);\n\t}\n\n\tprivate getAlignmentOfLastRange(\n\t\tfirstLocal: LocalCompressedId,\n\t\tfinalRanges: FinalRanges<TRangeObject>,\n\t): [\n\t\tfirstAlignedLocal: LocalCompressedId,\n\t\tlastAlignedLocal: LocalCompressedId,\n\t\tlastAlignedFinal: FinalCompressedId,\n\t\tlastFinalRange: FinalRange<TRangeObject>,\n\t] {\n\t\tconst isSingle = isSingleRange(finalRanges);\n\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\tlet firstAlignedLocal: LocalCompressedId;\n\t\tif (isSingle) {\n\t\t\tfirstAlignedLocal = firstLocal;\n\t\t\tlastFinalRange = finalRanges;\n\t\t} else {\n\t\t\t[firstAlignedLocal, lastFinalRange] =\n\t\t\t\tfinalRanges.last() ?? fail(\"Map should be non-empty.\");\n\t\t}\n\n\t\tconst [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;\n\t\tconst lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);\n\t\treturn [\n\t\t\tfirstAlignedLocal,\n\t\t\tlastAlignedLocal as LocalCompressedId,\n\t\t\tlastAlignedFinal,\n\t\t\tlastFinalRange,\n\t\t];\n\t}\n\n\t/**\n\t * Returns an enumerable of all session-space IDs known to this normalizer, in creation order.\n\t */\n\tpublic *[Symbol.iterator](): IterableIterator<SessionSpaceCompressedId> {\n\t\tfor (const [firstLocal, [lastLocal, finalRanges]] of this.idRanges.entries()) {\n\t\t\tfor (let i = firstLocal; i >= lastLocal; i--) {\n\t\t\t\tyield i;\n\t\t\t}\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t// Safe to get only the last final range, as all others must have corresponding locals (see `addFinalIds` docs)\n\t\t\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\t\t\tlet alignedLocal: LocalCompressedId;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\talignedLocal = firstLocal;\n\t\t\t\t\tlastFinalRange = finalRanges;\n\t\t\t\t} else {\n\t\t\t\t\t[alignedLocal, lastFinalRange] =\n\t\t\t\t\t\tfinalRanges.last() ?? fail(\"Map should be non-empty.\");\n\t\t\t\t}\n\t\t\t\tconst [firstFinal, lastFinal] = lastFinalRange;\n\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\tfor (let i = firstFinal + localRangeDelta + 1; i <= lastFinal; i++) {\n\t\t\t\t\tyield i as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(): SerializedSessionIdNormalizer {\n\t\tconst serialized: Mutable<SerializedSessionIdNormalizer> = {\n\t\t\tlocalRanges: [],\n\t\t\tnextLocalId: this.nextLocalId,\n\t\t};\n\t\tconst localRanges = serialized.localRanges as Mutable<typeof serialized.localRanges>;\n\t\tfor (const [firstLocal, finalRanges] of this.idRanges.entries()) {\n\t\t\tconst [lastLocal, finalRangesTable] = finalRanges;\n\t\t\tif (finalRangesTable !== undefined) {\n\t\t\t\tconst serializedFinalRanges: [\n\t\t\t\t\tLocalCompressedId,\n\t\t\t\t\tFinalCompressedId,\n\t\t\t\t\tFinalCompressedId,\n\t\t\t\t][] = [];\n\t\t\t\tfor (const [alignedLocal, [firstFinal, lastFinal]] of entries(\n\t\t\t\t\tfirstLocal,\n\t\t\t\t\tfinalRangesTable,\n\t\t\t\t)) {\n\t\t\t\t\tserializedFinalRanges.push([alignedLocal, firstFinal, lastFinal]);\n\t\t\t\t}\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal, serializedFinalRanges]);\n\t\t\t} else {\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal]);\n\t\t\t}\n\t\t}\n\t\treturn serialized;\n\t}\n\n\tpublic static deserialize<TRangeObject>(\n\t\tserialized: SerializedSessionIdNormalizer,\n\t\tgetRangeObject: (finalId: FinalCompressedId) => TRangeObject,\n\t): SessionIdNormalizer<TRangeObject> {\n\t\tconst normalizer = new SessionIdNormalizer<TRangeObject>();\n\t\tconst { idRanges } = normalizer;\n\t\tfor (const [firstLocal, lastLocal, serializedFinalRanges] of serialized.localRanges) {\n\t\t\tlet finalRanges: FinalRanges<TRangeObject> | undefined;\n\t\t\tif (serializedFinalRanges !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tserializedFinalRanges.length !== 0,\n\t\t\t\t\t0x4a1 /* Empty range should not be reified. */,\n\t\t\t\t);\n\t\t\t\tif (serializedFinalRanges.length === 1) {\n\t\t\t\t\tconst [_, firstFinal, lastFinal] = serializedFinalRanges[0];\n\t\t\t\t\tfinalRanges = [firstFinal, lastFinal, getRangeObject(firstFinal)];\n\t\t\t\t} else {\n\t\t\t\t\tfinalRanges = SessionIdNormalizer.makeFinalRangesMap<TRangeObject>();\n\t\t\t\t\tfor (const [alignedLocal, firstFinal, lastFinal] of serializedFinalRanges) {\n\t\t\t\t\t\tfinalRanges.append(alignedLocal, [\n\t\t\t\t\t\t\tfirstFinal,\n\t\t\t\t\t\t\tlastFinal,\n\t\t\t\t\t\t\tgetRangeObject(firstFinal),\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tidRanges.append(firstLocal, [lastLocal, finalRanges]);\n\t\t}\n\t\tnormalizer.nextLocalId = serialized.nextLocalId;\n\t\treturn normalizer;\n\t}\n\n\tpublic equals(\n\t\tother: SessionIdNormalizer<TRangeObject>,\n\t\tcompareRangeObjects: (a: TRangeObject, b: TRangeObject) => boolean = (a, b) => a === b,\n\t): boolean {\n\t\treturn (\n\t\t\tthis.nextLocalId === other.nextLocalId &&\n\t\t\tthis.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {\n\t\t\t\tconst [lastLocalA, finalRangesA] = localRangeA;\n\t\t\t\tconst [lastLocalB, finalRangesB] = localRangeB;\n\t\t\t\tif (finalRangesA === undefined || finalRangesB === undefined) {\n\t\t\t\t\treturn finalRangesA === finalRangesB;\n\t\t\t\t}\n\n\t\t\t\tconst rangeEquals = (\n\t\t\t\t\tfinalRangeA: FinalRange<TRangeObject>,\n\t\t\t\t\tfinalRangeB: FinalRange<TRangeObject>,\n\t\t\t\t) => {\n\t\t\t\t\tconst [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;\n\t\t\t\t\tconst [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;\n\t\t\t\t\treturn (\n\t\t\t\t\t\tfirstFinalA === firstFinalB &&\n\t\t\t\t\t\tlastFinalA === lastFinalB &&\n\t\t\t\t\t\tcompareRangeObjects(rangeObjectA, rangeObjectB)\n\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tif (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {\n\t\t\t\t\tif (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn rangeEquals(finalRangesA, finalRangesB);\n\t\t\t\t}\n\n\t\t\t\treturn lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);\n\t\t\t})\n\t\t);\n\t}\n}\n\ntype FinalRange<TRangeObject> = [\n\tfirstFinal: FinalCompressedId,\n\tlastFinal: FinalCompressedId,\n\trangeObject: TRangeObject,\n];\n\ntype FinalRangesMap<TRangeObject> = AppendOnlyDoublySortedMap<\n\tLocalCompressedId,\n\tFinalRange<TRangeObject>,\n\tFinalCompressedId\n>;\n\ntype FinalRanges<TRangeObject> = FinalRange<TRangeObject> | FinalRangesMap<TRangeObject>;\n\nfunction isSingleRange<TRangeObject>(\n\tranges: FinalRanges<TRangeObject>,\n): ranges is FinalRange<TRangeObject> {\n\treturn Array.isArray(ranges);\n}\n\nfunction getLastRange<TRangeObject>(\n\tfinalRanges: FinalRanges<TRangeObject>,\n): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.last() ?? fail(\"Map must be non-empty\"))[1];\n}\n\nfunction getFirstRange<TRangeObject>(\n\tfinalRanges: FinalRanges<TRangeObject>,\n): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.first() ?? fail(\"Map must be non-empty\"))[1];\n}\n\nfunction extractFirstFinalFromRange<TRangeObject>(\n\tfinalRange: FinalRange<TRangeObject>,\n): FinalCompressedId {\n\treturn finalRange[0];\n}\n\nfunction getPairOrNextLowerByValue<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tfinalId: FinalCompressedId,\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (finalId < finalRanges[0]) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLowerByValue(finalId);\n}\n\nfunction getPairOrNextLower<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tlocalId: LocalCompressedId,\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (localId > firstLocal) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLower(localId);\n}\n\nfunction* entries<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n): IterableIterator<readonly [LocalCompressedId, FinalRange<TRangeObject>]> {\n\tif (finalRanges !== undefined) {\n\t\tif (isSingleRange(finalRanges)) {\n\t\t\tyield [firstLocal, finalRanges];\n\t\t} else {\n\t\t\tfor (const range of finalRanges.entries()) {\n\t\t\t\tyield range;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Remove `readonly` from all fields.
|
|
7
|
-
*/
|
|
8
|
-
export declare type Mutable<T> = {
|
|
9
|
-
-readonly [P in keyof T]: T[P];
|
|
10
|
-
};
|
|
11
|
-
/** A union type of the first `N` positive integers */
|
|
12
|
-
export declare type TakeWholeNumbers<N extends number, A extends never[] = []> = N extends A["length"] ? never : A["length"] | TakeWholeNumbers<N, [never, ...A]>;
|
|
13
|
-
/** Returns a tuple type with exactly `Length` elements of type `T` */
|
|
14
|
-
export declare type ArrayOfLength<T, Length extends number, A extends T[] = []> = Length extends A["length"] ? A : ArrayOfLength<T, Length, [T, ...A]>;
|
|
15
|
-
/**
|
|
16
|
-
* Fails true iff `array` has at least `length` elements
|
|
17
|
-
*/
|
|
18
|
-
export declare function hasAtLeastLength<T, Len extends TakeWholeNumbers<16>>(array: readonly T[], length: Len): array is [...ArrayOfLength<T, Len>, ...T[]];
|
|
19
|
-
/**
|
|
20
|
-
* A numeric comparator used for sorting in ascending order.
|
|
21
|
-
*
|
|
22
|
-
* Handles +/-0 like Map: -0 is equal to +0.
|
|
23
|
-
*/
|
|
24
|
-
export declare function compareFiniteNumbers<T extends number>(a: T, b: T): number;
|
|
25
|
-
/**
|
|
26
|
-
* A numeric comparator used for sorting in descending order.
|
|
27
|
-
*
|
|
28
|
-
* Handles +/-0 like Map: -0 is equal to +0.
|
|
29
|
-
*/
|
|
30
|
-
export declare function compareFiniteNumbersReversed<T extends number>(a: T, b: T): number;
|
|
31
|
-
/**
|
|
32
|
-
* Compare two maps and return true if their contents are equivalent.
|
|
33
|
-
* @param mapA - The first array to compare
|
|
34
|
-
* @param mapB - The second array to compare
|
|
35
|
-
* @param elementComparator - The function used to check if two `T`s are equivalent.
|
|
36
|
-
* Defaults to `Object.is()` equality (a shallow compare)
|
|
37
|
-
*/
|
|
38
|
-
export declare function compareMaps<K, V>(mapA: ReadonlyMap<K, V>, mapB: ReadonlyMap<K, V>, elementComparator?: (a: V, b: V) => boolean): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.
|
|
41
|
-
* @param map - The map to query/update
|
|
42
|
-
* @param key - The key to lookup in the map
|
|
43
|
-
* @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists
|
|
44
|
-
* @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)
|
|
45
|
-
*/
|
|
46
|
-
export declare function getOrCreate<K, V>(map: Map<K, V>, key: K, defaultValue: (key: K) => V): V;
|
|
47
|
-
/**
|
|
48
|
-
* Compares strings lexically to form a strict partial ordering.
|
|
49
|
-
*/
|
|
50
|
-
export declare function compareStrings<T extends string>(a: T, b: T): number;
|
|
51
|
-
export declare function fail(message: string): never;
|
|
52
|
-
/**
|
|
53
|
-
* Sets a property in such a way that it is only set on `destination` if the provided value is not undefined.
|
|
54
|
-
* This avoids having explicit undefined values under properties that would cause `Object.hasOwnProperty` to return true.
|
|
55
|
-
*/
|
|
56
|
-
export declare function setPropertyIfDefined<TDst, P extends keyof TDst>(value: TDst[P] | undefined, destination: TDst, property: P): void;
|
|
57
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/id-compressor/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,OAAO,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE5D,sDAAsD;AACtD,oBAAY,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC3F,KAAK,GACL,CAAC,CAAC,QAAQ,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AAEpD,sEAAsE;AACtE,oBAAY,aAAa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