@fluidframework/merge-tree 0.54.3 → 0.55.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +5 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -6
- package/dist/client.js.map +1 -1
- package/dist/collections.d.ts.map +1 -1
- package/dist/collections.js +1 -0
- package/dist/collections.js.map +1 -1
- package/dist/partialLengths.d.ts.map +1 -1
- package/dist/partialLengths.js +4 -2
- package/dist/partialLengths.js.map +1 -1
- package/dist/snapshotChunks.d.ts +2 -1
- package/dist/snapshotChunks.d.ts.map +1 -1
- package/dist/snapshotChunks.js.map +1 -1
- package/dist/snapshotLoader.d.ts +1 -1
- package/dist/snapshotLoader.d.ts.map +1 -1
- package/dist/snapshotLoader.js.map +1 -1
- package/dist/snapshotV1.d.ts +6 -5
- package/dist/snapshotV1.d.ts.map +1 -1
- package/dist/snapshotV1.js +12 -28
- package/dist/snapshotV1.js.map +1 -1
- package/dist/snapshotlegacy.d.ts +7 -5
- package/dist/snapshotlegacy.d.ts.map +1 -1
- package/dist/snapshotlegacy.js +8 -35
- package/dist/snapshotlegacy.js.map +1 -1
- package/lib/client.d.ts +5 -3
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +4 -6
- package/lib/client.js.map +1 -1
- package/lib/collections.d.ts.map +1 -1
- package/lib/collections.js +1 -0
- package/lib/collections.js.map +1 -1
- package/lib/partialLengths.d.ts.map +1 -1
- package/lib/partialLengths.js +4 -2
- package/lib/partialLengths.js.map +1 -1
- package/lib/snapshotChunks.d.ts +2 -1
- package/lib/snapshotChunks.d.ts.map +1 -1
- package/lib/snapshotChunks.js.map +1 -1
- package/lib/snapshotLoader.d.ts +1 -1
- package/lib/snapshotLoader.d.ts.map +1 -1
- package/lib/snapshotLoader.js.map +1 -1
- package/lib/snapshotV1.d.ts +6 -5
- package/lib/snapshotV1.d.ts.map +1 -1
- package/lib/snapshotV1.js +12 -28
- package/lib/snapshotV1.js.map +1 -1
- package/lib/snapshotlegacy.d.ts +7 -5
- package/lib/snapshotlegacy.d.ts.map +1 -1
- package/lib/snapshotlegacy.js +8 -35
- package/lib/snapshotlegacy.js.map +1 -1
- package/package.json +18 -14
- package/src/client.ts +9 -9
- package/src/collections.ts +1 -0
- package/src/partialLengths.ts +4 -2
- package/src/snapshotChunks.ts +2 -4
- package/src/snapshotLoader.ts +1 -1
- package/src/snapshotV1.ts +28 -50
- package/src/snapshotlegacy.ts +27 -52
package/src/client.ts
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
7
7
|
|
|
8
|
-
import { IFluidHandle
|
|
9
|
-
import {
|
|
8
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
9
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
10
|
+
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
10
11
|
import { IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
|
|
12
|
+
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
11
13
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
12
14
|
import { assert, Trace } from "@fluidframework/common-utils";
|
|
13
15
|
import { LoggingError } from "@fluidframework/telemetry-utils";
|
|
@@ -873,29 +875,27 @@ export class Client {
|
|
|
873
875
|
return new MergeTreeTextHelper(this.mergeTree);
|
|
874
876
|
}
|
|
875
877
|
|
|
876
|
-
|
|
877
|
-
// (See https://github.com/microsoft/FluidFramework/issues/84)
|
|
878
|
-
public snapshot(
|
|
878
|
+
public summarize(
|
|
879
879
|
runtime: IFluidDataStoreRuntime,
|
|
880
880
|
handle: IFluidHandle,
|
|
881
881
|
serializer: IFluidSerializer,
|
|
882
882
|
catchUpMsgs: ISequencedDocumentMessage[],
|
|
883
|
-
):
|
|
883
|
+
): ISummaryTreeWithStats {
|
|
884
884
|
const deltaManager = runtime.deltaManager;
|
|
885
885
|
const minSeq = deltaManager.minimumSequenceNumber;
|
|
886
886
|
|
|
887
887
|
// Catch up to latest MSN, if we have not had a chance to do it.
|
|
888
888
|
// Required for case where FluidDataStoreRuntime.attachChannel()
|
|
889
|
-
// generates
|
|
889
|
+
// generates summary right after loading data store.
|
|
890
890
|
|
|
891
891
|
this.updateSeqNumbers(minSeq, deltaManager.lastSequenceNumber);
|
|
892
892
|
|
|
893
|
-
// One of the
|
|
893
|
+
// One of the summaries (from SPO) I observed to have chunk.chunkSequenceNumber > minSeq!
|
|
894
894
|
// Not sure why - need to catch it sooner
|
|
895
895
|
assert(this.getCollabWindow().minSeq === minSeq,
|
|
896
896
|
0x03e /* "minSeq mismatch between collab window and delta manager!" */);
|
|
897
897
|
|
|
898
|
-
//
|
|
898
|
+
// Must continue to support legacy
|
|
899
899
|
// (See https://github.com/microsoft/FluidFramework/issues/84)
|
|
900
900
|
if (this.mergeTree.options?.newMergeTreeSnapshotFormat === true) {
|
|
901
901
|
assert(
|
package/src/collections.ts
CHANGED
package/src/partialLengths.ts
CHANGED
|
@@ -177,7 +177,8 @@ export class PartialSequenceLengths {
|
|
|
177
177
|
// Find next earliest sequence number
|
|
178
178
|
if (indices[k] < childPartialsCounts[k]) {
|
|
179
179
|
const cpLen = childPartials[k].partialLengths[indices[k]];
|
|
180
|
-
// eslint-disable-next-line
|
|
180
|
+
// eslint-disable-next-line max-len
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion
|
|
181
182
|
if ((outerIndexOfEarliest < 0) || (cpLen.seq < earliestPartialLength!.seq)) {
|
|
182
183
|
outerIndexOfEarliest = k;
|
|
183
184
|
earliestPartialLength = cpLen;
|
|
@@ -185,7 +186,8 @@ export class PartialSequenceLengths {
|
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
188
|
if (outerIndexOfEarliest >= 0) {
|
|
188
|
-
// eslint-disable-next-line
|
|
189
|
+
// eslint-disable-next-line max-len
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion
|
|
189
191
|
addNext(earliestPartialLength!);
|
|
190
192
|
indices[outerIndexOfEarliest]++;
|
|
191
193
|
}
|
package/src/snapshotChunks.ts
CHANGED
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
IFluidHandle,
|
|
11
|
-
} from "@fluidframework/core-interfaces";
|
|
8
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
9
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
12
10
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
13
11
|
import { PropertySet } from "./properties";
|
|
14
12
|
import { SnapshotLegacy } from "./snapshotlegacy";
|
package/src/snapshotLoader.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
7
7
|
|
|
8
8
|
import { assert, bufferToString } from "@fluidframework/common-utils";
|
|
9
|
-
import { IFluidSerializer } from "@fluidframework/
|
|
9
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
10
10
|
import { ChildLogger } from "@fluidframework/telemetry-utils";
|
|
11
11
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
12
12
|
import { IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
|
package/src/snapshotV1.ts
CHANGED
|
@@ -4,19 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
IFluidSerializer,
|
|
10
|
-
} from "@fluidframework/core-interfaces";
|
|
7
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
8
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
11
9
|
import { assert, bufferToString } from "@fluidframework/common-utils";
|
|
12
10
|
import { ChildLogger } from "@fluidframework/telemetry-utils";
|
|
13
|
-
import {
|
|
14
|
-
FileMode,
|
|
15
|
-
ITree,
|
|
16
|
-
TreeEntry,
|
|
17
|
-
ITreeEntry,
|
|
18
|
-
} from "@fluidframework/protocol-definitions";
|
|
19
11
|
import { IChannelStorageService } from "@fluidframework/datastore-definitions";
|
|
12
|
+
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
13
|
+
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
20
14
|
import { UnassignedSequenceNumber } from "./constants";
|
|
21
15
|
import {
|
|
22
16
|
ISegment,
|
|
@@ -98,13 +92,13 @@ export class SnapshotV1 {
|
|
|
98
92
|
}
|
|
99
93
|
|
|
100
94
|
/**
|
|
101
|
-
* Emits the snapshot to an
|
|
102
|
-
* the summary data rather than JSON.stringify.
|
|
95
|
+
* Emits the snapshot to an ISummarizeResult. If provided the optional IFluidSerializer will be used when
|
|
96
|
+
* serializing the summary data rather than JSON.stringify.
|
|
103
97
|
*/
|
|
104
98
|
emit(
|
|
105
99
|
serializer: IFluidSerializer,
|
|
106
100
|
bind: IFluidHandle,
|
|
107
|
-
):
|
|
101
|
+
): ISummaryTreeWithStats {
|
|
108
102
|
const chunks: MergeTreeChunkV1[] = [];
|
|
109
103
|
this.header.totalSegmentCount = 0;
|
|
110
104
|
this.header.totalLength = 0;
|
|
@@ -124,48 +118,32 @@ export class SnapshotV1 {
|
|
|
124
118
|
const headerChunk = chunks.shift()!;
|
|
125
119
|
headerChunk.headerMetadata = this.header;
|
|
126
120
|
headerChunk.headerMetadata.orderedChunkMetadata = [{ id: SnapshotLegacy.header }];
|
|
127
|
-
const
|
|
121
|
+
const blobs: [key: string, content: string][] = [];
|
|
122
|
+
chunks.forEach((chunk, index) => {
|
|
128
123
|
const id = `${SnapshotLegacy.body}_${index}`;
|
|
129
124
|
this.header.orderedChunkMetadata.push({ id });
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
chunk,
|
|
138
|
-
this.logger,
|
|
139
|
-
this.mergeTree.options,
|
|
140
|
-
serializer,
|
|
141
|
-
bind),
|
|
142
|
-
encoding: "utf-8",
|
|
143
|
-
},
|
|
144
|
-
};
|
|
125
|
+
blobs.push([id, serializeAsMaxSupportedVersion(
|
|
126
|
+
id,
|
|
127
|
+
chunk,
|
|
128
|
+
this.logger,
|
|
129
|
+
this.mergeTree.options,
|
|
130
|
+
serializer,
|
|
131
|
+
bind)]);
|
|
145
132
|
});
|
|
146
133
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.mergeTree.options,
|
|
159
|
-
serializer,
|
|
160
|
-
bind),
|
|
161
|
-
encoding: "utf-8",
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
...entries,
|
|
165
|
-
],
|
|
166
|
-
};
|
|
134
|
+
const builder = new SummaryTreeBuilder();
|
|
135
|
+
builder.addBlob(SnapshotLegacy.header, serializeAsMaxSupportedVersion(
|
|
136
|
+
SnapshotLegacy.header,
|
|
137
|
+
headerChunk,
|
|
138
|
+
this.logger,
|
|
139
|
+
this.mergeTree.options,
|
|
140
|
+
serializer,
|
|
141
|
+
bind));
|
|
142
|
+
blobs.forEach((value) => {
|
|
143
|
+
builder.addBlob(value[0], value[1]);
|
|
144
|
+
});
|
|
167
145
|
|
|
168
|
-
return
|
|
146
|
+
return builder.getSummaryTree();
|
|
169
147
|
}
|
|
170
148
|
|
|
171
149
|
extractSync() {
|
package/src/snapshotlegacy.ts
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
9
9
|
import { assert } from "@fluidframework/common-utils";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "@fluidframework/core-interfaces";
|
|
10
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
11
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
12
|
+
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
14
13
|
import { ChildLogger } from "@fluidframework/telemetry-utils";
|
|
15
|
-
import {
|
|
14
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
15
|
+
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
16
16
|
import { NonCollabClient, UnassignedSequenceNumber } from "./constants";
|
|
17
17
|
import {
|
|
18
18
|
ISegment,
|
|
@@ -89,57 +89,38 @@ export class SnapshotLegacy {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Emits the snapshot to an
|
|
93
|
-
* the summary data rather than JSON.stringify.
|
|
92
|
+
* Emits the snapshot to an ISummarizeResult. If provided the optional IFluidSerializer will be used when
|
|
93
|
+
* serializing the summary data rather than JSON.stringify.
|
|
94
94
|
*/
|
|
95
95
|
emit(
|
|
96
96
|
catchUpMsgs: ISequencedDocumentMessage[],
|
|
97
97
|
serializer: IFluidSerializer,
|
|
98
98
|
bind: IFluidHandle,
|
|
99
|
-
):
|
|
99
|
+
): ISummaryTreeWithStats {
|
|
100
100
|
const chunk1 = this.getSeqLengthSegs(this.segments!, this.segmentLengths!, this.chunkSize);
|
|
101
101
|
let length: number = chunk1.chunkLengthChars;
|
|
102
102
|
let segments: number = chunk1.chunkSegmentCount;
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
SnapshotLegacy.header,
|
|
112
|
-
chunk1,
|
|
113
|
-
this.logger,
|
|
114
|
-
this.mergeTree.options,
|
|
115
|
-
serializer,
|
|
116
|
-
bind),
|
|
117
|
-
encoding: "utf-8",
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
};
|
|
103
|
+
const builder = new SummaryTreeBuilder();
|
|
104
|
+
builder.addBlob(SnapshotLegacy.header, serializeAsMinSupportedVersion(
|
|
105
|
+
SnapshotLegacy.header,
|
|
106
|
+
chunk1,
|
|
107
|
+
this.logger,
|
|
108
|
+
this.mergeTree.options,
|
|
109
|
+
serializer,
|
|
110
|
+
bind));
|
|
122
111
|
|
|
123
112
|
if (chunk1.chunkSegmentCount < chunk1.totalSegmentCount!) {
|
|
124
113
|
const chunk2 = this.getSeqLengthSegs(this.segments!, this.segmentLengths!,
|
|
125
114
|
this.header!.segmentsTotalLength, chunk1.chunkSegmentCount);
|
|
126
115
|
length += chunk2.chunkLengthChars;
|
|
127
116
|
segments += chunk2.chunkSegmentCount;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
chunk2,
|
|
136
|
-
this.logger,
|
|
137
|
-
this.mergeTree.options,
|
|
138
|
-
serializer,
|
|
139
|
-
bind),
|
|
140
|
-
encoding: "utf-8",
|
|
141
|
-
},
|
|
142
|
-
});
|
|
117
|
+
builder.addBlob(SnapshotLegacy.body, serializeAsMinSupportedVersion(
|
|
118
|
+
SnapshotLegacy.body,
|
|
119
|
+
chunk2,
|
|
120
|
+
this.logger,
|
|
121
|
+
this.mergeTree.options,
|
|
122
|
+
serializer,
|
|
123
|
+
bind));
|
|
143
124
|
}
|
|
144
125
|
|
|
145
126
|
assert(
|
|
@@ -151,18 +132,12 @@ export class SnapshotLegacy {
|
|
|
151
132
|
0x05e /* "emit: mismatch in totalSegmentCount" */);
|
|
152
133
|
|
|
153
134
|
if(catchUpMsgs !== undefined && catchUpMsgs.length > 0) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
type: TreeEntry.Blob,
|
|
158
|
-
value: {
|
|
159
|
-
contents: serializer ? serializer.stringify(catchUpMsgs, bind) : JSON.stringify(catchUpMsgs),
|
|
160
|
-
encoding: "utf-8",
|
|
161
|
-
},
|
|
162
|
-
});
|
|
135
|
+
builder.addBlob(
|
|
136
|
+
this.mergeTree.options?.catchUpBlobName ?? SnapshotLegacy.catchupOps,
|
|
137
|
+
serializer ? serializer.stringify(catchUpMsgs, bind) : JSON.stringify(catchUpMsgs));
|
|
163
138
|
}
|
|
164
139
|
|
|
165
|
-
return
|
|
140
|
+
return builder.getSummaryTree();
|
|
166
141
|
}
|
|
167
142
|
|
|
168
143
|
extractSync() {
|