@fluidframework/runtime-utils 1.2.1 → 2.0.0-internal.1.0.0.81601

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.
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/runtime-utils";
8
- export declare const pkgVersion = "1.2.1";
8
+ export declare const pkgVersion = "2.0.0-internal.1.0.0.81601";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,UAAU,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,+BAA+B,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/runtime-utils";
11
- exports.pkgVersion = "1.2.1";
11
+ exports.pkgVersion = "2.0.0-internal.1.0.0.81601";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"1.2.1\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"2.0.0-internal.1.0.0.81601\";\n"]}
@@ -37,7 +37,6 @@ export declare class SummarizerNode implements IRootSummarizerNode {
37
37
  get referenceSequenceNumber(): number;
38
38
  protected readonly children: Map<string, SummarizerNode>;
39
39
  protected readonly pendingSummaries: Map<string, SummaryNode>;
40
- private readonly outstandingOps;
41
40
  private wipReferenceSequenceNumber;
42
41
  private wipLocalPaths;
43
42
  private wipSkipRecursion;
@@ -68,10 +67,7 @@ export declare class SummarizerNode implements IRootSummarizerNode {
68
67
  protected refreshLatestSummaryFromSnapshot(referenceSequenceNumber: number, snapshotTree: ISnapshotTree, basePath: EscapedPath | undefined, localPath: EscapedPath, correlatedSummaryLogger: ITelemetryLogger, readAndParseBlob: ReadAndParseBlob): Promise<void>;
69
68
  private refreshLatestSummaryCore;
70
69
  loadBaseSummaryWithoutDifferential(snapshot: ISnapshotTree): void;
71
- loadBaseSummary(snapshot: ISnapshotTree, readAndParseBlob: ReadAndParseBlob): Promise<{
72
- baseSummary: ISnapshotTree;
73
- outstandingOps: ISequencedDocumentMessage[];
74
- }>;
70
+ loadBaseSummary(snapshot: ISnapshotTree, readAndParseBlob: ReadAndParseBlob): Promise<ISnapshotTree>;
75
71
  recordChange(op: ISequencedDocumentMessage): void;
76
72
  invalidate(sequenceNumber: number): void;
77
73
  /**
@@ -82,13 +78,6 @@ export declare class SummarizerNode implements IRootSummarizerNode {
82
78
  protected hasChanged(): boolean;
83
79
  get latestSummary(): Readonly<SummaryNode> | undefined;
84
80
  private readonly canReuseHandle;
85
- private readonly throwOnError;
86
- /**
87
- * Sequence number of latest tracked op. This updates during recordChange,
88
- * but not for invalidate since we don't have the op. If this drifts from
89
- * changeSequenceNumber and we try to create a differential summary we assert.
90
- */
91
- private trackingSequenceNumber;
92
81
  /**
93
82
  * Do not call constructor directly.
94
83
  * Use createRootSummarizerNode to create root node, or createChild to create child nodes.
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNode.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAEhB,8BAA8B,EAE9B,mBAAmB,EACnB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,yBAAyB,EAEzB,aAAa,EAEhB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAIH,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAG3B,oBAAoB,EACpB,WAAW,EACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,mBAAoB,SAAQ,eAAe,EAAE,2BAA2B;CAAG;AAE5F;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,YAAW,mBAAmB;IAqalD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,gBAAgB;IAClD,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAEpC,OAAO,CAAC,qBAAqB;IAC7B,8CAA8C;IAC9C,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,SAAS,CAAC,gBAAgB,C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U,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAM/C;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,OAAO;IAI/B,IAAW,aAAa,IAAI,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS,CAE5D;IAED,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IAEzC;;;OAGG;gBAEoB,aAAa,EAAE,gBAAgB,EACjC,mBAAmB,EAAE,mBAAmB,EACzD,MAAM,EAAE,qBAAqB,EACrB,qBAAqB,EAAE,MAAM;IACrC,8CAA8C;IACtC,cAAc,CAAC,yBAAa,EACnB,cAAc,CAAC,6BAAiB,EACvC,gBAAgB,CAAC,8BAAkB;IAK1C,WAAW;IACd,yBAAyB;IACzB,mBAAmB,EAAE,mBAAmB;IACxC,2CAA2C;IAC3C,EAAE,EAAE,MAAM;IACV;;;;OAIG;IACH,WAAW,EAAE,8BAA8B,EAC3C,MAAM,GAAE,qBAA0B,GACnC,eAAe;IAsBX,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIxD;;;;;OAKG;IACH,SAAS,CAAC,wBAAwB,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,8BAA8B,GAAG,mBAAmB;IAmFhH;;;;OAIG;IACH,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,cAAc;IAQrD;;OAEG;IACH,SAAS,CAAC,oBAAoB,IAAI,OAAO;CAG5C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,WACzB,gBAAgB,uBACH,mBAAmB,wBAClB,MAAM,2BACH,MAAM,GAAG,SAAS,WACnC,qBAAqB,KAC9B,mBAME,CAAC"}
@@ -40,14 +40,8 @@ class SummarizerNode {
40
40
  this.wipSummaryLogger = wipSummaryLogger;
41
41
  this.children = new Map();
42
42
  this.pendingSummaries = new Map();
43
- this.outstandingOps = [];
44
43
  this.wipSkipRecursion = false;
45
44
  this.canReuseHandle = (_a = config.canReuseHandle) !== null && _a !== void 0 ? _a : true;
46
- // BUGBUG: Seeing issues with differential summaries.
47
- // this will disable them, and throw instead
48
- // while we continue to investigate
49
- this.throwOnError = true; // config.throwOnFailure ?? false;
50
- this.trackingSequenceNumber = this._changeSequenceNumber;
51
45
  }
52
46
  /**
53
47
  * The reference sequence number of the most recent acked summary.
@@ -90,53 +84,12 @@ class SummarizerNode {
90
84
  };
91
85
  }
92
86
  }
93
- try {
94
- const result = await this.summarizeInternalFn(fullTree, true, telemetryContext);
95
- this.wipLocalPaths = { localPath: summarizerNodeUtils_1.EscapedPath.create(result.id) };
96
- if (result.pathPartsForChildren !== undefined) {
97
- this.wipLocalPaths.additionalPath = summarizerNodeUtils_1.EscapedPath.createAndConcat(result.pathPartsForChildren);
98
- }
99
- return { summary: result.summary, stats: result.stats };
100
- }
101
- catch (error) {
102
- if (this.throwOnError || this.trackingSequenceNumber < this._changeSequenceNumber) {
103
- throw error;
104
- }
105
- const latestSummary = this._latestSummary;
106
- const initialSummary = this.initialSummary;
107
- let encodeParam;
108
- let localPath;
109
- if (latestSummary !== undefined) {
110
- // Create using handle of latest acked summary
111
- encodeParam = {
112
- fromSummary: true,
113
- summaryNode: latestSummary,
114
- };
115
- localPath = latestSummary.localPath;
116
- }
117
- else if ((initialSummary === null || initialSummary === void 0 ? void 0 : initialSummary.summary) !== undefined) {
118
- // Create using initial summary from attach op
119
- encodeParam = {
120
- fromSummary: false,
121
- initialSummary: initialSummary.summary,
122
- };
123
- localPath = summarizerNodeUtils_1.EscapedPath.create(initialSummary.id);
124
- }
125
- else {
126
- // No base summary to reference
127
- throw error;
128
- }
129
- this.wipSummaryLogger.sendErrorEvent({
130
- eventName: "SummarizingWithBasePlusOps",
131
- }, error);
132
- const summary = (0, summarizerNodeUtils_1.encodeSummary)(encodeParam, this.outstandingOps);
133
- this.wipLocalPaths = {
134
- localPath,
135
- additionalPath: summary.additionalPath,
136
- };
137
- this.wipSkipRecursion = true;
138
- return { summary: summary.summary, stats: summary.stats };
87
+ const result = await this.summarizeInternalFn(fullTree, true, telemetryContext);
88
+ this.wipLocalPaths = { localPath: summarizerNodeUtils_1.EscapedPath.create(result.id) };
89
+ if (result.pathPartsForChildren !== undefined) {
90
+ this.wipLocalPaths.additionalPath = summarizerNodeUtils_1.EscapedPath.createAndConcat(result.pathPartsForChildren);
139
91
  }
92
+ return { summary: result.summary, stats: result.stats };
140
93
  }
141
94
  /**
142
95
  * Complete the WIP summary for the given proposalHandle
@@ -255,13 +208,13 @@ class SummarizerNode {
255
208
  return;
256
209
  }
257
210
  this.refreshLatestSummaryCore(referenceSequenceNumber);
258
- const { baseSummary, pathParts } = (0, summarizerNodeUtils_1.decodeSummary)(snapshotTree, correlatedSummaryLogger);
259
211
  this._latestSummary = new summarizerNodeUtils_1.SummaryNode({
260
212
  referenceSequenceNumber,
261
213
  basePath,
262
214
  localPath,
263
215
  });
264
- const { childrenTree, childrenPathPart } = (0, summarizerNodeUtils_1.parseSummaryForSubtrees)(baseSummary);
216
+ const pathParts = [];
217
+ const { childrenTree, childrenPathPart } = (0, summarizerNodeUtils_1.parseSummaryForSubtrees)(snapshotTree);
265
218
  if (childrenPathPart !== undefined) {
266
219
  pathParts.push(childrenPathPart);
267
220
  }
@@ -285,11 +238,6 @@ class SummarizerNode {
285
238
  this.pendingSummaries.delete(key);
286
239
  }
287
240
  }
288
- // Clear earlier outstanding ops
289
- while (this.outstandingOps.length > 0
290
- && this.outstandingOps[0].sequenceNumber <= referenceSequenceNumber) {
291
- this.outstandingOps.shift();
292
- }
293
241
  }
294
242
  loadBaseSummaryWithoutDifferential(snapshot) {
295
243
  // Check base summary to see if it has any additional path parts
@@ -300,34 +248,18 @@ class SummarizerNode {
300
248
  }
301
249
  }
302
250
  async loadBaseSummary(snapshot, readAndParseBlob) {
303
- const decodedSummary = (0, summarizerNodeUtils_1.decodeSummary)(snapshot, this.defaultLogger);
304
- const outstandingOps = await decodedSummary.getOutstandingOps(readAndParseBlob);
305
- const { childrenPathPart } = (0, summarizerNodeUtils_1.parseSummaryForSubtrees)(decodedSummary.baseSummary);
251
+ const pathParts = [];
252
+ const { childrenPathPart } = (0, summarizerNodeUtils_1.parseSummaryForSubtrees)(snapshot);
306
253
  if (childrenPathPart !== undefined) {
307
- decodedSummary.pathParts.push(childrenPathPart);
308
- }
309
- if (decodedSummary.pathParts.length > 0 && this._latestSummary !== undefined) {
310
- this._latestSummary.additionalPath = summarizerNodeUtils_1.EscapedPath.createAndConcat(decodedSummary.pathParts);
254
+ pathParts.push(childrenPathPart);
311
255
  }
312
- // Defensive assertion: tracking number should already exceed this number.
313
- // This is probably a little excessive; can remove when stable.
314
- if (outstandingOps.length > 0) {
315
- const newOpsLatestSeq = outstandingOps[outstandingOps.length - 1].sequenceNumber;
316
- (0, common_utils_1.assert)(newOpsLatestSeq <= this.trackingSequenceNumber, 0x1a9 /* "When loading base summary, expected outstanding ops <= tracking sequence number" */);
256
+ if (pathParts.length > 0 && this._latestSummary !== undefined) {
257
+ this._latestSummary.additionalPath = summarizerNodeUtils_1.EscapedPath.createAndConcat(pathParts);
317
258
  }
318
- return {
319
- baseSummary: decodedSummary.baseSummary,
320
- outstandingOps,
321
- };
259
+ return snapshot;
322
260
  }
323
261
  recordChange(op) {
324
- const lastOp = this.outstandingOps[this.outstandingOps.length - 1];
325
- if (lastOp !== undefined) {
326
- (0, common_utils_1.assert)(lastOp.sequenceNumber < op.sequenceNumber, 0x1aa /* Out of order change recorded */);
327
- }
328
262
  this.invalidate(op.sequenceNumber);
329
- this.trackingSequenceNumber = op.sequenceNumber;
330
- this.outstandingOps.push(op);
331
263
  }
332
264
  invalidate(sequenceNumber) {
333
265
  if (sequenceNumber > this._changeSequenceNumber) {
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNode.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6EAS6C;AAC7C,+EAK8C;AAE9C,+DAAuE;AACvE,kDAAmF;AAEnF,+DAY+B;AA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jD,6GAA6G;QAC7G,kCAAkC;QAClC,IAAI,IAAI,CAAC,oBAAoB,EAAE,EAAE;YAC7B,KAAK,CAAC,0BAA0B,GAAG,IAAI,CAAC,0BAA0B,CAAC;SACtE;IACL,CAAC;IAED;;OAEG;IACO,oBAAoB;QAC1B,OAAO,IAAI,CAAC,0BAA0B,KAAK,SAAS,CAAC;IACzD,CAAC;CACJ;AAxkBD,wCAwkBC;AAED;;;;;;;;GAQG;AACI,MAAM,wBAAwB,GAAG,CACpC,MAAwB,EACxB,mBAAwC,EACxC,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAgC,EAAE,EACf,EAAE,CAAC,IAAI,cAAc,CACpC,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,CACzG,CAAC;AAZO,QAAA,wBAAwB,4BAY/B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ISummarizerNode,\n ISummarizerNodeConfig,\n ISummarizeResult,\n ISummaryTreeWithStats,\n CreateChildSummarizerNodeParam,\n CreateSummarizerNodeSource,\n SummarizeInternalFn,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n ISequencedDocumentMessage,\n SummaryType,\n ISnapshotTree,\n SummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport { mergeStats, convertToSummaryTree, calculateStats } from \"../summaryUtils\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport {\n decodeSummary,\n encodeSummary,\n EncodeSummaryParam,\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n parseSummaryForSubtrees,\n parseSummaryTreeForSubtrees,\n RefreshSummaryResult,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNode extends ISummarizerNode, ISummarizerNodeRootContract {}\n\n/**\n * Encapsulates the summarizing work and state of an individual tree node in the\n * summary tree. It tracks changes and allows for optimizations when unchanged, or\n * can allow for fallback summaries to be generated when an error is encountered.\n * Usage is for the root node to call startSummary first to begin tracking a WIP\n * (work in progress) summary. Then all nodes will call summarize to summaries their\n * individual parts. Once completed and uploaded to storage, the root node will call\n * completeSummary or clearSummary to clear the WIP summary tracking state if something\n * went wrong. The SummarizerNodes will track all pending summaries that have been\n * recorded by the completeSummary call. When one of them is acked, the root node should\n * call refreshLatestSummary to inform the tree of SummarizerNodes of the new baseline\n * latest successful summary.\n */\nexport class SummarizerNode implements IRootSummarizerNode {\n /**\n * The reference sequence number of the most recent acked summary.\n * Returns 0 if there is not yet an acked summary.\n */\n public get referenceSequenceNumber() {\n return this._latestSummary?.referenceSequenceNumber ?? 0;\n }\n\n protected readonly children = new Map<string, SummarizerNode>();\n protected readonly pendingSummaries = new Map<string, SummaryNode>();\n private readonly outstandingOps: ISequencedDocumentMessage[] = [];\n private wipReferenceSequenceNumber: number | undefined;\n private wipLocalPaths: { localPath: EscapedPath; additionalPath?: EscapedPath; } | undefined;\n private wipSkipRecursion = false;\n\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n assert(this.wipSummaryLogger === undefined,\n 0x19f /* \"wipSummaryLogger should not be set yet in startSummary\" */);\n assert(this.wipReferenceSequenceNumber === undefined, 0x1a0 /* \"Already tracking a summary\" */);\n\n this.wipSummaryLogger = summaryLogger;\n\n for (const child of this.children.values()) {\n child.startSummary(referenceSequenceNumber, this.wipSummaryLogger);\n }\n this.wipReferenceSequenceNumber = referenceSequenceNumber;\n }\n\n public async summarize(\n fullTree: boolean,\n trackState: boolean = true,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult> {\n assert(this.isTrackingInProgress(), 0x1a1 /* \"summarize should not be called when not tracking the summary\" */);\n assert(this.wipSummaryLogger !== undefined,\n 0x1a2 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */);\n\n // Try to reuse the tree if unchanged\n if (this.canReuseHandle && !fullTree && !this.hasChanged()) {\n const latestSummary = this._latestSummary;\n if (latestSummary !== undefined) {\n this.wipLocalPaths = {\n localPath: latestSummary.localPath,\n additionalPath: latestSummary.additionalPath,\n };\n this.wipSkipRecursion = true;\n const stats = mergeStats();\n stats.handleNodeCount++;\n return {\n summary: {\n type: SummaryType.Handle,\n handle: latestSummary.fullPath.path,\n handleType: SummaryType.Tree,\n },\n stats,\n };\n }\n }\n\n try {\n const result = await this.summarizeInternalFn(fullTree, true, telemetryContext);\n this.wipLocalPaths = { localPath: EscapedPath.create(result.id) };\n if (result.pathPartsForChildren !== undefined) {\n this.wipLocalPaths.additionalPath = EscapedPath.createAndConcat(result.pathPartsForChildren);\n }\n return { summary: result.summary, stats: result.stats };\n } catch (error) {\n if (this.throwOnError || this.trackingSequenceNumber < this._changeSequenceNumber) {\n throw error;\n }\n const latestSummary = this._latestSummary;\n const initialSummary = this.initialSummary;\n\n let encodeParam: EncodeSummaryParam;\n let localPath: EscapedPath;\n if (latestSummary !== undefined) {\n // Create using handle of latest acked summary\n encodeParam = {\n fromSummary: true,\n summaryNode: latestSummary,\n };\n localPath = latestSummary.localPath;\n } else if (initialSummary?.summary !== undefined) {\n // Create using initial summary from attach op\n encodeParam = {\n fromSummary: false,\n initialSummary: initialSummary.summary,\n };\n localPath = EscapedPath.create(initialSummary.id);\n } else {\n // No base summary to reference\n throw error;\n }\n this.wipSummaryLogger.sendErrorEvent({\n eventName: \"SummarizingWithBasePlusOps\",\n },\n error);\n const summary = encodeSummary(encodeParam, this.outstandingOps);\n this.wipLocalPaths = {\n localPath,\n additionalPath: summary.additionalPath,\n };\n this.wipSkipRecursion = true;\n return { summary: summary.summary, stats: summary.stats };\n }\n }\n\n /**\n * Complete the WIP summary for the given proposalHandle\n */\n public completeSummary(proposalHandle: string) {\n this.completeSummaryCore(proposalHandle, undefined, false);\n }\n\n /**\n * Recursive implementation for completeSummary, with additional internal-only parameters\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n assert(this.wipSummaryLogger !== undefined,\n 0x1a3 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */);\n assert(this.wipReferenceSequenceNumber !== undefined, 0x1a4 /* \"Not tracking a summary\" */);\n let localPathsToUse = this.wipLocalPaths;\n\n if (parentSkipRecursion) {\n const latestSummary = this._latestSummary;\n if (latestSummary !== undefined) {\n // This case the parent node created a failure summary or was reused.\n // This node and all children should only try to reference their path\n // by its last known good state in the actual summary tree.\n // If parent fails or is reused, the child summarize is not called so\n // it did not get a chance to change its paths.\n // In this case, essentially only propagate the new summary ref seq num.\n localPathsToUse = {\n localPath: latestSummary.localPath,\n additionalPath: latestSummary.additionalPath,\n };\n } else {\n // This case the child is added after the latest non-failure summary.\n // This node and all children should consider themselves as still not\n // having a successful summary yet.\n // We cannot \"reuse\" this node if unchanged since that summary, because\n // handles will be unable to point to that node. It never made it to the\n // tree itself, and only exists as an attach op in the _outstandingOps.\n this.clearSummary();\n return;\n }\n }\n\n // This should come from wipLocalPaths in normal cases, or from the latestSummary\n // if parentIsFailure or parentIsReused is true.\n // If there is no latestSummary, clearSummary and return before reaching this code.\n assert(!!localPathsToUse, 0x1a5 /* \"Tracked summary local paths not set\" */);\n\n const summary = new SummaryNode({\n ...localPathsToUse,\n referenceSequenceNumber: this.wipReferenceSequenceNumber,\n basePath: parentPath,\n });\n const fullPathForChildren = summary.fullPathForChildren;\n for (const child of this.children.values()) {\n child.completeSummaryCore(\n proposalHandle,\n fullPathForChildren,\n this.wipSkipRecursion || parentSkipRecursion,\n );\n }\n // Note that this overwrites existing pending summary with\n // the same proposalHandle. If proposalHandle is something like\n // a hash or unique identifier, this should be fine. If storage\n // can return the same proposalHandle for a different summary,\n // this should still be okay, because we should be proposing the\n // newer one later which would have to overwrite the previous one.\n this.pendingSummaries.set(proposalHandle, summary);\n this.clearSummary();\n }\n\n public clearSummary() {\n this.wipReferenceSequenceNumber = undefined;\n this.wipLocalPaths = undefined;\n this.wipSkipRecursion = false;\n this.wipSummaryLogger = undefined;\n for (const child of this.children.values()) {\n child.clearSummary();\n }\n }\n\n /**\n * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,\n * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),\n * we skip the update. Otherwise, we get the snapshot by calling `getSnapshot` and update latest\n * summary based off of that.\n * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:\n * 1. The latest summary was not udpated.\n * 2. The latest summary was updated and the summary corresponding to the params was being tracked.\n * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this\n * case, the latest summary is updated based on the downloaded snapshot which is also returned.\n */\n public async refreshLatestSummary(\n proposalHandle: string | undefined,\n summaryRefSeq: number,\n getSnapshot: () => Promise<ISnapshotTree>,\n readAndParseBlob: ReadAndParseBlob,\n correlatedSummaryLogger: ITelemetryLogger,\n ): Promise<RefreshSummaryResult> {\n if (proposalHandle !== undefined) {\n const maybeSummaryNode = this.pendingSummaries.get(proposalHandle);\n\n if (maybeSummaryNode !== undefined) {\n this.refreshLatestSummaryFromPending(proposalHandle, maybeSummaryNode.referenceSequenceNumber);\n return { latestSummaryUpdated: true, wasSummaryTracked: true };\n }\n }\n\n // If we have seen a summary same or later as the current one, ignore it.\n if (this.referenceSequenceNumber >= summaryRefSeq) {\n return { latestSummaryUpdated: false };\n }\n\n const snapshotTree = await getSnapshot();\n await this.refreshLatestSummaryFromSnapshot(\n summaryRefSeq,\n snapshotTree,\n undefined,\n EscapedPath.create(\"\"),\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n return { latestSummaryUpdated: true, wasSummaryTracked: false, snapshot: snapshotTree };\n }\n\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode === undefined) {\n // This should only happen if parent skipped recursion AND no prior summary existed.\n assert(\n this._latestSummary === undefined,\n 0x1a6 /* \"Not found pending summary, but this node has previously completed a summary\" */,\n );\n return;\n } else {\n assert(\n referenceSequenceNumber === summaryNode.referenceSequenceNumber,\n 0x1a7 /* Pending summary reference sequence number should be consistent */,\n );\n\n // Clear earlier pending summaries\n this.pendingSummaries.delete(proposalHandle);\n }\n\n this.refreshLatestSummaryCore(referenceSequenceNumber);\n\n this._latestSummary = summaryNode;\n\n // Propagate update to all child nodes\n for (const child of this.children.values()) {\n child.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n }\n\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n this.refreshLatestSummaryCore(referenceSequenceNumber);\n\n const { baseSummary, pathParts } = decodeSummary(snapshotTree, correlatedSummaryLogger);\n\n this._latestSummary = new SummaryNode({\n referenceSequenceNumber,\n basePath,\n localPath,\n });\n\n const { childrenTree, childrenPathPart } = parseSummaryForSubtrees(baseSummary);\n if (childrenPathPart !== undefined) {\n pathParts.push(childrenPathPart);\n }\n\n if (pathParts.length > 0) {\n this._latestSummary.additionalPath = EscapedPath.createAndConcat(pathParts);\n }\n\n // Propagate update to all child nodes\n const pathForChildren = this._latestSummary.fullPathForChildren;\n await Promise.all(Array.from(this.children)\n .filter(([id]) => {\n // Assuming subtrees missing from snapshot are newer than the snapshot,\n // but might be nice to assert this using earliest seq for node.\n return childrenTree.trees[id] !== undefined;\n }).map(async ([id, child]) => {\n return child.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n childrenTree.trees[id],\n pathForChildren,\n EscapedPath.create(id),\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }));\n }\n\n private refreshLatestSummaryCore(referenceSequenceNumber: number): void {\n for (const [key, value] of this.pendingSummaries) {\n if (value.referenceSequenceNumber < referenceSequenceNumber) {\n this.pendingSummaries.delete(key);\n }\n }\n\n // Clear earlier outstanding ops\n while (\n this.outstandingOps.length > 0\n && this.outstandingOps[0].sequenceNumber <= referenceSequenceNumber\n ) {\n this.outstandingOps.shift();\n }\n }\n\n public loadBaseSummaryWithoutDifferential(snapshot: ISnapshotTree) {\n // Check base summary to see if it has any additional path parts\n // separating child SummarizerNodes. Checks for .channels subtrees.\n const { childrenPathPart } = parseSummaryForSubtrees(snapshot);\n if (childrenPathPart !== undefined && this._latestSummary !== undefined) {\n this._latestSummary.additionalPath = EscapedPath.create(childrenPathPart);\n }\n }\n\n public async loadBaseSummary(\n snapshot: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<{ baseSummary: ISnapshotTree; outstandingOps: ISequencedDocumentMessage[]; }> {\n const decodedSummary = decodeSummary(snapshot, this.defaultLogger);\n const outstandingOps = await decodedSummary.getOutstandingOps(readAndParseBlob);\n\n const { childrenPathPart } = parseSummaryForSubtrees(decodedSummary.baseSummary);\n if (childrenPathPart !== undefined) {\n decodedSummary.pathParts.push(childrenPathPart);\n }\n\n if (decodedSummary.pathParts.length > 0 && this._latestSummary !== undefined) {\n this._latestSummary.additionalPath = EscapedPath.createAndConcat(decodedSummary.pathParts);\n }\n\n // Defensive assertion: tracking number should already exceed this number.\n // This is probably a little excessive; can remove when stable.\n if (outstandingOps.length > 0) {\n const newOpsLatestSeq = outstandingOps[outstandingOps.length - 1].sequenceNumber;\n assert(\n newOpsLatestSeq <= this.trackingSequenceNumber,\n 0x1a9 /* \"When loading base summary, expected outstanding ops <= tracking sequence number\" */,\n );\n }\n\n return {\n baseSummary: decodedSummary.baseSummary,\n outstandingOps,\n };\n }\n\n public recordChange(op: ISequencedDocumentMessage): void {\n const lastOp = this.outstandingOps[this.outstandingOps.length - 1];\n if (lastOp !== undefined) {\n assert(\n lastOp.sequenceNumber < op.sequenceNumber,\n 0x1aa /* Out of order change recorded */,\n );\n }\n this.invalidate(op.sequenceNumber);\n this.trackingSequenceNumber = op.sequenceNumber;\n this.outstandingOps.push(op);\n }\n\n public invalidate(sequenceNumber: number): void {\n if (sequenceNumber > this._changeSequenceNumber) {\n this._changeSequenceNumber = sequenceNumber;\n }\n }\n\n /**\n * True if a change has been recorded with sequence number exceeding\n * the latest successfully acked summary reference sequence number.\n * False implies that the previous summary can be reused.\n */\n protected hasChanged(): boolean {\n return this._changeSequenceNumber > this.referenceSequenceNumber;\n }\n\n public get latestSummary(): Readonly<SummaryNode> | undefined {\n return this._latestSummary;\n }\n\n private readonly canReuseHandle: boolean;\n private readonly throwOnError: boolean;\n /**\n * Sequence number of latest tracked op. This updates during recordChange,\n * but not for invalidate since we don't have the op. If this drifts from\n * changeSequenceNumber and we try to create a differential summary we assert.\n */\n private trackingSequenceNumber: number;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNode to create root node, or createChild to create child nodes.\n */\n public constructor(\n protected readonly defaultLogger: ITelemetryLogger,\n private readonly summarizeInternalFn: SummarizeInternalFn,\n config: ISummarizerNodeConfig,\n private _changeSequenceNumber: number,\n /** Undefined means created without summary */\n private _latestSummary?: SummaryNode,\n private readonly initialSummary?: IInitialSummary,\n protected wipSummaryLogger?: ITelemetryLogger,\n ) {\n this.canReuseHandle = config.canReuseHandle ?? true;\n // BUGBUG: Seeing issues with differential summaries.\n // this will disable them, and throw instead\n // while we continue to investigate\n this.throwOnError = true; // config.throwOnFailure ?? false;\n this.trackingSequenceNumber = this._changeSequenceNumber;\n }\n\n public createChild(\n /** Summarize function */\n summarizeInternalFn: SummarizeInternalFn,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfig = {},\n ): ISummarizerNode {\n assert(!this.children.has(id), 0x1ab /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNode(\n this.defaultLogger,\n summarizeInternalFn,\n config,\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n );\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n public getChild(id: string): ISummarizerNode | undefined {\n return this.children.get(id);\n }\n\n /**\n * Returns the details needed to create a child node.\n * @param id - Initial id or path part of the child node.\n * @param createParam - Information needed to create the node.\n * @returns the details needed to create the child node.\n */\n protected getCreateDetailsForChild(id: string, createParam: CreateChildSummarizerNodeParam): ICreateChildDetails {\n let initialSummary: IInitialSummary | undefined;\n let latestSummary: SummaryNode | undefined;\n let changeSequenceNumber: number;\n\n const parentLatestSummary = this._latestSummary;\n switch (createParam.type) {\n case CreateSummarizerNodeSource.FromAttach: {\n if (\n parentLatestSummary !== undefined\n && createParam.sequenceNumber <= parentLatestSummary.referenceSequenceNumber\n ) {\n // Prioritize latest summary if it was after this node was attached.\n latestSummary = parentLatestSummary.createForChild(id);\n } else {\n const summary = convertToSummaryTree(createParam.snapshot) as ISummaryTreeWithStats;\n initialSummary = {\n sequenceNumber: createParam.sequenceNumber,\n id,\n summary,\n };\n }\n changeSequenceNumber = createParam.sequenceNumber;\n break;\n }\n case CreateSummarizerNodeSource.FromSummary: {\n if (this.initialSummary === undefined) {\n assert(\n !!parentLatestSummary,\n 0x1ac /* \"Cannot create child from summary if parent does not have latest summary\" */);\n }\n // fallthrough to local\n }\n case CreateSummarizerNodeSource.Local: {\n const parentInitialSummary = this.initialSummary;\n if (parentInitialSummary !== undefined) {\n let childSummary: SummaryObject | undefined;\n if (parentInitialSummary.summary !== undefined) {\n const { childrenTree } = parseSummaryTreeForSubtrees(parentInitialSummary.summary.summary);\n assert(\n childrenTree.type === SummaryType.Tree,\n 0x1d6 /* \"Parent summary object is not a tree\" */,\n );\n childSummary = childrenTree.tree[id];\n }\n if (createParam.type === CreateSummarizerNodeSource.FromSummary) {\n // Locally created would not have differential subtree.\n assert(!!childSummary, 0x1ad /* \"Missing child summary tree\" */);\n }\n let childSummaryWithStats: ISummaryTreeWithStats | undefined;\n if (childSummary !== undefined) {\n assert(\n childSummary.type === SummaryType.Tree,\n 0x1ae /* \"Child summary object is not a tree\" */,\n );\n childSummaryWithStats = {\n summary: childSummary,\n stats: calculateStats(childSummary),\n };\n }\n initialSummary = {\n sequenceNumber: parentInitialSummary.sequenceNumber,\n id,\n summary: childSummaryWithStats,\n };\n }\n latestSummary = parentLatestSummary?.createForChild(id);\n changeSequenceNumber = parentLatestSummary?.referenceSequenceNumber ?? -1;\n break;\n }\n default: {\n const type = (createParam as unknown as CreateChildSummarizerNodeParam).type;\n unreachableCase(createParam, `Unexpected CreateSummarizerNodeSource: ${type}`);\n }\n }\n\n return {\n initialSummary,\n latestSummary,\n changeSequenceNumber,\n };\n }\n\n /**\n * Updates the state of the child if required. For example, if a summary is currently being tracked, the child's\n * summary tracking state needs to be updated too.\n * @param child - The child node whose state is to be updated.\n */\n protected maybeUpdateChildState(child: SummarizerNode) {\n // If we are tracking a summary, this child was created after the tracking started. So, we need to update the\n // child's tracking state as well.\n if (this.isTrackingInProgress()) {\n child.wipReferenceSequenceNumber = this.wipReferenceSequenceNumber;\n }\n }\n\n /**\n * Tells whether summary tracking is in progress. True if \"startSummary\" API is called before summarize.\n */\n protected isTrackingInProgress(): boolean {\n return this.wipReferenceSequenceNumber !== undefined;\n }\n}\n\n/**\n * Creates a root summarizer node.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n */\nexport const createRootSummarizerNode = (\n logger: ITelemetryLogger,\n summarizeInternalFn: SummarizeInternalFn,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfig = {},\n): IRootSummarizerNode => new SummarizerNode(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n );\n"]}
1
+ {"version":3,"file":"summarizerNode.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6EAS6C;AAC7C,+EAK8C;AAE9C,+DAAuE;AACvE,kDAAmF;AAEnF,+DAS+B;AAI/B;;;;;;;;;;;;GAYG;AACH,MAAa,cAAc;IA+UvB;;;OAGG;IACH,YACuB,aAA+B,EACjC,mBAAwC,EACzD,MAA6B,EACrB,qBAA6B;IACrC,8CAA8C;IACtC,cAA4B,EACnB,cAAgC,EACvC,gBAAmC;;QAP1B,kBAAa,GAAb,aAAa,CAAkB;QACjC,wBAAmB,GAAnB,mBAAmB,CAAqB;QAEjD,0BAAqB,GAArB,qBAAqB,CAAQ;QAE7B,mBAAc,GAAd,cAAc,CAAc;QACnB,mBAAc,GAAd,cAAc,CAAkB;QACvC,qBAAgB,GAAhB,gBAAgB,CAAmB;QAlV9B,aAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;QAC7C,qBAAgB,GAAG,IAAI,GAAG,EAAuB,CAAC;QAG7D,qBAAgB,GAAG,KAAK,CAAC;QAgV7B,IAAI,CAAC,cAAc,GAAG,MAAA,MAAM,CAAC,cAAc,mCAAI,IAAI,CAAC;IACxD,CAAC;IA7VD;;;OAGG;IACH,IAAW,uBAAuB;;QAC9B,OAAO,MAAA,MAAA,IAAI,CAAC,cAAc,0CAAE,uBAAuB,mCAAI,CAAC,C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BAAmB,CAAE,cAAc,CAAC,EAAE,CAAC,CAAC;gBACxD,oBAAoB,GAAG,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,uBAAuB,mCAAI,CAAC,CAAC,CAAC;gBAC1E,MAAM;aACT;YACD,OAAO,CAAC,CAAC;gBACL,MAAM,IAAI,GAAI,WAAyD,CAAC,IAAI,CAAC;gBAC7E,IAAA,8BAAe,EAAC,WAAW,EAAE,0CAA0C,IAAI,EAAE,CAAC,CAAC;aAClF;SACJ;QAED,OAAO;YACH,cAAc;YACd,aAAa;YACb,oBAAoB;SACvB,CAAC;IACN,CAAC;IAED;;;;OAIG;IACO,qBAAqB,CAAC,KAAqB;QACjD,6GAA6G;QAC7G,kCAAkC;QAClC,IAAI,IAAI,CAAC,oBAAoB,EAAE,EAAE;YAC7B,KAAK,CAAC,0BAA0B,GAAG,IAAI,CAAC,0BAA0B,CAAC;SACtE;IACL,CAAC;IAED;;OAEG;IACO,oBAAoB;QAC1B,OAAO,IAAI,CAAC,0BAA0B,KAAK,SAAS,CAAC;IACzD,CAAC;CACJ;AAlfD,wCAkfC;AAED;;;;;;;;GAQG;AACI,MAAM,wBAAwB,GAAG,CACpC,MAAwB,EACxB,mBAAwC,EACxC,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAgC,EAAE,EACf,EAAE,CAAC,IAAI,cAAc,CACpC,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,CACzG,CAAC;AAZO,QAAA,wBAAwB,4BAY/B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ISummarizerNode,\n ISummarizerNodeConfig,\n ISummarizeResult,\n ISummaryTreeWithStats,\n CreateChildSummarizerNodeParam,\n CreateSummarizerNodeSource,\n SummarizeInternalFn,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n ISequencedDocumentMessage,\n SummaryType,\n ISnapshotTree,\n SummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport { mergeStats, convertToSummaryTree, calculateStats } from \"../summaryUtils\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n parseSummaryForSubtrees,\n parseSummaryTreeForSubtrees,\n RefreshSummaryResult,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNode extends ISummarizerNode, ISummarizerNodeRootContract {}\n\n/**\n * Encapsulates the summarizing work and state of an individual tree node in the\n * summary tree. It tracks changes and allows for optimizations when unchanged, or\n * can allow for fallback summaries to be generated when an error is encountered.\n * Usage is for the root node to call startSummary first to begin tracking a WIP\n * (work in progress) summary. Then all nodes will call summarize to summaries their\n * individual parts. Once completed and uploaded to storage, the root node will call\n * completeSummary or clearSummary to clear the WIP summary tracking state if something\n * went wrong. The SummarizerNodes will track all pending summaries that have been\n * recorded by the completeSummary call. When one of them is acked, the root node should\n * call refreshLatestSummary to inform the tree of SummarizerNodes of the new baseline\n * latest successful summary.\n */\nexport class SummarizerNode implements IRootSummarizerNode {\n /**\n * The reference sequence number of the most recent acked summary.\n * Returns 0 if there is not yet an acked summary.\n */\n public get referenceSequenceNumber() {\n return this._latestSummary?.referenceSequenceNumber ?? 0;\n }\n\n protected readonly children = new Map<string, SummarizerNode>();\n protected readonly pendingSummaries = new Map<string, SummaryNode>();\n private wipReferenceSequenceNumber: number | undefined;\n private wipLocalPaths: { localPath: EscapedPath; additionalPath?: EscapedPath; } | undefined;\n private wipSkipRecursion = false;\n\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n assert(this.wipSummaryLogger === undefined,\n 0x19f /* \"wipSummaryLogger should not be set yet in startSummary\" */);\n assert(this.wipReferenceSequenceNumber === undefined, 0x1a0 /* \"Already tracking a summary\" */);\n\n this.wipSummaryLogger = summaryLogger;\n\n for (const child of this.children.values()) {\n child.startSummary(referenceSequenceNumber, this.wipSummaryLogger);\n }\n this.wipReferenceSequenceNumber = referenceSequenceNumber;\n }\n\n public async summarize(\n fullTree: boolean,\n trackState: boolean = true,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult> {\n assert(this.isTrackingInProgress(), 0x1a1 /* \"summarize should not be called when not tracking the summary\" */);\n assert(this.wipSummaryLogger !== undefined,\n 0x1a2 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */);\n\n // Try to reuse the tree if unchanged\n if (this.canReuseHandle && !fullTree && !this.hasChanged()) {\n const latestSummary = this._latestSummary;\n if (latestSummary !== undefined) {\n this.wipLocalPaths = {\n localPath: latestSummary.localPath,\n additionalPath: latestSummary.additionalPath,\n };\n this.wipSkipRecursion = true;\n const stats = mergeStats();\n stats.handleNodeCount++;\n return {\n summary: {\n type: SummaryType.Handle,\n handle: latestSummary.fullPath.path,\n handleType: SummaryType.Tree,\n },\n stats,\n };\n }\n }\n\n const result = await this.summarizeInternalFn(fullTree, true, telemetryContext);\n this.wipLocalPaths = { localPath: EscapedPath.create(result.id) };\n if (result.pathPartsForChildren !== undefined) {\n this.wipLocalPaths.additionalPath = EscapedPath.createAndConcat(result.pathPartsForChildren);\n }\n return { summary: result.summary, stats: result.stats };\n }\n\n /**\n * Complete the WIP summary for the given proposalHandle\n */\n public completeSummary(proposalHandle: string) {\n this.completeSummaryCore(proposalHandle, undefined, false);\n }\n\n /**\n * Recursive implementation for completeSummary, with additional internal-only parameters\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n assert(this.wipSummaryLogger !== undefined,\n 0x1a3 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */);\n assert(this.wipReferenceSequenceNumber !== undefined, 0x1a4 /* \"Not tracking a summary\" */);\n let localPathsToUse = this.wipLocalPaths;\n\n if (parentSkipRecursion) {\n const latestSummary = this._latestSummary;\n if (latestSummary !== undefined) {\n // This case the parent node created a failure summary or was reused.\n // This node and all children should only try to reference their path\n // by its last known good state in the actual summary tree.\n // If parent fails or is reused, the child summarize is not called so\n // it did not get a chance to change its paths.\n // In this case, essentially only propagate the new summary ref seq num.\n localPathsToUse = {\n localPath: latestSummary.localPath,\n additionalPath: latestSummary.additionalPath,\n };\n } else {\n // This case the child is added after the latest non-failure summary.\n // This node and all children should consider themselves as still not\n // having a successful summary yet.\n // We cannot \"reuse\" this node if unchanged since that summary, because\n // handles will be unable to point to that node. It never made it to the\n // tree itself, and only exists as an attach op in the _outstandingOps.\n this.clearSummary();\n return;\n }\n }\n\n // This should come from wipLocalPaths in normal cases, or from the latestSummary\n // if parentIsFailure or parentIsReused is true.\n // If there is no latestSummary, clearSummary and return before reaching this code.\n assert(!!localPathsToUse, 0x1a5 /* \"Tracked summary local paths not set\" */);\n\n const summary = new SummaryNode({\n ...localPathsToUse,\n referenceSequenceNumber: this.wipReferenceSequenceNumber,\n basePath: parentPath,\n });\n const fullPathForChildren = summary.fullPathForChildren;\n for (const child of this.children.values()) {\n child.completeSummaryCore(\n proposalHandle,\n fullPathForChildren,\n this.wipSkipRecursion || parentSkipRecursion,\n );\n }\n // Note that this overwrites existing pending summary with\n // the same proposalHandle. If proposalHandle is something like\n // a hash or unique identifier, this should be fine. If storage\n // can return the same proposalHandle for a different summary,\n // this should still be okay, because we should be proposing the\n // newer one later which would have to overwrite the previous one.\n this.pendingSummaries.set(proposalHandle, summary);\n this.clearSummary();\n }\n\n public clearSummary() {\n this.wipReferenceSequenceNumber = undefined;\n this.wipLocalPaths = undefined;\n this.wipSkipRecursion = false;\n this.wipSummaryLogger = undefined;\n for (const child of this.children.values()) {\n child.clearSummary();\n }\n }\n\n /**\n * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,\n * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),\n * we skip the update. Otherwise, we get the snapshot by calling `getSnapshot` and update latest\n * summary based off of that.\n * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:\n * 1. The latest summary was not udpated.\n * 2. The latest summary was updated and the summary corresponding to the params was being tracked.\n * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this\n * case, the latest summary is updated based on the downloaded snapshot which is also returned.\n */\n public async refreshLatestSummary(\n proposalHandle: string | undefined,\n summaryRefSeq: number,\n getSnapshot: () => Promise<ISnapshotTree>,\n readAndParseBlob: ReadAndParseBlob,\n correlatedSummaryLogger: ITelemetryLogger,\n ): Promise<RefreshSummaryResult> {\n if (proposalHandle !== undefined) {\n const maybeSummaryNode = this.pendingSummaries.get(proposalHandle);\n\n if (maybeSummaryNode !== undefined) {\n this.refreshLatestSummaryFromPending(proposalHandle, maybeSummaryNode.referenceSequenceNumber);\n return { latestSummaryUpdated: true, wasSummaryTracked: true };\n }\n }\n\n // If we have seen a summary same or later as the current one, ignore it.\n if (this.referenceSequenceNumber >= summaryRefSeq) {\n return { latestSummaryUpdated: false };\n }\n\n const snapshotTree = await getSnapshot();\n await this.refreshLatestSummaryFromSnapshot(\n summaryRefSeq,\n snapshotTree,\n undefined,\n EscapedPath.create(\"\"),\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n return { latestSummaryUpdated: true, wasSummaryTracked: false, snapshot: snapshotTree };\n }\n\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode === undefined) {\n // This should only happen if parent skipped recursion AND no prior summary existed.\n assert(\n this._latestSummary === undefined,\n 0x1a6 /* \"Not found pending summary, but this node has previously completed a summary\" */,\n );\n return;\n } else {\n assert(\n referenceSequenceNumber === summaryNode.referenceSequenceNumber,\n 0x1a7 /* Pending summary reference sequence number should be consistent */,\n );\n\n // Clear earlier pending summaries\n this.pendingSummaries.delete(proposalHandle);\n }\n\n this.refreshLatestSummaryCore(referenceSequenceNumber);\n\n this._latestSummary = summaryNode;\n\n // Propagate update to all child nodes\n for (const child of this.children.values()) {\n child.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n }\n\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n this.refreshLatestSummaryCore(referenceSequenceNumber);\n\n this._latestSummary = new SummaryNode({\n referenceSequenceNumber,\n basePath,\n localPath,\n });\n\n const pathParts: string[] = [];\n const { childrenTree, childrenPathPart } = parseSummaryForSubtrees(snapshotTree);\n if (childrenPathPart !== undefined) {\n pathParts.push(childrenPathPart);\n }\n\n if (pathParts.length > 0) {\n this._latestSummary.additionalPath = EscapedPath.createAndConcat(pathParts);\n }\n\n // Propagate update to all child nodes\n const pathForChildren = this._latestSummary.fullPathForChildren;\n await Promise.all(Array.from(this.children)\n .filter(([id]) => {\n // Assuming subtrees missing from snapshot are newer than the snapshot,\n // but might be nice to assert this using earliest seq for node.\n return childrenTree.trees[id] !== undefined;\n }).map(async ([id, child]) => {\n return child.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n childrenTree.trees[id],\n pathForChildren,\n EscapedPath.create(id),\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }));\n }\n\n private refreshLatestSummaryCore(referenceSequenceNumber: number): void {\n for (const [key, value] of this.pendingSummaries) {\n if (value.referenceSequenceNumber < referenceSequenceNumber) {\n this.pendingSummaries.delete(key);\n }\n }\n }\n\n public loadBaseSummaryWithoutDifferential(snapshot: ISnapshotTree) {\n // Check base summary to see if it has any additional path parts\n // separating child SummarizerNodes. Checks for .channels subtrees.\n const { childrenPathPart } = parseSummaryForSubtrees(snapshot);\n if (childrenPathPart !== undefined && this._latestSummary !== undefined) {\n this._latestSummary.additionalPath = EscapedPath.create(childrenPathPart);\n }\n }\n\n public async loadBaseSummary(\n snapshot: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<ISnapshotTree> {\n const pathParts: string[] = [];\n const { childrenPathPart } = parseSummaryForSubtrees(snapshot);\n if (childrenPathPart !== undefined) {\n pathParts.push(childrenPathPart);\n }\n\n if (pathParts.length > 0 && this._latestSummary !== undefined) {\n this._latestSummary.additionalPath = EscapedPath.createAndConcat(pathParts);\n }\n\n return snapshot;\n }\n\n public recordChange(op: ISequencedDocumentMessage): void {\n this.invalidate(op.sequenceNumber);\n }\n\n public invalidate(sequenceNumber: number): void {\n if (sequenceNumber > this._changeSequenceNumber) {\n this._changeSequenceNumber = sequenceNumber;\n }\n }\n\n /**\n * True if a change has been recorded with sequence number exceeding\n * the latest successfully acked summary reference sequence number.\n * False implies that the previous summary can be reused.\n */\n protected hasChanged(): boolean {\n return this._changeSequenceNumber > this.referenceSequenceNumber;\n }\n\n public get latestSummary(): Readonly<SummaryNode> | undefined {\n return this._latestSummary;\n }\n\n private readonly canReuseHandle: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNode to create root node, or createChild to create child nodes.\n */\n public constructor(\n protected readonly defaultLogger: ITelemetryLogger,\n private readonly summarizeInternalFn: SummarizeInternalFn,\n config: ISummarizerNodeConfig,\n private _changeSequenceNumber: number,\n /** Undefined means created without summary */\n private _latestSummary?: SummaryNode,\n private readonly initialSummary?: IInitialSummary,\n protected wipSummaryLogger?: ITelemetryLogger,\n ) {\n this.canReuseHandle = config.canReuseHandle ?? true;\n }\n\n public createChild(\n /** Summarize function */\n summarizeInternalFn: SummarizeInternalFn,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfig = {},\n ): ISummarizerNode {\n assert(!this.children.has(id), 0x1ab /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNode(\n this.defaultLogger,\n summarizeInternalFn,\n config,\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n );\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n public getChild(id: string): ISummarizerNode | undefined {\n return this.children.get(id);\n }\n\n /**\n * Returns the details needed to create a child node.\n * @param id - Initial id or path part of the child node.\n * @param createParam - Information needed to create the node.\n * @returns the details needed to create the child node.\n */\n protected getCreateDetailsForChild(id: string, createParam: CreateChildSummarizerNodeParam): ICreateChildDetails {\n let initialSummary: IInitialSummary | undefined;\n let latestSummary: SummaryNode | undefined;\n let changeSequenceNumber: number;\n\n const parentLatestSummary = this._latestSummary;\n switch (createParam.type) {\n case CreateSummarizerNodeSource.FromAttach: {\n if (\n parentLatestSummary !== undefined\n && createParam.sequenceNumber <= parentLatestSummary.referenceSequenceNumber\n ) {\n // Prioritize latest summary if it was after this node was attached.\n latestSummary = parentLatestSummary.createForChild(id);\n } else {\n const summary = convertToSummaryTree(createParam.snapshot) as ISummaryTreeWithStats;\n initialSummary = {\n sequenceNumber: createParam.sequenceNumber,\n id,\n summary,\n };\n }\n changeSequenceNumber = createParam.sequenceNumber;\n break;\n }\n case CreateSummarizerNodeSource.FromSummary: {\n if (this.initialSummary === undefined) {\n assert(\n !!parentLatestSummary,\n 0x1ac /* \"Cannot create child from summary if parent does not have latest summary\" */);\n }\n // fallthrough to local\n }\n case CreateSummarizerNodeSource.Local: {\n const parentInitialSummary = this.initialSummary;\n if (parentInitialSummary !== undefined) {\n let childSummary: SummaryObject | undefined;\n if (parentInitialSummary.summary !== undefined) {\n const { childrenTree } = parseSummaryTreeForSubtrees(parentInitialSummary.summary.summary);\n assert(\n childrenTree.type === SummaryType.Tree,\n 0x1d6 /* \"Parent summary object is not a tree\" */,\n );\n childSummary = childrenTree.tree[id];\n }\n if (createParam.type === CreateSummarizerNodeSource.FromSummary) {\n // Locally created would not have differential subtree.\n assert(!!childSummary, 0x1ad /* \"Missing child summary tree\" */);\n }\n let childSummaryWithStats: ISummaryTreeWithStats | undefined;\n if (childSummary !== undefined) {\n assert(\n childSummary.type === SummaryType.Tree,\n 0x1ae /* \"Child summary object is not a tree\" */,\n );\n childSummaryWithStats = {\n summary: childSummary,\n stats: calculateStats(childSummary),\n };\n }\n initialSummary = {\n sequenceNumber: parentInitialSummary.sequenceNumber,\n id,\n summary: childSummaryWithStats,\n };\n }\n latestSummary = parentLatestSummary?.createForChild(id);\n changeSequenceNumber = parentLatestSummary?.referenceSequenceNumber ?? -1;\n break;\n }\n default: {\n const type = (createParam as unknown as CreateChildSummarizerNodeParam).type;\n unreachableCase(createParam, `Unexpected CreateSummarizerNodeSource: ${type}`);\n }\n }\n\n return {\n initialSummary,\n latestSummary,\n changeSequenceNumber,\n };\n }\n\n /**\n * Updates the state of the child if required. For example, if a summary is currently being tracked, the child's\n * summary tracking state needs to be updated too.\n * @param child - The child node whose state is to be updated.\n */\n protected maybeUpdateChildState(child: SummarizerNode) {\n // If we are tracking a summary, this child was created after the tracking started. So, we need to update the\n // child's tracking state as well.\n if (this.isTrackingInProgress()) {\n child.wipReferenceSequenceNumber = this.wipReferenceSequenceNumber;\n }\n }\n\n /**\n * Tells whether summary tracking is in progress. True if \"startSummary\" API is called before summarize.\n */\n protected isTrackingInProgress(): boolean {\n return this.wipReferenceSequenceNumber !== undefined;\n }\n}\n\n/**\n * Creates a root summarizer node.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n */\nexport const createRootSummarizerNode = (\n logger: ITelemetryLogger,\n summarizeInternalFn: SummarizeInternalFn,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfig = {},\n): IRootSummarizerNode => new SummarizerNode(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n );\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
- import { ISnapshotTree, ISequencedDocumentMessage, ISummaryTree, SummaryObject } from "@fluidframework/protocol-definitions";
6
+ import { ISnapshotTree, ISummaryTree, SummaryObject } from "@fluidframework/protocol-definitions";
7
7
  import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
8
  import { ReadAndParseBlob } from "../utils";
9
9
  /**
@@ -71,32 +71,6 @@ export declare class SummaryNode {
71
71
  */
72
72
  createForChild(id: string): SummaryNode;
73
73
  }
74
- /** Result from decoding summary which may have been a differential summary. */
75
- interface IDecodedSummary {
76
- /** The innermost base summary which is not itself a differential summary */
77
- readonly baseSummary: ISnapshotTree;
78
- /** The entire path name to the innermost base summary */
79
- readonly pathParts: string[];
80
- /** Function to fetch all outstanding ops since the innermost base summary */
81
- getOutstandingOps(readAndParseBlob: ReadAndParseBlob): Promise<ISequencedDocumentMessage[]>;
82
- }
83
- /**
84
- * Checks if the snapshot is created by referencing a previous successful
85
- * summary plus outstanding ops. If so, it will recursively "decode" it until
86
- * it gets to the last successful summary (the base summary) and returns that
87
- * as well as a function for fetching the outstanding ops. Also returns the
88
- * full path to the previous base summary for child summarizer nodes to use as
89
- * their base path when necessary.
90
- * @param snapshot - snapshot tree to decode
91
- */
92
- export declare function decodeSummary(snapshot: ISnapshotTree, logger: Pick<ITelemetryLogger, "sendTelemetryEvent">): IDecodedSummary;
93
- /**
94
- * Summary tree which is a handle of the previous successfully acked summary
95
- * and a blob of the outstanding ops since that summary.
96
- */
97
- interface IEncodedSummary extends ISummaryTreeWithStats {
98
- readonly additionalPath: EscapedPath;
99
- }
100
74
  /**
101
75
  * Parameter to help encode summary with conditional behavior.
102
76
  * When fromSummary is true, it will contain the SummaryNode of
@@ -111,15 +85,6 @@ export declare type EncodeSummaryParam = {
111
85
  fromSummary: false;
112
86
  initialSummary: ISummaryTreeWithStats;
113
87
  };
114
- /**
115
- * Creates a summary tree which is a handle of the previous successfully acked summary
116
- * and a blob of the outstanding ops since that summary. If there is no acked summary yet,
117
- * it will create with the tree found in the initial attach op and the blob of outstanding ops.
118
- * @param summaryParam - information about last acked summary and paths to encode if from summary,
119
- * otherwise the initial summary from the attach op.
120
- * @param outstandingOps - outstanding ops since last acked summary
121
- */
122
- export declare function encodeSummary(summaryParam: EncodeSummaryParam, outstandingOps: ISequencedDocumentMessage[]): IEncodedSummary;
123
88
  /**
124
89
  * Information about the initial summary tree found from an attach op.
125
90
  */
@@ -157,5 +122,4 @@ export declare function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISu
157
122
  * @param baseSummary - summary to check
158
123
  */
159
124
  export declare function parseSummaryTreeForSubtrees(summary: ISummaryTree): ISubtreeInfo<SummaryObject>;
160
- export {};
161
125
  //# sourceMappingURL=summarizerNodeUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNodeUtils.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EACH,aAAa,EACb,yBAAyB,EAEzB,YAAY,EACZ,aAAa,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAoB,qBAAqB,EAAE,MAAM,qCA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B,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC,CAa/F;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,CAa9F"}
@@ -4,14 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.parseSummaryTreeForSubtrees = exports.parseSummaryForSubtrees = exports.encodeSummary = exports.decodeSummary = exports.SummaryNode = exports.EscapedPath = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
9
- const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
7
+ exports.parseSummaryTreeForSubtrees = exports.parseSummaryForSubtrees = exports.SummaryNode = exports.EscapedPath = void 0;
10
8
  const runtime_definitions_1 = require("@fluidframework/runtime-definitions");
11
- const summaryUtils_1 = require("../summaryUtils");
12
- const baseSummaryTreeKey = "_baseSummary";
13
- const outstandingOpsBlobKey = "_outstandingOps";
14
- const maxDecodeDepth = 100;
15
9
  /** Path for nodes in a tree with escaped special characters */
16
10
  class EscapedPath {
17
11
  constructor(path) {
@@ -95,93 +89,6 @@ class SummaryNode {
95
89
  }
96
90
  }
97
91
  exports.SummaryNode = SummaryNode;
98
- /**
99
- * Checks if the snapshot is created by referencing a previous successful
100
- * summary plus outstanding ops. If so, it will recursively "decode" it until
101
- * it gets to the last successful summary (the base summary) and returns that
102
- * as well as a function for fetching the outstanding ops. Also returns the
103
- * full path to the previous base summary for child summarizer nodes to use as
104
- * their base path when necessary.
105
- * @param snapshot - snapshot tree to decode
106
- */
107
- function decodeSummary(snapshot, logger) {
108
- let baseSummary = snapshot;
109
- const pathParts = [];
110
- const opsBlobs = [];
111
- for (let i = 0;; i++) {
112
- if (i > maxDecodeDepth) {
113
- logger.sendTelemetryEvent({
114
- eventName: "DecodeSummaryMaxDepth",
115
- maxDecodeDepth,
116
- });
117
- }
118
- const outstandingOpsBlob = baseSummary.blobs[outstandingOpsBlobKey];
119
- const newBaseSummary = baseSummary.trees[baseSummaryTreeKey];
120
- if (outstandingOpsBlob === undefined && newBaseSummary === undefined) {
121
- return {
122
- baseSummary,
123
- pathParts,
124
- async getOutstandingOps(readAndParseBlob) {
125
- let outstandingOps = [];
126
- for (const opsBlob of opsBlobs) {
127
- const newOutstandingOps = await readAndParseBlob(opsBlob);
128
- if (outstandingOps.length > 0 && newOutstandingOps.length > 0) {
129
- const latestSeq = outstandingOps[outstandingOps.length - 1].sequenceNumber;
130
- const newEarliestSeq = newOutstandingOps[0].sequenceNumber;
131
- if (newEarliestSeq <= latestSeq) {
132
- logger.sendTelemetryEvent({
133
- eventName: "DuplicateOutstandingOps",
134
- // eslint-disable-next-line max-len
135
- message: `newEarliestSeq <= latestSeq in decodeSummary: ${newEarliestSeq} <= ${latestSeq}`,
136
- });
137
- while (newOutstandingOps.length > 0
138
- && newOutstandingOps[0].sequenceNumber <= latestSeq) {
139
- newOutstandingOps.shift();
140
- }
141
- }
142
- }
143
- outstandingOps = outstandingOps.concat(newOutstandingOps);
144
- }
145
- return outstandingOps;
146
- },
147
- };
148
- }
149
- (0, common_utils_1.assert)(!!outstandingOpsBlob, 0x1af /* "Outstanding ops blob missing, but base summary tree exists" */);
150
- (0, common_utils_1.assert)(newBaseSummary !== undefined, 0x1b0 /* "Base summary tree missing, but outstanding ops blob exists" */);
151
- baseSummary = newBaseSummary;
152
- pathParts.push(baseSummaryTreeKey);
153
- opsBlobs.unshift(outstandingOpsBlob);
154
- }
155
- }
156
- exports.decodeSummary = decodeSummary;
157
- /**
158
- * Creates a summary tree which is a handle of the previous successfully acked summary
159
- * and a blob of the outstanding ops since that summary. If there is no acked summary yet,
160
- * it will create with the tree found in the initial attach op and the blob of outstanding ops.
161
- * @param summaryParam - information about last acked summary and paths to encode if from summary,
162
- * otherwise the initial summary from the attach op.
163
- * @param outstandingOps - outstanding ops since last acked summary
164
- */
165
- function encodeSummary(summaryParam, outstandingOps) {
166
- let additionalPath = EscapedPath.create(baseSummaryTreeKey);
167
- const builder = new summaryUtils_1.SummaryTreeBuilder();
168
- builder.addBlob(outstandingOpsBlobKey, JSON.stringify(outstandingOps));
169
- if (summaryParam.fromSummary) {
170
- // Create using handle of latest acked summary
171
- const summaryNode = summaryParam.summaryNode;
172
- if (summaryNode.additionalPath !== undefined) {
173
- additionalPath = additionalPath.concat(summaryNode.additionalPath);
174
- }
175
- builder.addHandle(baseSummaryTreeKey, protocol_definitions_1.SummaryType.Tree, summaryNode.fullPath.path);
176
- }
177
- else {
178
- // Create using initial summary from attach op
179
- builder.addWithStats(baseSummaryTreeKey, summaryParam.initialSummary);
180
- }
181
- const summary = builder.getSummaryTree();
182
- return Object.assign(Object.assign({}, summary), { additionalPath });
183
- }
184
- exports.encodeSummary = encodeSummary;
185
92
  /**
186
93
  * Checks if the summary contains .channels subtree where the children subtrees
187
94
  * would be located if exists.