@fluidframework/merge-tree 2.21.0 → 2.22.1
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/.eslintrc.cjs +0 -1
- package/CHANGELOG.md +4 -0
- package/README.md +1 -0
- package/dist/attributionCollection.js +5 -7
- package/dist/attributionCollection.js.map +1 -1
- package/dist/localReference.js +6 -8
- package/dist/localReference.js.map +1 -1
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +107 -43
- package/dist/mergeTree.js.map +1 -1
- package/dist/mergeTreeNodes.d.ts +15 -4
- package/dist/mergeTreeNodes.d.ts.map +1 -1
- package/dist/mergeTreeNodes.js +1 -1
- package/dist/mergeTreeNodes.js.map +1 -1
- package/dist/partialLengths.d.ts +114 -144
- package/dist/partialLengths.d.ts.map +1 -1
- package/dist/partialLengths.js +431 -525
- package/dist/partialLengths.js.map +1 -1
- package/dist/perspective.d.ts +10 -1
- package/dist/perspective.d.ts.map +1 -1
- package/dist/perspective.js +10 -1
- package/dist/perspective.js.map +1 -1
- package/dist/properties.d.ts.map +1 -1
- package/dist/properties.js +2 -3
- package/dist/properties.js.map +1 -1
- package/dist/revertibles.js +3 -3
- package/dist/revertibles.js.map +1 -1
- package/dist/segmentInfos.d.ts +3 -0
- package/dist/segmentInfos.d.ts.map +1 -1
- package/dist/segmentInfos.js.map +1 -1
- package/dist/segmentPropertiesManager.js +3 -3
- package/dist/segmentPropertiesManager.js.map +1 -1
- package/dist/snapshotLoader.js +2 -2
- package/dist/snapshotLoader.js.map +1 -1
- package/dist/sortedSegmentSet.d.ts +5 -3
- package/dist/sortedSegmentSet.d.ts.map +1 -1
- package/dist/sortedSegmentSet.js +33 -41
- package/dist/sortedSegmentSet.js.map +1 -1
- package/dist/sortedSet.d.ts +20 -3
- package/dist/sortedSet.d.ts.map +1 -1
- package/dist/sortedSet.js +23 -14
- package/dist/sortedSet.js.map +1 -1
- package/dist/test/Snapshot.perf.spec.js +1 -1
- package/dist/test/Snapshot.perf.spec.js.map +1 -1
- package/dist/test/client.applyMsg.spec.js +20 -0
- package/dist/test/client.applyMsg.spec.js.map +1 -1
- package/dist/test/client.applyStashedOpFarm.spec.js +1 -1
- package/dist/test/client.applyStashedOpFarm.spec.js.map +1 -1
- package/dist/test/client.attributionFarm.spec.js +1 -1
- package/dist/test/client.attributionFarm.spec.js.map +1 -1
- package/dist/test/client.localReference.spec.js +48 -0
- package/dist/test/client.localReference.spec.js.map +1 -1
- package/dist/test/client.obliterateFarm.spec.d.ts.map +1 -1
- package/dist/test/client.obliterateFarm.spec.js +12 -3
- package/dist/test/client.obliterateFarm.spec.js.map +1 -1
- package/dist/test/client.reconnectFarm.spec.js +1 -1
- package/dist/test/client.reconnectFarm.spec.js.map +1 -1
- package/dist/test/client.searchForMarker.spec.js +2 -2
- package/dist/test/client.searchForMarker.spec.js.map +1 -1
- package/dist/test/mergeTreeOperationRunner.d.ts +1 -1
- package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -1
- package/dist/test/mergeTreeOperationRunner.js +23 -11
- package/dist/test/mergeTreeOperationRunner.js.map +1 -1
- package/dist/test/obliterate.concurrent.spec.js +97 -1
- package/dist/test/obliterate.concurrent.spec.js.map +1 -1
- package/dist/test/obliterate.rangeExpansion.spec.js +81 -5
- package/dist/test/obliterate.rangeExpansion.spec.js.map +1 -1
- package/dist/test/obliterate.spec.js +3 -3
- package/dist/test/obliterate.spec.js.map +1 -1
- package/dist/test/obliterateOperations.d.ts.map +1 -1
- package/dist/test/obliterateOperations.js +29 -18
- package/dist/test/obliterateOperations.js.map +1 -1
- package/dist/test/partialSyncHelper.d.ts +42 -0
- package/dist/test/partialSyncHelper.d.ts.map +1 -0
- package/dist/test/partialSyncHelper.js +96 -0
- package/dist/test/partialSyncHelper.js.map +1 -0
- package/dist/test/revertibles.spec.js +3 -3
- package/dist/test/revertibles.spec.js.map +1 -1
- package/dist/test/sortedSegmentSet.spec.js +21 -0
- package/dist/test/sortedSegmentSet.spec.js.map +1 -1
- package/dist/test/testClient.d.ts +1 -1
- package/dist/test/testClient.d.ts.map +1 -1
- package/dist/test/testClient.js +1 -0
- package/dist/test/testClient.js.map +1 -1
- package/dist/test/testUtils.js +2 -2
- package/dist/test/testUtils.js.map +1 -1
- package/lib/attributionCollection.js +5 -7
- package/lib/attributionCollection.js.map +1 -1
- package/lib/localReference.js +6 -8
- package/lib/localReference.js.map +1 -1
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +107 -43
- package/lib/mergeTree.js.map +1 -1
- package/lib/mergeTreeNodes.d.ts +15 -4
- package/lib/mergeTreeNodes.d.ts.map +1 -1
- package/lib/mergeTreeNodes.js +1 -1
- package/lib/mergeTreeNodes.js.map +1 -1
- package/lib/partialLengths.d.ts +114 -144
- package/lib/partialLengths.d.ts.map +1 -1
- package/lib/partialLengths.js +432 -525
- package/lib/partialLengths.js.map +1 -1
- package/lib/perspective.d.ts +10 -1
- package/lib/perspective.d.ts.map +1 -1
- package/lib/perspective.js +10 -1
- package/lib/perspective.js.map +1 -1
- package/lib/properties.d.ts.map +1 -1
- package/lib/properties.js +2 -3
- package/lib/properties.js.map +1 -1
- package/lib/revertibles.js +3 -3
- package/lib/revertibles.js.map +1 -1
- package/lib/segmentInfos.d.ts +3 -0
- package/lib/segmentInfos.d.ts.map +1 -1
- package/lib/segmentInfos.js.map +1 -1
- package/lib/segmentPropertiesManager.js +3 -3
- package/lib/segmentPropertiesManager.js.map +1 -1
- package/lib/snapshotLoader.js +2 -2
- package/lib/snapshotLoader.js.map +1 -1
- package/lib/sortedSegmentSet.d.ts +5 -3
- package/lib/sortedSegmentSet.d.ts.map +1 -1
- package/lib/sortedSegmentSet.js +33 -41
- package/lib/sortedSegmentSet.js.map +1 -1
- package/lib/sortedSet.d.ts +20 -3
- package/lib/sortedSet.d.ts.map +1 -1
- package/lib/sortedSet.js +23 -14
- package/lib/sortedSet.js.map +1 -1
- package/lib/test/Snapshot.perf.spec.js +1 -1
- package/lib/test/Snapshot.perf.spec.js.map +1 -1
- package/lib/test/client.applyMsg.spec.js +20 -0
- package/lib/test/client.applyMsg.spec.js.map +1 -1
- package/lib/test/client.applyStashedOpFarm.spec.js +1 -1
- package/lib/test/client.applyStashedOpFarm.spec.js.map +1 -1
- package/lib/test/client.attributionFarm.spec.js +1 -1
- package/lib/test/client.attributionFarm.spec.js.map +1 -1
- package/lib/test/client.localReference.spec.js +48 -0
- package/lib/test/client.localReference.spec.js.map +1 -1
- package/lib/test/client.obliterateFarm.spec.d.ts.map +1 -1
- package/lib/test/client.obliterateFarm.spec.js +16 -5
- package/lib/test/client.obliterateFarm.spec.js.map +1 -1
- package/lib/test/client.reconnectFarm.spec.js +1 -1
- package/lib/test/client.reconnectFarm.spec.js.map +1 -1
- package/lib/test/client.searchForMarker.spec.js +2 -2
- package/lib/test/client.searchForMarker.spec.js.map +1 -1
- package/lib/test/mergeTreeOperationRunner.d.ts +1 -1
- package/lib/test/mergeTreeOperationRunner.d.ts.map +1 -1
- package/lib/test/mergeTreeOperationRunner.js +23 -11
- package/lib/test/mergeTreeOperationRunner.js.map +1 -1
- package/lib/test/obliterate.concurrent.spec.js +97 -1
- package/lib/test/obliterate.concurrent.spec.js.map +1 -1
- package/lib/test/obliterate.rangeExpansion.spec.js +81 -5
- package/lib/test/obliterate.rangeExpansion.spec.js.map +1 -1
- package/lib/test/obliterate.spec.js +3 -3
- package/lib/test/obliterate.spec.js.map +1 -1
- package/lib/test/obliterateOperations.d.ts.map +1 -1
- package/lib/test/obliterateOperations.js +29 -18
- package/lib/test/obliterateOperations.js.map +1 -1
- package/lib/test/partialSyncHelper.d.ts +42 -0
- package/lib/test/partialSyncHelper.d.ts.map +1 -0
- package/lib/test/partialSyncHelper.js +92 -0
- package/lib/test/partialSyncHelper.js.map +1 -0
- package/lib/test/revertibles.spec.js +3 -3
- package/lib/test/revertibles.spec.js.map +1 -1
- package/lib/test/sortedSegmentSet.spec.js +21 -0
- package/lib/test/sortedSegmentSet.spec.js.map +1 -1
- package/lib/test/testClient.d.ts +1 -1
- package/lib/test/testClient.d.ts.map +1 -1
- package/lib/test/testClient.js +1 -0
- package/lib/test/testClient.js.map +1 -1
- package/lib/test/testUtils.js +2 -2
- package/lib/test/testUtils.js.map +1 -1
- package/package.json +18 -18
- package/src/mergeTree.ts +126 -37
- package/src/mergeTreeNodes.ts +15 -4
- package/src/partialLengths.ts +559 -776
- package/src/perspective.ts +10 -1
- package/src/properties.ts +2 -3
- package/src/segmentInfos.ts +3 -0
- package/src/snapshotLoader.ts +1 -1
- package/src/sortedSegmentSet.ts +41 -50
- package/src/sortedSet.ts +32 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testClient.js","sourceRoot":"","sources":["../../src/test/testClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAGlE,OAAO,EAEN,WAAW,GAEX,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAa,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGN,MAAM,EACN,eAAe,EAEf,iBAAiB,GACjB,MAAM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AAC,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC;gBACxC,KAAK,CAAC,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC;gBACxC,KAAK,CAAC,gBAAgB,IAAI,UAAU,CAAC,gBAAgB,CAAC;gBACtD,KAAK,CAAC,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC;gBACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC1C,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACvC,CAAC;YACF,CAAC;YACD,IAAI,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;gBAC9B,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;YAC1B,CAAC;QACF,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,KAAK,CAAC,SAAS,EAAE,CAAC;QAClB,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC;QACpC,OAAO,KAAK,CAAC;IACd,CAAC,CAAC;IACF,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport { Trace } from \"@fluid-internal/client-utils\";\nimport { makeRandom } from \"@fluid-private/stochastic-test-utils\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tITree,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport { MockStorage } from \"@fluidframework/test-runtime-utils/internal\";\n\nimport { MergeTreeTextHelper } from \"../MergeTreeTextHelper.js\";\nimport { Client } from \"../client.js\";\nimport { DoublyLinkedList } from \"../collections/index.js\";\nimport { UnassignedSequenceNumber } from \"../constants.js\";\nimport { IMergeTreeOptions, ReferencePosition } from \"../index.js\";\nimport { MergeTree, getSlideToSegoff } from \"../mergeTree.js\";\nimport {\n\tbackwardExcursion,\n\tforwardExcursion,\n\twalkAllChildSegments,\n} from \"../mergeTreeNodeWalk.js\";\nimport {\n\tMergeBlock,\n\tISegmentPrivate,\n\tMarker,\n\tMaxNodesInBlock,\n\ttype SegmentGroup,\n\tassertSegmentLeaf,\n} from \"../mergeTreeNodes.js\";\nimport {\n\tcreateAnnotateRangeOp,\n\tcreateInsertSegmentOp,\n\tcreateRemoveRangeOp,\n} from \"../opBuilder.js\";\nimport {\n\tIJSONSegment,\n\tIMarkerDef,\n\tIMergeTreeOp,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\ttype IMergeTreeInsertMsg,\n} from \"../ops.js\";\nimport { PropertySet } from \"../properties.js\";\nimport { DetachedReferencePosition, refHasTileLabel } from \"../referencePositions.js\";\nimport { MergeTreeRevertibleDriver } from \"../revertibles.js\";\nimport {\n\tassertInserted,\n\tassertMergeNode,\n\tisInserted,\n\tisMoved,\n\tisRemoved,\n} from \"../segmentInfos.js\";\nimport { SnapshotLegacy } from \"../snapshotlegacy.js\";\nimport { TextSegment } from \"../textSegment.js\";\n\nimport { TestSerializer } from \"./testSerializer.js\";\nimport { nodeOrdinalsHaveIntegrity } from \"./testUtils.js\";\n\nexport function specToSegment(spec: IJSONSegment): ISegmentPrivate {\n\tconst maybeText = TextSegment.fromJSONObject(spec);\n\tif (maybeText) {\n\t\treturn maybeText;\n\t}\n\n\tconst maybeMarker = Marker.fromJSONObject(spec);\n\tif (maybeMarker) {\n\t\treturn maybeMarker;\n\t}\n\n\tthrow new Error(`Unrecognized IJSONSegment type: '${JSON.stringify(spec)}'`);\n}\n\nconst random = makeRandom(0xdeadbeef, 0xfeedbed);\n\nexport class TestClient extends Client {\n\tpublic static searchChunkSize = 256;\n\tpublic static readonly serializer = new TestSerializer();\n\tpublic measureOps = false;\n\tpublic accumTime = 0;\n\tpublic accumWindowTime = 0;\n\tpublic accumWindow = 0;\n\tpublic accumOps = 0;\n\tpublic maxWindowTime = 0;\n\n\t/**\n\t * Used for in-memory testing. This will queue a reference string for each client message.\n\t */\n\tpublic static useCheckQ = false;\n\n\tpublic static async createFromClientSnapshot(\n\t\tclient1: TestClient,\n\t\tnewLongClientId: string,\n\t): Promise<TestClient> {\n\t\tconst snapshot = new SnapshotLegacy(\n\t\t\tclient1.mergeTree,\n\t\t\tcreateChildLogger({ namespace: \"fluid:snapshot\" }),\n\t\t);\n\t\tsnapshot.extractSync();\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst summaryTree = snapshot.emit([], TestClient.serializer, undefined!).summary;\n\t\treturn TestClient.createFromSummary(\n\t\t\tsummaryTree,\n\t\t\tnewLongClientId,\n\t\t\tclient1.specToSegment,\n\t\t\tclient1.mergeTree.options,\n\t\t);\n\t}\n\n\tpublic static async createFromSnapshot(\n\t\tsnapshotTree: ITree,\n\t\tnewLongClientId: string,\n\t\tspecToSeg: (spec: IJSONSegment) => ISegmentPrivate,\n\t\toptions?: PropertySet,\n\t): Promise<TestClient> {\n\t\treturn TestClient.createFromStorage(\n\t\t\tnew MockStorage(snapshotTree),\n\t\t\tnewLongClientId,\n\t\t\tspecToSeg,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tpublic static async createFromSummary(\n\t\tsummaryTree: ISummaryTree,\n\t\tnewLongClientId: string,\n\t\tspecToSeg: (spec: IJSONSegment) => ISegmentPrivate,\n\t\toptions?: PropertySet,\n\t): Promise<TestClient> {\n\t\treturn TestClient.createFromStorage(\n\t\t\tMockStorage.createFromSummary(summaryTree),\n\t\t\tnewLongClientId,\n\t\t\tspecToSeg,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tpublic static async createFromStorage(\n\t\tstorage: MockStorage,\n\t\tnewLongClientId: string,\n\t\tspecToSeg: (spec: IJSONSegment) => ISegmentPrivate,\n\t\toptions?: PropertySet,\n\t): Promise<TestClient> {\n\t\tconst client2 = new TestClient(options, specToSeg);\n\t\tconst { catchupOpsP } = await client2.load(\n\t\t\t{\n\t\t\t\tlogger: client2.logger,\n\t\t\t\tclientId: newLongClientId,\n\t\t\t} as unknown as IFluidDataStoreRuntime,\n\t\t\tstorage,\n\t\t\tTestClient.serializer,\n\t\t);\n\t\tawait catchupOpsP;\n\t\treturn client2;\n\t}\n\n\tpublic readonly mergeTree: MergeTree;\n\n\tpublic readonly checkQ: DoublyLinkedList<string> = new DoublyLinkedList<string>();\n\tprotected readonly q: DoublyLinkedList<ISequencedDocumentMessage> =\n\t\tnew DoublyLinkedList<ISequencedDocumentMessage>();\n\n\tprivate readonly textHelper: MergeTreeTextHelper;\n\tconstructor(\n\t\toptions?: IMergeTreeOptions & PropertySet,\n\t\tspecToSeg = specToSegment,\n\t\tgetMinInFlightRefSeq: () => number | undefined = (): undefined => undefined,\n\t) {\n\t\tsuper(\n\t\t\tspecToSeg,\n\t\t\tcreateChildLogger({ namespace: \"fluid:testClient\" }),\n\t\t\toptions,\n\t\t\tgetMinInFlightRefSeq,\n\t\t);\n\t\tthis.mergeTree = (this as Record<\"_mergeTree\", MergeTree>)._mergeTree;\n\t\tthis.textHelper = new MergeTreeTextHelper(this.mergeTree);\n\n\t\t// Validate by default\n\t\tthis.on(\"delta\", (o, d) => {\n\t\t\t// assert.notEqual(d.deltaSegments.length, 0);\n\t\t\tfor (const s of d.deltaSegments) {\n\t\t\t\tif (d.operation === MergeTreeDeltaType.INSERT) {\n\t\t\t\t\tassertMergeNode(s.segment);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic getText(start?: number, end?: number): string {\n\t\treturn this.textHelper.getText(this.getCurrentSeq(), this.getClientId(), \"\", start, end);\n\t}\n\n\tpublic enqueueTestString(): void {\n\t\tthis.checkQ.push(this.getText());\n\t}\n\tpublic getMessageCount(): number {\n\t\treturn this.q.length;\n\t}\n\tpublic enqueueMsg(msg: ISequencedDocumentMessage): void {\n\t\tthis.q.push(msg);\n\t}\n\tpublic dequeueMsg(): ISequencedDocumentMessage | undefined {\n\t\treturn this.q.shift()?.data;\n\t}\n\tpublic applyMessages(msgCount: number): boolean {\n\t\tlet currMsgCount = msgCount;\n\t\twhile (currMsgCount > 0) {\n\t\t\tconst msg = this.dequeueMsg();\n\t\t\tif (msg) {\n\t\t\t\tthis.applyMsg(msg);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcurrMsgCount--;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic insertTextLocal(\n\t\tpos: number,\n\t\ttext: string,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = TextSegment.make(text, props);\n\t\treturn this.insertSegmentLocal(pos, segment);\n\t}\n\n\tpublic insertTextRemote(\n\t\tpos: number,\n\t\ttext: string,\n\t\tprops: PropertySet | undefined,\n\t\tseq: number,\n\t\trefSeq: number,\n\t\tlongClientId: string,\n\t): void {\n\t\tconst segment = TextSegment.make(text, props);\n\t\tthis.applyMsg(\n\t\t\tthis.makeOpMessage(createInsertSegmentOp(pos, segment), seq, refSeq, longClientId),\n\t\t);\n\t}\n\n\tpublic removeRangeRemote(\n\t\tstart: number,\n\t\tend: number,\n\t\tseq: number,\n\t\trefSeq: number,\n\t\tlongClientId: string,\n\t): void {\n\t\tthis.applyMsg(\n\t\t\tthis.makeOpMessage(createRemoveRangeOp(start, end), seq, refSeq, longClientId),\n\t\t);\n\t}\n\n\tpublic annotateRangeRemote(\n\t\tstart: number,\n\t\tend: number,\n\t\tprops: PropertySet,\n\t\tseq: number,\n\t\trefSeq: number,\n\t\tlongClientId: string,\n\t): void {\n\t\tthis.applyMsg(\n\t\t\tthis.makeOpMessage(createAnnotateRangeOp(start, end, props), seq, refSeq, longClientId),\n\t\t);\n\t}\n\n\tpublic insertMarkerLocal(\n\t\tpos: number,\n\t\tbehaviors: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = Marker.make(behaviors, props);\n\n\t\treturn this.insertSegmentLocal(pos, segment);\n\t}\n\n\tpublic insertMarkerRemote(\n\t\tpos: number,\n\t\tmarkerDef: IMarkerDef,\n\t\tprops: PropertySet,\n\t\tseq: number,\n\t\trefSeq: number,\n\t\tlongClientId: string,\n\t): void {\n\t\tconst segment = Marker.make(markerDef.refType ?? ReferenceType.Tile, props);\n\n\t\tthis.applyMsg(\n\t\t\tthis.makeOpMessage(createInsertSegmentOp(pos, segment), seq, refSeq, longClientId),\n\t\t);\n\t}\n\n\tpublic relText(clientId: number, refSeq: number): string {\n\t\treturn `cli: ${this.getLongClientId(\n\t\t\tclientId,\n\t\t)} refSeq: ${refSeq}: ${this.textHelper.getText(refSeq, clientId)}`;\n\t}\n\n\tpublic makeOpMessage(\n\t\top: IMergeTreeOp | undefined,\n\t\tseq: number = UnassignedSequenceNumber,\n\t\trefSeq: number = this.getCurrentSeq(),\n\t\tlongClientId?: string,\n\t\tminSeqNumber = 0,\n\t): ISequencedDocumentMessage {\n\t\tif (op === undefined) {\n\t\t\tthrow new Error(\"op cannot be undefined\");\n\t\t}\n\t\tconst msg: ISequencedDocumentMessage = {\n\t\t\tclientId: longClientId ?? this.longClientId ?? \"\",\n\t\t\tclientSequenceNumber: 1,\n\t\t\tcontents: op,\n\t\t\tmetadata: undefined,\n\t\t\tminimumSequenceNumber: minSeqNumber,\n\t\t\treferenceSequenceNumber: refSeq,\n\t\t\tsequenceNumber: seq,\n\t\t\ttimestamp: Date.now(),\n\t\t\ttraces: [],\n\t\t\ttype: MessageType.Operation,\n\t\t};\n\t\treturn msg;\n\t}\n\n\tpublic validate(): void {\n\t\tassert(nodeOrdinalsHaveIntegrity(this.mergeTree.root));\n\t}\n\n\tpublic searchFromPos(\n\t\tpos: number,\n\t\ttarget: RegExp,\n\t): { text: string; pos: number } | undefined {\n\t\tlet start = pos;\n\t\tlet chunk = \"\";\n\t\twhile (start < this.getLength()) {\n\t\t\tchunk = this.getText(start, start + TestClient.searchChunkSize);\n\n\t\t\tconst result = chunk.match(target);\n\t\t\tif (result?.index) {\n\t\t\t\treturn { text: result[0], pos: result.index + start };\n\t\t\t}\n\t\t\tstart += TestClient.searchChunkSize;\n\t\t}\n\t}\n\n\tpublic findRandomWord(): { text: string; pos: number } | undefined {\n\t\tconst len = this.getLength();\n\t\tconst pos = random.integer(0, len);\n\t\tconst nextWord = this.searchFromPos(pos, /\\s\\w+\\b/);\n\t\treturn nextWord;\n\t}\n\n\tpublic debugDumpTree(tree: MergeTree): void {\n\t\t// want the segment's content and the state of insert/remove\n\t\tconst test: string[] = [];\n\t\twalkAllChildSegments(tree.root, (segment: ISegmentPrivate) => {\n\t\t\tconst prefixes: (string | undefined | number)[] = [];\n\t\t\tassertInserted(segment);\n\t\t\tprefixes.push(\n\t\t\t\tsegment.seq === UnassignedSequenceNumber ? `L${segment.localSeq}` : segment.seq,\n\t\t\t);\n\t\t\tif (isRemoved(segment)) {\n\t\t\t\tprefixes.push(\n\t\t\t\t\tsegment.removedSeq === UnassignedSequenceNumber\n\t\t\t\t\t\t? `L${segment.localRemovedSeq}`\n\t\t\t\t\t\t: segment.removedSeq,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\ttest.push(`${prefixes.join(\",\")}:${(segment as any).text}`);\n\t\t});\n\t}\n\n\t/**\n\t * Rebases a (local) position from the perspective `{ seq: seqNumberFrom, localSeq }` to the perspective\n\t * of the current sequence number. This is desirable when rebasing operations for reconnection. Perform\n\t * slow-path computations in this function without leveraging the merge-tree's structure\n\t */\n\tpublic rebasePosition(pos: number, seqNumberFrom: number, localSeq: number): number {\n\t\tlet segment: ISegmentPrivate | undefined;\n\t\tlet posAccumulated = 0;\n\t\tlet offset = pos;\n\t\tconst isInsertedInView = (seg: ISegmentPrivate): boolean =>\n\t\t\tisInserted(seg) &&\n\t\t\t((seg.seq !== UnassignedSequenceNumber && seg.seq <= seqNumberFrom) ||\n\t\t\t\t(seg.localSeq !== undefined && seg.localSeq <= localSeq));\n\n\t\tconst isRemovedFromView = (s: ISegmentPrivate): boolean =>\n\t\t\tisRemoved(s) &&\n\t\t\t((s.removedSeq !== UnassignedSequenceNumber && s.removedSeq <= seqNumberFrom) ||\n\t\t\t\t(s.localRemovedSeq !== undefined && s.localRemovedSeq <= localSeq));\n\n\t\twalkAllChildSegments(this.mergeTree.root, (seg) => {\n\t\t\tassertInserted(seg);\n\t\t\tsegment = seg;\n\n\t\t\tif (isInsertedInView(seg) && !isRemovedFromView(seg)) {\n\t\t\t\tposAccumulated += seg.cachedLength;\n\t\t\t\tif (offset >= seg.cachedLength) {\n\t\t\t\t\toffset -= seg.cachedLength;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Keep going while we've yet to reach the segment at the desired position\n\t\t\treturn posAccumulated <= pos;\n\t\t});\n\n\t\tassert(segment !== undefined, \"No segment found\");\n\t\tconst segoff = getSlideToSegoff({ segment, offset }) ?? segment;\n\t\tif (segoff.segment === undefined || segoff.offset === undefined) {\n\t\t\treturn DetachedReferencePosition;\n\t\t}\n\n\t\treturn this.findReconnectionPosition(segoff.segment, localSeq) + segoff.offset;\n\t}\n\n\tpublic findReconnectionPosition(segment: ISegmentPrivate, localSeq: number): number {\n\t\tconst fasterComputedPosition = super.findReconnectionPosition(segment, localSeq);\n\n\t\tlet segmentPosition = 0;\n\t\tconst isInsertedInView = (seg: ISegmentPrivate): boolean =>\n\t\t\tisInserted(seg) && (seg.localSeq === undefined || seg.localSeq <= localSeq);\n\t\tconst isRemovedFromView = (s: ISegmentPrivate): boolean =>\n\t\t\tisRemoved(s) &&\n\t\t\t(s.removedSeq !== UnassignedSequenceNumber ||\n\t\t\t\t(s.localRemovedSeq !== undefined && s.localRemovedSeq <= localSeq));\n\t\tconst isMovedFromView = (s: ISegmentPrivate): boolean =>\n\t\t\tisMoved(s) &&\n\t\t\t(s.movedSeq !== UnassignedSequenceNumber ||\n\t\t\t\t(s.localMovedSeq !== undefined && s.localMovedSeq <= localSeq));\n\t\t/*\n Walk the segments up to the current segment, and calculate its\n position taking into account local segments that were modified,\n after the current segment.\n */\n\t\twalkAllChildSegments(this.mergeTree.root, (seg) => {\n\t\t\t// If we've found the desired segment, terminate the walk and return 'segmentPosition'.\n\t\t\tif (seg === segment) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Otherwise, advance segmentPosition if the segment has been inserted and not removed\n\t\t\t// with respect to the given 'localSeq'.\n\t\t\t//\n\t\t\t// Note that all ACKed / remote ops are applied and we only need concern ourself with\n\t\t\t// determining if locally pending ops fall before/after the given 'localSeq'.\n\t\t\tif (isInsertedInView(seg) && !isRemovedFromView(seg) && !isMovedFromView(seg)) {\n\t\t\t\tsegmentPosition += seg.cachedLength;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\n\t\tassert.equal(\n\t\t\tfasterComputedPosition,\n\t\t\tsegmentPosition,\n\t\t\t\"Expected fast-path computation to match result from walk all segments\",\n\t\t);\n\t\treturn segmentPosition;\n\t}\n\n\t/**\n\t * Validates segments either all have attribution information or none of them.\n\t * If no segment has attribution information, returns undefined.\n\t *\n\t * @param channel - Attribution channel name to request information from.\n\t * @returns an array of all attribution seq#s from the current perspective.\n\t * The `i`th entry of the array is the attribution key for the character at position `i`.\n\t */\n\tpublic getAllAttributionSeqs(channel?: string): (number | AttributionKey | undefined)[] {\n\t\tconst seqs: (number | AttributionKey | undefined)[] = [];\n\t\tthis.walkAllSegments((segment) => {\n\t\t\tfor (let i = 0; i < segment.cachedLength; i++) {\n\t\t\t\tconst key = segment.attribution?.getAtOffset(i, channel);\n\t\t\t\tseqs.push(key?.type === \"op\" ? key.seq : key);\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\n\t\treturn seqs;\n\t}\n\n\tpublic peekPendingSegmentGroups(): SegmentGroup | undefined;\n\tpublic peekPendingSegmentGroups(count: number): SegmentGroup | SegmentGroup[] | undefined;\n\tpublic peekPendingSegmentGroups(\n\t\tcount: number = 1,\n\t): SegmentGroup | SegmentGroup[] | undefined {\n\t\treturn super.peekPendingSegmentGroups(count) as SegmentGroup | SegmentGroup[] | undefined;\n\t}\n\n\t/**\n\t * Override and add some test only metrics\n\t */\n\tpublic applyMsg(msg: ISequencedDocumentMessage, local: boolean = false): void {\n\t\tlet traceStart: Trace | undefined;\n\t\tif (this.measureOps) {\n\t\t\ttraceStart = Trace.start();\n\t\t}\n\n\t\tsuper.applyMsg(msg, local);\n\n\t\tif (traceStart) {\n\t\t\tthis.accumTime += elapsedMicroseconds(traceStart);\n\t\t\tthis.accumOps++;\n\t\t\tthis.accumWindow += this.getCurrentSeq() - this.getCollabWindow().minSeq;\n\t\t}\n\t}\n\n\t/**\n\t * Override and add some test only metrics\n\t */\n\tupdateMinSeq(minSeq: number): void {\n\t\tlet trace: Trace | undefined;\n\t\tif (this.measureOps) {\n\t\t\ttrace = Trace.start();\n\t\t}\n\n\t\tsuper.updateMinSeq(minSeq);\n\t\tif (trace) {\n\t\t\tconst elapsed = elapsedMicroseconds(trace);\n\t\t\tthis.accumWindowTime += elapsed;\n\t\t\tif (elapsed > this.maxWindowTime) {\n\t\t\t\tthis.maxWindowTime = elapsed;\n\t\t\t}\n\t\t}\n\t}\n\n\tslowSearchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards = true,\n\t): ReferencePosition | undefined {\n\t\tlet foundMarker: Marker | undefined;\n\n\t\tconst { segment } = this.getContainingSegment<ISegmentPrivate>(startPos);\n\t\tassertSegmentLeaf(segment);\n\t\tif (Marker.is(segment)) {\n\t\t\tif (refHasTileLabel(segment, markerLabel)) {\n\t\t\t\tfoundMarker = segment;\n\t\t\t}\n\t\t} else {\n\t\t\tif (forwards) {\n\t\t\t\tforwardExcursion(segment, (seg) => {\n\t\t\t\t\tif (Marker.is(seg) && refHasTileLabel(seg, markerLabel)) {\n\t\t\t\t\t\tfoundMarker = seg;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tbackwardExcursion(segment, (seg) => {\n\t\t\t\t\tif (Marker.is(seg) && refHasTileLabel(seg, markerLabel)) {\n\t\t\t\t\t\tfoundMarker = seg;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn foundMarker;\n\t}\n}\n\nfunction elapsedMicroseconds(trace: Trace): number {\n\treturn trace.trace().duration * 1000;\n}\n\n// the client doesn't submit ops, so this adds a callback to capture them\nexport type TestClientRevertibleDriver = MergeTreeRevertibleDriver &\n\tPartial<{ submitOpCallback?: (op: IMergeTreeOp | undefined) => void }>;\n\nexport const createRevertDriver = (client: TestClient): TestClientRevertibleDriver => {\n\treturn {\n\t\tremoveRange(start: number, end: number): void {\n\t\t\tconst op = client.removeRangeLocal(start, end);\n\t\t\tthis.submitOpCallback?.(op);\n\t\t},\n\t\tannotateRange(start: number, end: number, props: PropertySet): void {\n\t\t\tconst op = client.annotateRangeLocal(start, end, props);\n\t\t\tthis.submitOpCallback?.(op);\n\t\t},\n\t\tinsertFromSpec(pos: number, spec: IJSONSegment): void {\n\t\t\tconst op = client.insertSegmentLocal(pos, client.specToSegment(spec));\n\t\t\tthis.submitOpCallback?.(op);\n\t\t},\n\t};\n};\n\nexport interface MergeTreeStats {\n\tmaxHeight: number;\n\tnodeCount: number;\n\tleafCount: number;\n\tremovedLeafCount: number;\n\tliveCount: number;\n\thisto: number[];\n\twindowTime?: number;\n\tpackTime?: number;\n\tordTime?: number;\n\tmaxOrdTime?: number;\n}\n\nexport function getStats(tree: MergeTree): MergeTreeStats {\n\tconst nodeGetStats = (block: MergeBlock): MergeTreeStats => {\n\t\tconst stats: MergeTreeStats = {\n\t\t\tmaxHeight: 0,\n\t\t\tnodeCount: 0,\n\t\t\tleafCount: 0,\n\t\t\tremovedLeafCount: 0,\n\t\t\tliveCount: 0,\n\t\t\thisto: [],\n\t\t};\n\t\tfor (let k = 0; k < MaxNodesInBlock; k++) {\n\t\t\tstats.histo[k] = 0;\n\t\t}\n\t\tfor (let i = 0; i < block.childCount; i++) {\n\t\t\tconst child = block.children[i];\n\t\t\tlet height = 1;\n\t\t\tif (child.isLeaf()) {\n\t\t\t\tstats.leafCount++;\n\t\t\t\tconst segment = child;\n\t\t\t\tif (isRemoved(segment)) {\n\t\t\t\t\tstats.removedLeafCount++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst childStats = nodeGetStats(child);\n\t\t\t\theight = 1 + childStats.maxHeight;\n\t\t\t\tstats.nodeCount += childStats.nodeCount;\n\t\t\t\tstats.leafCount += childStats.leafCount;\n\t\t\t\tstats.removedLeafCount += childStats.removedLeafCount;\n\t\t\t\tstats.liveCount += childStats.liveCount;\n\t\t\t\tfor (let j = 0; j < MaxNodesInBlock; j++) {\n\t\t\t\t\tstats.histo[j] += childStats.histo[j];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (height > stats.maxHeight) {\n\t\t\t\tstats.maxHeight = height;\n\t\t\t}\n\t\t}\n\t\tstats.histo[block.childCount]++;\n\t\tstats.nodeCount++;\n\t\tstats.liveCount += block.childCount;\n\t\treturn stats;\n\t};\n\tconst rootStats = nodeGetStats(tree.root);\n\treturn rootStats;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testClient.js","sourceRoot":"","sources":["../../src/test/testClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,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S,EAAE,CAAC;QAClB,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC;QACpC,OAAO,KAAK,CAAC;IACd,CAAC,CAAC;IACF,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport { Trace } from \"@fluid-internal/client-utils\";\nimport { makeRandom } from \"@fluid-private/stochastic-test-utils\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tITree,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport { MockStorage } from \"@fluidframework/test-runtime-utils/internal\";\n\nimport { MergeTreeTextHelper } from \"../MergeTreeTextHelper.js\";\nimport { Client } from \"../client.js\";\nimport { DoublyLinkedList } from \"../collections/index.js\";\nimport { UnassignedSequenceNumber } from \"../constants.js\";\nimport { IMergeTreeOptions, ReferencePosition } from \"../index.js\";\nimport { MergeTree, getSlideToSegoff } from \"../mergeTree.js\";\nimport {\n\tbackwardExcursion,\n\tforwardExcursion,\n\twalkAllChildSegments,\n} from \"../mergeTreeNodeWalk.js\";\nimport {\n\tMergeBlock,\n\tISegmentPrivate,\n\tMarker,\n\tMaxNodesInBlock,\n\ttype SegmentGroup,\n\tassertSegmentLeaf,\n} from \"../mergeTreeNodes.js\";\nimport {\n\tcreateAnnotateRangeOp,\n\tcreateInsertSegmentOp,\n\tcreateRemoveRangeOp,\n} from \"../opBuilder.js\";\nimport {\n\tIJSONSegment,\n\tIMarkerDef,\n\tIMergeTreeOp,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\ttype IMergeTreeInsertMsg,\n} from \"../ops.js\";\nimport { PropertySet } from \"../properties.js\";\nimport { DetachedReferencePosition, refHasTileLabel } from \"../referencePositions.js\";\nimport { MergeTreeRevertibleDriver } from \"../revertibles.js\";\nimport {\n\tassertInserted,\n\tassertMergeNode,\n\tisInserted,\n\tisMoved,\n\tisRemoved,\n} from \"../segmentInfos.js\";\nimport { SnapshotLegacy } from \"../snapshotlegacy.js\";\nimport { TextSegment } from \"../textSegment.js\";\n\nimport { TestSerializer } from \"./testSerializer.js\";\nimport { nodeOrdinalsHaveIntegrity } from \"./testUtils.js\";\n\nexport function specToSegment(spec: IJSONSegment): ISegmentPrivate {\n\tconst maybeText = TextSegment.fromJSONObject(spec);\n\tif (maybeText) {\n\t\treturn maybeText;\n\t}\n\n\tconst maybeMarker = Marker.fromJSONObject(spec);\n\tif (maybeMarker) {\n\t\treturn maybeMarker;\n\t}\n\n\tthrow new Error(`Unrecognized IJSONSegment type: '${JSON.stringify(spec)}'`);\n}\n\nconst random = makeRandom(0xdeadbeef, 0xfeedbed);\n\nexport class TestClient extends Client {\n\tpublic static searchChunkSize = 256;\n\tpublic static readonly serializer = new TestSerializer();\n\tpublic measureOps = false;\n\tpublic accumTime = 0;\n\tpublic accumWindowTime = 0;\n\tpublic accumWindow = 0;\n\tpublic accumOps = 0;\n\tpublic maxWindowTime = 0;\n\n\t/**\n\t * Used for in-memory testing. This will queue a reference string for each client message.\n\t */\n\tpublic static useCheckQ = false;\n\n\tpublic static async createFromClientSnapshot(\n\t\tclient1: TestClient,\n\t\tnewLongClientId: string,\n\t): Promise<TestClient> {\n\t\tconst snapshot = new SnapshotLegacy(\n\t\t\tclient1.mergeTree,\n\t\t\tcreateChildLogger({ namespace: \"fluid:snapshot\" }),\n\t\t);\n\t\tsnapshot.extractSync();\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst summaryTree = snapshot.emit([], TestClient.serializer, undefined!).summary;\n\t\treturn TestClient.createFromSummary(\n\t\t\tsummaryTree,\n\t\t\tnewLongClientId,\n\t\t\tclient1.specToSegment,\n\t\t\tclient1.mergeTree.options,\n\t\t);\n\t}\n\n\tpublic static async createFromSnapshot(\n\t\tsnapshotTree: ITree,\n\t\tnewLongClientId: string,\n\t\tspecToSeg: (spec: IJSONSegment) => ISegmentPrivate,\n\t\toptions?: PropertySet,\n\t): Promise<TestClient> {\n\t\treturn TestClient.createFromStorage(\n\t\t\tnew MockStorage(snapshotTree),\n\t\t\tnewLongClientId,\n\t\t\tspecToSeg,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tpublic static async createFromSummary(\n\t\tsummaryTree: ISummaryTree,\n\t\tnewLongClientId: string,\n\t\tspecToSeg: (spec: IJSONSegment) => ISegmentPrivate,\n\t\toptions?: PropertySet,\n\t): Promise<TestClient> {\n\t\treturn TestClient.createFromStorage(\n\t\t\tMockStorage.createFromSummary(summaryTree),\n\t\t\tnewLongClientId,\n\t\t\tspecToSeg,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tpublic static async createFromStorage(\n\t\tstorage: MockStorage,\n\t\tnewLongClientId: string,\n\t\tspecToSeg: (spec: IJSONSegment) => ISegmentPrivate,\n\t\toptions?: PropertySet,\n\t): Promise<TestClient> {\n\t\tconst client2 = new TestClient(options, specToSeg);\n\t\tconst { catchupOpsP } = await client2.load(\n\t\t\t{\n\t\t\t\tlogger: client2.logger,\n\t\t\t\tclientId: newLongClientId,\n\t\t\t} as unknown as IFluidDataStoreRuntime,\n\t\t\tstorage,\n\t\t\tTestClient.serializer,\n\t\t);\n\t\tawait catchupOpsP;\n\t\treturn client2;\n\t}\n\n\tpublic readonly mergeTree: MergeTree;\n\n\tpublic readonly checkQ: DoublyLinkedList<string> = new DoublyLinkedList<string>();\n\tprotected readonly q: DoublyLinkedList<ISequencedDocumentMessage> =\n\t\tnew DoublyLinkedList<ISequencedDocumentMessage>();\n\n\tprivate readonly textHelper: MergeTreeTextHelper;\n\tconstructor(\n\t\toptions?: IMergeTreeOptions & PropertySet,\n\t\tspecToSeg = specToSegment,\n\t\tgetMinInFlightRefSeq: () => number | undefined = (): undefined => undefined,\n\t) {\n\t\tsuper(\n\t\t\tspecToSeg,\n\t\t\tcreateChildLogger({ namespace: \"fluid:testClient\" }),\n\t\t\toptions,\n\t\t\tgetMinInFlightRefSeq,\n\t\t);\n\t\tthis.mergeTree = (this as Record<\"_mergeTree\", MergeTree>)._mergeTree;\n\t\tthis.textHelper = new MergeTreeTextHelper(this.mergeTree);\n\n\t\t// Validate by default\n\t\tthis.on(\"delta\", (o, d) => {\n\t\t\t// assert.notEqual(d.deltaSegments.length, 0);\n\t\t\tfor (const s of d.deltaSegments) {\n\t\t\t\tif (d.operation === MergeTreeDeltaType.INSERT) {\n\t\t\t\t\tassertMergeNode(s.segment);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic getText(start?: number, end?: number): string {\n\t\treturn this.textHelper.getText(this.getCurrentSeq(), this.getClientId(), \"\", start, end);\n\t}\n\n\tpublic enqueueTestString(): void {\n\t\tthis.checkQ.push(this.getText());\n\t}\n\tpublic getMessageCount(): number {\n\t\treturn this.q.length;\n\t}\n\tpublic enqueueMsg(msg: ISequencedDocumentMessage): void {\n\t\tthis.q.push(msg);\n\t}\n\tpublic dequeueMsg(): ISequencedDocumentMessage | undefined {\n\t\treturn this.q.shift()?.data;\n\t}\n\tpublic applyMessages(msgCount: number): boolean {\n\t\tlet currMsgCount = msgCount;\n\t\twhile (currMsgCount > 0) {\n\t\t\tconst msg = this.dequeueMsg();\n\t\t\tif (msg) {\n\t\t\t\tthis.applyMsg(msg);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcurrMsgCount--;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic insertTextLocal(\n\t\tpos: number,\n\t\ttext: string,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = TextSegment.make(text, props);\n\t\treturn this.insertSegmentLocal(pos, segment);\n\t}\n\n\tpublic insertTextRemote(\n\t\tpos: number,\n\t\ttext: string,\n\t\tprops: PropertySet | undefined,\n\t\tseq: number,\n\t\trefSeq: number,\n\t\tlongClientId: string,\n\t): void {\n\t\tconst segment = TextSegment.make(text, props);\n\t\tthis.applyMsg(\n\t\t\tthis.makeOpMessage(createInsertSegmentOp(pos, segment), seq, refSeq, longClientId),\n\t\t);\n\t}\n\n\tpublic removeRangeRemote(\n\t\tstart: number,\n\t\tend: number,\n\t\tseq: number,\n\t\trefSeq: number,\n\t\tlongClientId: string,\n\t): void {\n\t\tthis.applyMsg(\n\t\t\tthis.makeOpMessage(createRemoveRangeOp(start, end), seq, refSeq, longClientId),\n\t\t);\n\t}\n\n\tpublic annotateRangeRemote(\n\t\tstart: number,\n\t\tend: number,\n\t\tprops: PropertySet,\n\t\tseq: number,\n\t\trefSeq: number,\n\t\tlongClientId: string,\n\t): void {\n\t\tthis.applyMsg(\n\t\t\tthis.makeOpMessage(createAnnotateRangeOp(start, end, props), seq, refSeq, longClientId),\n\t\t);\n\t}\n\n\tpublic insertMarkerLocal(\n\t\tpos: number,\n\t\tbehaviors: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = Marker.make(behaviors, props);\n\n\t\treturn this.insertSegmentLocal(pos, segment);\n\t}\n\n\tpublic insertMarkerRemote(\n\t\tpos: number,\n\t\tmarkerDef: IMarkerDef,\n\t\tprops: PropertySet,\n\t\tseq: number,\n\t\trefSeq: number,\n\t\tlongClientId: string,\n\t): void {\n\t\tconst segment = Marker.make(markerDef.refType ?? ReferenceType.Tile, props);\n\n\t\tthis.applyMsg(\n\t\t\tthis.makeOpMessage(createInsertSegmentOp(pos, segment), seq, refSeq, longClientId),\n\t\t);\n\t}\n\n\tpublic relText(clientId: number, refSeq: number): string {\n\t\treturn `cli: ${this.getLongClientId(\n\t\t\tclientId,\n\t\t)} refSeq: ${refSeq}: ${this.textHelper.getText(refSeq, clientId)}`;\n\t}\n\n\tpublic makeOpMessage(\n\t\top: IMergeTreeOp | undefined,\n\t\tseq: number = UnassignedSequenceNumber,\n\t\trefSeq: number = this.getCurrentSeq(),\n\t\tlongClientId?: string,\n\t\tminSeqNumber = 0,\n\t): ISequencedDocumentMessage {\n\t\tif (op === undefined) {\n\t\t\tthrow new Error(\"op cannot be undefined\");\n\t\t}\n\t\tconst msg: ISequencedDocumentMessage = {\n\t\t\tclientId: longClientId ?? this.longClientId ?? \"\",\n\t\t\tclientSequenceNumber: 1,\n\t\t\tcontents: op,\n\t\t\tmetadata: undefined,\n\t\t\tminimumSequenceNumber: minSeqNumber,\n\t\t\treferenceSequenceNumber: refSeq,\n\t\t\tsequenceNumber: seq,\n\t\t\ttimestamp: Date.now(),\n\t\t\ttraces: [],\n\t\t\ttype: MessageType.Operation,\n\t\t};\n\t\treturn msg;\n\t}\n\n\tpublic validate(): void {\n\t\tassert(nodeOrdinalsHaveIntegrity(this.mergeTree.root));\n\t}\n\n\tpublic searchFromPos(\n\t\tpos: number,\n\t\ttarget: RegExp,\n\t): { text: string; pos: number } | undefined {\n\t\tlet start = pos;\n\t\tlet chunk = \"\";\n\t\twhile (start < this.getLength()) {\n\t\t\tchunk = this.getText(start, start + TestClient.searchChunkSize);\n\n\t\t\tconst result = chunk.match(target);\n\t\t\tif (result?.index) {\n\t\t\t\treturn { text: result[0], pos: result.index + start };\n\t\t\t}\n\t\t\tstart += TestClient.searchChunkSize;\n\t\t}\n\t}\n\n\tpublic findRandomWord(): { text: string; pos: number } | undefined {\n\t\tconst len = this.getLength();\n\t\tconst pos = random.integer(0, len);\n\t\tconst nextWord = this.searchFromPos(pos, /\\s\\w+\\b/);\n\t\treturn nextWord;\n\t}\n\n\tpublic debugDumpTree(tree: MergeTree): string[] {\n\t\t// want the segment's content and the state of insert/remove\n\t\tconst test: string[] = [];\n\t\twalkAllChildSegments(tree.root, (segment: ISegmentPrivate) => {\n\t\t\tconst prefixes: (string | undefined | number)[] = [];\n\t\t\tassertInserted(segment);\n\t\t\tprefixes.push(\n\t\t\t\tsegment.seq === UnassignedSequenceNumber ? `L${segment.localSeq}` : segment.seq,\n\t\t\t);\n\t\t\tif (isRemoved(segment)) {\n\t\t\t\tprefixes.push(\n\t\t\t\t\tsegment.removedSeq === UnassignedSequenceNumber\n\t\t\t\t\t\t? `L${segment.localRemovedSeq}`\n\t\t\t\t\t\t: segment.removedSeq,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\ttest.push(`${prefixes.join(\",\")}:${(segment as any).text}`);\n\t\t});\n\t\treturn test;\n\t}\n\n\t/**\n\t * Rebases a (local) position from the perspective `{ seq: seqNumberFrom, localSeq }` to the perspective\n\t * of the current sequence number. This is desirable when rebasing operations for reconnection. Perform\n\t * slow-path computations in this function without leveraging the merge-tree's structure\n\t */\n\tpublic rebasePosition(pos: number, seqNumberFrom: number, localSeq: number): number {\n\t\tlet segment: ISegmentPrivate | undefined;\n\t\tlet posAccumulated = 0;\n\t\tlet offset = pos;\n\t\tconst isInsertedInView = (seg: ISegmentPrivate): boolean =>\n\t\t\tisInserted(seg) &&\n\t\t\t((seg.seq !== UnassignedSequenceNumber && seg.seq <= seqNumberFrom) ||\n\t\t\t\t(seg.localSeq !== undefined && seg.localSeq <= localSeq));\n\n\t\tconst isRemovedFromView = (s: ISegmentPrivate): boolean =>\n\t\t\tisRemoved(s) &&\n\t\t\t((s.removedSeq !== UnassignedSequenceNumber && s.removedSeq <= seqNumberFrom) ||\n\t\t\t\t(s.localRemovedSeq !== undefined && s.localRemovedSeq <= localSeq));\n\n\t\twalkAllChildSegments(this.mergeTree.root, (seg) => {\n\t\t\tassertInserted(seg);\n\t\t\tsegment = seg;\n\n\t\t\tif (isInsertedInView(seg) && !isRemovedFromView(seg)) {\n\t\t\t\tposAccumulated += seg.cachedLength;\n\t\t\t\tif (offset >= seg.cachedLength) {\n\t\t\t\t\toffset -= seg.cachedLength;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Keep going while we've yet to reach the segment at the desired position\n\t\t\treturn posAccumulated <= pos;\n\t\t});\n\n\t\tassert(segment !== undefined, \"No segment found\");\n\t\tconst segoff = getSlideToSegoff({ segment, offset }) ?? segment;\n\t\tif (segoff.segment === undefined || segoff.offset === undefined) {\n\t\t\treturn DetachedReferencePosition;\n\t\t}\n\n\t\treturn this.findReconnectionPosition(segoff.segment, localSeq) + segoff.offset;\n\t}\n\n\tpublic findReconnectionPosition(segment: ISegmentPrivate, localSeq: number): number {\n\t\tconst fasterComputedPosition = super.findReconnectionPosition(segment, localSeq);\n\n\t\tlet segmentPosition = 0;\n\t\tconst isInsertedInView = (seg: ISegmentPrivate): boolean =>\n\t\t\tisInserted(seg) && (seg.localSeq === undefined || seg.localSeq <= localSeq);\n\t\tconst isRemovedFromView = (s: ISegmentPrivate): boolean =>\n\t\t\tisRemoved(s) &&\n\t\t\t(s.removedSeq !== UnassignedSequenceNumber ||\n\t\t\t\t(s.localRemovedSeq !== undefined && s.localRemovedSeq <= localSeq));\n\t\tconst isMovedFromView = (s: ISegmentPrivate): boolean =>\n\t\t\tisMoved(s) &&\n\t\t\t(s.movedSeq !== UnassignedSequenceNumber ||\n\t\t\t\t(s.localMovedSeq !== undefined && s.localMovedSeq <= localSeq));\n\t\t/*\n Walk the segments up to the current segment, and calculate its\n position taking into account local segments that were modified,\n after the current segment.\n */\n\t\twalkAllChildSegments(this.mergeTree.root, (seg) => {\n\t\t\t// If we've found the desired segment, terminate the walk and return 'segmentPosition'.\n\t\t\tif (seg === segment) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Otherwise, advance segmentPosition if the segment has been inserted and not removed\n\t\t\t// with respect to the given 'localSeq'.\n\t\t\t//\n\t\t\t// Note that all ACKed / remote ops are applied and we only need concern ourself with\n\t\t\t// determining if locally pending ops fall before/after the given 'localSeq'.\n\t\t\tif (isInsertedInView(seg) && !isRemovedFromView(seg) && !isMovedFromView(seg)) {\n\t\t\t\tsegmentPosition += seg.cachedLength;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\n\t\tassert.equal(\n\t\t\tfasterComputedPosition,\n\t\t\tsegmentPosition,\n\t\t\t\"Expected fast-path computation to match result from walk all segments\",\n\t\t);\n\t\treturn segmentPosition;\n\t}\n\n\t/**\n\t * Validates segments either all have attribution information or none of them.\n\t * If no segment has attribution information, returns undefined.\n\t *\n\t * @param channel - Attribution channel name to request information from.\n\t * @returns an array of all attribution seq#s from the current perspective.\n\t * The `i`th entry of the array is the attribution key for the character at position `i`.\n\t */\n\tpublic getAllAttributionSeqs(channel?: string): (number | AttributionKey | undefined)[] {\n\t\tconst seqs: (number | AttributionKey | undefined)[] = [];\n\t\tthis.walkAllSegments((segment) => {\n\t\t\tfor (let i = 0; i < segment.cachedLength; i++) {\n\t\t\t\tconst key = segment.attribution?.getAtOffset(i, channel);\n\t\t\t\tseqs.push(key?.type === \"op\" ? key.seq : key);\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\n\t\treturn seqs;\n\t}\n\n\tpublic peekPendingSegmentGroups(): SegmentGroup | undefined;\n\tpublic peekPendingSegmentGroups(count: number): SegmentGroup | SegmentGroup[] | undefined;\n\tpublic peekPendingSegmentGroups(\n\t\tcount: number = 1,\n\t): SegmentGroup | SegmentGroup[] | undefined {\n\t\treturn super.peekPendingSegmentGroups(count) as SegmentGroup | SegmentGroup[] | undefined;\n\t}\n\n\t/**\n\t * Override and add some test only metrics\n\t */\n\tpublic applyMsg(msg: ISequencedDocumentMessage, local: boolean = false): void {\n\t\tlet traceStart: Trace | undefined;\n\t\tif (this.measureOps) {\n\t\t\ttraceStart = Trace.start();\n\t\t}\n\n\t\tsuper.applyMsg(msg, local);\n\n\t\tif (traceStart) {\n\t\t\tthis.accumTime += elapsedMicroseconds(traceStart);\n\t\t\tthis.accumOps++;\n\t\t\tthis.accumWindow += this.getCurrentSeq() - this.getCollabWindow().minSeq;\n\t\t}\n\t}\n\n\t/**\n\t * Override and add some test only metrics\n\t */\n\tupdateMinSeq(minSeq: number): void {\n\t\tlet trace: Trace | undefined;\n\t\tif (this.measureOps) {\n\t\t\ttrace = Trace.start();\n\t\t}\n\n\t\tsuper.updateMinSeq(minSeq);\n\t\tif (trace) {\n\t\t\tconst elapsed = elapsedMicroseconds(trace);\n\t\t\tthis.accumWindowTime += elapsed;\n\t\t\tif (elapsed > this.maxWindowTime) {\n\t\t\t\tthis.maxWindowTime = elapsed;\n\t\t\t}\n\t\t}\n\t}\n\n\tslowSearchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards = true,\n\t): ReferencePosition | undefined {\n\t\tlet foundMarker: Marker | undefined;\n\n\t\tconst { segment } = this.getContainingSegment<ISegmentPrivate>(startPos);\n\t\tassertSegmentLeaf(segment);\n\t\tif (Marker.is(segment)) {\n\t\t\tif (refHasTileLabel(segment, markerLabel)) {\n\t\t\t\tfoundMarker = segment;\n\t\t\t}\n\t\t} else {\n\t\t\tif (forwards) {\n\t\t\t\tforwardExcursion(segment, (seg) => {\n\t\t\t\t\tif (Marker.is(seg) && refHasTileLabel(seg, markerLabel)) {\n\t\t\t\t\t\tfoundMarker = seg;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tbackwardExcursion(segment, (seg) => {\n\t\t\t\t\tif (Marker.is(seg) && refHasTileLabel(seg, markerLabel)) {\n\t\t\t\t\t\tfoundMarker = seg;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn foundMarker;\n\t}\n}\n\nfunction elapsedMicroseconds(trace: Trace): number {\n\treturn trace.trace().duration * 1000;\n}\n\n// the client doesn't submit ops, so this adds a callback to capture them\nexport type TestClientRevertibleDriver = MergeTreeRevertibleDriver &\n\tPartial<{ submitOpCallback?: (op: IMergeTreeOp | undefined) => void }>;\n\nexport const createRevertDriver = (client: TestClient): TestClientRevertibleDriver => {\n\treturn {\n\t\tremoveRange(start: number, end: number): void {\n\t\t\tconst op = client.removeRangeLocal(start, end);\n\t\t\tthis.submitOpCallback?.(op);\n\t\t},\n\t\tannotateRange(start: number, end: number, props: PropertySet): void {\n\t\t\tconst op = client.annotateRangeLocal(start, end, props);\n\t\t\tthis.submitOpCallback?.(op);\n\t\t},\n\t\tinsertFromSpec(pos: number, spec: IJSONSegment): void {\n\t\t\tconst op = client.insertSegmentLocal(pos, client.specToSegment(spec));\n\t\t\tthis.submitOpCallback?.(op);\n\t\t},\n\t};\n};\n\nexport interface MergeTreeStats {\n\tmaxHeight: number;\n\tnodeCount: number;\n\tleafCount: number;\n\tremovedLeafCount: number;\n\tliveCount: number;\n\thisto: number[];\n\twindowTime?: number;\n\tpackTime?: number;\n\tordTime?: number;\n\tmaxOrdTime?: number;\n}\n\nexport function getStats(tree: MergeTree): MergeTreeStats {\n\tconst nodeGetStats = (block: MergeBlock): MergeTreeStats => {\n\t\tconst stats: MergeTreeStats = {\n\t\t\tmaxHeight: 0,\n\t\t\tnodeCount: 0,\n\t\t\tleafCount: 0,\n\t\t\tremovedLeafCount: 0,\n\t\t\tliveCount: 0,\n\t\t\thisto: [],\n\t\t};\n\t\tfor (let k = 0; k < MaxNodesInBlock; k++) {\n\t\t\tstats.histo[k] = 0;\n\t\t}\n\t\tfor (let i = 0; i < block.childCount; i++) {\n\t\t\tconst child = block.children[i];\n\t\t\tlet height = 1;\n\t\t\tif (child.isLeaf()) {\n\t\t\t\tstats.leafCount++;\n\t\t\t\tconst segment = child;\n\t\t\t\tif (isRemoved(segment)) {\n\t\t\t\t\tstats.removedLeafCount++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst childStats = nodeGetStats(child);\n\t\t\t\theight = 1 + childStats.maxHeight;\n\t\t\t\tstats.nodeCount += childStats.nodeCount;\n\t\t\t\tstats.leafCount += childStats.leafCount;\n\t\t\t\tstats.removedLeafCount += childStats.removedLeafCount;\n\t\t\t\tstats.liveCount += childStats.liveCount;\n\t\t\t\tfor (let j = 0; j < MaxNodesInBlock; j++) {\n\t\t\t\t\tstats.histo[j] += childStats.histo[j];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (height > stats.maxHeight) {\n\t\t\t\tstats.maxHeight = height;\n\t\t\t}\n\t\t}\n\t\tstats.histo[block.childCount]++;\n\t\tstats.nodeCount++;\n\t\tstats.liveCount += block.childCount;\n\t\treturn stats;\n\t};\n\tconst rootStats = nodeGetStats(tree.root);\n\treturn rootStats;\n}\n"]}
|
package/lib/test/testUtils.js
CHANGED
|
@@ -141,11 +141,11 @@ export function validateRefCount(collection) {
|
|
|
141
141
|
* fuzz tests).
|
|
142
142
|
*/
|
|
143
143
|
export function useStrictPartialLengthChecks() {
|
|
144
|
-
beforeEach(() => {
|
|
144
|
+
beforeEach("Enable strict partial lengths", () => {
|
|
145
145
|
PartialSequenceLengths.options.verifier = verifyPartialLengths;
|
|
146
146
|
PartialSequenceLengths.options.verifyExpected = verifyExpectedPartialLengths;
|
|
147
147
|
});
|
|
148
|
-
afterEach(() => {
|
|
148
|
+
afterEach("Disable strict partial lengths", () => {
|
|
149
149
|
PartialSequenceLengths.options.verifier = undefined;
|
|
150
150
|
PartialSequenceLengths.options.verifyExpected = undefined;
|
|
151
151
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../../src/test/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAQ3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAA+B,MAAM,EAAE,MAAM,sBAAsB,CAAC;AA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AAE,gBAAgB,EAAE,IAAI,cAAc,EAAE,CAAC;QACvE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,iBAAiB,CAClD,QAAQ,EACR,GAAG,EACH,SAAS,EACT,gBAAgB,IAAI,QAAQ,EAC5B,UAAU,CACV,CAAC;QAEF,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC;AACF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,UAAqC;IACrE,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,OAAO;IACR,CAAC;IAED,MAAM,cAAc,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CAAC;IAE9C,2DAA2D;IAC3D,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B;IAC3C,UAAU,CAAC,GAAG,EAAE;QACf,sBAAsB,CAAC,OAAO,CAAC,QAAQ,GAAG,oBAAoB,CAAC;QAC/D,sBAAsB,CAAC,OAAO,CAAC,cAAc,GAAG,4BAA4B,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACd,sBAAsB,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;QACpD,sBAAsB,CAAC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAC3D,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport fs from \"node:fs\";\n\nimport { UnassignedSequenceNumber } from \"../constants.js\";\nimport { LocalReferenceCollection } from \"../localReference.js\";\nimport { MergeTree } from \"../mergeTree.js\";\nimport {\n\tIMergeTreeDeltaOpArgs,\n\ttype IMergeTreeDeltaCallbackArgs,\n\ttype IMergeTreeMaintenanceCallbackArgs,\n} from \"../mergeTreeDeltaCallback.js\";\nimport { walkAllChildSegments } from \"../mergeTreeNodeWalk.js\";\nimport { MergeBlock, ISegmentPrivate, Marker } from \"../mergeTreeNodes.js\";\nimport { ReferenceType } from \"../ops.js\";\nimport {\n\tPartialSequenceLengths,\n\tverifyExpectedPartialLengths,\n\tverifyPartialLengths,\n} from \"../partialLengths.js\";\nimport { PropertySet } from \"../properties.js\";\nimport * as info from \"../segmentInfos.js\";\nimport { TextSegment } from \"../textSegment.js\";\n\nimport { loadText } from \"./text.js\";\n\nexport function loadTextFromFile(\n\tfilename: string,\n\tmergeTree: MergeTree,\n\tsegLimit = 0,\n): MergeTree {\n\tconst content = fs.readFileSync(filename, \"utf8\");\n\treturn loadText(content, mergeTree, segLimit);\n}\n\nexport function loadTextFromFileWithMarkers(\n\tfilename: string,\n\tmergeTree: MergeTree,\n\tsegLimit = 0,\n): MergeTree {\n\tconst content = fs.readFileSync(filename, \"utf8\");\n\treturn loadText(content, mergeTree, segLimit, true);\n}\n\ninterface InsertMarkerArgs {\n\tmergeTree: MergeTree;\n\tpos: number;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\tbehaviors: ReferenceType;\n\tprops: PropertySet | undefined;\n\topArgs: IMergeTreeDeltaOpArgs;\n}\n\nexport function insertMarker({\n\tmergeTree,\n\tpos,\n\trefSeq,\n\tclientId,\n\tseq,\n\tbehaviors,\n\tprops,\n\topArgs,\n}: InsertMarkerArgs): void {\n\tmergeTree.insertSegments(\n\t\tpos,\n\t\t[Marker.make(behaviors, props)],\n\t\trefSeq,\n\t\tclientId,\n\t\tseq,\n\t\topArgs,\n\t);\n}\n\ninterface InsertTextArgs {\n\tmergeTree: MergeTree;\n\tpos: number;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\ttext: string;\n\tprops?: PropertySet;\n\topArgs?: IMergeTreeDeltaOpArgs;\n}\n\nexport function insertText({\n\tmergeTree,\n\tpos,\n\trefSeq,\n\tclientId,\n\tseq,\n\ttext,\n\tprops,\n\topArgs,\n}: InsertTextArgs): void {\n\tmergeTree.insertSegments(\n\t\tpos,\n\t\t[TextSegment.make(text, props)],\n\t\trefSeq,\n\t\tclientId,\n\t\tseq,\n\t\topArgs,\n\t);\n}\n\ninterface InsertSegmentsArgs {\n\tmergeTree: MergeTree;\n\tpos: number;\n\tsegments: ISegmentPrivate[];\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\topArgs: IMergeTreeDeltaOpArgs | undefined;\n}\n\nexport function insertSegments({\n\tmergeTree,\n\tpos,\n\tsegments,\n\trefSeq,\n\tclientId,\n\tseq,\n\topArgs,\n}: InsertSegmentsArgs): void {\n\tmergeTree.insertSegments(pos, segments, refSeq, clientId, seq, opArgs);\n}\n\ninterface MarkRangeRemovedArgs {\n\tmergeTree: MergeTree;\n\tstart: number;\n\tend: number;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\toverwrite: boolean;\n\topArgs: IMergeTreeDeltaOpArgs;\n}\n\nexport function markRangeRemoved({\n\tmergeTree,\n\tstart,\n\tend,\n\trefSeq,\n\tclientId,\n\tseq,\n\topArgs,\n}: MarkRangeRemovedArgs): void {\n\tmergeTree.markRangeRemoved(start, end, refSeq, clientId, seq, opArgs);\n}\n\nexport function obliterateRange({\n\tmergeTree,\n\tstart,\n\tend,\n\trefSeq,\n\tclientId,\n\tseq,\n\topArgs,\n}: {\n\tmergeTree: MergeTree;\n\tstart: number;\n\tend: number;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\topArgs: IMergeTreeDeltaOpArgs;\n}): void {\n\tmergeTree.obliterateRange(start, end, refSeq, clientId, seq, opArgs);\n}\n\nexport function nodeOrdinalsHaveIntegrity(block: MergeBlock): boolean {\n\tconst olen = block.ordinal.length;\n\tfor (let i = 0; i < block.childCount; i++) {\n\t\tif (block.children[i].ordinal) {\n\t\t\tif (olen !== block.children[i].ordinal.length - 1) {\n\t\t\t\tconsole.log(\"node integrity issue\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (i > 0 && block.children[i].ordinal <= block.children[i - 1].ordinal) {\n\t\t\t\tconsole.log(\"node sib integrity issue\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!block.children[i].isLeaf()) {\n\t\t\t\treturn nodeOrdinalsHaveIntegrity(block.children[i] as MergeBlock);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.log(`node child ordinal not set ${i}`);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Returns an object that tallies each delta and maintenance operation observed\n * for the given 'mergeTree'.\n */\nexport function countOperations(mergeTree: MergeTree): object {\n\tconst counts = {};\n\n\tassert.strictEqual(mergeTree.mergeTreeDeltaCallback, undefined);\n\tassert.strictEqual(mergeTree.mergeTreeMaintenanceCallback, undefined);\n\n\tconst fn = (\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs | IMergeTreeMaintenanceCallbackArgs,\n\t): void => {\n\t\tconst previous = counts[deltaArgs.operation] as undefined | number;\n\t\tcounts[deltaArgs.operation] = previous === undefined ? 1 : previous + 1;\n\t};\n\n\tmergeTree.mergeTreeDeltaCallback = (opArgs, deltaArgs): void => {\n\t\tfn(deltaArgs);\n\t};\n\tmergeTree.mergeTreeMaintenanceCallback = fn;\n\n\treturn counts;\n}\n\nfunction getPartialLengths(\n\tclientId: number,\n\tseq: number,\n\tmergeTree: MergeTree,\n\tlocalSeq?: number,\n\tmergeBlock: MergeBlock = mergeTree.root,\n): {\n\tpartialLen: number | undefined;\n\tactualLen: number;\n} {\n\tconst partialLen = mergeBlock.partialLengths?.getPartialLength(seq, clientId, localSeq);\n\n\tlet actualLen = 0;\n\n\tconst isInserted = (segment: ISegmentPrivate): boolean =>\n\t\tinfo.isInserted(segment) &&\n\t\t((segment.seq !== UnassignedSequenceNumber && segment.seq <= seq) ||\n\t\t\t(localSeq !== undefined &&\n\t\t\t\tsegment.seq === UnassignedSequenceNumber &&\n\t\t\t\tsegment.localSeq !== undefined &&\n\t\t\t\tsegment.localSeq <= localSeq));\n\n\tconst isRemoved = (segment: ISegmentPrivate): boolean =>\n\t\tinfo.isRemoved(segment) &&\n\t\t((localSeq !== undefined &&\n\t\t\tsegment.removedSeq === UnassignedSequenceNumber &&\n\t\t\tsegment.localRemovedSeq !== undefined &&\n\t\t\tsegment.localRemovedSeq <= localSeq) ||\n\t\t\t(segment.removedSeq !== UnassignedSequenceNumber && segment.removedSeq <= seq));\n\n\tconst isMoved = (segment: ISegmentPrivate): boolean =>\n\t\tinfo.isMoved(segment) &&\n\t\t((localSeq !== undefined &&\n\t\t\tsegment.movedSeq === UnassignedSequenceNumber &&\n\t\t\tsegment.localMovedSeq !== undefined &&\n\t\t\tsegment.localMovedSeq <= localSeq) ||\n\t\t\t(segment.movedSeq !== UnassignedSequenceNumber && segment.movedSeq <= seq));\n\n\twalkAllChildSegments(mergeBlock, (segment) => {\n\t\tif (isInserted(segment) && !isRemoved(segment) && !isMoved(segment)) {\n\t\t\tactualLen += segment.cachedLength;\n\t\t}\n\t\treturn true;\n\t});\n\n\treturn {\n\t\tpartialLen,\n\t\tactualLen,\n\t};\n}\n\nexport function validatePartialLengths(\n\tclientId: number,\n\tmergeTree: MergeTree,\n\texpectedValues?: { seq: number; len: number; localSeq?: number }[],\n\tlocalSeq?: number,\n\tmergeBlock: MergeBlock = mergeTree.root,\n): void {\n\tmergeTree.computeLocalPartials(0);\n\tfor (\n\t\tlet i = mergeTree.collabWindow.minSeq + 1;\n\t\ti <= mergeTree.collabWindow.currentSeq;\n\t\ti++\n\t) {\n\t\tconst { partialLen, actualLen } = getPartialLengths(\n\t\t\tclientId,\n\t\t\ti,\n\t\t\tmergeTree,\n\t\t\tlocalSeq,\n\t\t\tmergeBlock,\n\t\t);\n\n\t\tif (partialLen && partialLen < 0) {\n\t\t\tassert.fail(\"Negative partial length returned\");\n\t\t}\n\t\tassert.equal(partialLen, actualLen);\n\t}\n\n\tif (!expectedValues) {\n\t\treturn;\n\t}\n\n\tfor (const { seq, len, localSeq: expectedLocalSeq } of expectedValues) {\n\t\tconst { partialLen, actualLen } = getPartialLengths(\n\t\t\tclientId,\n\t\t\tseq,\n\t\t\tmergeTree,\n\t\t\texpectedLocalSeq ?? localSeq,\n\t\t\tmergeBlock,\n\t\t);\n\n\t\tassert.equal(partialLen, len);\n\t\tassert.equal(actualLen, len);\n\t}\n}\n\nexport function validateRefCount(collection?: LocalReferenceCollection): void {\n\tif (!collection) {\n\t\treturn;\n\t}\n\n\tconst expectedLength = [...collection].length;\n\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tassert.equal(collection[\"refCount\"], expectedLength);\n}\n\n/**\n * Enable stricter partial length assertions inside tests\n *\n * Note that these assertions can be expensive, and so should not be enabled in\n * production code or tests that run through thousands of ops (e.g. the SharedString\n * fuzz tests).\n */\nexport function useStrictPartialLengthChecks(): void {\n\tbeforeEach(() => {\n\t\tPartialSequenceLengths.options.verifier = verifyPartialLengths;\n\t\tPartialSequenceLengths.options.verifyExpected = verifyExpectedPartialLengths;\n\t});\n\n\tafterEach(() => {\n\t\tPartialSequenceLengths.options.verifier = undefined;\n\t\tPartialSequenceLengths.options.verifyExpected = undefined;\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../../src/test/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAQ3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAA+B,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EACN,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,GACpB,MAA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AU,EAAE,SAAS,EAAE,GAAG,iBAAiB,CAClD,QAAQ,EACR,GAAG,EACH,SAAS,EACT,gBAAgB,IAAI,QAAQ,EAC5B,UAAU,CACV,CAAC;QAEF,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC;AACF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,UAAqC;IACrE,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,OAAO;IACR,CAAC;IAED,MAAM,cAAc,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CAAC;IAE9C,2DAA2D;IAC3D,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B;IAC3C,UAAU,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAChD,sBAAsB,CAAC,OAAO,CAAC,QAAQ,GAAG,oBAAoB,CAAC;QAC/D,sBAAsB,CAAC,OAAO,CAAC,cAAc,GAAG,4BAA4B,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,gCAAgC,EAAE,GAAG,EAAE;QAChD,sBAAsB,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;QACpD,sBAAsB,CAAC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAC3D,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport fs from \"node:fs\";\n\nimport { UnassignedSequenceNumber } from \"../constants.js\";\nimport { LocalReferenceCollection } from \"../localReference.js\";\nimport { MergeTree } from \"../mergeTree.js\";\nimport {\n\tIMergeTreeDeltaOpArgs,\n\ttype IMergeTreeDeltaCallbackArgs,\n\ttype IMergeTreeMaintenanceCallbackArgs,\n} from \"../mergeTreeDeltaCallback.js\";\nimport { walkAllChildSegments } from \"../mergeTreeNodeWalk.js\";\nimport { MergeBlock, ISegmentPrivate, Marker } from \"../mergeTreeNodes.js\";\nimport { ReferenceType } from \"../ops.js\";\nimport {\n\tPartialSequenceLengths,\n\tverifyExpectedPartialLengths,\n\tverifyPartialLengths,\n} from \"../partialLengths.js\";\nimport { PropertySet } from \"../properties.js\";\nimport * as info from \"../segmentInfos.js\";\nimport { TextSegment } from \"../textSegment.js\";\n\nimport { loadText } from \"./text.js\";\n\nexport function loadTextFromFile(\n\tfilename: string,\n\tmergeTree: MergeTree,\n\tsegLimit = 0,\n): MergeTree {\n\tconst content = fs.readFileSync(filename, \"utf8\");\n\treturn loadText(content, mergeTree, segLimit);\n}\n\nexport function loadTextFromFileWithMarkers(\n\tfilename: string,\n\tmergeTree: MergeTree,\n\tsegLimit = 0,\n): MergeTree {\n\tconst content = fs.readFileSync(filename, \"utf8\");\n\treturn loadText(content, mergeTree, segLimit, true);\n}\n\ninterface InsertMarkerArgs {\n\tmergeTree: MergeTree;\n\tpos: number;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\tbehaviors: ReferenceType;\n\tprops: PropertySet | undefined;\n\topArgs: IMergeTreeDeltaOpArgs;\n}\n\nexport function insertMarker({\n\tmergeTree,\n\tpos,\n\trefSeq,\n\tclientId,\n\tseq,\n\tbehaviors,\n\tprops,\n\topArgs,\n}: InsertMarkerArgs): void {\n\tmergeTree.insertSegments(\n\t\tpos,\n\t\t[Marker.make(behaviors, props)],\n\t\trefSeq,\n\t\tclientId,\n\t\tseq,\n\t\topArgs,\n\t);\n}\n\ninterface InsertTextArgs {\n\tmergeTree: MergeTree;\n\tpos: number;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\ttext: string;\n\tprops?: PropertySet;\n\topArgs?: IMergeTreeDeltaOpArgs;\n}\n\nexport function insertText({\n\tmergeTree,\n\tpos,\n\trefSeq,\n\tclientId,\n\tseq,\n\ttext,\n\tprops,\n\topArgs,\n}: InsertTextArgs): void {\n\tmergeTree.insertSegments(\n\t\tpos,\n\t\t[TextSegment.make(text, props)],\n\t\trefSeq,\n\t\tclientId,\n\t\tseq,\n\t\topArgs,\n\t);\n}\n\ninterface InsertSegmentsArgs {\n\tmergeTree: MergeTree;\n\tpos: number;\n\tsegments: ISegmentPrivate[];\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\topArgs: IMergeTreeDeltaOpArgs | undefined;\n}\n\nexport function insertSegments({\n\tmergeTree,\n\tpos,\n\tsegments,\n\trefSeq,\n\tclientId,\n\tseq,\n\topArgs,\n}: InsertSegmentsArgs): void {\n\tmergeTree.insertSegments(pos, segments, refSeq, clientId, seq, opArgs);\n}\n\ninterface MarkRangeRemovedArgs {\n\tmergeTree: MergeTree;\n\tstart: number;\n\tend: number;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\toverwrite: boolean;\n\topArgs: IMergeTreeDeltaOpArgs;\n}\n\nexport function markRangeRemoved({\n\tmergeTree,\n\tstart,\n\tend,\n\trefSeq,\n\tclientId,\n\tseq,\n\topArgs,\n}: MarkRangeRemovedArgs): void {\n\tmergeTree.markRangeRemoved(start, end, refSeq, clientId, seq, opArgs);\n}\n\nexport function obliterateRange({\n\tmergeTree,\n\tstart,\n\tend,\n\trefSeq,\n\tclientId,\n\tseq,\n\topArgs,\n}: {\n\tmergeTree: MergeTree;\n\tstart: number;\n\tend: number;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\topArgs: IMergeTreeDeltaOpArgs;\n}): void {\n\tmergeTree.obliterateRange(start, end, refSeq, clientId, seq, opArgs);\n}\n\nexport function nodeOrdinalsHaveIntegrity(block: MergeBlock): boolean {\n\tconst olen = block.ordinal.length;\n\tfor (let i = 0; i < block.childCount; i++) {\n\t\tif (block.children[i].ordinal) {\n\t\t\tif (olen !== block.children[i].ordinal.length - 1) {\n\t\t\t\tconsole.log(\"node integrity issue\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (i > 0 && block.children[i].ordinal <= block.children[i - 1].ordinal) {\n\t\t\t\tconsole.log(\"node sib integrity issue\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!block.children[i].isLeaf()) {\n\t\t\t\treturn nodeOrdinalsHaveIntegrity(block.children[i] as MergeBlock);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.log(`node child ordinal not set ${i}`);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Returns an object that tallies each delta and maintenance operation observed\n * for the given 'mergeTree'.\n */\nexport function countOperations(mergeTree: MergeTree): object {\n\tconst counts = {};\n\n\tassert.strictEqual(mergeTree.mergeTreeDeltaCallback, undefined);\n\tassert.strictEqual(mergeTree.mergeTreeMaintenanceCallback, undefined);\n\n\tconst fn = (\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs | IMergeTreeMaintenanceCallbackArgs,\n\t): void => {\n\t\tconst previous = counts[deltaArgs.operation] as undefined | number;\n\t\tcounts[deltaArgs.operation] = previous === undefined ? 1 : previous + 1;\n\t};\n\n\tmergeTree.mergeTreeDeltaCallback = (opArgs, deltaArgs): void => {\n\t\tfn(deltaArgs);\n\t};\n\tmergeTree.mergeTreeMaintenanceCallback = fn;\n\n\treturn counts;\n}\n\nfunction getPartialLengths(\n\tclientId: number,\n\tseq: number,\n\tmergeTree: MergeTree,\n\tlocalSeq?: number,\n\tmergeBlock: MergeBlock = mergeTree.root,\n): {\n\tpartialLen: number | undefined;\n\tactualLen: number;\n} {\n\tconst partialLen = mergeBlock.partialLengths?.getPartialLength(seq, clientId, localSeq);\n\n\tlet actualLen = 0;\n\n\tconst isInserted = (segment: ISegmentPrivate): boolean =>\n\t\tinfo.isInserted(segment) &&\n\t\t((segment.seq !== UnassignedSequenceNumber && segment.seq <= seq) ||\n\t\t\t(localSeq !== undefined &&\n\t\t\t\tsegment.seq === UnassignedSequenceNumber &&\n\t\t\t\tsegment.localSeq !== undefined &&\n\t\t\t\tsegment.localSeq <= localSeq));\n\n\tconst isRemoved = (segment: ISegmentPrivate): boolean =>\n\t\tinfo.isRemoved(segment) &&\n\t\t((localSeq !== undefined &&\n\t\t\tsegment.removedSeq === UnassignedSequenceNumber &&\n\t\t\tsegment.localRemovedSeq !== undefined &&\n\t\t\tsegment.localRemovedSeq <= localSeq) ||\n\t\t\t(segment.removedSeq !== UnassignedSequenceNumber && segment.removedSeq <= seq));\n\n\tconst isMoved = (segment: ISegmentPrivate): boolean =>\n\t\tinfo.isMoved(segment) &&\n\t\t((localSeq !== undefined &&\n\t\t\tsegment.movedSeq === UnassignedSequenceNumber &&\n\t\t\tsegment.localMovedSeq !== undefined &&\n\t\t\tsegment.localMovedSeq <= localSeq) ||\n\t\t\t(segment.movedSeq !== UnassignedSequenceNumber && segment.movedSeq <= seq));\n\n\twalkAllChildSegments(mergeBlock, (segment) => {\n\t\tif (isInserted(segment) && !isRemoved(segment) && !isMoved(segment)) {\n\t\t\tactualLen += segment.cachedLength;\n\t\t}\n\t\treturn true;\n\t});\n\n\treturn {\n\t\tpartialLen,\n\t\tactualLen,\n\t};\n}\n\nexport function validatePartialLengths(\n\tclientId: number,\n\tmergeTree: MergeTree,\n\texpectedValues?: { seq: number; len: number; localSeq?: number }[],\n\tlocalSeq?: number,\n\tmergeBlock: MergeBlock = mergeTree.root,\n): void {\n\tmergeTree.computeLocalPartials(0);\n\tfor (\n\t\tlet i = mergeTree.collabWindow.minSeq + 1;\n\t\ti <= mergeTree.collabWindow.currentSeq;\n\t\ti++\n\t) {\n\t\tconst { partialLen, actualLen } = getPartialLengths(\n\t\t\tclientId,\n\t\t\ti,\n\t\t\tmergeTree,\n\t\t\tlocalSeq,\n\t\t\tmergeBlock,\n\t\t);\n\n\t\tif (partialLen && partialLen < 0) {\n\t\t\tassert.fail(\"Negative partial length returned\");\n\t\t}\n\t\tassert.equal(partialLen, actualLen);\n\t}\n\n\tif (!expectedValues) {\n\t\treturn;\n\t}\n\n\tfor (const { seq, len, localSeq: expectedLocalSeq } of expectedValues) {\n\t\tconst { partialLen, actualLen } = getPartialLengths(\n\t\t\tclientId,\n\t\t\tseq,\n\t\t\tmergeTree,\n\t\t\texpectedLocalSeq ?? localSeq,\n\t\t\tmergeBlock,\n\t\t);\n\n\t\tassert.equal(partialLen, len);\n\t\tassert.equal(actualLen, len);\n\t}\n}\n\nexport function validateRefCount(collection?: LocalReferenceCollection): void {\n\tif (!collection) {\n\t\treturn;\n\t}\n\n\tconst expectedLength = [...collection].length;\n\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tassert.equal(collection[\"refCount\"], expectedLength);\n}\n\n/**\n * Enable stricter partial length assertions inside tests\n *\n * Note that these assertions can be expensive, and so should not be enabled in\n * production code or tests that run through thousands of ops (e.g. the SharedString\n * fuzz tests).\n */\nexport function useStrictPartialLengthChecks(): void {\n\tbeforeEach(\"Enable strict partial lengths\", () => {\n\t\tPartialSequenceLengths.options.verifier = verifyPartialLengths;\n\t\tPartialSequenceLengths.options.verifyExpected = verifyExpectedPartialLengths;\n\t});\n\n\tafterEach(\"Disable strict partial lengths\", () => {\n\t\tPartialSequenceLengths.options.verifier = undefined;\n\t\tPartialSequenceLengths.options.verifyExpected = undefined;\n\t});\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/merge-tree",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.1",
|
|
4
4
|
"description": "Merge tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -81,30 +81,30 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "~2.
|
|
85
|
-
"@fluidframework/container-definitions": "~2.
|
|
86
|
-
"@fluidframework/core-interfaces": "~2.
|
|
87
|
-
"@fluidframework/core-utils": "~2.
|
|
88
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
89
|
-
"@fluidframework/driver-definitions": "~2.
|
|
90
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
91
|
-
"@fluidframework/runtime-utils": "~2.
|
|
92
|
-
"@fluidframework/shared-object-base": "~2.
|
|
93
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
84
|
+
"@fluid-internal/client-utils": "~2.22.1",
|
|
85
|
+
"@fluidframework/container-definitions": "~2.22.1",
|
|
86
|
+
"@fluidframework/core-interfaces": "~2.22.1",
|
|
87
|
+
"@fluidframework/core-utils": "~2.22.1",
|
|
88
|
+
"@fluidframework/datastore-definitions": "~2.22.1",
|
|
89
|
+
"@fluidframework/driver-definitions": "~2.22.1",
|
|
90
|
+
"@fluidframework/runtime-definitions": "~2.22.1",
|
|
91
|
+
"@fluidframework/runtime-utils": "~2.22.1",
|
|
92
|
+
"@fluidframework/shared-object-base": "~2.22.1",
|
|
93
|
+
"@fluidframework/telemetry-utils": "~2.22.1"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
97
97
|
"@biomejs/biome": "~1.9.3",
|
|
98
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
99
|
-
"@fluid-private/stochastic-test-utils": "~2.
|
|
100
|
-
"@fluid-private/test-pairwise-generator": "~2.
|
|
98
|
+
"@fluid-internal/mocha-test-setup": "~2.22.1",
|
|
99
|
+
"@fluid-private/stochastic-test-utils": "~2.22.1",
|
|
100
|
+
"@fluid-private/test-pairwise-generator": "~2.22.1",
|
|
101
101
|
"@fluid-tools/benchmark": "^0.50.0",
|
|
102
102
|
"@fluid-tools/build-cli": "^0.51.0",
|
|
103
103
|
"@fluidframework/build-common": "^2.0.3",
|
|
104
104
|
"@fluidframework/build-tools": "^0.51.0",
|
|
105
105
|
"@fluidframework/eslint-config-fluid": "^5.7.3",
|
|
106
|
-
"@fluidframework/merge-tree-previous": "npm:@fluidframework/merge-tree@2.
|
|
107
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
106
|
+
"@fluidframework/merge-tree-previous": "npm:@fluidframework/merge-tree@2.22.0",
|
|
107
|
+
"@fluidframework/test-runtime-utils": "~2.22.1",
|
|
108
108
|
"@microsoft/api-extractor": "7.47.8",
|
|
109
109
|
"@types/diff": "^3.5.1",
|
|
110
110
|
"@types/mocha": "^10.0.10",
|
|
@@ -171,8 +171,8 @@
|
|
|
171
171
|
"test:benchmark:report": "mocha \"dist/test/*.perf.spec.*js\" --node-option unhandled-rejections=strict,expose-gc --exit --perfMode --fgrep @Benchmark -r @fluid-internal/mocha-test-setup --reporter @fluid-tools/benchmark/dist/MochaReporter.js --timeout 60000",
|
|
172
172
|
"test:coverage": "c8 npm test",
|
|
173
173
|
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
174
|
-
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\"
|
|
175
|
-
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\"
|
|
174
|
+
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\"",
|
|
175
|
+
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\"",
|
|
176
176
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
177
177
|
"test:stress": "cross-env FUZZ_STRESS_RUN=1 FUZZ_TEST_COUNT=normal npm run test:mocha",
|
|
178
178
|
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
package/src/mergeTree.ts
CHANGED
|
@@ -593,6 +593,8 @@ export class MergeTree {
|
|
|
593
593
|
public mergeTreeDeltaCallback?: MergeTreeDeltaCallback;
|
|
594
594
|
public mergeTreeMaintenanceCallback?: MergeTreeMaintenanceCallback;
|
|
595
595
|
|
|
596
|
+
// TODO:AB#29553: This property doesn't seem to be adequately round-tripped through summarization.
|
|
597
|
+
// Specifically, it seems like we drop information about obliterates within the collab window for at least V1 summaries.
|
|
596
598
|
private readonly obliterates = new Obliterates(this);
|
|
597
599
|
|
|
598
600
|
public constructor(public options?: IMergeTreeOptionsInternal) {
|
|
@@ -1300,7 +1302,7 @@ export class MergeTree {
|
|
|
1300
1302
|
pendingSegmentGroup.segments.map((pendingSegment: ISegmentLeaf) => {
|
|
1301
1303
|
const overlappingRemove = !ackSegment(pendingSegment, pendingSegmentGroup, opArgs);
|
|
1302
1304
|
|
|
1303
|
-
overwrite
|
|
1305
|
+
overwrite ||= overlappingRemove || toMoveInfo(pendingSegment) !== undefined;
|
|
1304
1306
|
|
|
1305
1307
|
overlappingRemoves.push(overlappingRemove);
|
|
1306
1308
|
if (MergeTree.options.zamboniSegments) {
|
|
@@ -1609,6 +1611,8 @@ export class MergeTree {
|
|
|
1609
1611
|
let normalizedNewestSeq: number = 0;
|
|
1610
1612
|
const movedClientIds: number[] = [];
|
|
1611
1613
|
const movedSeqs: number[] = [];
|
|
1614
|
+
let newestAcked: ObliterateInfo | undefined;
|
|
1615
|
+
let oldestUnacked: ObliterateInfo | undefined;
|
|
1612
1616
|
for (const ob of this.obliterates.findOverlapping(newSegment)) {
|
|
1613
1617
|
// compute a normalized seq that takes into account local seqs
|
|
1614
1618
|
// but is still comparable to remote seqs to keep the checks below easy
|
|
@@ -1619,47 +1623,101 @@ export class MergeTree {
|
|
|
1619
1623
|
? Number.MAX_SAFE_INTEGER - this.collabWindow.localSeq + ob.localSeq!
|
|
1620
1624
|
: ob.seq;
|
|
1621
1625
|
if (normalizedObSeq > refSeq) {
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1626
|
+
// Any obliterate from the same client that's inserting this segment cannot cause the segment to be marked as
|
|
1627
|
+
// obliterated (since that client must have performed the obliterate before this insertion).
|
|
1628
|
+
// We still need to consider such obliterates when determining the winning obliterate for the insertion point,
|
|
1629
|
+
// see `obliteratePrecedingInsertion` docs.
|
|
1630
|
+
if (clientId !== ob.clientId) {
|
|
1631
|
+
if (oldest === undefined || normalizedOldestSeq > normalizedObSeq) {
|
|
1632
|
+
normalizedOldestSeq = normalizedObSeq;
|
|
1633
|
+
oldest = ob;
|
|
1634
|
+
movedClientIds.unshift(ob.clientId);
|
|
1635
|
+
movedSeqs.unshift(ob.seq);
|
|
1636
|
+
} else {
|
|
1637
|
+
movedClientIds.push(ob.clientId);
|
|
1638
|
+
movedSeqs.push(ob.seq);
|
|
1639
|
+
}
|
|
1630
1640
|
}
|
|
1641
|
+
|
|
1631
1642
|
if (newest === undefined || normalizedNewestSeq < normalizedObSeq) {
|
|
1632
1643
|
normalizedNewestSeq = normalizedObSeq;
|
|
1633
1644
|
newest = ob;
|
|
1634
1645
|
}
|
|
1646
|
+
|
|
1647
|
+
if (
|
|
1648
|
+
ob.seq !== UnassignedSequenceNumber &&
|
|
1649
|
+
(newestAcked === undefined || newestAcked.seq < ob.seq)
|
|
1650
|
+
) {
|
|
1651
|
+
newestAcked = ob;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
if (
|
|
1655
|
+
ob.seq === UnassignedSequenceNumber &&
|
|
1656
|
+
(oldestUnacked === undefined || oldestUnacked.localSeq! > ob.localSeq!)
|
|
1657
|
+
) {
|
|
1658
|
+
// There can be one local obliterate surrounding a segment if a client repeatedly obliterates
|
|
1659
|
+
// a region (ex: in the text ABCDEFG, obliterate D, then obliterate CE, then BF). In this case,
|
|
1660
|
+
// the first one that's applied will be the one that actually removes the segment.
|
|
1661
|
+
oldestUnacked = ob;
|
|
1662
|
+
}
|
|
1635
1663
|
}
|
|
1636
1664
|
}
|
|
1637
1665
|
|
|
1666
|
+
newSegment.obliteratePrecedingInsertion = newest;
|
|
1667
|
+
// See doc comment on obliteratePrecedingInsertion for more details: if the newest obliterate was performed
|
|
1668
|
+
// by the same client that's inserting this segment, we let them insert into this range and therefore don't
|
|
1669
|
+
// mark it obliterated.
|
|
1638
1670
|
if (oldest && newest?.clientId !== clientId) {
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1671
|
+
let moveInfo: IMoveInfo;
|
|
1672
|
+
if (newestAcked === newest || newestAcked?.clientId !== clientId) {
|
|
1673
|
+
moveInfo = {
|
|
1674
|
+
movedClientIds,
|
|
1675
|
+
movedSeq: oldest.seq,
|
|
1676
|
+
movedSeqs,
|
|
1677
|
+
localMovedSeq: oldestUnacked?.localSeq,
|
|
1678
|
+
wasMovedOnInsert: oldest.seq !== UnassignedSequenceNumber,
|
|
1679
|
+
};
|
|
1680
|
+
} else {
|
|
1681
|
+
assert(
|
|
1682
|
+
oldestUnacked !== undefined,
|
|
1683
|
+
"Expected local obliterate to be defined if newestAcked is not equal to newest",
|
|
1684
|
+
);
|
|
1685
|
+
// There's a pending local obliterate for this range, so it will be marked as obliterated by us. However,
|
|
1686
|
+
// all other clients are under the impression that the most recent acked obliterate won the right to insert
|
|
1687
|
+
// in this range.
|
|
1688
|
+
moveInfo = {
|
|
1689
|
+
movedClientIds: [oldestUnacked.clientId],
|
|
1690
|
+
movedSeq: oldestUnacked.seq,
|
|
1691
|
+
movedSeqs: [oldestUnacked.seq],
|
|
1692
|
+
localMovedSeq: oldestUnacked.localSeq,
|
|
1693
|
+
wasMovedOnInsert: false,
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1646
1696
|
|
|
1647
1697
|
overwriteInfo(newSegment, moveInfo);
|
|
1648
1698
|
|
|
1649
1699
|
if (moveInfo.localMovedSeq !== undefined) {
|
|
1650
1700
|
assert(
|
|
1651
|
-
|
|
1701
|
+
oldestUnacked?.segmentGroup !== undefined,
|
|
1652
1702
|
0x86c /* expected segment group to exist */,
|
|
1653
1703
|
);
|
|
1654
1704
|
|
|
1655
|
-
this.addToPendingList(newSegment,
|
|
1705
|
+
this.addToPendingList(newSegment, oldestUnacked?.segmentGroup);
|
|
1656
1706
|
}
|
|
1657
1707
|
|
|
1658
1708
|
if (newSegment.parent) {
|
|
1659
|
-
|
|
1709
|
+
// The incremental update codepath in theory can handle most cases where segments are obliterated upon insertion,
|
|
1710
|
+
// but it's not idempotent with respect to segment insertion in the first place. Since we already update partial
|
|
1711
|
+
// lengths inside the inserting walk, we'd be at risk of double-counting the insertion in any case if we allow
|
|
1712
|
+
// incremental updates here.
|
|
1713
|
+
const newStructure = true;
|
|
1714
|
+
this.blockUpdatePathLengths(
|
|
1715
|
+
newSegment.parent,
|
|
1716
|
+
moveInfo.movedSeq,
|
|
1717
|
+
clientId,
|
|
1718
|
+
newStructure,
|
|
1719
|
+
);
|
|
1660
1720
|
}
|
|
1661
|
-
} else if (oldest && newest?.clientId === clientId) {
|
|
1662
|
-
newSegment.prevObliterateByInserter = newest;
|
|
1663
1721
|
}
|
|
1664
1722
|
|
|
1665
1723
|
saveIfLocal(newSegment);
|
|
@@ -1682,8 +1740,8 @@ export class MergeTree {
|
|
|
1682
1740
|
segment.segmentGroups.copyTo(next.segmentGroups);
|
|
1683
1741
|
}
|
|
1684
1742
|
|
|
1685
|
-
if (segment.
|
|
1686
|
-
next.
|
|
1743
|
+
if (segment.obliteratePrecedingInsertion) {
|
|
1744
|
+
next.obliteratePrecedingInsertion = segment.obliteratePrecedingInsertion;
|
|
1687
1745
|
}
|
|
1688
1746
|
copyPropertiesAndManager(segment, next);
|
|
1689
1747
|
if (segment.localRefs) {
|
|
@@ -2050,7 +2108,8 @@ export class MergeTree {
|
|
|
2050
2108
|
(start.side === Side.After && startPos === pos + segment.cachedLength) || // exclusive start segment
|
|
2051
2109
|
(end.side === Side.Before &&
|
|
2052
2110
|
endPos === pos &&
|
|
2053
|
-
|
|
2111
|
+
// TODO:AB#29765: The clientId check here should be handled by isSegmentPresent and/or PerspectiveImpl
|
|
2112
|
+
(segment.clientId === clientId || isSegmentPresent(segment, { refSeq, localSeq }))) // exclusive end segment
|
|
2054
2113
|
) {
|
|
2055
2114
|
// We walk these segments because we want to also walk any concurrently inserted segments between here and the obliterated segments.
|
|
2056
2115
|
// These segments are outside of the obliteration range though, so return true to keep walking.
|
|
@@ -2058,18 +2117,23 @@ export class MergeTree {
|
|
|
2058
2117
|
}
|
|
2059
2118
|
const existingMoveInfo = toMoveInfo(segment);
|
|
2060
2119
|
|
|
2061
|
-
|
|
2120
|
+
// The "last-to-obliterate-gets-to-insert" policy described by the doc comment on `obliteratePrecedingInsertion`
|
|
2121
|
+
// is mostly handled by logic at insertion time, but we need a small bit of handling here.
|
|
2122
|
+
// Specifically, we want to avoid marking a local-only segment as obliterated when we know one of our own local obliterates
|
|
2123
|
+
// will win against the obliterate we're processing, hence the early exit.
|
|
2124
|
+
if (
|
|
2125
|
+
segment.seq === UnassignedSequenceNumber &&
|
|
2126
|
+
segment.obliteratePrecedingInsertion?.seq === UnassignedSequenceNumber &&
|
|
2127
|
+
seq !== UnassignedSequenceNumber
|
|
2128
|
+
) {
|
|
2062
2129
|
// We chose to not obliterate this segment because we are aware of an unacked local obliteration.
|
|
2063
2130
|
// The local obliterate has not been sequenced yet, so it is still the newest obliterate we are aware of.
|
|
2064
2131
|
// Other clients will also choose not to obliterate this segment because the most recent obliteration has the same clientId
|
|
2065
2132
|
return true;
|
|
2066
2133
|
}
|
|
2067
2134
|
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
segment.seq !== undefined &&
|
|
2071
|
-
seq !== UnassignedSequenceNumber &&
|
|
2072
|
-
(refSeq < segment.seq || segment.seq === UnassignedSequenceNumber);
|
|
2135
|
+
// Partial lengths incrementality is not supported for overlapping obliterate/removes.
|
|
2136
|
+
_overwrite ||= existingMoveInfo !== undefined || toRemovalInfo(segment) !== undefined;
|
|
2073
2137
|
|
|
2074
2138
|
if (existingMoveInfo === undefined) {
|
|
2075
2139
|
const movedSeg = overwriteInfo<IMoveInfo, ISegmentLeaf>(segment, {
|
|
@@ -2077,17 +2141,33 @@ export class MergeTree {
|
|
|
2077
2141
|
movedSeq: seq,
|
|
2078
2142
|
localMovedSeq: localSeq,
|
|
2079
2143
|
movedSeqs: [seq],
|
|
2080
|
-
wasMovedOnInsert
|
|
2144
|
+
wasMovedOnInsert:
|
|
2145
|
+
segment.seq === UnassignedSequenceNumber && seq !== UnassignedSequenceNumber,
|
|
2081
2146
|
});
|
|
2082
2147
|
|
|
2083
|
-
|
|
2148
|
+
const existingRemoval = toRemovalInfo(movedSeg);
|
|
2149
|
+
if (existingRemoval === undefined) {
|
|
2084
2150
|
movedSegments.push(movedSeg);
|
|
2151
|
+
} else if (
|
|
2152
|
+
existingRemoval.removedSeq === UnassignedSequenceNumber &&
|
|
2153
|
+
segment.localRefs?.empty === false
|
|
2154
|
+
) {
|
|
2155
|
+
// We removed this locally already so we don't need to event it again, but it might have references
|
|
2156
|
+
// that need sliding now that a move may have been acked.
|
|
2157
|
+
localOverlapWithRefs.push(segment);
|
|
2085
2158
|
}
|
|
2086
2159
|
} else {
|
|
2087
|
-
_overwrite = true;
|
|
2088
|
-
// never move wasMovedOnInsert from true to false
|
|
2089
|
-
existingMoveInfo.wasMovedOnInsert ||= wasMovedOnInsert;
|
|
2090
2160
|
if (existingMoveInfo.movedSeq === UnassignedSequenceNumber) {
|
|
2161
|
+
// Should not need explicit set here, but this should be implied:
|
|
2162
|
+
assert(
|
|
2163
|
+
!existingMoveInfo.wasMovedOnInsert,
|
|
2164
|
+
0xab4 /* Local obliterate cannot have removed a segment as soon as it was inserted */,
|
|
2165
|
+
);
|
|
2166
|
+
assert(
|
|
2167
|
+
seq !== UnassignedSequenceNumber,
|
|
2168
|
+
0xab5 /* Cannot obliterate the same segment locally twice */,
|
|
2169
|
+
);
|
|
2170
|
+
existingMoveInfo.wasMovedOnInsert = segment.seq === UnassignedSequenceNumber;
|
|
2091
2171
|
// we moved this locally, but someone else moved it first
|
|
2092
2172
|
// so put them at the head of the list
|
|
2093
2173
|
// The list isn't ordered, but we keep the first move at the head
|
|
@@ -2227,6 +2307,8 @@ export class MergeTree {
|
|
|
2227
2307
|
): boolean => {
|
|
2228
2308
|
const existingRemovalInfo = toRemovalInfo(segment);
|
|
2229
2309
|
|
|
2310
|
+
// Partial lengths incrementality is not supported for overlapping obliterate/removes.
|
|
2311
|
+
_overwrite ||= existingRemovalInfo !== undefined || toMoveInfo(segment) !== undefined;
|
|
2230
2312
|
if (existingRemovalInfo === undefined) {
|
|
2231
2313
|
const removed = overwriteInfo<IRemovalInfo, ISegmentLeaf>(segment, {
|
|
2232
2314
|
removedClientIds: [clientId],
|
|
@@ -2234,11 +2316,18 @@ export class MergeTree {
|
|
|
2234
2316
|
localRemovedSeq: localSeq,
|
|
2235
2317
|
});
|
|
2236
2318
|
|
|
2237
|
-
|
|
2319
|
+
const existingMoveInfo = toMoveInfo(removed);
|
|
2320
|
+
if (existingMoveInfo === undefined) {
|
|
2238
2321
|
removedSegments.push(removed);
|
|
2322
|
+
} else if (
|
|
2323
|
+
existingMoveInfo.movedSeq === UnassignedSequenceNumber &&
|
|
2324
|
+
segment.localRefs?.empty === false
|
|
2325
|
+
) {
|
|
2326
|
+
// We moved this locally already so we don't need to event it again, but it might have references
|
|
2327
|
+
// that need sliding now that a remove may have been acked.
|
|
2328
|
+
localOverlapWithRefs.push(segment);
|
|
2239
2329
|
}
|
|
2240
2330
|
} else {
|
|
2241
|
-
_overwrite = true;
|
|
2242
2331
|
if (existingRemovalInfo.removedSeq === UnassignedSequenceNumber) {
|
|
2243
2332
|
// we removed this locally, but someone else removed it first
|
|
2244
2333
|
// so put them at the head of the list
|
package/src/mergeTreeNodes.ts
CHANGED
|
@@ -73,11 +73,22 @@ export interface ISegmentPrivate extends ISegmentInternal {
|
|
|
73
73
|
segmentGroups?: SegmentGroupCollection;
|
|
74
74
|
propertyManager?: PropertiesManager;
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
76
|
+
* Populated iff this segment was inserted into a range affected by concurrent obliterates at the time of its insertion.
|
|
77
|
+
* Contains information about the 'most recent' (i.e. 'winning' in the sense below) obliterate.
|
|
78
|
+
*
|
|
79
|
+
* BEWARE: We have opted for a certain form of last-write wins (LWW) semantics for obliterates:
|
|
80
|
+
* the client which last obliterated a range is considered to have "won ownership" of that range and may insert into it
|
|
81
|
+
* without that insertion being obliterated by other clients' concurrent obliterates.
|
|
82
|
+
*
|
|
83
|
+
* Therefore, this field can be populated even if the segment has not been obliterated (i.e. is still visible).
|
|
84
|
+
* This happens precisely when the segment was inserted by the same client that 'won' the obliterate (in a scenario where
|
|
85
|
+
* a client first issues a sided obliterate impacting a range, then inserts into that range before the server has acked the obliterate).
|
|
86
|
+
*
|
|
87
|
+
* See the test case "obliterate with mismatched final states" for an example of such a scenario.
|
|
88
|
+
*
|
|
89
|
+
* TODO:AB#29553: This property is not persisted in the summary, but it should be.
|
|
79
90
|
*/
|
|
80
|
-
|
|
91
|
+
obliteratePrecedingInsertion?: ObliterateInfo;
|
|
81
92
|
}
|
|
82
93
|
/**
|
|
83
94
|
* Segment leafs are segments that have both IMergeNodeInfo and IInsertionInfo. This means they
|