@fluid-experimental/tree 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +22 -7
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.d.ts +2 -2
- package/dist/id-compressor/SessionIdNormalizer.js +2 -2
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +22 -7
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.d.ts +2 -2
- package/lib/id-compressor/SessionIdNormalizer.js +2 -2
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +23 -0
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/package.json +17 -17
- package/src/id-compressor/IdCompressor.ts +28 -7
- package/src/id-compressor/SessionIdNormalizer.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/tree",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
40
40
|
"@fluidframework/common-utils": "^0.32.1",
|
|
41
|
-
"@fluidframework/container-definitions": "^1.2.
|
|
42
|
-
"@fluidframework/core-interfaces": "^1.2.
|
|
43
|
-
"@fluidframework/datastore-definitions": "^1.2.
|
|
41
|
+
"@fluidframework/container-definitions": "^1.2.7",
|
|
42
|
+
"@fluidframework/core-interfaces": "^1.2.7",
|
|
43
|
+
"@fluidframework/datastore-definitions": "^1.2.7",
|
|
44
44
|
"@fluidframework/protocol-definitions": "^0.1028.2000",
|
|
45
|
-
"@fluidframework/runtime-definitions": "^1.2.
|
|
46
|
-
"@fluidframework/shared-object-base": "^1.2.
|
|
47
|
-
"@fluidframework/telemetry-utils": "^1.2.
|
|
45
|
+
"@fluidframework/runtime-definitions": "^1.2.7",
|
|
46
|
+
"@fluidframework/shared-object-base": "^1.2.7",
|
|
47
|
+
"@fluidframework/telemetry-utils": "^1.2.7",
|
|
48
48
|
"buffer": "^6.0.3",
|
|
49
49
|
"denque": "^1.5.1",
|
|
50
50
|
"lru-cache": "^6.0.0",
|
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
"uuid": "^8.3.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@fluid-internal/stochastic-test-utils": "^1.2.
|
|
55
|
+
"@fluid-internal/stochastic-test-utils": "^1.2.7",
|
|
56
56
|
"@fluid-tools/benchmark": "^0.40.0",
|
|
57
57
|
"@fluidframework/build-common": "^0.24.0",
|
|
58
|
-
"@fluidframework/container-loader": "^1.2.
|
|
59
|
-
"@fluidframework/container-runtime": "^1.2.
|
|
58
|
+
"@fluidframework/container-loader": "^1.2.7",
|
|
59
|
+
"@fluidframework/container-runtime": "^1.2.7",
|
|
60
60
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
61
|
-
"@fluidframework/mocha-test-setup": "^1.2.
|
|
62
|
-
"@fluidframework/runtime-utils": "^1.2.
|
|
63
|
-
"@fluidframework/test-driver-definitions": "^1.2.
|
|
64
|
-
"@fluidframework/test-drivers": "^1.2.
|
|
65
|
-
"@fluidframework/test-runtime-utils": "^1.2.
|
|
66
|
-
"@fluidframework/test-utils": "^1.2.
|
|
67
|
-
"@fluidframework/undo-redo": "^1.2.
|
|
61
|
+
"@fluidframework/mocha-test-setup": "^1.2.7",
|
|
62
|
+
"@fluidframework/runtime-utils": "^1.2.7",
|
|
63
|
+
"@fluidframework/test-driver-definitions": "^1.2.7",
|
|
64
|
+
"@fluidframework/test-drivers": "^1.2.7",
|
|
65
|
+
"@fluidframework/test-runtime-utils": "^1.2.7",
|
|
66
|
+
"@fluidframework/test-utils": "^1.2.7",
|
|
67
|
+
"@fluidframework/undo-redo": "^1.2.7",
|
|
68
68
|
"@microsoft/api-extractor": "^7.22.2",
|
|
69
69
|
"@rushstack/eslint-config": "^2.5.1",
|
|
70
70
|
"@types/lru-cache": "^5.1.0",
|
|
@@ -612,16 +612,37 @@ export class IdCompressor {
|
|
|
612
612
|
// Example with cluster size of 3:
|
|
613
613
|
// Ids generated so far: -1 1 2 -4 -5 <-- note positive numbers are eager finals
|
|
614
614
|
// Cluster: [ 0 1 2 ]
|
|
615
|
-
// ~ finalizing happens, causing expansion ~
|
|
616
|
-
// Cluster: [ 0 1 2 3 4
|
|
617
|
-
// corresponding locals: -1 -4
|
|
618
|
-
// lastFinalizedLocalId^
|
|
615
|
+
// ~ finalizing happens, causing expansion of 2 (overflow) + 3 (cluster capacity) ~
|
|
616
|
+
// Cluster: [ 0 1 2 3 4 _ _ _ ]
|
|
617
|
+
// corresponding locals: -1 -4 -5
|
|
618
|
+
// lastFinalizedLocalId^ ^newLastFinalizedLocalId = -5
|
|
619
619
|
// overflow = 2: ----
|
|
620
620
|
// localIdPivot^
|
|
621
621
|
// lastFinalizedFinal^
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
const newLastFinalizedFinal = (currentBaseFinalId +
|
|
623
|
+
currentCluster.count -
|
|
624
|
+
1) as FinalCompressedId;
|
|
625
|
+
assert(
|
|
626
|
+
session.lastFinalizedLocalId !== undefined,
|
|
627
|
+
'Cluster already exists for session but there is no finalized local ID'
|
|
628
|
+
);
|
|
629
|
+
const newLastFinalizedLocal = session.lastFinalizedLocalId - finalizeCount;
|
|
630
|
+
const lastLocal = -this.localIdCount;
|
|
631
|
+
// Calculate the last final in the cluster that aligns with an existing local. If there are more unfinalized locals
|
|
632
|
+
// than fit in the expanded cluster, this will be the last final in the cluster
|
|
633
|
+
const newLastFinal = (newLastFinalizedFinal +
|
|
634
|
+
Math.min(newLastFinalizedLocal - lastLocal, this.newClusterCapacity)) as FinalCompressedId;
|
|
635
|
+
assert(
|
|
636
|
+
newLastFinal >= newLastFinalizedFinal,
|
|
637
|
+
'The number of unfinalized locals should only be positive'
|
|
638
|
+
);
|
|
639
|
+
const finalPivot = (newLastFinalizedFinal - overflow + 1) as FinalCompressedId;
|
|
640
|
+
// Inform the normalizer of all IDs that we now know will end up being finalized into this cluster, including the ones
|
|
641
|
+
// that were given out as locals (non-eager) because they exceeded the bounds of the current cluster before it was expanded.
|
|
642
|
+
// It is safe to associate the unfinalized locals with their future final IDs even before the ranges for those locals are
|
|
643
|
+
// actually finalized, because total order broadcast guarantees that any usage of those final IDs will be observed after
|
|
644
|
+
// the finalization of the ranges.
|
|
645
|
+
this.sessionIdNormalizer.addFinalIds(finalPivot, newLastFinal, currentCluster);
|
|
625
646
|
this.logger?.sendTelemetryEvent({
|
|
626
647
|
eventName: 'IdCompressor:ClusterExpansion',
|
|
627
648
|
sessionId: this.localSessionId,
|
|
@@ -113,8 +113,8 @@ export class SessionIdNormalizer<TRangeObject> {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
|
-
* Returns the index of the supplied
|
|
117
|
-
* by the session for this `SessionIdNormalizer`.
|
|
116
|
+
* Returns the index of the local ID corresponding to the supplied final ID in the total range of IDs created by the session,
|
|
117
|
+
* if the ID was created by the session for this `SessionIdNormalizer`.
|
|
118
118
|
*/
|
|
119
119
|
public getCreationIndex(finalId: FinalCompressedId): number | undefined {
|
|
120
120
|
const localRange = this.idRanges.getPairOrNextLowerByValue(finalId);
|