@fluid-experimental/tree 1.2.6 → 1.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/tree",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
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.6",
42
- "@fluidframework/core-interfaces": "^1.2.6",
43
- "@fluidframework/datastore-definitions": "^1.2.6",
41
+ "@fluidframework/container-definitions": "^1.2.8",
42
+ "@fluidframework/core-interfaces": "^1.2.8",
43
+ "@fluidframework/datastore-definitions": "^1.2.8",
44
44
  "@fluidframework/protocol-definitions": "^0.1028.2000",
45
- "@fluidframework/runtime-definitions": "^1.2.6",
46
- "@fluidframework/shared-object-base": "^1.2.6",
47
- "@fluidframework/telemetry-utils": "^1.2.6",
45
+ "@fluidframework/runtime-definitions": "^1.2.8",
46
+ "@fluidframework/shared-object-base": "^1.2.8",
47
+ "@fluidframework/telemetry-utils": "^1.2.8",
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.6",
55
+ "@fluid-internal/stochastic-test-utils": "^1.2.8",
56
56
  "@fluid-tools/benchmark": "^0.40.0",
57
57
  "@fluidframework/build-common": "^0.24.0",
58
- "@fluidframework/container-loader": "^1.2.6",
59
- "@fluidframework/container-runtime": "^1.2.6",
58
+ "@fluidframework/container-loader": "^1.2.8",
59
+ "@fluidframework/container-runtime": "^1.2.8",
60
60
  "@fluidframework/eslint-config-fluid": "^0.28.2000",
61
- "@fluidframework/mocha-test-setup": "^1.2.6",
62
- "@fluidframework/runtime-utils": "^1.2.6",
63
- "@fluidframework/test-driver-definitions": "^1.2.6",
64
- "@fluidframework/test-drivers": "^1.2.6",
65
- "@fluidframework/test-runtime-utils": "^1.2.6",
66
- "@fluidframework/test-utils": "^1.2.6",
67
- "@fluidframework/undo-redo": "^1.2.6",
61
+ "@fluidframework/mocha-test-setup": "^1.2.8",
62
+ "@fluidframework/runtime-utils": "^1.2.8",
63
+ "@fluidframework/test-driver-definitions": "^1.2.8",
64
+ "@fluidframework/test-drivers": "^1.2.8",
65
+ "@fluidframework/test-runtime-utils": "^1.2.8",
66
+ "@fluidframework/test-utils": "^1.2.8",
67
+ "@fluidframework/undo-redo": "^1.2.8",
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 5 ]
617
- // corresponding locals: -1 -4
618
- // lastFinalizedLocalId^ ^newLastFinalizedLocalId = -6
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 lastFinalizedFinal = (currentBaseFinalId + currentCluster.count - 1) as FinalCompressedId;
623
- const finalPivot = (lastFinalizedFinal - overflow + 1) as FinalCompressedId;
624
- this.sessionIdNormalizer.addFinalIds(finalPivot, lastFinalizedFinal, currentCluster);
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 session-space ID in the total range of IDs created by the session, if the ID was created
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);