@fluidframework/container-runtime 2.0.0-internal.7.3.0 → 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 +18 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +9 -1
- package/api-report/container-runtime.api.md +124 -107
- package/dist/blobManager.d.ts +4 -4
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.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 +30 -30
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +62 -40
- 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 +15 -7
- package/dist/messageTypes.d.ts.map +1 -1
- package/dist/messageTypes.js +6 -1
- package/dist/messageTypes.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +1 -1
- package/dist/opLifecycle/definitions.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 -0
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +1 -0
- package/dist/pendingStateManager.js.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/lib/blobManager.d.ts +4 -4
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.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 +30 -30
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +64 -42
- 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 +15 -7
- package/lib/messageTypes.d.ts.map +1 -1
- package/lib/messageTypes.js +6 -1
- package/lib/messageTypes.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +1 -1
- package/lib/opLifecycle/definitions.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 -0
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +1 -0
- package/lib/pendingStateManager.js.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 +42 -19
- package/src/blobManager.ts +5 -5
- package/src/containerRuntime.ts +86 -56
- 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 +19 -4
- package/src/opLifecycle/definitions.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +1 -0
- 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,13 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Exports for `id-compressor`
|
|
7
|
-
*/
|
|
8
|
-
export { IdCompressor } from "./idCompressor";
|
|
9
|
-
export { compareFiniteNumbers, createSessionId, assertIsSessionId, numericUuidFromStableId, offsetNumericUuid, stableIdFromNumericUuid, subtractNumericUuids, addNumericUuids, assertIsStableId, generateStableId, isStableId, } from "./utilities";
|
|
10
|
-
export { readNumericUuid, writeNumericUuid } from "./persistanceUtilities";
|
|
11
|
-
export { AppendOnlySortedMap } from "./appendOnlySortedMap";
|
|
12
|
-
export { SessionSpaceNormalizer } from "./sessionSpaceNormalizer";
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/id-compressor/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACN,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Exports for `id-compressor`\n */\n\nexport { IdCompressor } from \"./idCompressor\";\nexport {\n\tcompareFiniteNumbers,\n\tcreateSessionId,\n\tassertIsSessionId,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n\taddNumericUuids,\n\tassertIsStableId,\n\tgenerateStableId,\n\tisStableId,\n} from \"./utilities\";\nexport { readNumericUuid, writeNumericUuid } from \"./persistanceUtilities\";\nexport { AppendOnlySortedMap } from \"./appendOnlySortedMap\";\nexport { SessionSpaceNormalizer } from \"./sessionSpaceNormalizer\";\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { NumericUuid } from "./identifiers";
|
|
6
|
-
export declare function writeNumber(buffer: Float64Array, index: number, value: number): number;
|
|
7
|
-
export declare function writeNumericUuid(buffer: BigUint64Array, index: number, value: NumericUuid): number;
|
|
8
|
-
export declare function writeBoolean(buffer: Float64Array, index: number, value: boolean): number;
|
|
9
|
-
/**
|
|
10
|
-
* Helper type to allow returning a value when reading as well as incrementing an index to make
|
|
11
|
-
* deserialization easier.
|
|
12
|
-
* Should be constructed with two views of the same buffer and index set to 0.
|
|
13
|
-
*/
|
|
14
|
-
export interface Index {
|
|
15
|
-
bufferFloat: Float64Array;
|
|
16
|
-
bufferUint: BigUint64Array;
|
|
17
|
-
index: number;
|
|
18
|
-
}
|
|
19
|
-
export declare function readNumber(index: Index): number;
|
|
20
|
-
export declare function readNumericUuid(index: Index): NumericUuid;
|
|
21
|
-
export declare function readBoolean(index: Index): boolean;
|
|
22
|
-
//# sourceMappingURL=persistanceUtilities.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"persistanceUtilities.d.ts","sourceRoot":"","sources":["../../src/id-compressor/persistanceUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGtF;AAED,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,WAAW,GAChB,MAAM,CAIR;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAExF;AAED;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACrB,WAAW,EAAE,YAAY,CAAC;IAC1B,UAAU,EAAE,cAAc,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAI/C;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAMzD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEjD"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
const halfNumeric = BigInt("0xFFFFFFFFFFFFFFFF");
|
|
6
|
-
const sixtyFour = BigInt(64);
|
|
7
|
-
export function writeNumber(buffer, index, value) {
|
|
8
|
-
buffer[index] = value;
|
|
9
|
-
return index + 1;
|
|
10
|
-
}
|
|
11
|
-
export function writeNumericUuid(buffer, index, value) {
|
|
12
|
-
buffer[index] = value & halfNumeric;
|
|
13
|
-
buffer[index + 1] = value >> sixtyFour;
|
|
14
|
-
return index + 2; // UUID values are 16 bytes.
|
|
15
|
-
}
|
|
16
|
-
export function writeBoolean(buffer, index, value) {
|
|
17
|
-
return writeNumber(buffer, index, value ? 1 : 0);
|
|
18
|
-
}
|
|
19
|
-
export function readNumber(index) {
|
|
20
|
-
const value = index.bufferFloat[index.index];
|
|
21
|
-
index.index += 1;
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
export function readNumericUuid(index) {
|
|
25
|
-
const lowerHalf = index.bufferUint[index.index];
|
|
26
|
-
const upperHalf = index.bufferUint[index.index + 1];
|
|
27
|
-
const value = (upperHalf << sixtyFour) | lowerHalf;
|
|
28
|
-
index.index += 2;
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
export function readBoolean(index) {
|
|
32
|
-
return readNumber(index) === 1;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=persistanceUtilities.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"persistanceUtilities.js","sourceRoot":"","sources":["../../src/id-compressor/persistanceUt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AK,CAAC,KAAK,IAAI,CAAC,CAAC;IACjB,OAAO,KAAoB,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAY;IACvC,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\nimport { NumericUuid } from \"./identifiers\";\n\nconst halfNumeric = BigInt(\"0xFFFFFFFFFFFFFFFF\");\nconst sixtyFour = BigInt(64);\n\nexport function writeNumber(buffer: Float64Array, index: number, value: number): number {\n\tbuffer[index] = value;\n\treturn index + 1;\n}\n\nexport function writeNumericUuid(\n\tbuffer: BigUint64Array,\n\tindex: number,\n\tvalue: NumericUuid,\n): number {\n\tbuffer[index] = value & halfNumeric;\n\tbuffer[index + 1] = value >> sixtyFour;\n\treturn index + 2; // UUID values are 16 bytes.\n}\n\nexport function writeBoolean(buffer: Float64Array, index: number, value: boolean): number {\n\treturn writeNumber(buffer, index, value ? 1 : 0);\n}\n\n/**\n * Helper type to allow returning a value when reading as well as incrementing an index to make\n * deserialization easier.\n * Should be constructed with two views of the same buffer and index set to 0.\n */\nexport interface Index {\n\tbufferFloat: Float64Array;\n\tbufferUint: BigUint64Array;\n\tindex: number;\n}\n\nexport function readNumber(index: Index): number {\n\tconst value = index.bufferFloat[index.index];\n\tindex.index += 1;\n\treturn value;\n}\n\nexport function readNumericUuid(index: Index): NumericUuid {\n\tconst lowerHalf = index.bufferUint[index.index];\n\tconst upperHalf = index.bufferUint[index.index + 1];\n\tconst value = (upperHalf << sixtyFour) | lowerHalf;\n\tindex.index += 2;\n\treturn value as NumericUuid;\n}\n\nexport function readBoolean(index: Index): boolean {\n\treturn readNumber(index) === 1;\n}\n"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { AppendOnlySortedMap } from "./appendOnlySortedMap";
|
|
6
|
-
import { LocalCompressedId } from "./identifiers";
|
|
7
|
-
/**
|
|
8
|
-
* The `SessionSpaceNormalizer` tracks the form of the IDs created by the local session.
|
|
9
|
-
* More precisely, it acts as a set of all `LocalCompressedId`s created by the local session and allows querying whether a specific
|
|
10
|
-
* ID was produced by the local session. This information can be used to determine whether the nth ID created by the local session
|
|
11
|
-
* was produced as a local ID (negative) or a final ID (positive).
|
|
12
|
-
*
|
|
13
|
-
* The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such
|
|
14
|
-
* that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.
|
|
15
|
-
* Below is an example to illustrate how various mappings can arise:
|
|
16
|
-
*
|
|
17
|
-
* ```
|
|
18
|
-
* +- Creation Index
|
|
19
|
-
* / +- Locals
|
|
20
|
-
* / / +- Finals
|
|
21
|
-
* / / /
|
|
22
|
-
* ---+-----+----
|
|
23
|
-
* 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.
|
|
24
|
-
* 1 | -2 | 1 -|
|
|
25
|
-
* 2 | | 2 -|
|
|
26
|
-
* 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.
|
|
27
|
-
* 4 | | 4 -|
|
|
28
|
-
* 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.
|
|
29
|
-
* 6 | | 11 ----- This ID (and the subsequent few) is allocated eagerly as a final ID into the existing cluster.
|
|
30
|
-
* 7 | | 12
|
|
31
|
-
* 8 | | 13
|
|
32
|
-
* 9 | | 14
|
|
33
|
-
* 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.
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* This class stores the set of local IDs and thus their indices, as local IDs are essentially negative offsets from the first ID.
|
|
37
|
-
* 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.
|
|
38
|
-
*/
|
|
39
|
-
export declare class SessionSpaceNormalizer {
|
|
40
|
-
private readonly localIdRanges;
|
|
41
|
-
get idRanges(): Pick<AppendOnlySortedMap<number, number>, "size" | "entries">;
|
|
42
|
-
addLocalRange(baseGenCount: number, count: number): void;
|
|
43
|
-
contains(query: LocalCompressedId): boolean;
|
|
44
|
-
equals(other: SessionSpaceNormalizer): boolean;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=sessionSpaceNormalizer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessionSpaceNormalizer.d.ts","sourceRoot":"","sources":["../../src/id-compressor/sessionSpaceNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,sBAAsB;IAGlC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiE;IAE/F,IAAW,QAAQ,IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,CAEnF;IAEM,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAcxD,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO;IAY3C,MAAM,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO;CAMrD"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { AppendOnlySortedMap } from "./appendOnlySortedMap";
|
|
6
|
-
import { compareFiniteNumbers, genCountFromLocalId } from "./utilities";
|
|
7
|
-
/**
|
|
8
|
-
* The `SessionSpaceNormalizer` tracks the form of the IDs created by the local session.
|
|
9
|
-
* More precisely, it acts as a set of all `LocalCompressedId`s created by the local session and allows querying whether a specific
|
|
10
|
-
* ID was produced by the local session. This information can be used to determine whether the nth ID created by the local session
|
|
11
|
-
* was produced as a local ID (negative) or a final ID (positive).
|
|
12
|
-
*
|
|
13
|
-
* The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such
|
|
14
|
-
* that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.
|
|
15
|
-
* Below is an example to illustrate how various mappings can arise:
|
|
16
|
-
*
|
|
17
|
-
* ```
|
|
18
|
-
* +- Creation Index
|
|
19
|
-
* / +- Locals
|
|
20
|
-
* / / +- Finals
|
|
21
|
-
* / / /
|
|
22
|
-
* ---+-----+----
|
|
23
|
-
* 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.
|
|
24
|
-
* 1 | -2 | 1 -|
|
|
25
|
-
* 2 | | 2 -|
|
|
26
|
-
* 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.
|
|
27
|
-
* 4 | | 4 -|
|
|
28
|
-
* 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.
|
|
29
|
-
* 6 | | 11 ----- This ID (and the subsequent few) is allocated eagerly as a final ID into the existing cluster.
|
|
30
|
-
* 7 | | 12
|
|
31
|
-
* 8 | | 13
|
|
32
|
-
* 9 | | 14
|
|
33
|
-
* 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.
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* This class stores the set of local IDs and thus their indices, as local IDs are essentially negative offsets from the first ID.
|
|
37
|
-
* 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.
|
|
38
|
-
*/
|
|
39
|
-
export class SessionSpaceNormalizer {
|
|
40
|
-
constructor() {
|
|
41
|
-
// Run-length encoding of IDs that were generated as local IDs. They are stored as a list of tuples (genCount, count)
|
|
42
|
-
// that are sorted on the genCount so that contains checks can use a binary search.
|
|
43
|
-
this.localIdRanges = new AppendOnlySortedMap(compareFiniteNumbers);
|
|
44
|
-
}
|
|
45
|
-
get idRanges() {
|
|
46
|
-
return this.localIdRanges;
|
|
47
|
-
}
|
|
48
|
-
addLocalRange(baseGenCount, count) {
|
|
49
|
-
const last = this.localIdRanges.last();
|
|
50
|
-
if (last !== undefined) {
|
|
51
|
-
const [lastGenCount, lastCount] = last;
|
|
52
|
-
// Check to see if the added run of local IDs is contiguous with the last range added.
|
|
53
|
-
// If it is, simply merge them (this is the common case).
|
|
54
|
-
if (lastGenCount + lastCount === baseGenCount) {
|
|
55
|
-
this.localIdRanges.replaceLast(lastGenCount, lastCount + count);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
this.localIdRanges.append(baseGenCount, count);
|
|
60
|
-
}
|
|
61
|
-
contains(query) {
|
|
62
|
-
const genCount = genCountFromLocalId(query);
|
|
63
|
-
const containingBlock = this.localIdRanges.getPairOrNextLower(genCount);
|
|
64
|
-
if (containingBlock !== undefined) {
|
|
65
|
-
const [baseGenCount, count] = containingBlock;
|
|
66
|
-
if (genCount <= baseGenCount + (count - 1)) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
equals(other) {
|
|
73
|
-
return this.localIdRanges.equals(other.localIdRanges, (countA, countB) => countA === countB);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=sessionSpaceNormalizer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessionSpaceNormalizer.js","sourceRoot":"","sources":["../../src/id-compressor/sessionSpaceNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAG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AK,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,KAA6B;QAC1C,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAC/B,KAAK,CAAC,aAAa,EACnB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,MAAM,CACrC,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AppendOnlySortedMap } from \"./appendOnlySortedMap\";\nimport { LocalCompressedId } from \"./identifiers\";\nimport { compareFiniteNumbers, genCountFromLocalId } from \"./utilities\";\n\n/**\n * The `SessionSpaceNormalizer` tracks the form of the IDs created by the local session.\n * More precisely, it acts as a set of all `LocalCompressedId`s created by the local session and allows querying whether a specific\n * ID was produced by the local session. This information can be used to determine whether the nth ID created by the local session\n * was produced as a local ID (negative) or a final ID (positive).\n *\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 ----- This ID (and the subsequent few) is allocated eagerly as a final ID into the existing cluster.\n * 7 | | 12\n * 8 | | 13\n * 9 | | 14\n * 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.\n * ```\n *\n * This class stores the set of local IDs and thus their indices, as local IDs are essentially negative offsets from the first ID.\n * 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.\n */\nexport class SessionSpaceNormalizer {\n\t// Run-length encoding of IDs that were generated as local IDs. They are stored as a list of tuples (genCount, count)\n\t// that are sorted on the genCount so that contains checks can use a binary search.\n\tprivate readonly localIdRanges = new AppendOnlySortedMap<number, number>(compareFiniteNumbers);\n\n\tpublic get idRanges(): Pick<AppendOnlySortedMap<number, number>, \"size\" | \"entries\"> {\n\t\treturn this.localIdRanges;\n\t}\n\n\tpublic addLocalRange(baseGenCount: number, count: number): void {\n\t\tconst last = this.localIdRanges.last();\n\t\tif (last !== undefined) {\n\t\t\tconst [lastGenCount, lastCount] = last;\n\t\t\t// Check to see if the added run of local IDs is contiguous with the last range added.\n\t\t\t// If it is, simply merge them (this is the common case).\n\t\t\tif (lastGenCount + lastCount === baseGenCount) {\n\t\t\t\tthis.localIdRanges.replaceLast(lastGenCount, lastCount + count);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tthis.localIdRanges.append(baseGenCount, count);\n\t}\n\n\tpublic contains(query: LocalCompressedId): boolean {\n\t\tconst genCount = genCountFromLocalId(query);\n\t\tconst containingBlock = this.localIdRanges.getPairOrNextLower(genCount);\n\t\tif (containingBlock !== undefined) {\n\t\t\tconst [baseGenCount, count] = containingBlock;\n\t\t\tif (genCount <= baseGenCount + (count - 1)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic equals(other: SessionSpaceNormalizer): boolean {\n\t\treturn this.localIdRanges.equals(\n\t\t\tother.localIdRanges,\n\t\t\t(countA, countB) => countA === countB,\n\t\t);\n\t}\n}\n"]}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { SessionId, StableId } from "@fluidframework/runtime-definitions";
|
|
6
|
-
import { FinalCompressedId, LocalCompressedId, NumericUuid } from "./identifiers";
|
|
7
|
-
/**
|
|
8
|
-
* A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).
|
|
9
|
-
* This collection of all sessions comprises a distributed document's IDs.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Sessions {
|
|
12
|
-
private readonly uuidSpace;
|
|
13
|
-
private readonly sessionCache;
|
|
14
|
-
constructor(sessions?: [sessionBase: NumericUuid, session: Session][]);
|
|
15
|
-
sessions(): IterableIterator<Session>;
|
|
16
|
-
getOrCreate(sessionId: SessionId): Session;
|
|
17
|
-
get(sessionId: SessionId): Session | undefined;
|
|
18
|
-
getContainingCluster(query: StableId): [cluster: IdCluster, alignedLocal: LocalCompressedId] | undefined;
|
|
19
|
-
clusterCollides(cluster: IdCluster): boolean;
|
|
20
|
-
equals(other: Sessions, includeLocalState: boolean): boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.
|
|
24
|
-
*/
|
|
25
|
-
export declare class Session {
|
|
26
|
-
private readonly clusterChain;
|
|
27
|
-
readonly sessionUuid: NumericUuid;
|
|
28
|
-
constructor(sessionId: SessionId | NumericUuid);
|
|
29
|
-
/**
|
|
30
|
-
* Adds a new empty cluster to the cluster chain of this session.
|
|
31
|
-
*/
|
|
32
|
-
addNewCluster(baseFinalId: FinalCompressedId, capacity: number, count: number): IdCluster;
|
|
33
|
-
isEmpty(): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Returns the last cluster in this session's cluster chain, if any.
|
|
36
|
-
*/
|
|
37
|
-
getLastCluster(): IdCluster | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Converts the local ID from this session to a final ID, if possible.
|
|
40
|
-
* @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.
|
|
41
|
-
*/
|
|
42
|
-
tryConvertToFinal(searchLocal: LocalCompressedId, includeAllocated: boolean): FinalCompressedId | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Returns the cluster containing the supplied local ID, if possible.
|
|
45
|
-
* @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.
|
|
46
|
-
*/
|
|
47
|
-
getClusterByLocal(localId: LocalCompressedId, includeAllocated: boolean): IdCluster | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Returns the cluster containing the supplied final ID, if possible.
|
|
50
|
-
*/
|
|
51
|
-
getClusterByAllocatedFinal(final: FinalCompressedId): IdCluster | undefined;
|
|
52
|
-
/**
|
|
53
|
-
* Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.
|
|
54
|
-
* `clusterChain` must be sorted by final/local base ID.
|
|
55
|
-
*/
|
|
56
|
-
static getContainingCluster(finalId: FinalCompressedId, clusterChain: readonly IdCluster[]): IdCluster | undefined;
|
|
57
|
-
static binarySearch<S, T>(search: S, arr: readonly T[], comparator: (a: S, b: T) => number): T | undefined;
|
|
58
|
-
equals(other: Session): boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* A cluster of final (sequenced via consensus), sequentially allocated compressed IDs.
|
|
62
|
-
* A final ID in a cluster decompresses to a sequentially allocated UUID that is the result of adding its offset within
|
|
63
|
-
* the cluster to base UUID for the session that created it.
|
|
64
|
-
*/
|
|
65
|
-
export interface IdCluster {
|
|
66
|
-
/**
|
|
67
|
-
* The session that created this cluster.
|
|
68
|
-
*/
|
|
69
|
-
readonly session: Session;
|
|
70
|
-
/**
|
|
71
|
-
* The first final ID in the cluster.
|
|
72
|
-
*/
|
|
73
|
-
readonly baseFinalId: FinalCompressedId;
|
|
74
|
-
/**
|
|
75
|
-
* The local ID aligned with `baseFinalId`.
|
|
76
|
-
*/
|
|
77
|
-
readonly baseLocalId: LocalCompressedId;
|
|
78
|
-
/**
|
|
79
|
-
* The total number of final IDs reserved for allocation in the cluster.
|
|
80
|
-
* Clusters are reserved in blocks as a performance optimization.
|
|
81
|
-
*/
|
|
82
|
-
capacity: number;
|
|
83
|
-
/**
|
|
84
|
-
* The number of final IDs currently allocated in the cluster.
|
|
85
|
-
*/
|
|
86
|
-
count: number;
|
|
87
|
-
}
|
|
88
|
-
export declare function clustersEqual(a: IdCluster, b: IdCluster): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Returns the final ID that is aligned with the supplied local ID within a cluster.
|
|
91
|
-
* Includes allocated IDs.
|
|
92
|
-
*/
|
|
93
|
-
export declare function getAlignedFinal(cluster: IdCluster, localWithin: LocalCompressedId): FinalCompressedId | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* Returns the local ID that is aligned with the supplied final ID within a cluster.
|
|
96
|
-
* Fails if the supplied ID does not fall within the cluster bounds.
|
|
97
|
-
*/
|
|
98
|
-
export declare function getAlignedLocal(cluster: IdCluster, finalWithin: FinalCompressedId): LocalCompressedId;
|
|
99
|
-
/**
|
|
100
|
-
* Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster
|
|
101
|
-
*/
|
|
102
|
-
export declare function lastAllocatedFinal(cluster: IdCluster): FinalCompressedId;
|
|
103
|
-
/**
|
|
104
|
-
* Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster
|
|
105
|
-
*/
|
|
106
|
-
export declare function lastFinalizedFinal(cluster: IdCluster): FinalCompressedId;
|
|
107
|
-
/**
|
|
108
|
-
* Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster
|
|
109
|
-
*/
|
|
110
|
-
export declare function lastAllocatedLocal(cluster: IdCluster): LocalCompressedId;
|
|
111
|
-
/**
|
|
112
|
-
* Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster
|
|
113
|
-
*/
|
|
114
|
-
export declare function lastFinalizedLocal(cluster: IdCluster): LocalCompressedId;
|
|
115
|
-
//# sourceMappingURL=sessions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/id-compressor/sessions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAA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ED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAExE"}
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import BTree from "sorted-btree";
|
|
6
|
-
import { assert } from "@fluidframework/core-utils";
|
|
7
|
-
import { compareBigints, localIdFromGenCount, genCountFromLocalId, numericUuidFromStableId, stableIdFromNumericUuid, subtractNumericUuids, offsetNumericUuid, } from "./utilities";
|
|
8
|
-
/**
|
|
9
|
-
* A collection of all sessions known to the compressor (i.e. all finalized/acked allocated UUIDs and their corresponding local and final forms).
|
|
10
|
-
* This collection of all sessions comprises a distributed document's IDs.
|
|
11
|
-
*/
|
|
12
|
-
export class Sessions {
|
|
13
|
-
constructor(sessions) {
|
|
14
|
-
// A range-queryable store of all sessions. A btree is used as it solves the predecessor problem for any given UUID, allowing
|
|
15
|
-
// us to quickly find the session that may have produced it.
|
|
16
|
-
this.uuidSpace = new BTree(undefined, compareBigints);
|
|
17
|
-
// A fast lookup table from session ID to the session object, used to avoid accessing the slower btree
|
|
18
|
-
this.sessionCache = new Map();
|
|
19
|
-
if (sessions !== undefined) {
|
|
20
|
-
// bulk load path
|
|
21
|
-
for (const [numeric, session] of sessions) {
|
|
22
|
-
this.sessionCache.set(stableIdFromNumericUuid(numeric), session);
|
|
23
|
-
}
|
|
24
|
-
this.uuidSpace = new BTree(sessions, compareBigints);
|
|
25
|
-
if (this.sessionCache.size !== sessions.length ||
|
|
26
|
-
sessions.length !== this.uuidSpace.size) {
|
|
27
|
-
throw new Error("Cannot resume existing session.");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
sessions() {
|
|
32
|
-
return this.sessionCache.values();
|
|
33
|
-
}
|
|
34
|
-
getOrCreate(sessionId) {
|
|
35
|
-
const existing = this.sessionCache.get(sessionId);
|
|
36
|
-
if (existing !== undefined) {
|
|
37
|
-
return existing;
|
|
38
|
-
}
|
|
39
|
-
const session = new Session(sessionId);
|
|
40
|
-
assert(this.uuidSpace.set(session.sessionUuid, session), 0x760 /* Duplicate session in map. */);
|
|
41
|
-
this.sessionCache.set(sessionId, session);
|
|
42
|
-
return session;
|
|
43
|
-
}
|
|
44
|
-
get(sessionId) {
|
|
45
|
-
return this.sessionCache.get(sessionId);
|
|
46
|
-
}
|
|
47
|
-
getContainingCluster(query) {
|
|
48
|
-
const numericStable = numericUuidFromStableId(query);
|
|
49
|
-
const possibleMatch = this.uuidSpace.getPairOrNextLower(numericStable);
|
|
50
|
-
if (possibleMatch === undefined) {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
const [_, session] = possibleMatch;
|
|
54
|
-
const numericDelta = subtractNumericUuids(numericStable, session.sessionUuid);
|
|
55
|
-
if (numericDelta > Number.MAX_SAFE_INTEGER) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
const alignedLocal = localIdFromGenCount(Number(numericDelta) + 1);
|
|
59
|
-
const containingCluster = session.getClusterByLocal(alignedLocal, true);
|
|
60
|
-
if (containingCluster === undefined) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
return [containingCluster, alignedLocal];
|
|
64
|
-
}
|
|
65
|
-
clusterCollides(cluster) {
|
|
66
|
-
const { session: owningSession, baseLocalId, capacity } = cluster;
|
|
67
|
-
const clusterBaseNumeric = offsetNumericUuid(owningSession.sessionUuid, genCountFromLocalId(baseLocalId) - 1);
|
|
68
|
-
const clusterMaxNumeric = offsetNumericUuid(clusterBaseNumeric, capacity - 1);
|
|
69
|
-
let closestMatch = this.uuidSpace.getPairOrNextLower(clusterMaxNumeric);
|
|
70
|
-
// Find the first session that is not the owner of this new cluster.
|
|
71
|
-
// Once we have that, check to see if its cluster chain overlaps with the new cluster.
|
|
72
|
-
// Consider the following diagram of UUID space:
|
|
73
|
-
// Cluster chain A: |----------------------|
|
|
74
|
-
// Cluster chain B: |----------|
|
|
75
|
-
// Cluster chain C: |-------|
|
|
76
|
-
// While it is true that when adding a cluster to chain C, we would find
|
|
77
|
-
// the next lower session (which is B) and erroneously determine we do not collide
|
|
78
|
-
// with any other session, but this situation is impossible to get into as B would
|
|
79
|
-
// have detected that it collided with A (or the other way around, depending on ordering).
|
|
80
|
-
while (closestMatch !== undefined && closestMatch[1] === owningSession) {
|
|
81
|
-
closestMatch = this.uuidSpace.nextLowerPair(closestMatch[0]);
|
|
82
|
-
}
|
|
83
|
-
if (closestMatch === undefined) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
const [_, session] = closestMatch;
|
|
87
|
-
assert(session !== owningSession, 0x761 /* Failed to attempt to detect collisions. */);
|
|
88
|
-
const lastCluster = session.getLastCluster();
|
|
89
|
-
if (lastCluster === undefined) {
|
|
90
|
-
// If the closest session is empty (the local session), then it is guaranteed (probabilistically) that there are no
|
|
91
|
-
// non-empty sessions that have a cluster chain that starts prior to the empty session and collides with the cluster
|
|
92
|
-
// we are checking, so we can return false.
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
const lastAllocatedNumeric = offsetNumericUuid(session.sessionUuid, genCountFromLocalId(lastAllocatedLocal(lastCluster)) - 1);
|
|
96
|
-
return lastAllocatedNumeric >= clusterBaseNumeric;
|
|
97
|
-
}
|
|
98
|
-
equals(other, includeLocalState) {
|
|
99
|
-
const checkIsSubset = (sessionsA, sessionsB) => {
|
|
100
|
-
const first = sessionsA.sessions().next();
|
|
101
|
-
const firstSessionThis = first.done ? undefined : first.value;
|
|
102
|
-
for (const [stableId, session] of sessionsA.sessionCache.entries()) {
|
|
103
|
-
const otherSession = sessionsB.sessionCache.get(stableId);
|
|
104
|
-
if (otherSession === undefined) {
|
|
105
|
-
if (!session.isEmpty() || includeLocalState) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
assert(session === firstSessionThis, 0x762 /* The only non-empty session must be the local session. */);
|
|
109
|
-
}
|
|
110
|
-
else if (!session.equals(otherSession)) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
};
|
|
116
|
-
return checkIsSubset(this, other) && checkIsSubset(other, this);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* The IDs created by a specific session, stored as a cluster chain to allow for fast conversions.
|
|
121
|
-
*/
|
|
122
|
-
export class Session {
|
|
123
|
-
constructor(sessionId) {
|
|
124
|
-
// All clusters created by this session, in creation order (thus sorted by base final and local ID).
|
|
125
|
-
this.clusterChain = [];
|
|
126
|
-
this.sessionUuid =
|
|
127
|
-
typeof sessionId === "string" ? numericUuidFromStableId(sessionId) : sessionId;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Adds a new empty cluster to the cluster chain of this session.
|
|
131
|
-
*/
|
|
132
|
-
addNewCluster(baseFinalId, capacity, count) {
|
|
133
|
-
const lastCluster = this.getLastCluster();
|
|
134
|
-
const newCluster = {
|
|
135
|
-
session: this,
|
|
136
|
-
baseFinalId,
|
|
137
|
-
baseLocalId: (lastCluster === undefined
|
|
138
|
-
? -1
|
|
139
|
-
: lastAllocatedLocal(lastCluster) - 1),
|
|
140
|
-
capacity,
|
|
141
|
-
count,
|
|
142
|
-
};
|
|
143
|
-
this.clusterChain.push(newCluster);
|
|
144
|
-
return newCluster;
|
|
145
|
-
}
|
|
146
|
-
isEmpty() {
|
|
147
|
-
return this.clusterChain.length === 0;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Returns the last cluster in this session's cluster chain, if any.
|
|
151
|
-
*/
|
|
152
|
-
getLastCluster() {
|
|
153
|
-
return this.clusterChain[this.clusterChain.length - 1];
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Converts the local ID from this session to a final ID, if possible.
|
|
157
|
-
* @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.
|
|
158
|
-
*/
|
|
159
|
-
tryConvertToFinal(searchLocal, includeAllocated) {
|
|
160
|
-
const containingCluster = this.getClusterByLocal(searchLocal, includeAllocated);
|
|
161
|
-
if (containingCluster === undefined) {
|
|
162
|
-
return undefined;
|
|
163
|
-
}
|
|
164
|
-
return getAlignedFinal(containingCluster, searchLocal);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Returns the cluster containing the supplied local ID, if possible.
|
|
168
|
-
* @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.
|
|
169
|
-
*/
|
|
170
|
-
getClusterByLocal(localId, includeAllocated) {
|
|
171
|
-
const lastValidLocal = includeAllocated
|
|
172
|
-
? lastAllocatedLocal
|
|
173
|
-
: lastFinalizedLocal;
|
|
174
|
-
const matchedCluster = Session.binarySearch(localId, this.clusterChain, (local, cluster) => {
|
|
175
|
-
const lastLocal = lastValidLocal(cluster);
|
|
176
|
-
if (local < lastLocal) {
|
|
177
|
-
return 1;
|
|
178
|
-
}
|
|
179
|
-
else if (local > cluster.baseLocalId) {
|
|
180
|
-
return -1;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
return 0;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
return matchedCluster;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Returns the cluster containing the supplied final ID, if possible.
|
|
190
|
-
*/
|
|
191
|
-
getClusterByAllocatedFinal(final) {
|
|
192
|
-
return Session.getContainingCluster(final, this.clusterChain);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Returns the cluster from the supplied cluster chain containing the supplied final ID, if possible.
|
|
196
|
-
* `clusterChain` must be sorted by final/local base ID.
|
|
197
|
-
*/
|
|
198
|
-
static getContainingCluster(finalId, clusterChain) {
|
|
199
|
-
return Session.binarySearch(finalId, clusterChain, (final, cluster) => {
|
|
200
|
-
const lastFinal = lastAllocatedFinal(cluster);
|
|
201
|
-
if (final < cluster.baseFinalId) {
|
|
202
|
-
return -1;
|
|
203
|
-
}
|
|
204
|
-
else if (final > lastFinal) {
|
|
205
|
-
return 1;
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
return 0;
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
static binarySearch(search, arr, comparator) {
|
|
213
|
-
let left = 0;
|
|
214
|
-
let right = arr.length - 1;
|
|
215
|
-
while (left <= right) {
|
|
216
|
-
const mid = Math.floor((left + right) / 2);
|
|
217
|
-
const c = comparator(search, arr[mid]);
|
|
218
|
-
if (c === 0) {
|
|
219
|
-
return arr[mid]; // Found the target, return its index.
|
|
220
|
-
}
|
|
221
|
-
else if (c > 0) {
|
|
222
|
-
left = mid + 1; // Continue search on right half.
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
right = mid - 1; // Continue search on left half.
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return undefined; // If we reach here, target is not in array.
|
|
229
|
-
}
|
|
230
|
-
equals(other) {
|
|
231
|
-
for (let i = 0; i < this.clusterChain.length; i++) {
|
|
232
|
-
if (!clustersEqual(this.clusterChain[i], other.clusterChain[i])) {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return this.sessionUuid === other.sessionUuid;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
export function clustersEqual(a, b) {
|
|
240
|
-
return (a.session.sessionUuid === b.session.sessionUuid &&
|
|
241
|
-
a.baseFinalId === b.baseFinalId &&
|
|
242
|
-
a.baseLocalId === b.baseLocalId &&
|
|
243
|
-
a.capacity === b.capacity &&
|
|
244
|
-
a.count === b.count);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Returns the final ID that is aligned with the supplied local ID within a cluster.
|
|
248
|
-
* Includes allocated IDs.
|
|
249
|
-
*/
|
|
250
|
-
export function getAlignedFinal(cluster, localWithin) {
|
|
251
|
-
const clusterOffset = genCountFromLocalId(localWithin) - genCountFromLocalId(cluster.baseLocalId);
|
|
252
|
-
if (clusterOffset < cluster.capacity) {
|
|
253
|
-
return (cluster.baseFinalId + clusterOffset);
|
|
254
|
-
}
|
|
255
|
-
return undefined;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Returns the local ID that is aligned with the supplied final ID within a cluster.
|
|
259
|
-
* Fails if the supplied ID does not fall within the cluster bounds.
|
|
260
|
-
*/
|
|
261
|
-
export function getAlignedLocal(cluster, finalWithin) {
|
|
262
|
-
assert(finalWithin >= cluster.baseFinalId && finalWithin <= lastAllocatedFinal(cluster), 0x763 /* Supplied ID is not within the cluster. */);
|
|
263
|
-
const finalDelta = finalWithin - cluster.baseFinalId;
|
|
264
|
-
return (cluster.baseLocalId - finalDelta);
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Returns the last allocated final ID (i.e. any ID between base final and base final + capacity) within a cluster
|
|
268
|
-
*/
|
|
269
|
-
export function lastAllocatedFinal(cluster) {
|
|
270
|
-
return (cluster.baseFinalId + (cluster.capacity - 1));
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Returns the last allocated final ID (i.e. any ID between base final and base final + count) within a cluster
|
|
274
|
-
*/
|
|
275
|
-
export function lastFinalizedFinal(cluster) {
|
|
276
|
-
return (cluster.baseFinalId + (cluster.count - 1));
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Returns the last allocated local ID (i.e. any ID between base local and base local + capacity) within a cluster
|
|
280
|
-
*/
|
|
281
|
-
export function lastAllocatedLocal(cluster) {
|
|
282
|
-
return (cluster.baseLocalId - (cluster.capacity - 1));
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Returns the last allocated local ID (i.e. any ID between base local and base local + count) within a cluster
|
|
286
|
-
*/
|
|
287
|
-
export function lastFinalizedLocal(cluster) {
|
|
288
|
-
return (cluster.baseLocalId - (cluster.count - 1));
|
|
289
|
-
}
|
|
290
|
-
//# sourceMappingURL=sessions.js.map
|