@fluidframework/container-runtime 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.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 +22 -0
- package/README.md +1 -2
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +9 -1
- package/api-report/container-runtime.api.md +124 -107
- package/dist/batchTracker.d.ts +1 -0
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/blobManager.d.ts +4 -4
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js.map +1 -1
- package/dist/connectionTelemetry.js +1 -1
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/container-runtime-alpha.d.ts +1473 -0
- package/dist/container-runtime-beta.d.ts +300 -0
- package/dist/container-runtime-public.d.ts +300 -0
- package/dist/container-runtime-untrimmed.d.ts +1836 -0
- package/dist/containerRuntime.d.ts +34 -40
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +79 -67
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreRegistry.d.ts +1 -1
- package/dist/dataStoreRegistry.js +1 -1
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/dataStores.d.ts +10 -15
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +77 -40
- package/dist/dataStores.js.map +1 -1
- package/dist/gc/garbageCollection.d.ts +41 -13
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +215 -78
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.d.ts.map +1 -1
- package/dist/gc/gcConfigs.js +34 -37
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +121 -46
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js +26 -18
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcHelpers.d.ts +18 -25
- package/dist/gc/gcHelpers.d.ts.map +1 -1
- package/dist/gc/gcHelpers.js +29 -45
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcTelemetry.d.ts +0 -5
- package/dist/gc/gcTelemetry.d.ts.map +1 -1
- package/dist/gc/gcTelemetry.js +14 -42
- package/dist/gc/gcTelemetry.js.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.d.ts +11 -5
- package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.js +43 -19
- 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 +4 -5
- package/dist/gc/index.js.map +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/messageTypes.d.ts +16 -11
- package/dist/messageTypes.d.ts.map +1 -1
- package/dist/messageTypes.js +6 -1
- package/dist/messageTypes.js.map +1 -1
- package/dist/metadata.d.ts +6 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
- package/dist/opLifecycle/opGroupingManager.js +10 -1
- package/dist/opLifecycle/opGroupingManager.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +2 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +21 -0
- package/dist/opLifecycle/outbox.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 +1 -1
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +2 -11
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/scheduleManager.d.ts +1 -0
- package/dist/scheduleManager.d.ts.map +1 -1
- package/dist/summary/orderedClientElection.d.ts +1 -1
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/dist/summary/runWhileConnectedCoordinator.d.ts +2 -2
- package/dist/summary/runWhileConnectedCoordinator.js +1 -1
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/summary/summarizer.d.ts +1 -1
- package/dist/summary/summarizer.js +1 -1
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerTypes.d.ts +30 -30
- package/dist/summary/summarizerTypes.js.map +1 -1
- package/dist/summary/summaryCollection.d.ts +10 -10
- package/dist/summary/summaryCollection.js +1 -1
- package/dist/summary/summaryCollection.js.map +1 -1
- package/dist/summary/summaryFormat.d.ts +3 -3
- package/dist/summary/summaryFormat.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/batchTracker.d.ts +1 -0
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/blobManager.d.ts +4 -4
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js.map +1 -1
- package/lib/connectionTelemetry.js +1 -1
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/container-runtime-alpha.d.ts +1473 -0
- package/lib/container-runtime-beta.d.ts +300 -0
- package/lib/container-runtime-public.d.ts +300 -0
- package/lib/container-runtime-untrimmed.d.ts +1836 -0
- package/lib/containerRuntime.d.ts +34 -40
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +81 -69
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreRegistry.d.ts +1 -1
- package/lib/dataStoreRegistry.js +1 -1
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/dataStores.d.ts +10 -15
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +80 -43
- package/lib/dataStores.js.map +1 -1
- package/lib/gc/garbageCollection.d.ts +41 -13
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +217 -80
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.d.ts.map +1 -1
- package/lib/gc/gcConfigs.js +37 -40
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +121 -46
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js +25 -17
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcHelpers.d.ts +18 -25
- package/lib/gc/gcHelpers.d.ts.map +1 -1
- package/lib/gc/gcHelpers.js +27 -43
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcTelemetry.d.ts +0 -5
- package/lib/gc/gcTelemetry.d.ts.map +1 -1
- package/lib/gc/gcTelemetry.js +15 -43
- package/lib/gc/gcTelemetry.js.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.d.ts +11 -5
- package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.js +43 -19
- 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/index.d.ts +14 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -1
- package/lib/index.js.map +1 -1
- package/lib/messageTypes.d.ts +16 -11
- package/lib/messageTypes.d.ts.map +1 -1
- package/lib/messageTypes.js +6 -1
- package/lib/messageTypes.js.map +1 -1
- package/lib/metadata.d.ts +6 -0
- package/lib/metadata.d.ts.map +1 -1
- package/lib/metadata.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
- package/lib/opLifecycle/opGroupingManager.js +10 -1
- package/lib/opLifecycle/opGroupingManager.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +2 -0
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +21 -0
- package/lib/opLifecycle/outbox.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 +1 -1
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +2 -11
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/scheduleManager.d.ts +1 -0
- package/lib/scheduleManager.d.ts.map +1 -1
- package/lib/summary/orderedClientElection.d.ts +1 -1
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/lib/summary/runWhileConnectedCoordinator.d.ts +2 -2
- package/lib/summary/runWhileConnectedCoordinator.js +1 -1
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/summary/summarizer.d.ts +1 -1
- package/lib/summary/summarizer.js +1 -1
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerTypes.d.ts +30 -30
- package/lib/summary/summarizerTypes.js.map +1 -1
- package/lib/summary/summaryCollection.d.ts +10 -10
- package/lib/summary/summaryCollection.js +1 -1
- package/lib/summary/summaryCollection.js.map +1 -1
- package/lib/summary/summaryFormat.d.ts +3 -3
- package/lib/summary/summaryFormat.js.map +1 -1
- package/package.json +56 -29
- package/src/blobManager.ts +5 -5
- package/src/connectionTelemetry.ts +1 -1
- package/src/containerRuntime.ts +113 -90
- package/src/dataStoreRegistry.ts +1 -1
- package/src/dataStores.ts +140 -69
- package/src/gc/garbageCollection.md +14 -15
- package/src/gc/garbageCollection.ts +256 -96
- package/src/gc/gcConfigs.ts +50 -52
- package/src/gc/gcDefinitions.ts +137 -52
- package/src/gc/gcHelpers.ts +31 -52
- package/src/gc/gcTelemetry.ts +16 -57
- package/src/gc/gcUnreferencedStateTracker.ts +61 -22
- package/src/gc/index.ts +6 -4
- package/src/index.ts +19 -1
- package/src/messageTypes.ts +21 -11
- package/src/metadata.ts +7 -0
- package/src/opLifecycle/definitions.ts +1 -1
- package/src/opLifecycle/opGroupingManager.ts +10 -1
- package/src/opLifecycle/outbox.ts +34 -0
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +3 -13
- package/src/summary/orderedClientElection.ts +1 -1
- package/src/summary/runWhileConnectedCoordinator.ts +2 -2
- package/src/summary/summarizer.ts +1 -1
- package/src/summary/summarizerTypes.ts +30 -30
- package/src/summary/summaryCollection.ts +10 -10
- package/src/summary/summaryFormat.ts +3 -3
- package/dist/id-compressor/appendOnlySortedMap.d.ts +0 -124
- package/dist/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
- package/dist/id-compressor/appendOnlySortedMap.js +0 -318
- package/dist/id-compressor/appendOnlySortedMap.js.map +0 -1
- package/dist/id-compressor/finalSpace.d.ts +0 -29
- package/dist/id-compressor/finalSpace.d.ts.map +0 -1
- package/dist/id-compressor/finalSpace.js +0 -62
- package/dist/id-compressor/finalSpace.js.map +0 -1
- package/dist/id-compressor/idCompressor.d.ts +0 -54
- package/dist/id-compressor/idCompressor.d.ts.map +0 -1
- package/dist/id-compressor/idCompressor.js +0 -495
- package/dist/id-compressor/idCompressor.js.map +0 -1
- package/dist/id-compressor/identifiers.d.ts +0 -32
- package/dist/id-compressor/identifiers.d.ts.map +0 -1
- package/dist/id-compressor/identifiers.js +0 -15
- package/dist/id-compressor/identifiers.js.map +0 -1
- package/dist/id-compressor/index.d.ts +0 -13
- package/dist/id-compressor/index.d.ts.map +0 -1
- package/dist/id-compressor/index.js +0 -32
- package/dist/id-compressor/index.js.map +0 -1
- package/dist/id-compressor/persistanceUtilities.d.ts +0 -22
- package/dist/id-compressor/persistanceUtilities.d.ts.map +0 -1
- package/dist/id-compressor/persistanceUtilities.js +0 -43
- package/dist/id-compressor/persistanceUtilities.js.map +0 -1
- package/dist/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
- package/dist/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
- package/dist/id-compressor/sessionSpaceNormalizer.js +0 -80
- package/dist/id-compressor/sessionSpaceNormalizer.js.map +0 -1
- package/dist/id-compressor/sessions.d.ts +0 -115
- package/dist/id-compressor/sessions.d.ts.map +0 -1
- package/dist/id-compressor/sessions.js +0 -305
- package/dist/id-compressor/sessions.js.map +0 -1
- package/dist/id-compressor/utilities.d.ts +0 -52
- package/dist/id-compressor/utilities.d.ts.map +0 -1
- package/dist/id-compressor/utilities.js +0 -169
- package/dist/id-compressor/utilities.js.map +0 -1
- package/lib/id-compressor/appendOnlySortedMap.d.ts +0 -124
- package/lib/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
- package/lib/id-compressor/appendOnlySortedMap.js +0 -314
- package/lib/id-compressor/appendOnlySortedMap.js.map +0 -1
- package/lib/id-compressor/finalSpace.d.ts +0 -29
- package/lib/id-compressor/finalSpace.d.ts.map +0 -1
- package/lib/id-compressor/finalSpace.js +0 -58
- package/lib/id-compressor/finalSpace.js.map +0 -1
- package/lib/id-compressor/idCompressor.d.ts +0 -54
- package/lib/id-compressor/idCompressor.d.ts.map +0 -1
- package/lib/id-compressor/idCompressor.js +0 -491
- package/lib/id-compressor/idCompressor.js.map +0 -1
- package/lib/id-compressor/identifiers.d.ts +0 -32
- package/lib/id-compressor/identifiers.d.ts.map +0 -1
- package/lib/id-compressor/identifiers.js +0 -11
- package/lib/id-compressor/identifiers.js.map +0 -1
- package/lib/id-compressor/index.d.ts +0 -13
- package/lib/id-compressor/index.d.ts.map +0 -1
- package/lib/id-compressor/index.js +0 -13
- package/lib/id-compressor/index.js.map +0 -1
- package/lib/id-compressor/persistanceUtilities.d.ts +0 -22
- package/lib/id-compressor/persistanceUtilities.d.ts.map +0 -1
- package/lib/id-compressor/persistanceUtilities.js +0 -34
- package/lib/id-compressor/persistanceUtilities.js.map +0 -1
- package/lib/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
- package/lib/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
- package/lib/id-compressor/sessionSpaceNormalizer.js +0 -76
- package/lib/id-compressor/sessionSpaceNormalizer.js.map +0 -1
- package/lib/id-compressor/sessions.d.ts +0 -115
- package/lib/id-compressor/sessions.d.ts.map +0 -1
- package/lib/id-compressor/sessions.js +0 -290
- package/lib/id-compressor/sessions.js.map +0 -1
- package/lib/id-compressor/utilities.d.ts +0 -52
- package/lib/id-compressor/utilities.d.ts.map +0 -1
- package/lib/id-compressor/utilities.js +0 -151
- package/lib/id-compressor/utilities.js.map +0 -1
- package/src/id-compressor/README.md +0 -3
- package/src/id-compressor/appendOnlySortedMap.ts +0 -366
- package/src/id-compressor/finalSpace.ts +0 -67
- package/src/id-compressor/idCompressor.ts +0 -630
- package/src/id-compressor/identifiers.ts +0 -42
- package/src/id-compressor/index.ts +0 -26
- package/src/id-compressor/persistanceUtilities.ts +0 -58
- package/src/id-compressor/sessionSpaceNormalizer.ts +0 -83
- package/src/id-compressor/sessions.ts +0 -405
- package/src/id-compressor/utilities.ts +0 -190
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { OpSpaceCompressedId, SessionSpaceCompressedId } from "@fluidframework/runtime-definitions";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A compressed ID that is stable and unique within the scope of network of compressors (i.e. a document).
|
|
10
|
-
* It can only be used/decompressed in the context of the originating document.
|
|
11
|
-
*/
|
|
12
|
-
export type FinalCompressedId = number & {
|
|
13
|
-
readonly FinalCompressedId: "5d83d1e2-98b7-4e4e-a889-54c855cfa73d";
|
|
14
|
-
|
|
15
|
-
// Same brand as OpNormalizedCompressedId, as final IDs are always finally normalized
|
|
16
|
-
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).
|
|
21
|
-
* Internally, it should not be persisted outside a scope annotated with the originating SessionId in order to be unambiguous.
|
|
22
|
-
* If external persistence is needed (e.g. by a client), a StableId should be used instead.
|
|
23
|
-
*/
|
|
24
|
-
export type LocalCompressedId = number & {
|
|
25
|
-
readonly LocalCompressedId: "6fccb42f-e2a4-4243-bd29-f13d12b9c6d1";
|
|
26
|
-
} & SessionSpaceCompressedId; // Same brand as CompressedId, as local IDs are always locally normalized
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @returns true if the supplied ID is a final ID.
|
|
30
|
-
*/
|
|
31
|
-
export function isFinalId(
|
|
32
|
-
id: SessionSpaceCompressedId | OpSpaceCompressedId,
|
|
33
|
-
): id is FinalCompressedId {
|
|
34
|
-
return id >= 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A StableId which is suitable for use as a session identifier
|
|
39
|
-
*/
|
|
40
|
-
export type NumericUuid = bigint & {
|
|
41
|
-
readonly NumericUuid: "be04dd4d-9d7e-4337-a833-eec64c61aa46";
|
|
42
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Exports for `id-compressor`
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export { IdCompressor } from "./idCompressor";
|
|
11
|
-
export {
|
|
12
|
-
compareFiniteNumbers,
|
|
13
|
-
createSessionId,
|
|
14
|
-
assertIsSessionId,
|
|
15
|
-
numericUuidFromStableId,
|
|
16
|
-
offsetNumericUuid,
|
|
17
|
-
stableIdFromNumericUuid,
|
|
18
|
-
subtractNumericUuids,
|
|
19
|
-
addNumericUuids,
|
|
20
|
-
assertIsStableId,
|
|
21
|
-
generateStableId,
|
|
22
|
-
isStableId,
|
|
23
|
-
} from "./utilities";
|
|
24
|
-
export { readNumericUuid, writeNumericUuid } from "./persistanceUtilities";
|
|
25
|
-
export { AppendOnlySortedMap } from "./appendOnlySortedMap";
|
|
26
|
-
export { SessionSpaceNormalizer } from "./sessionSpaceNormalizer";
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/* eslint-disable no-bitwise */
|
|
7
|
-
import { NumericUuid } from "./identifiers";
|
|
8
|
-
|
|
9
|
-
const halfNumeric = BigInt("0xFFFFFFFFFFFFFFFF");
|
|
10
|
-
const sixtyFour = BigInt(64);
|
|
11
|
-
|
|
12
|
-
export function writeNumber(buffer: Float64Array, index: number, value: number): number {
|
|
13
|
-
buffer[index] = value;
|
|
14
|
-
return index + 1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function writeNumericUuid(
|
|
18
|
-
buffer: BigUint64Array,
|
|
19
|
-
index: number,
|
|
20
|
-
value: NumericUuid,
|
|
21
|
-
): number {
|
|
22
|
-
buffer[index] = value & halfNumeric;
|
|
23
|
-
buffer[index + 1] = value >> sixtyFour;
|
|
24
|
-
return index + 2; // UUID values are 16 bytes.
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function writeBoolean(buffer: Float64Array, index: number, value: boolean): number {
|
|
28
|
-
return writeNumber(buffer, index, value ? 1 : 0);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Helper type to allow returning a value when reading as well as incrementing an index to make
|
|
33
|
-
* deserialization easier.
|
|
34
|
-
* Should be constructed with two views of the same buffer and index set to 0.
|
|
35
|
-
*/
|
|
36
|
-
export interface Index {
|
|
37
|
-
bufferFloat: Float64Array;
|
|
38
|
-
bufferUint: BigUint64Array;
|
|
39
|
-
index: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function readNumber(index: Index): number {
|
|
43
|
-
const value = index.bufferFloat[index.index];
|
|
44
|
-
index.index += 1;
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function readNumericUuid(index: Index): NumericUuid {
|
|
49
|
-
const lowerHalf = index.bufferUint[index.index];
|
|
50
|
-
const upperHalf = index.bufferUint[index.index + 1];
|
|
51
|
-
const value = (upperHalf << sixtyFour) | lowerHalf;
|
|
52
|
-
index.index += 2;
|
|
53
|
-
return value as NumericUuid;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function readBoolean(index: Index): boolean {
|
|
57
|
-
return readNumber(index) === 1;
|
|
58
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { AppendOnlySortedMap } from "./appendOnlySortedMap";
|
|
7
|
-
import { LocalCompressedId } from "./identifiers";
|
|
8
|
-
import { compareFiniteNumbers, genCountFromLocalId } from "./utilities";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The `SessionSpaceNormalizer` tracks the form of the IDs created by the local session.
|
|
12
|
-
* More precisely, it acts as a set of all `LocalCompressedId`s created by the local session and allows querying whether a specific
|
|
13
|
-
* ID was produced by the local session. This information can be used to determine whether the nth ID created by the local session
|
|
14
|
-
* was produced as a local ID (negative) or a final ID (positive).
|
|
15
|
-
*
|
|
16
|
-
* The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such
|
|
17
|
-
* that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.
|
|
18
|
-
* Below is an example to illustrate how various mappings can arise:
|
|
19
|
-
*
|
|
20
|
-
* ```
|
|
21
|
-
* +- Creation Index
|
|
22
|
-
* / +- Locals
|
|
23
|
-
* / / +- Finals
|
|
24
|
-
* / / /
|
|
25
|
-
* ---+-----+----
|
|
26
|
-
* 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.
|
|
27
|
-
* 1 | -2 | 1 -|
|
|
28
|
-
* 2 | | 2 -|
|
|
29
|
-
* 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.
|
|
30
|
-
* 4 | | 4 -|
|
|
31
|
-
* 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.
|
|
32
|
-
* 6 | | 11 ----- This ID (and the subsequent few) is allocated eagerly as a final ID into the existing cluster.
|
|
33
|
-
* 7 | | 12
|
|
34
|
-
* 8 | | 13
|
|
35
|
-
* 9 | | 14
|
|
36
|
-
* 10 | -11 | ----- The cluster is out of room, so a local ID is allocated. It has no corresponding final ID since it has not been acked.
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* This class stores the set of local IDs and thus their indices, as local IDs are essentially negative offsets from the first ID.
|
|
40
|
-
* The form (local or final) of a given ID index (for example, the 5th ID made by the local session) can be deduced from this information.
|
|
41
|
-
*/
|
|
42
|
-
export class SessionSpaceNormalizer {
|
|
43
|
-
// Run-length encoding of IDs that were generated as local IDs. They are stored as a list of tuples (genCount, count)
|
|
44
|
-
// that are sorted on the genCount so that contains checks can use a binary search.
|
|
45
|
-
private readonly localIdRanges = new AppendOnlySortedMap<number, number>(compareFiniteNumbers);
|
|
46
|
-
|
|
47
|
-
public get idRanges(): Pick<AppendOnlySortedMap<number, number>, "size" | "entries"> {
|
|
48
|
-
return this.localIdRanges;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public addLocalRange(baseGenCount: number, count: number): void {
|
|
52
|
-
const last = this.localIdRanges.last();
|
|
53
|
-
if (last !== undefined) {
|
|
54
|
-
const [lastGenCount, lastCount] = last;
|
|
55
|
-
// Check to see if the added run of local IDs is contiguous with the last range added.
|
|
56
|
-
// If it is, simply merge them (this is the common case).
|
|
57
|
-
if (lastGenCount + lastCount === baseGenCount) {
|
|
58
|
-
this.localIdRanges.replaceLast(lastGenCount, lastCount + count);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
this.localIdRanges.append(baseGenCount, count);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public contains(query: LocalCompressedId): boolean {
|
|
66
|
-
const genCount = genCountFromLocalId(query);
|
|
67
|
-
const containingBlock = this.localIdRanges.getPairOrNextLower(genCount);
|
|
68
|
-
if (containingBlock !== undefined) {
|
|
69
|
-
const [baseGenCount, count] = containingBlock;
|
|
70
|
-
if (genCount <= baseGenCount + (count - 1)) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public equals(other: SessionSpaceNormalizer): boolean {
|
|
78
|
-
return this.localIdRanges.equals(
|
|
79
|
-
other.localIdRanges,
|
|
80
|
-
(countA, countB) => countA === countB,
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import BTree from "sorted-btree";
|
|
7
|
-
import { SessionId, StableId } from "@fluidframework/runtime-definitions";
|
|
8
|
-
import { assert } from "@fluidframework/core-utils";
|
|
9
|
-
import {
|
|
10
|
-
compareBigints,
|
|
11
|
-
localIdFromGenCount,
|
|
12
|
-
genCountFromLocalId,
|
|
13
|
-
numericUuidFromStableId,
|
|
14
|
-
stableIdFromNumericUuid,
|
|
15
|
-
subtractNumericUuids,
|
|
16
|
-
offsetNumericUuid,
|
|
17
|
-
} from "./utilities";
|
|
18
|
-
import { FinalCompressedId, LocalCompressedId, NumericUuid } from "./identifiers";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).
|
|
22
|
-
* This collection of all sessions comprises a distributed document's IDs.
|
|
23
|
-
*/
|
|
24
|
-
export class Sessions {
|
|
25
|
-
// A range-queryable store of all sessions. A btree is used as it solves the predecessor problem for any given UUID, allowing
|
|
26
|
-
// us to quickly find the session that may have produced it.
|
|
27
|
-
private readonly uuidSpace = new BTree<NumericUuid, Session>(undefined, compareBigints);
|
|
28
|
-
// A fast lookup table from session ID to the session object, used to avoid accessing the slower btree
|
|
29
|
-
private readonly sessionCache = new Map<SessionId, Session>();
|
|
30
|
-
|
|
31
|
-
public constructor(sessions?: [sessionBase: NumericUuid, session: Session][]) {
|
|
32
|
-
if (sessions !== undefined) {
|
|
33
|
-
// bulk load path
|
|
34
|
-
for (const [numeric, session] of sessions) {
|
|
35
|
-
this.sessionCache.set(stableIdFromNumericUuid(numeric) as SessionId, session);
|
|
36
|
-
}
|
|
37
|
-
this.uuidSpace = new BTree(sessions, compareBigints);
|
|
38
|
-
if (
|
|
39
|
-
this.sessionCache.size !== sessions.length ||
|
|
40
|
-
sessions.length !== this.uuidSpace.size
|
|
41
|
-
) {
|
|
42
|
-
throw new Error("Cannot resume existing session.");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public sessions(): IterableIterator<Session> {
|
|
48
|
-
return this.sessionCache.values();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public getOrCreate(sessionId: SessionId): Session {
|
|
52
|
-
const existing = this.sessionCache.get(sessionId);
|
|
53
|
-
if (existing !== undefined) {
|
|
54
|
-
return existing;
|
|
55
|
-
}
|
|
56
|
-
const session = new Session(sessionId);
|
|
57
|
-
assert(
|
|
58
|
-
this.uuidSpace.set(session.sessionUuid, session),
|
|
59
|
-
0x760 /* Duplicate session in map. */,
|
|
60
|
-
);
|
|
61
|
-
this.sessionCache.set(sessionId, session);
|
|
62
|
-
return session;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public get(sessionId: SessionId): Session | undefined {
|
|
66
|
-
return this.sessionCache.get(sessionId);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public getContainingCluster(
|
|
70
|
-
query: StableId,
|
|
71
|
-
): [cluster: IdCluster, alignedLocal: LocalCompressedId] | undefined {
|
|
72
|
-
const numericStable = numericUuidFromStableId(query);
|
|
73
|
-
const possibleMatch = this.uuidSpace.getPairOrNextLower(numericStable);
|
|
74
|
-
if (possibleMatch === undefined) {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
const [_, session] = possibleMatch;
|
|
78
|
-
const numericDelta = subtractNumericUuids(numericStable, session.sessionUuid);
|
|
79
|
-
if (numericDelta > Number.MAX_SAFE_INTEGER) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
const alignedLocal = localIdFromGenCount(Number(numericDelta) + 1);
|
|
83
|
-
const containingCluster = session.getClusterByLocal(alignedLocal, true);
|
|
84
|
-
if (containingCluster === undefined) {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
return [containingCluster, alignedLocal];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public clusterCollides(cluster: IdCluster): boolean {
|
|
91
|
-
const { session: owningSession, baseLocalId, capacity } = cluster;
|
|
92
|
-
const clusterBaseNumeric = offsetNumericUuid(
|
|
93
|
-
owningSession.sessionUuid,
|
|
94
|
-
genCountFromLocalId(baseLocalId) - 1,
|
|
95
|
-
);
|
|
96
|
-
const clusterMaxNumeric = offsetNumericUuid(clusterBaseNumeric, capacity - 1);
|
|
97
|
-
let closestMatch: [NumericUuid, Session] | undefined =
|
|
98
|
-
this.uuidSpace.getPairOrNextLower(clusterMaxNumeric);
|
|
99
|
-
// Find the first session that is not the owner of this new cluster.
|
|
100
|
-
// Once we have that, check to see if its cluster chain overlaps with the new cluster.
|
|
101
|
-
// Consider the following diagram of UUID space:
|
|
102
|
-
// Cluster chain A: |----------------------|
|
|
103
|
-
// Cluster chain B: |----------|
|
|
104
|
-
// Cluster chain C: |-------|
|
|
105
|
-
// While it is true that when adding a cluster to chain C, we would find
|
|
106
|
-
// the next lower session (which is B) and erroneously determine we do not collide
|
|
107
|
-
// with any other session, but this situation is impossible to get into as B would
|
|
108
|
-
// have detected that it collided with A (or the other way around, depending on ordering).
|
|
109
|
-
while (closestMatch !== undefined && closestMatch[1] === owningSession) {
|
|
110
|
-
closestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);
|
|
111
|
-
}
|
|
112
|
-
if (closestMatch === undefined) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const [_, session] = closestMatch;
|
|
117
|
-
assert(session !== owningSession, 0x761 /* Failed to attempt to detect collisions. */);
|
|
118
|
-
const lastCluster = session.getLastCluster();
|
|
119
|
-
if (lastCluster === undefined) {
|
|
120
|
-
// If the closest session is empty (the local session), then it is guaranteed (probabilistically) that there are no
|
|
121
|
-
// non-empty sessions that have a cluster chain that starts prior to the empty session and collides with the cluster
|
|
122
|
-
// we are checking, so we can return false.
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
const lastAllocatedNumeric = offsetNumericUuid(
|
|
126
|
-
session.sessionUuid,
|
|
127
|
-
genCountFromLocalId(lastAllocatedLocal(lastCluster)) - 1,
|
|
128
|
-
);
|
|
129
|
-
return lastAllocatedNumeric >= clusterBaseNumeric;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public equals(other: Sessions, includeLocalState: boolean): boolean {
|
|
133
|
-
const checkIsSubset = (sessionsA: Sessions, sessionsB: Sessions) => {
|
|
134
|
-
const first = sessionsA.sessions().next();
|
|
135
|
-
const firstSessionThis = first.done ? undefined : first.value;
|
|
136
|
-
for (const [stableId, session] of sessionsA.sessionCache.entries()) {
|
|
137
|
-
const otherSession = sessionsB.sessionCache.get(stableId);
|
|
138
|
-
if (otherSession === undefined) {
|
|
139
|
-
if (!session.isEmpty() || includeLocalState) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
assert(
|
|
143
|
-
session === firstSessionThis,
|
|
144
|
-
0x762 /* The only non-empty session must be the local session. */,
|
|
145
|
-
);
|
|
146
|
-
} else if (!session.equals(otherSession)) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return true;
|
|
151
|
-
};
|
|
152
|
-
return checkIsSubset(this, other) && checkIsSubset(other, this);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.
|
|
158
|
-
*/
|
|
159
|
-
export class Session {
|
|
160
|
-
// All clusters created by this session, in creation order (thus sorted by base final and local ID).
|
|
161
|
-
private readonly clusterChain: IdCluster[] = [];
|
|
162
|
-
// The numeric form of the SessionId
|
|
163
|
-
public readonly sessionUuid: NumericUuid;
|
|
164
|
-
|
|
165
|
-
public constructor(sessionId: SessionId | NumericUuid) {
|
|
166
|
-
this.sessionUuid =
|
|
167
|
-
typeof sessionId === "string" ? numericUuidFromStableId(sessionId) : sessionId;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Adds a new empty cluster to the cluster chain of this session.
|
|
172
|
-
*/
|
|
173
|
-
public addNewCluster(
|
|
174
|
-
baseFinalId: FinalCompressedId,
|
|
175
|
-
capacity: number,
|
|
176
|
-
count: number,
|
|
177
|
-
): IdCluster {
|
|
178
|
-
const lastCluster = this.getLastCluster();
|
|
179
|
-
const newCluster: IdCluster = {
|
|
180
|
-
session: this,
|
|
181
|
-
baseFinalId,
|
|
182
|
-
baseLocalId: (lastCluster === undefined
|
|
183
|
-
? -1
|
|
184
|
-
: lastAllocatedLocal(lastCluster) - 1) as LocalCompressedId,
|
|
185
|
-
capacity,
|
|
186
|
-
count,
|
|
187
|
-
};
|
|
188
|
-
this.clusterChain.push(newCluster);
|
|
189
|
-
return newCluster;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public isEmpty(): boolean {
|
|
193
|
-
return this.clusterChain.length === 0;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Returns the last cluster in this session's cluster chain, if any.
|
|
198
|
-
*/
|
|
199
|
-
public getLastCluster(): IdCluster | undefined {
|
|
200
|
-
return this.clusterChain[this.clusterChain.length - 1];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Converts the local ID from this session to a final ID, if possible.
|
|
205
|
-
* @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.
|
|
206
|
-
*/
|
|
207
|
-
public tryConvertToFinal(
|
|
208
|
-
searchLocal: LocalCompressedId,
|
|
209
|
-
includeAllocated: boolean,
|
|
210
|
-
): FinalCompressedId | undefined {
|
|
211
|
-
const containingCluster = this.getClusterByLocal(searchLocal, includeAllocated);
|
|
212
|
-
if (containingCluster === undefined) {
|
|
213
|
-
return undefined;
|
|
214
|
-
}
|
|
215
|
-
return getAlignedFinal(containingCluster, searchLocal);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Returns the cluster containing the supplied local ID, if possible.
|
|
220
|
-
* @param includeAllocated - true if the conversion should succeed even if the local ID aligns with a part of the cluster that is allocated but not finalized.
|
|
221
|
-
*/
|
|
222
|
-
public getClusterByLocal(
|
|
223
|
-
localId: LocalCompressedId,
|
|
224
|
-
includeAllocated: boolean,
|
|
225
|
-
): IdCluster | undefined {
|
|
226
|
-
const lastValidLocal: (cluster: IdCluster) => LocalCompressedId = includeAllocated
|
|
227
|
-
? lastAllocatedLocal
|
|
228
|
-
: lastFinalizedLocal;
|
|
229
|
-
const matchedCluster = Session.binarySearch(
|
|
230
|
-
localId,
|
|
231
|
-
this.clusterChain,
|
|
232
|
-
(local, cluster): number => {
|
|
233
|
-
const lastLocal = lastValidLocal(cluster);
|
|
234
|
-
if (local < lastLocal) {
|
|
235
|
-
return 1;
|
|
236
|
-
} else if (local > cluster.baseLocalId) {
|
|
237
|
-
return -1;
|
|
238
|
-
} else {
|
|
239
|
-
return 0;
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
);
|
|
243
|
-
return matchedCluster;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Returns the cluster containing the supplied final ID, if possible.
|
|
248
|
-
*/
|
|
249
|
-
public getClusterByAllocatedFinal(final: FinalCompressedId): IdCluster | undefined {
|
|
250
|
-
return Session.getContainingCluster(final, this.clusterChain);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.
|
|
255
|
-
* `clusterChain` must be sorted by final/local base ID.
|
|
256
|
-
*/
|
|
257
|
-
public static getContainingCluster(
|
|
258
|
-
finalId: FinalCompressedId,
|
|
259
|
-
clusterChain: readonly IdCluster[],
|
|
260
|
-
): IdCluster | undefined {
|
|
261
|
-
return Session.binarySearch(finalId, clusterChain, (final, cluster) => {
|
|
262
|
-
const lastFinal = lastAllocatedFinal(cluster);
|
|
263
|
-
if (final < cluster.baseFinalId) {
|
|
264
|
-
return -1;
|
|
265
|
-
} else if (final > lastFinal) {
|
|
266
|
-
return 1;
|
|
267
|
-
} else {
|
|
268
|
-
return 0;
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
static binarySearch<S, T>(
|
|
274
|
-
search: S,
|
|
275
|
-
arr: readonly T[],
|
|
276
|
-
comparator: (a: S, b: T) => number,
|
|
277
|
-
): T | undefined {
|
|
278
|
-
let left = 0;
|
|
279
|
-
let right = arr.length - 1;
|
|
280
|
-
while (left <= right) {
|
|
281
|
-
const mid = Math.floor((left + right) / 2);
|
|
282
|
-
const c = comparator(search, arr[mid]);
|
|
283
|
-
if (c === 0) {
|
|
284
|
-
return arr[mid]; // Found the target, return its index.
|
|
285
|
-
} else if (c > 0) {
|
|
286
|
-
left = mid + 1; // Continue search on right half.
|
|
287
|
-
} else {
|
|
288
|
-
right = mid - 1; // Continue search on left half.
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return undefined; // If we reach here, target is not in array.
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
public equals(other: Session): boolean {
|
|
295
|
-
for (let i = 0; i < this.clusterChain.length; i++) {
|
|
296
|
-
if (!clustersEqual(this.clusterChain[i], other.clusterChain[i])) {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return this.sessionUuid === other.sessionUuid;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* A cluster of final (sequenced via consensus), sequentially allocated compressed IDs.
|
|
306
|
-
* A final ID in a cluster decompresses to a sequentially allocated UUID that is the result of adding its offset within
|
|
307
|
-
* the cluster to base UUID for the session that created it.
|
|
308
|
-
*/
|
|
309
|
-
export interface IdCluster {
|
|
310
|
-
/**
|
|
311
|
-
* The session that created this cluster.
|
|
312
|
-
*/
|
|
313
|
-
readonly session: Session;
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* The first final ID in the cluster.
|
|
317
|
-
*/
|
|
318
|
-
readonly baseFinalId: FinalCompressedId;
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* The local ID aligned with `baseFinalId`.
|
|
322
|
-
*/
|
|
323
|
-
readonly baseLocalId: LocalCompressedId;
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* The total number of final IDs reserved for allocation in the cluster.
|
|
327
|
-
* Clusters are reserved in blocks as a performance optimization.
|
|
328
|
-
*/
|
|
329
|
-
capacity: number;
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* The number of final IDs currently allocated in the cluster.
|
|
333
|
-
*/
|
|
334
|
-
count: number;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
export function clustersEqual(a: IdCluster, b: IdCluster): boolean {
|
|
338
|
-
return (
|
|
339
|
-
a.session.sessionUuid === b.session.sessionUuid &&
|
|
340
|
-
a.baseFinalId === b.baseFinalId &&
|
|
341
|
-
a.baseLocalId === b.baseLocalId &&
|
|
342
|
-
a.capacity === b.capacity &&
|
|
343
|
-
a.count === b.count
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Returns the final ID that is aligned with the supplied local ID within a cluster.
|
|
349
|
-
* Includes allocated IDs.
|
|
350
|
-
*/
|
|
351
|
-
export function getAlignedFinal(
|
|
352
|
-
cluster: IdCluster,
|
|
353
|
-
localWithin: LocalCompressedId,
|
|
354
|
-
): FinalCompressedId | undefined {
|
|
355
|
-
const clusterOffset =
|
|
356
|
-
genCountFromLocalId(localWithin) - genCountFromLocalId(cluster.baseLocalId);
|
|
357
|
-
if (clusterOffset < cluster.capacity) {
|
|
358
|
-
return ((cluster.baseFinalId as number) + clusterOffset) as FinalCompressedId;
|
|
359
|
-
}
|
|
360
|
-
return undefined;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Returns the local ID that is aligned with the supplied final ID within a cluster.
|
|
365
|
-
* Fails if the supplied ID does not fall within the cluster bounds.
|
|
366
|
-
*/
|
|
367
|
-
export function getAlignedLocal(
|
|
368
|
-
cluster: IdCluster,
|
|
369
|
-
finalWithin: FinalCompressedId,
|
|
370
|
-
): LocalCompressedId {
|
|
371
|
-
assert(
|
|
372
|
-
finalWithin >= cluster.baseFinalId && finalWithin <= lastAllocatedFinal(cluster),
|
|
373
|
-
0x763 /* Supplied ID is not within the cluster. */,
|
|
374
|
-
);
|
|
375
|
-
const finalDelta = finalWithin - cluster.baseFinalId;
|
|
376
|
-
return (cluster.baseLocalId - finalDelta) as LocalCompressedId;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster
|
|
381
|
-
*/
|
|
382
|
-
export function lastAllocatedFinal(cluster: IdCluster): FinalCompressedId {
|
|
383
|
-
return ((cluster.baseFinalId as number) + (cluster.capacity - 1)) as FinalCompressedId;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster
|
|
388
|
-
*/
|
|
389
|
-
export function lastFinalizedFinal(cluster: IdCluster): FinalCompressedId {
|
|
390
|
-
return ((cluster.baseFinalId as number) + (cluster.count - 1)) as FinalCompressedId;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster
|
|
395
|
-
*/
|
|
396
|
-
export function lastAllocatedLocal(cluster: IdCluster): LocalCompressedId {
|
|
397
|
-
return ((cluster.baseLocalId as number) - (cluster.capacity - 1)) as LocalCompressedId;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster
|
|
402
|
-
*/
|
|
403
|
-
export function lastFinalizedLocal(cluster: IdCluster): LocalCompressedId {
|
|
404
|
-
return ((cluster.baseLocalId as number) - (cluster.count - 1)) as LocalCompressedId;
|
|
405
|
-
}
|