@fluidframework/container-runtime 2.0.0-internal.6.2.0 → 2.0.0-internal.6.3.0

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.
Files changed (310) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/batchTracker.d.ts.map +1 -1
  3. package/dist/batchTracker.js +4 -3
  4. package/dist/batchTracker.js.map +1 -1
  5. package/dist/blobManager.d.ts +1 -2
  6. package/dist/blobManager.d.ts.map +1 -1
  7. package/dist/blobManager.js +81 -69
  8. package/dist/blobManager.js.map +1 -1
  9. package/dist/connectionTelemetry.d.ts.map +1 -1
  10. package/dist/connectionTelemetry.js +13 -12
  11. package/dist/connectionTelemetry.js.map +1 -1
  12. package/dist/containerRuntime.d.ts +18 -3
  13. package/dist/containerRuntime.d.ts.map +1 -1
  14. package/dist/containerRuntime.js +185 -145
  15. package/dist/containerRuntime.js.map +1 -1
  16. package/dist/dataStore.js +3 -3
  17. package/dist/dataStore.js.map +1 -1
  18. package/dist/dataStoreContext.d.ts +2 -1
  19. package/dist/dataStoreContext.d.ts.map +1 -1
  20. package/dist/dataStoreContext.js +36 -36
  21. package/dist/dataStoreContext.js.map +1 -1
  22. package/dist/dataStoreContexts.d.ts.map +1 -1
  23. package/dist/dataStoreContexts.js +7 -8
  24. package/dist/dataStoreContexts.js.map +1 -1
  25. package/dist/dataStores.d.ts.map +1 -1
  26. package/dist/dataStores.js +19 -20
  27. package/dist/dataStores.js.map +1 -1
  28. package/dist/deltaManagerProxyBase.d.ts +1 -1
  29. package/dist/deltaManagerProxyBase.js +2 -2
  30. package/dist/deltaManagerProxyBase.js.map +1 -1
  31. package/dist/deltaScheduler.js +6 -6
  32. package/dist/deltaScheduler.js.map +1 -1
  33. package/dist/gc/garbageCollection.d.ts +3 -5
  34. package/dist/gc/garbageCollection.d.ts.map +1 -1
  35. package/dist/gc/garbageCollection.js +4 -21
  36. package/dist/gc/garbageCollection.js.map +1 -1
  37. package/dist/gc/gcDefinitions.d.ts +2 -2
  38. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  39. package/dist/gc/gcDefinitions.js.map +1 -1
  40. package/dist/gc/gcHelpers.js +7 -7
  41. package/dist/gc/gcHelpers.js.map +1 -1
  42. package/dist/gc/gcSummaryStateTracker.d.ts +4 -7
  43. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  44. package/dist/gc/gcSummaryStateTracker.js +15 -52
  45. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  46. package/dist/gc/gcUnreferencedStateTracker.js +4 -4
  47. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  48. package/dist/gc/index.d.ts +1 -1
  49. package/dist/gc/index.d.ts.map +1 -1
  50. package/dist/gc/index.js +1 -2
  51. package/dist/gc/index.js.map +1 -1
  52. package/dist/id-compressor/appendOnlySortedMap.js +2 -2
  53. package/dist/id-compressor/appendOnlySortedMap.js.map +1 -1
  54. package/dist/id-compressor/finalSpace.js +2 -2
  55. package/dist/id-compressor/finalSpace.js.map +1 -1
  56. package/dist/id-compressor/idCompressor.d.ts.map +1 -1
  57. package/dist/id-compressor/idCompressor.js +16 -15
  58. package/dist/id-compressor/idCompressor.js.map +1 -1
  59. package/dist/id-compressor/sessions.js +5 -5
  60. package/dist/id-compressor/sessions.js.map +1 -1
  61. package/dist/id-compressor/utilities.js +2 -2
  62. package/dist/id-compressor/utilities.js.map +1 -1
  63. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  64. package/dist/opLifecycle/opCompressor.js +4 -3
  65. package/dist/opLifecycle/opCompressor.js.map +1 -1
  66. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  67. package/dist/opLifecycle/opDecompressor.js +11 -10
  68. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  69. package/dist/opLifecycle/opGroupingManager.js +3 -3
  70. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  71. package/dist/opLifecycle/opSplitter.js +12 -12
  72. package/dist/opLifecycle/opSplitter.js.map +1 -1
  73. package/dist/opLifecycle/outbox.js +6 -6
  74. package/dist/opLifecycle/outbox.js.map +1 -1
  75. package/dist/packageVersion.d.ts +1 -1
  76. package/dist/packageVersion.js +1 -1
  77. package/dist/packageVersion.js.map +1 -1
  78. package/dist/pendingStateManager.d.ts.map +1 -1
  79. package/dist/pendingStateManager.js +12 -13
  80. package/dist/pendingStateManager.js.map +1 -1
  81. package/dist/scheduleManager.d.ts.map +1 -1
  82. package/dist/scheduleManager.js +19 -18
  83. package/dist/scheduleManager.js.map +1 -1
  84. package/dist/summary/index.d.ts +1 -1
  85. package/dist/summary/index.d.ts.map +1 -1
  86. package/dist/summary/index.js.map +1 -1
  87. package/dist/summary/orderedClientElection.d.ts +1 -1
  88. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  89. package/dist/summary/orderedClientElection.js +6 -5
  90. package/dist/summary/orderedClientElection.js.map +1 -1
  91. package/dist/summary/runWhileConnectedCoordinator.js +3 -3
  92. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  93. package/dist/summary/runningSummarizer.d.ts +1 -1
  94. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  95. package/dist/summary/runningSummarizer.js +13 -12
  96. package/dist/summary/runningSummarizer.js.map +1 -1
  97. package/dist/summary/summarizer.d.ts +1 -1
  98. package/dist/summary/summarizer.d.ts.map +1 -1
  99. package/dist/summary/summarizer.js +4 -3
  100. package/dist/summary/summarizer.js.map +1 -1
  101. package/dist/summary/summarizerClientElection.d.ts +1 -1
  102. package/dist/summary/summarizerClientElection.js +2 -2
  103. package/dist/summary/summarizerClientElection.js.map +1 -1
  104. package/dist/summary/summarizerHeuristics.js +2 -2
  105. package/dist/summary/summarizerHeuristics.js.map +1 -1
  106. package/dist/summary/summarizerNode/index.d.ts +1 -1
  107. package/dist/summary/summarizerNode/index.d.ts.map +1 -1
  108. package/dist/summary/summarizerNode/index.js.map +1 -1
  109. package/dist/summary/summarizerNode/summarizerNode.d.ts +5 -14
  110. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  111. package/dist/summary/summarizerNode/summarizerNode.js +32 -109
  112. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  113. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +6 -30
  114. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  115. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  116. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +0 -11
  117. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  118. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +5 -88
  119. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  120. package/dist/summary/summaryCollection.d.ts +1 -1
  121. package/dist/summary/summaryCollection.d.ts.map +1 -1
  122. package/dist/summary/summaryCollection.js +9 -8
  123. package/dist/summary/summaryCollection.js.map +1 -1
  124. package/dist/summary/summaryFormat.js +2 -2
  125. package/dist/summary/summaryFormat.js.map +1 -1
  126. package/dist/summary/summaryGenerator.d.ts +1 -1
  127. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  128. package/dist/summary/summaryGenerator.js +10 -10
  129. package/dist/summary/summaryGenerator.js.map +1 -1
  130. package/dist/summary/summaryManager.d.ts +1 -1
  131. package/dist/summary/summaryManager.d.ts.map +1 -1
  132. package/dist/summary/summaryManager.js +9 -8
  133. package/dist/summary/summaryManager.js.map +1 -1
  134. package/lib/batchTracker.d.ts.map +1 -1
  135. package/lib/batchTracker.js +2 -1
  136. package/lib/batchTracker.js.map +1 -1
  137. package/lib/blobManager.d.ts +1 -2
  138. package/lib/blobManager.d.ts.map +1 -1
  139. package/lib/blobManager.js +52 -40
  140. package/lib/blobManager.js.map +1 -1
  141. package/lib/connectionTelemetry.d.ts.map +1 -1
  142. package/lib/connectionTelemetry.js +2 -1
  143. package/lib/connectionTelemetry.js.map +1 -1
  144. package/lib/containerRuntime.d.ts +18 -3
  145. package/lib/containerRuntime.d.ts.map +1 -1
  146. package/lib/containerRuntime.js +147 -107
  147. package/lib/containerRuntime.js.map +1 -1
  148. package/lib/dataStore.js +1 -1
  149. package/lib/dataStore.js.map +1 -1
  150. package/lib/dataStoreContext.d.ts +2 -1
  151. package/lib/dataStoreContext.d.ts.map +1 -1
  152. package/lib/dataStoreContext.js +2 -2
  153. package/lib/dataStoreContext.js.map +1 -1
  154. package/lib/dataStoreContexts.d.ts.map +1 -1
  155. package/lib/dataStoreContexts.js +1 -2
  156. package/lib/dataStoreContexts.js.map +1 -1
  157. package/lib/dataStores.d.ts.map +1 -1
  158. package/lib/dataStores.js +1 -2
  159. package/lib/dataStores.js.map +1 -1
  160. package/lib/deltaManagerProxyBase.d.ts +1 -1
  161. package/lib/deltaManagerProxyBase.js +1 -1
  162. package/lib/deltaManagerProxyBase.js.map +1 -1
  163. package/lib/deltaScheduler.js +1 -1
  164. package/lib/deltaScheduler.js.map +1 -1
  165. package/lib/gc/garbageCollection.d.ts +3 -5
  166. package/lib/gc/garbageCollection.d.ts.map +1 -1
  167. package/lib/gc/garbageCollection.js +5 -22
  168. package/lib/gc/garbageCollection.js.map +1 -1
  169. package/lib/gc/gcDefinitions.d.ts +2 -2
  170. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  171. package/lib/gc/gcDefinitions.js.map +1 -1
  172. package/lib/gc/gcHelpers.js +1 -1
  173. package/lib/gc/gcHelpers.js.map +1 -1
  174. package/lib/gc/gcSummaryStateTracker.d.ts +4 -7
  175. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
  176. package/lib/gc/gcSummaryStateTracker.js +16 -53
  177. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  178. package/lib/gc/gcUnreferencedStateTracker.js +1 -1
  179. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  180. package/lib/gc/index.d.ts +1 -1
  181. package/lib/gc/index.d.ts.map +1 -1
  182. package/lib/gc/index.js +1 -1
  183. package/lib/gc/index.js.map +1 -1
  184. package/lib/id-compressor/appendOnlySortedMap.js +1 -1
  185. package/lib/id-compressor/appendOnlySortedMap.js.map +1 -1
  186. package/lib/id-compressor/finalSpace.js +1 -1
  187. package/lib/id-compressor/finalSpace.js.map +1 -1
  188. package/lib/id-compressor/idCompressor.d.ts.map +1 -1
  189. package/lib/id-compressor/idCompressor.js +2 -1
  190. package/lib/id-compressor/idCompressor.js.map +1 -1
  191. package/lib/id-compressor/sessions.js +1 -1
  192. package/lib/id-compressor/sessions.js.map +1 -1
  193. package/lib/id-compressor/utilities.js +1 -1
  194. package/lib/id-compressor/utilities.js.map +1 -1
  195. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  196. package/lib/opLifecycle/opCompressor.js +2 -1
  197. package/lib/opLifecycle/opCompressor.js.map +1 -1
  198. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  199. package/lib/opLifecycle/opDecompressor.js +2 -1
  200. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  201. package/lib/opLifecycle/opGroupingManager.js +1 -1
  202. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  203. package/lib/opLifecycle/opSplitter.js +1 -1
  204. package/lib/opLifecycle/opSplitter.js.map +1 -1
  205. package/lib/opLifecycle/outbox.js +1 -1
  206. package/lib/opLifecycle/outbox.js.map +1 -1
  207. package/lib/packageVersion.d.ts +1 -1
  208. package/lib/packageVersion.js +1 -1
  209. package/lib/packageVersion.js.map +1 -1
  210. package/lib/pendingStateManager.d.ts.map +1 -1
  211. package/lib/pendingStateManager.js +1 -2
  212. package/lib/pendingStateManager.js.map +1 -1
  213. package/lib/scheduleManager.d.ts.map +1 -1
  214. package/lib/scheduleManager.js +2 -1
  215. package/lib/scheduleManager.js.map +1 -1
  216. package/lib/summary/index.d.ts +1 -1
  217. package/lib/summary/index.d.ts.map +1 -1
  218. package/lib/summary/index.js.map +1 -1
  219. package/lib/summary/orderedClientElection.d.ts +1 -1
  220. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  221. package/lib/summary/orderedClientElection.js +2 -1
  222. package/lib/summary/orderedClientElection.js.map +1 -1
  223. package/lib/summary/runWhileConnectedCoordinator.js +1 -1
  224. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  225. package/lib/summary/runningSummarizer.d.ts +1 -1
  226. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  227. package/lib/summary/runningSummarizer.js +5 -4
  228. package/lib/summary/runningSummarizer.js.map +1 -1
  229. package/lib/summary/summarizer.d.ts +1 -1
  230. package/lib/summary/summarizer.d.ts.map +1 -1
  231. package/lib/summary/summarizer.js +2 -1
  232. package/lib/summary/summarizer.js.map +1 -1
  233. package/lib/summary/summarizerClientElection.d.ts +1 -1
  234. package/lib/summary/summarizerClientElection.js +1 -1
  235. package/lib/summary/summarizerClientElection.js.map +1 -1
  236. package/lib/summary/summarizerHeuristics.js +1 -1
  237. package/lib/summary/summarizerHeuristics.js.map +1 -1
  238. package/lib/summary/summarizerNode/index.d.ts +1 -1
  239. package/lib/summary/summarizerNode/index.d.ts.map +1 -1
  240. package/lib/summary/summarizerNode/index.js.map +1 -1
  241. package/lib/summary/summarizerNode/summarizerNode.d.ts +5 -14
  242. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  243. package/lib/summary/summarizerNode/summarizerNode.js +16 -93
  244. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  245. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +6 -30
  246. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  247. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  248. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +0 -11
  249. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  250. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +3 -86
  251. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  252. package/lib/summary/summaryCollection.d.ts +1 -1
  253. package/lib/summary/summaryCollection.d.ts.map +1 -1
  254. package/lib/summary/summaryCollection.js +2 -1
  255. package/lib/summary/summaryCollection.js.map +1 -1
  256. package/lib/summary/summaryFormat.js +1 -1
  257. package/lib/summary/summaryFormat.js.map +1 -1
  258. package/lib/summary/summaryGenerator.d.ts +1 -1
  259. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  260. package/lib/summary/summaryGenerator.js +3 -3
  261. package/lib/summary/summaryGenerator.js.map +1 -1
  262. package/lib/summary/summaryManager.d.ts +1 -1
  263. package/lib/summary/summaryManager.d.ts.map +1 -1
  264. package/lib/summary/summaryManager.js +4 -3
  265. package/lib/summary/summaryManager.js.map +1 -1
  266. package/package.json +22 -24
  267. package/src/batchTracker.ts +2 -1
  268. package/src/blobManager.ts +57 -48
  269. package/src/connectionTelemetry.ts +2 -1
  270. package/src/containerRuntime.ts +207 -166
  271. package/src/dataStore.ts +1 -1
  272. package/src/dataStoreContext.ts +2 -2
  273. package/src/dataStoreContexts.ts +1 -2
  274. package/src/dataStores.ts +1 -2
  275. package/src/deltaManagerProxyBase.ts +1 -1
  276. package/src/deltaScheduler.ts +1 -1
  277. package/src/gc/garbageCollection.ts +6 -41
  278. package/src/gc/gcDefinitions.ts +2 -6
  279. package/src/gc/gcHelpers.ts +1 -1
  280. package/src/gc/gcSummaryStateTracker.ts +19 -65
  281. package/src/gc/gcUnreferencedStateTracker.ts +1 -1
  282. package/src/gc/index.ts +0 -1
  283. package/src/id-compressor/appendOnlySortedMap.ts +1 -1
  284. package/src/id-compressor/finalSpace.ts +1 -1
  285. package/src/id-compressor/idCompressor.ts +2 -1
  286. package/src/id-compressor/sessions.ts +1 -1
  287. package/src/id-compressor/utilities.ts +1 -1
  288. package/src/opLifecycle/opCompressor.ts +2 -1
  289. package/src/opLifecycle/opDecompressor.ts +2 -1
  290. package/src/opLifecycle/opGroupingManager.ts +1 -1
  291. package/src/opLifecycle/opSplitter.ts +1 -1
  292. package/src/opLifecycle/outbox.ts +1 -1
  293. package/src/packageVersion.ts +1 -1
  294. package/src/pendingStateManager.ts +1 -2
  295. package/src/scheduleManager.ts +2 -1
  296. package/src/summary/index.ts +1 -2
  297. package/src/summary/orderedClientElection.ts +2 -1
  298. package/src/summary/runWhileConnectedCoordinator.ts +1 -1
  299. package/src/summary/runningSummarizer.ts +5 -10
  300. package/src/summary/summarizer.ts +2 -1
  301. package/src/summary/summarizerClientElection.ts +1 -1
  302. package/src/summary/summarizerHeuristics.ts +1 -1
  303. package/src/summary/summarizerNode/index.ts +1 -2
  304. package/src/summary/summarizerNode/summarizerNode.ts +23 -145
  305. package/src/summary/summarizerNode/summarizerNodeUtils.ts +7 -38
  306. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +3 -123
  307. package/src/summary/summaryCollection.ts +2 -1
  308. package/src/summary/summaryFormat.ts +1 -1
  309. package/src/summary/summaryGenerator.ts +3 -3
  310. package/src/summary/summaryManager.ts +4 -3
@@ -1 +1 @@
1
- {"version":3,"file":"gcSummaryStateTracker.d.ts","sourceRoot":"","sources":["../../src/gc/gcSummaryStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAKN,gBAAgB,EAEhB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAc,gBAAgB,EAAsB,MAAM,+BAA+B,CAAC;AACjG,OAAO,EAA+C,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAa,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,8BAA8B,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,GAAG,CAAC;AAE7C,eAAO,MAAM,cAAc,QAAyB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,sBAAsB,EAAE,MAAM,GAAG,SAAS,CA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M,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB/E;;OAEG;IACI,yBAAyB,CAAC,KAAK,EAAE,QAAQ;CAGhD"}
@@ -5,8 +5,7 @@
5
5
  import { SummaryType } from "@fluidframework/protocol-definitions";
6
6
  import { gcBlobPrefix, gcDeletedBlobKey, gcTombstoneBlobKey, gcTreeKey, } from "@fluidframework/runtime-definitions";
7
7
  import { mergeStats, SummaryTreeBuilder } from "@fluidframework/runtime-utils";
8
- import { metadataBlobName } from "../summary";
9
- import { getGCDataFromSnapshot, generateSortedGCState, getGCVersion } from "./gcHelpers";
8
+ import { generateSortedGCState } from "./gcHelpers";
10
9
  export const gcStateBlobKey = `${gcBlobPrefix}_root`;
11
10
  /**
12
11
  * Encapsulates the garbage collection state that is tracked across summaries.
@@ -178,60 +177,24 @@ export class GCSummaryStateTracker {
178
177
  return builder.getSummaryTree();
179
178
  }
180
179
  /**
181
- * Called to refresh the latest summary state. This happens when either a pending summary is acked or a snapshot
182
- * is downloaded and should be used to update the state.
180
+ * Called to refresh the latest summary state. This happens when either a pending summary is acked.
183
181
  */
184
- async refreshLatestSummary(proposalHandle, result, readAndParseBlob) {
185
- // If the latest summary was updated and the summary was tracked, this client is the one that generated this
186
- // summary. So, update wasGCRunInLatestSummary.
187
- // Note that this has to be updated if GC did not run too. Otherwise, `gcStateNeedsReset` will always return
188
- // true in scenarios where GC is disabled but enabled in the snapshot we loaded from.
189
- if (result.latestSummaryUpdated && result.wasSummaryTracked) {
190
- this.wasGCRunInLatestSummary = this.configs.shouldRunGC;
191
- }
192
- if (!result.latestSummaryUpdated || !this.configs.shouldRunGC) {
193
- return undefined;
194
- }
195
- // If the summary was tracked by this client, it was the one that generated the summary in the first place.
196
- // Update latest state from pending.
197
- if (result.wasSummaryTracked) {
198
- this.latestSummaryGCVersion = this.configs.gcVersionInEffect;
199
- this.latestSummaryData = this.pendingSummaryData;
200
- this.pendingSummaryData = undefined;
201
- this.updatedDSCountSinceLastSummary = 0;
202
- return undefined;
203
- }
204
- // If the summary was not tracked by this client, the state should be updated from the downloaded snapshot.
205
- const snapshotTree = result.snapshotTree;
206
- const metadataBlobId = snapshotTree.blobs[metadataBlobName];
207
- const metadata = metadataBlobId
208
- ? await readAndParseBlob(metadataBlobId)
209
- : undefined;
210
- this.latestSummaryGCVersion = getGCVersion(metadata);
211
- const gcSnapshotTree = snapshotTree.trees[gcTreeKey];
212
- // If GC ran in the container that generated this snapshot, it will have a GC tree.
213
- this.wasGCRunInLatestSummary = gcSnapshotTree !== undefined;
214
- if (gcSnapshotTree === undefined) {
215
- return undefined;
182
+ async refreshLatestSummary(result) {
183
+ if (!result.isSummaryTracked) {
184
+ return;
216
185
  }
217
- let snapshotData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);
218
- // If the GC version in the snapshot does not match the GC version currently in effect, the GC data
219
- // in the snapshot cannot be interpreted correctly. Set everything to undefined except for deletedNodes
220
- // because irrespective of GC versions, these nodes have been deleted and cannot be brought back. The
221
- // deletedNodes info is needed to identify when these nodes are used.
222
- if (getGCVersion(metadata) !== this.configs.gcVersionInEffect) {
223
- snapshotData = {
224
- gcState: undefined,
225
- tombstones: undefined,
226
- deletedNodes: snapshotData.deletedNodes,
227
- };
186
+ // If the summary is tracked, this client is the one that generated it. So, update wasGCRunInLatestSummary.
187
+ // Note that this has to be updated if GC did not run too. Otherwise, `gcStateNeedsReset` will always return
188
+ // true in scenarios where GC is currently disabled but enabled in the snapshot we loaded from.
189
+ this.wasGCRunInLatestSummary = this.configs.shouldRunGC;
190
+ if (!this.configs.shouldRunGC) {
191
+ return;
228
192
  }
229
- this.latestSummaryData = {
230
- serializedGCState: JSON.stringify(snapshotData.gcState),
231
- serializedTombstones: JSON.stringify(snapshotData.tombstones),
232
- serializedDeletedNodes: JSON.stringify(snapshotData.deletedNodes),
233
- };
234
- return snapshotData;
193
+ this.latestSummaryGCVersion = this.configs.gcVersionInEffect;
194
+ this.latestSummaryData = this.pendingSummaryData;
195
+ this.pendingSummaryData = undefined;
196
+ this.updatedDSCountSinceLastSummary = 0;
197
+ return;
235
198
  }
236
199
  /**
237
200
  * Called to update the state from a GC run's stats. Used to update the count of data stores whose state updated.
@@ -1 +1 @@
1
- {"version":3,"file":"gcSummaryStateTracker.js","sourceRoot":"","sources":["../../src/gc/gcSummaryStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,GAGT,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAoB,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjG,OAAO,EAA6B,gBAAgB,EAAwB,MAAM,YAAY,CAAC;AAE/F,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIzF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,YAAY,OAAO,CAAC;AAWrD;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAgBjC;IACC,sCAAsC;IACrB,OAGhB;IACD,4EAA4E;IAC5E,sBAA+B;QALd,YAAO,GAAP,OAAO,CAGvB;QATF,8GAA8G;QAC9G,iCAAiC;QAC1B,mCAA8B,GAAW,CAAC,CAAC;QAWjD,IAAI,CAAC,uBAAuB,GAAG,sBAAsB,CAAC;QACtD,0GAA0G;QAC1G,+GAA+G;QAC/G,IAAI,CAAC,sBAAsB;YAC1B,IAAI,CAAC,OAAO,CAAC,uBAAuB,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;IACzE,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,oBAAoB;QAC9B,OAAO,IAAI,CAAC,uBAAuB,KAAK,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IAClE,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,IAAW,yBAAyB;QACnC,OA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EAAE,SAAS;gBACrB,YAAY,EAAE,YAAY,CAAC,YAAY;aACvC,CAAC;SACF;QAED,IAAI,CAAC,iBAAiB,GAAG;YACxB,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC;YACvD,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC;YAC7D,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC;SACjE,CAAC;QACF,OAAO,YAAY,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,yBAAyB,CAAC,KAAe;QAC/C,IAAI,CAAC,8BAA8B,IAAI,KAAK,CAAC,qBAAqB,CAAC;IACpE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SummaryType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgcBlobPrefix,\n\tgcDeletedBlobKey,\n\tgcTombstoneBlobKey,\n\tgcTreeKey,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport { mergeStats, ReadAndParseBlob, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { IContainerRuntimeMetadata, metadataBlobName, RefreshSummaryResult } from \"../summary\";\nimport { GCVersion, IGCStats } from \"./gcDefinitions\";\nimport { getGCDataFromSnapshot, generateSortedGCState, getGCVersion } from \"./gcHelpers\";\nimport { IGarbageCollectionSnapshotData, IGarbageCollectionState } from \"./gcSummaryDefinitions\";\nimport { IGarbageCollectorConfigs } from \".\";\n\nexport const gcStateBlobKey = `${gcBlobPrefix}_root`;\n\n/**\n * The GC data that is tracked for a summary.\n */\nexport interface IGCSummaryTrackingData {\n\tserializedGCState: string | undefined;\n\tserializedTombstones: string | undefined;\n\tserializedDeletedNodes: string | undefined;\n}\n\n/**\n * Encapsulates the garbage collection state that is tracked across summaries.\n * It maintains the GC state as per the latest summary in by the server. It updates state when a summary tracked by this\n * client is acked by the server or from a snapshot is downloaded from the server.\n * On summarize, it decides whether to write new state or re-use previous summary's state.\n */\nexport class GCSummaryStateTracker {\n\t// This is the version of GC data in the latest summary being tracked.\n\tprivate latestSummaryGCVersion: GCVersion;\n\n\t// Keeps track of the GC data from the latest summary successfully acked by the server.\n\tprivate latestSummaryData: IGCSummaryTrackingData | undefined;\n\t// Keeps track of the GC data from the last summary submitted to the server but not yet acked.\n\tprivate pendingSummaryData: IGCSummaryTrackingData | undefined;\n\n\t// Tracks whether there was GC was run in latest summary being tracked.\n\tprivate wasGCRunInLatestSummary: boolean;\n\n\t// Tracks the count of data stores whose state updated since the last summary, i.e., they went from referenced\n\t// to unreferenced or vice-versa.\n\tpublic updatedDSCountSinceLastSummary: number = 0;\n\n\tconstructor(\n\t\t// Tells whether GC should run or not.\n\t\tprivate readonly configs: Pick<\n\t\t\tIGarbageCollectorConfigs,\n\t\t\t\"shouldRunGC\" | \"tombstoneMode\" | \"gcVersionInBaseSnapshot\" | \"gcVersionInEffect\"\n\t\t>,\n\t\t// Tells whether GC was run in the base snapshot this container loaded from.\n\t\twasGCRunInBaseSnapshot: boolean,\n\t) {\n\t\tthis.wasGCRunInLatestSummary = wasGCRunInBaseSnapshot;\n\t\t// For existing document, the latest summary is the one that we loaded from. So, use its GC version as the\n\t\t// latest tracked GC version. For new documents, we will be writing the first summary with the current version.\n\t\tthis.latestSummaryGCVersion =\n\t\t\tthis.configs.gcVersionInBaseSnapshot ?? this.configs.gcVersionInEffect;\n\t}\n\n\t/**\n\t * Tells whether the GC state needs to be reset. This can happen under 3 conditions:\n\t *\n\t * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after\n\t * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.\n\t *\n\t * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on\n\t * a document and the first time GC is enabled after is was disabled before.\n\t *\n\t * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.\n\t *\n\t * Note that the state will be reset only once for the first summary generated after this returns true. After that,\n\t * this will return false.\n\t */\n\tpublic get doesGCStateNeedReset(): boolean {\n\t\treturn this.wasGCRunInLatestSummary !== this.configs.shouldRunGC;\n\t}\n\n\t/**\n\t * Tells whether the GC state needs to be reset in the next summary. We need to do this if:\n\t *\n\t * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.\n\t *\n\t * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.\n\t *\n\t * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.\n\t *\n\t * 4. The GC version in the latest summary is different from the current GC version. This can happen if:\n\t *\n\t * 4.1. The summary this client loaded with has data from a different GC version.\n\t *\n\t * 4.2. This client's latest summary was updated from a snapshot that has a different GC version.\n\t */\n\tpublic get doesSummaryStateNeedReset(): boolean {\n\t\treturn (\n\t\t\tthis.doesGCStateNeedReset ||\n\t\t\t(this.configs.shouldRunGC &&\n\t\t\t\tthis.latestSummaryGCVersion !== this.configs.gcVersionInEffect)\n\t\t);\n\t}\n\n\t/**\n\t * Called during GC initialization. Initialize the latest summary data from the base snapshot data.\n\t */\n\tpublic initializeBaseState(baseSnapshotData: IGarbageCollectionSnapshotData) {\n\t\t// If tracking state across summaries, update latest summary data from the snapshot's GC data.\n\t\tthis.latestSummaryData = {\n\t\t\tserializedGCState: baseSnapshotData.gcState\n\t\t\t\t? JSON.stringify(generateSortedGCState(baseSnapshotData.gcState))\n\t\t\t\t: undefined,\n\t\t\tserializedTombstones: JSON.stringify(baseSnapshotData.tombstones),\n\t\t\tserializedDeletedNodes: JSON.stringify(baseSnapshotData.deletedNodes),\n\t\t};\n\t}\n\n\t/**\n\t * Summarizes three component of the GC data - GC state, tombstones and deleted nodes.\n\t * It does incremental summary, i.e., it writes summary tree / summary blob only for the component that changed.\n\t * For components that did not change, a summary handle is returned that points to the previous successful summary.\n\t * If none of the components changed, it returns a summary handle for the entire GC data.\n\t */\n\tpublic summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\tgcState: IGarbageCollectionState,\n\t\tdeletedNodes: Set<string>,\n\t\ttombstones: string[],\n\t): ISummarizeResult | undefined {\n\t\tif (!this.configs.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializedGCState = JSON.stringify(generateSortedGCState(gcState));\n\t\t// Serialize and write deleted nodes, if any. This is done irrespective of whether sweep is enabled or not so\n\t\t// to identify deleted nodes' usage.\n\t\tconst serializedDeletedNodes =\n\t\t\tdeletedNodes.size > 0 ? JSON.stringify(Array.from(deletedNodes).sort()) : undefined;\n\t\t// If running in tombstone mode, serialize and write tombstones, if any.\n\t\tconst serializedTombstones = this.configs.tombstoneMode\n\t\t\t? tombstones.length > 0\n\t\t\t\t? JSON.stringify(tombstones.sort())\n\t\t\t\t: undefined\n\t\t\t: undefined;\n\n\t\t/**\n\t\t * Incremental summary of GC data - If none of GC state, deleted nodes or tombstones changed since last summary,\n\t\t * write summary handle instead of summary tree for GC.\n\t\t * Otherwise, write the GC summary tree. In the tree, for each of these that changed, write a summary blob and\n\t\t * for each of these that did not change, write a summary handle.\n\t\t */\n\t\tthis.pendingSummaryData = {\n\t\t\tserializedGCState,\n\t\t\tserializedTombstones,\n\t\t\tserializedDeletedNodes,\n\t\t};\n\n\t\tif (trackState && !fullTree && this.latestSummaryData !== undefined) {\n\t\t\t// If nothing changed since last summary, send a summary handle for the entire GC data.\n\t\t\tif (\n\t\t\t\tthis.latestSummaryData.serializedGCState === serializedGCState &&\n\t\t\t\tthis.latestSummaryData.serializedTombstones === serializedTombstones &&\n\t\t\t\tthis.latestSummaryData.serializedDeletedNodes === serializedDeletedNodes\n\t\t\t) {\n\t\t\t\tconst stats = mergeStats();\n\t\t\t\tstats.handleNodeCount++;\n\t\t\t\treturn {\n\t\t\t\t\tsummary: {\n\t\t\t\t\t\ttype: SummaryType.Handle,\n\t\t\t\t\t\thandle: `/${gcTreeKey}`,\n\t\t\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\t\t},\n\t\t\t\t\tstats,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If some state changed, build a GC summary tree.\n\t\t\treturn this.buildGCSummaryTree(\n\t\t\t\tserializedGCState,\n\t\t\t\tserializedTombstones,\n\t\t\t\tserializedDeletedNodes,\n\t\t\t\ttrue /* trackState */,\n\t\t\t);\n\t\t}\n\t\t// If not tracking GC state, build a GC summary tree without any summary handles.\n\t\treturn this.buildGCSummaryTree(\n\t\t\tserializedGCState,\n\t\t\tserializedTombstones,\n\t\t\tserializedDeletedNodes,\n\t\t\tfalse /* trackState */,\n\t\t);\n\t}\n\n\t/**\n\t * Builds the GC summary tree which contains GC state, deleted nodes and tombstones.\n\t * If trackState is false, all of GC state, deleted nodes and tombstones are written as summary blobs.\n\t * If trackState is true, only states that changed are written. Rest are written as handles.\n\t * @param serializedGCState - The GC state serialized as string.\n\t * @param serializedTombstones - The tombstone state serialized as string.\n\t * @param serializedDeletedNodes - Deleted nodes serialized as string.\n\t * @param trackState - Whether we are tracking GC state across summaries.\n\t * @returns the GC summary tree.\n\t */\n\tprivate buildGCSummaryTree(\n\t\tserializedGCState: string,\n\t\tserializedTombstones: string | undefined,\n\t\tserializedDeletedNodes: string | undefined,\n\t\ttrackState: boolean,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\t// If the GC state hasn't changed, write a summary handle, else write a summary blob for it.\n\t\tif (this.latestSummaryData?.serializedGCState === serializedGCState && trackState) {\n\t\t\tbuilder.addHandle(gcStateBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcStateBlobKey}`);\n\t\t} else {\n\t\t\tbuilder.addBlob(gcStateBlobKey, serializedGCState);\n\t\t}\n\n\t\t// If tombstones exist, write a summary handle if it hasn't changed. If it has changed, write a\n\t\t// summary blob.\n\t\tif (serializedTombstones !== undefined) {\n\t\t\tif (\n\t\t\t\tthis.latestSummaryData?.serializedTombstones === serializedTombstones &&\n\t\t\t\ttrackState\n\t\t\t) {\n\t\t\t\tbuilder.addHandle(\n\t\t\t\t\tgcTombstoneBlobKey,\n\t\t\t\t\tSummaryType.Blob,\n\t\t\t\t\t`/${gcTreeKey}/${gcTombstoneBlobKey}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tbuilder.addBlob(gcTombstoneBlobKey, serializedTombstones);\n\t\t\t}\n\t\t}\n\n\t\t// If there are no deleted nodes, return the summary tree.\n\t\tif (serializedDeletedNodes === undefined) {\n\t\t\treturn builder.getSummaryTree();\n\t\t}\n\n\t\t// If the deleted nodes hasn't changed, write a summary handle, else write a summary blob for it.\n\t\tif (\n\t\t\tthis.latestSummaryData?.serializedDeletedNodes === serializedDeletedNodes &&\n\t\t\ttrackState\n\t\t) {\n\t\t\tbuilder.addHandle(\n\t\t\t\tgcDeletedBlobKey,\n\t\t\t\tSummaryType.Blob,\n\t\t\t\t`/${gcTreeKey}/${gcDeletedBlobKey}`,\n\t\t\t);\n\t\t} else {\n\t\t\tbuilder.addBlob(gcDeletedBlobKey, serializedDeletedNodes);\n\t\t}\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Called to refresh the latest summary state. This happens when either a pending summary is acked or a snapshot\n\t * is downloaded and should be used to update the state.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tresult: RefreshSummaryResult,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<IGarbageCollectionSnapshotData | undefined> {\n\t\t// If the latest summary was updated and the summary was tracked, this client is the one that generated this\n\t\t// summary. So, update wasGCRunInLatestSummary.\n\t\t// Note that this has to be updated if GC did not run too. Otherwise, `gcStateNeedsReset` will always return\n\t\t// true in scenarios where GC is disabled but enabled in the snapshot we loaded from.\n\t\tif (result.latestSummaryUpdated && result.wasSummaryTracked) {\n\t\t\tthis.wasGCRunInLatestSummary = this.configs.shouldRunGC;\n\t\t}\n\n\t\tif (!result.latestSummaryUpdated || !this.configs.shouldRunGC) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// If the summary was tracked by this client, it was the one that generated the summary in the first place.\n\t\t// Update latest state from pending.\n\t\tif (result.wasSummaryTracked) {\n\t\t\tthis.latestSummaryGCVersion = this.configs.gcVersionInEffect;\n\t\t\tthis.latestSummaryData = this.pendingSummaryData;\n\t\t\tthis.pendingSummaryData = undefined;\n\t\t\tthis.updatedDSCountSinceLastSummary = 0;\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// If the summary was not tracked by this client, the state should be updated from the downloaded snapshot.\n\t\tconst snapshotTree = result.snapshotTree;\n\t\tconst metadataBlobId = snapshotTree.blobs[metadataBlobName];\n\t\tconst metadata = metadataBlobId\n\t\t\t? await readAndParseBlob<IContainerRuntimeMetadata>(metadataBlobId)\n\t\t\t: undefined;\n\t\tthis.latestSummaryGCVersion = getGCVersion(metadata);\n\n\t\tconst gcSnapshotTree = snapshotTree.trees[gcTreeKey];\n\t\t// If GC ran in the container that generated this snapshot, it will have a GC tree.\n\t\tthis.wasGCRunInLatestSummary = gcSnapshotTree !== undefined;\n\n\t\tif (gcSnapshotTree === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tlet snapshotData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\n\t\t// If the GC version in the snapshot does not match the GC version currently in effect, the GC data\n\t\t// in the snapshot cannot be interpreted correctly. Set everything to undefined except for deletedNodes\n\t\t// because irrespective of GC versions, these nodes have been deleted and cannot be brought back. The\n\t\t// deletedNodes info is needed to identify when these nodes are used.\n\t\tif (getGCVersion(metadata) !== this.configs.gcVersionInEffect) {\n\t\t\tsnapshotData = {\n\t\t\t\tgcState: undefined,\n\t\t\t\ttombstones: undefined,\n\t\t\t\tdeletedNodes: snapshotData.deletedNodes,\n\t\t\t};\n\t\t}\n\n\t\tthis.latestSummaryData = {\n\t\t\tserializedGCState: JSON.stringify(snapshotData.gcState),\n\t\t\tserializedTombstones: JSON.stringify(snapshotData.tombstones),\n\t\t\tserializedDeletedNodes: JSON.stringify(snapshotData.deletedNodes),\n\t\t};\n\t\treturn snapshotData;\n\t}\n\n\t/**\n\t * Called to update the state from a GC run's stats. Used to update the count of data stores whose state updated.\n\t */\n\tpublic updateStateFromGCRunStats(stats: IGCStats) {\n\t\tthis.updatedDSCountSinceLastSummary += stats.updatedDataStoreCount;\n\t}\n}\n"]}
1
+ {"version":3,"file":"gcSummaryStateTracker.js","sourceRoot":"","sources":["../../src/gc/gcSummaryStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,GAGT,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAG/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,YAAY,OAAO,CAAC;AAWrD;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAgBjC;IACC,sCAAsC;IACrB,OAGhB;IACD,4EAA4E;IAC5E,sBAA+B;QALd,YAAO,GAAP,OAAO,CAGvB;QATF,8GAA8G;QAC9G,iCAAiC;QAC1B,mCAA8B,GAAW,CAAC,CAAC;QAWjD,IAAI,CAAC,uBAAuB,GAAG,sBAAsB,CAAC;QACtD,0GAA0G;QAC1G,+GAA+G;QAC/G,IAAI,CAAC,sBAAsB;YAC1B,IAAI,CAAC,OAAO,CAAC,uBAAuB,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;IACzE,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,oBAAoB;QAC9B,OAAO,IAAI,CAAC,uBAAuB,KAAK,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IAClE,CAAC;IAED;;;;;;;;;;;;;;OAcG;IAC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AAI,CAAC,OAAO,CAAC,WAAW,EAAE;YAC9B,OAAO;SACP;QAED,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC7D,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACjD,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QACpC,IAAI,CAAC,8BAA8B,GAAG,CAAC,CAAC;QACxC,OAAO;IACR,CAAC;IAED;;OAEG;IACI,yBAAyB,CAAC,KAAe;QAC/C,IAAI,CAAC,8BAA8B,IAAI,KAAK,CAAC,qBAAqB,CAAC;IACpE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SummaryType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgcBlobPrefix,\n\tgcDeletedBlobKey,\n\tgcTombstoneBlobKey,\n\tgcTreeKey,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport { mergeStats, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { IRefreshSummaryResult } from \"../summary\";\nimport { GCVersion, IGarbageCollectorConfigs, IGCStats } from \"./gcDefinitions\";\nimport { generateSortedGCState } from \"./gcHelpers\";\nimport { IGarbageCollectionSnapshotData, IGarbageCollectionState } from \"./gcSummaryDefinitions\";\n\nexport const gcStateBlobKey = `${gcBlobPrefix}_root`;\n\n/**\n * The GC data that is tracked for a summary.\n */\nexport interface IGCSummaryTrackingData {\n\tserializedGCState: string | undefined;\n\tserializedTombstones: string | undefined;\n\tserializedDeletedNodes: string | undefined;\n}\n\n/**\n * Encapsulates the garbage collection state that is tracked across summaries.\n * It maintains the GC state as per the latest summary in by the server. It updates state when a summary tracked by this\n * client is acked by the server or from a snapshot is downloaded from the server.\n * On summarize, it decides whether to write new state or re-use previous summary's state.\n */\nexport class GCSummaryStateTracker {\n\t// This is the version of GC data in the latest summary being tracked.\n\tprivate latestSummaryGCVersion: GCVersion;\n\n\t// Keeps track of the GC data from the latest summary successfully acked by the server.\n\tprivate latestSummaryData: IGCSummaryTrackingData | undefined;\n\t// Keeps track of the GC data from the last summary submitted to the server but not yet acked.\n\tprivate pendingSummaryData: IGCSummaryTrackingData | undefined;\n\n\t// Tracks whether there was GC was run in latest summary being tracked.\n\tprivate wasGCRunInLatestSummary: boolean;\n\n\t// Tracks the count of data stores whose state updated since the last summary, i.e., they went from referenced\n\t// to unreferenced or vice-versa.\n\tpublic updatedDSCountSinceLastSummary: number = 0;\n\n\tconstructor(\n\t\t// Tells whether GC should run or not.\n\t\tprivate readonly configs: Pick<\n\t\t\tIGarbageCollectorConfigs,\n\t\t\t\"shouldRunGC\" | \"tombstoneMode\" | \"gcVersionInBaseSnapshot\" | \"gcVersionInEffect\"\n\t\t>,\n\t\t// Tells whether GC was run in the base snapshot this container loaded from.\n\t\twasGCRunInBaseSnapshot: boolean,\n\t) {\n\t\tthis.wasGCRunInLatestSummary = wasGCRunInBaseSnapshot;\n\t\t// For existing document, the latest summary is the one that we loaded from. So, use its GC version as the\n\t\t// latest tracked GC version. For new documents, we will be writing the first summary with the current version.\n\t\tthis.latestSummaryGCVersion =\n\t\t\tthis.configs.gcVersionInBaseSnapshot ?? this.configs.gcVersionInEffect;\n\t}\n\n\t/**\n\t * Tells whether the GC state needs to be reset. This can happen under 3 conditions:\n\t *\n\t * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after\n\t * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.\n\t *\n\t * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on\n\t * a document and the first time GC is enabled after is was disabled before.\n\t *\n\t * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.\n\t *\n\t * Note that the state will be reset only once for the first summary generated after this returns true. After that,\n\t * this will return false.\n\t */\n\tpublic get doesGCStateNeedReset(): boolean {\n\t\treturn this.wasGCRunInLatestSummary !== this.configs.shouldRunGC;\n\t}\n\n\t/**\n\t * Tells whether the GC state needs to be reset in the next summary. We need to do this if:\n\t *\n\t * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.\n\t *\n\t * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.\n\t *\n\t * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.\n\t *\n\t * 4. The GC version in the latest summary is different from the current GC version. This can happen if:\n\t *\n\t * 4.1. The summary this client loaded with has data from a different GC version.\n\t *\n\t * 4.2. This client's latest summary was updated from a snapshot that has a different GC version.\n\t */\n\tpublic get doesSummaryStateNeedReset(): boolean {\n\t\treturn (\n\t\t\tthis.doesGCStateNeedReset ||\n\t\t\t(this.configs.shouldRunGC &&\n\t\t\t\tthis.latestSummaryGCVersion !== this.configs.gcVersionInEffect)\n\t\t);\n\t}\n\n\t/**\n\t * Called during GC initialization. Initialize the latest summary data from the base snapshot data.\n\t */\n\tpublic initializeBaseState(baseSnapshotData: IGarbageCollectionSnapshotData) {\n\t\t// If tracking state across summaries, update latest summary data from the snapshot's GC data.\n\t\tthis.latestSummaryData = {\n\t\t\tserializedGCState: baseSnapshotData.gcState\n\t\t\t\t? JSON.stringify(generateSortedGCState(baseSnapshotData.gcState))\n\t\t\t\t: undefined,\n\t\t\tserializedTombstones: JSON.stringify(baseSnapshotData.tombstones),\n\t\t\tserializedDeletedNodes: JSON.stringify(baseSnapshotData.deletedNodes),\n\t\t};\n\t}\n\n\t/**\n\t * Summarizes three component of the GC data - GC state, tombstones and deleted nodes.\n\t * It does incremental summary, i.e., it writes summary tree / summary blob only for the component that changed.\n\t * For components that did not change, a summary handle is returned that points to the previous successful summary.\n\t * If none of the components changed, it returns a summary handle for the entire GC data.\n\t */\n\tpublic summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\tgcState: IGarbageCollectionState,\n\t\tdeletedNodes: Set<string>,\n\t\ttombstones: string[],\n\t): ISummarizeResult | undefined {\n\t\tif (!this.configs.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializedGCState = JSON.stringify(generateSortedGCState(gcState));\n\t\t// Serialize and write deleted nodes, if any. This is done irrespective of whether sweep is enabled or not so\n\t\t// to identify deleted nodes' usage.\n\t\tconst serializedDeletedNodes =\n\t\t\tdeletedNodes.size > 0 ? JSON.stringify(Array.from(deletedNodes).sort()) : undefined;\n\t\t// If running in tombstone mode, serialize and write tombstones, if any.\n\t\tconst serializedTombstones = this.configs.tombstoneMode\n\t\t\t? tombstones.length > 0\n\t\t\t\t? JSON.stringify(tombstones.sort())\n\t\t\t\t: undefined\n\t\t\t: undefined;\n\n\t\t/**\n\t\t * Incremental summary of GC data - If none of GC state, deleted nodes or tombstones changed since last summary,\n\t\t * write summary handle instead of summary tree for GC.\n\t\t * Otherwise, write the GC summary tree. In the tree, for each of these that changed, write a summary blob and\n\t\t * for each of these that did not change, write a summary handle.\n\t\t */\n\t\tthis.pendingSummaryData = {\n\t\t\tserializedGCState,\n\t\t\tserializedTombstones,\n\t\t\tserializedDeletedNodes,\n\t\t};\n\n\t\tif (trackState && !fullTree && this.latestSummaryData !== undefined) {\n\t\t\t// If nothing changed since last summary, send a summary handle for the entire GC data.\n\t\t\tif (\n\t\t\t\tthis.latestSummaryData.serializedGCState === serializedGCState &&\n\t\t\t\tthis.latestSummaryData.serializedTombstones === serializedTombstones &&\n\t\t\t\tthis.latestSummaryData.serializedDeletedNodes === serializedDeletedNodes\n\t\t\t) {\n\t\t\t\tconst stats = mergeStats();\n\t\t\t\tstats.handleNodeCount++;\n\t\t\t\treturn {\n\t\t\t\t\tsummary: {\n\t\t\t\t\t\ttype: SummaryType.Handle,\n\t\t\t\t\t\thandle: `/${gcTreeKey}`,\n\t\t\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\t\t},\n\t\t\t\t\tstats,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If some state changed, build a GC summary tree.\n\t\t\treturn this.buildGCSummaryTree(\n\t\t\t\tserializedGCState,\n\t\t\t\tserializedTombstones,\n\t\t\t\tserializedDeletedNodes,\n\t\t\t\ttrue /* trackState */,\n\t\t\t);\n\t\t}\n\t\t// If not tracking GC state, build a GC summary tree without any summary handles.\n\t\treturn this.buildGCSummaryTree(\n\t\t\tserializedGCState,\n\t\t\tserializedTombstones,\n\t\t\tserializedDeletedNodes,\n\t\t\tfalse /* trackState */,\n\t\t);\n\t}\n\n\t/**\n\t * Builds the GC summary tree which contains GC state, deleted nodes and tombstones.\n\t * If trackState is false, all of GC state, deleted nodes and tombstones are written as summary blobs.\n\t * If trackState is true, only states that changed are written. Rest are written as handles.\n\t * @param serializedGCState - The GC state serialized as string.\n\t * @param serializedTombstones - The tombstone state serialized as string.\n\t * @param serializedDeletedNodes - Deleted nodes serialized as string.\n\t * @param trackState - Whether we are tracking GC state across summaries.\n\t * @returns the GC summary tree.\n\t */\n\tprivate buildGCSummaryTree(\n\t\tserializedGCState: string,\n\t\tserializedTombstones: string | undefined,\n\t\tserializedDeletedNodes: string | undefined,\n\t\ttrackState: boolean,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\t// If the GC state hasn't changed, write a summary handle, else write a summary blob for it.\n\t\tif (this.latestSummaryData?.serializedGCState === serializedGCState && trackState) {\n\t\t\tbuilder.addHandle(gcStateBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcStateBlobKey}`);\n\t\t} else {\n\t\t\tbuilder.addBlob(gcStateBlobKey, serializedGCState);\n\t\t}\n\n\t\t// If tombstones exist, write a summary handle if it hasn't changed. If it has changed, write a\n\t\t// summary blob.\n\t\tif (serializedTombstones !== undefined) {\n\t\t\tif (\n\t\t\t\tthis.latestSummaryData?.serializedTombstones === serializedTombstones &&\n\t\t\t\ttrackState\n\t\t\t) {\n\t\t\t\tbuilder.addHandle(\n\t\t\t\t\tgcTombstoneBlobKey,\n\t\t\t\t\tSummaryType.Blob,\n\t\t\t\t\t`/${gcTreeKey}/${gcTombstoneBlobKey}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tbuilder.addBlob(gcTombstoneBlobKey, serializedTombstones);\n\t\t\t}\n\t\t}\n\n\t\t// If there are no deleted nodes, return the summary tree.\n\t\tif (serializedDeletedNodes === undefined) {\n\t\t\treturn builder.getSummaryTree();\n\t\t}\n\n\t\t// If the deleted nodes hasn't changed, write a summary handle, else write a summary blob for it.\n\t\tif (\n\t\t\tthis.latestSummaryData?.serializedDeletedNodes === serializedDeletedNodes &&\n\t\t\ttrackState\n\t\t) {\n\t\t\tbuilder.addHandle(\n\t\t\t\tgcDeletedBlobKey,\n\t\t\t\tSummaryType.Blob,\n\t\t\t\t`/${gcTreeKey}/${gcDeletedBlobKey}`,\n\t\t\t);\n\t\t} else {\n\t\t\tbuilder.addBlob(gcDeletedBlobKey, serializedDeletedNodes);\n\t\t}\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Called to refresh the latest summary state. This happens when either a pending summary is acked.\n\t */\n\tpublic async refreshLatestSummary(result: IRefreshSummaryResult): Promise<void> {\n\t\tif (!result.isSummaryTracked) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the summary is tracked, this client is the one that generated it. So, update wasGCRunInLatestSummary.\n\t\t// Note that this has to be updated if GC did not run too. Otherwise, `gcStateNeedsReset` will always return\n\t\t// true in scenarios where GC is currently disabled but enabled in the snapshot we loaded from.\n\t\tthis.wasGCRunInLatestSummary = this.configs.shouldRunGC;\n\n\t\tif (!this.configs.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.latestSummaryGCVersion = this.configs.gcVersionInEffect;\n\t\tthis.latestSummaryData = this.pendingSummaryData;\n\t\tthis.pendingSummaryData = undefined;\n\t\tthis.updatedDSCountSinceLastSummary = 0;\n\t\treturn;\n\t}\n\n\t/**\n\t * Called to update the state from a GC run's stats. Used to update the count of data stores whose state updated.\n\t */\n\tpublic updateStateFromGCRunStats(stats: IGCStats) {\n\t\tthis.updatedDSCountSinceLastSummary += stats.updatedDataStoreCount;\n\t}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert, Timer } from "@fluidframework/common-utils";
5
+ import { assert, Timer } from "@fluidframework/core-utils";
6
6
  import { UnreferencedState } from "./gcDefinitions";
7
7
  /** A wrapper around common-utils Timer that requires the timeout when calling start/restart */
8
8
  class TimerWithNoDefaultTimeout extends Timer {
@@ -1 +1 @@
1
- {"version":3,"file":"gcUnreferencedStateTracker.js","sourceRoot":"","sources":["../../src/gc/gcUnreferencedStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,+FAA+F;AAC/F,MAAM,yBAA0B,SAAQ,KAAK;IAC5C,YAA6B,QAAoB;QAChD,2FAA2F;QAC3F,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;QAJyB,aAAQ,GAAR,QAAQ,CAAY;IAKjD,CAAC;IAED,KAAK,CAAC,SAAiB;QACtB,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,SAAiB;QACxB,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAWpC,YACiB,uBAA+B;IAC/C,+DAA+D;IAC9C,iBAAyB;IAC1C,kGAAkG;IAClG,2BAAmC;IACnC,0GAA0G;IACzF,cAAkC;QANnC,4BAAuB,GAAvB,uBAAuB,CAA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C,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;SACP;QAED,yGAAyG;QACzG,6CAA6C;QAC7C,IAAI,sBAAsB,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACrD,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC;YACzC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAE3B,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE;gBACtC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,GAAG,sBAAsB,CAAC,CAAC;aACtE;YACD,OAAO;SACP;QAED,qGAAqG;QACrG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,CAAC;IAC7E,CAAC;IAEO,WAAW;QAClB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,gFAAgF;IACzE,YAAY;QAClB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;IACxC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Timer } from \"@fluidframework/common-utils\";\nimport { UnreferencedState } from \"./gcDefinitions\";\n\n/** A wrapper around common-utils Timer that requires the timeout when calling start/restart */\nclass TimerWithNoDefaultTimeout extends Timer {\n\tconstructor(private readonly callback: () => void) {\n\t\t// The default timeout/handlers will never be used since start/restart pass overrides below\n\t\tsuper(0, () => {\n\t\t\tthrow new Error(\"DefaultHandler should not be used\");\n\t\t});\n\t}\n\n\tstart(timeoutMs: number) {\n\t\tsuper.start(timeoutMs, this.callback);\n\t}\n\n\trestart(timeoutMs: number): void {\n\t\tsuper.restart(timeoutMs, this.callback);\n\t}\n}\n\n/**\n * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced and if it can\n * be deleted by the sweep phase.\n */\nexport class UnreferencedStateTracker {\n\tprivate _state: UnreferencedState = UnreferencedState.Active;\n\tpublic get state(): UnreferencedState {\n\t\treturn this._state;\n\t}\n\n\t/** Timer to indicate when an unreferenced object is considered Inactive */\n\tprivate readonly inactiveTimer: TimerWithNoDefaultTimeout;\n\t/** Timer to indicate when an unreferenced object is Sweep-Ready */\n\tprivate readonly sweepTimer: TimerWithNoDefaultTimeout;\n\n\tconstructor(\n\t\tpublic readonly unreferencedTimestampMs: number,\n\t\t/** The time after which node transitions to Inactive state. */\n\t\tprivate readonly inactiveTimeoutMs: number,\n\t\t/** The current reference timestamp used to track how long this node has been unreferenced for. */\n\t\tcurrentReferenceTimestampMs: number,\n\t\t/** The time after which node transitions to SweepReady state; undefined if session expiry is disabled. */\n\t\tprivate readonly sweepTimeoutMs: number | undefined,\n\t) {\n\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.inactiveTimeoutMs <= this.sweepTimeoutMs,\n\t\t\t\t0x3b0 /* inactive timeout must not be greater than the sweep timeout */,\n\t\t\t);\n\t\t}\n\n\t\tthis.sweepTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\tassert(\n\t\t\t\t!this.inactiveTimer.hasTimer,\n\t\t\t\t0x3b1 /* inactiveTimer still running after sweepTimer fired! */,\n\t\t\t);\n\t\t});\n\n\t\tthis.inactiveTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\n\t\t\t// After the node becomes inactive, start the sweep timer after which the node will be ready for sweep.\n\t\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\t\tthis.sweepTimer.restart(this.sweepTimeoutMs - this.inactiveTimeoutMs);\n\t\t\t}\n\t\t});\n\t\tthis.updateTracking(currentReferenceTimestampMs);\n\t}\n\n\t/* Updates the unreferenced state based on the provided timestamp. */\n\tpublic updateTracking(currentReferenceTimestampMs: number) {\n\t\tconst unreferencedDurationMs = currentReferenceTimestampMs - this.unreferencedTimestampMs;\n\n\t\t// If the node has been unreferenced for sweep timeout amount of time, update the state to SweepReady.\n\t\tif (this.sweepTimeoutMs !== undefined && unreferencedDurationMs >= this.sweepTimeoutMs) {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\tthis.clearTimers();\n\t\t\treturn;\n\t\t}\n\n\t\t// If the node has been unreferenced for inactive timeoutMs amount of time, update the state to inactive.\n\t\t// Also, start a timer for the sweep timeout.\n\t\tif (unreferencedDurationMs >= this.inactiveTimeoutMs) {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\t\t\tthis.inactiveTimer.clear();\n\n\t\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\t\tthis.sweepTimer.restart(this.sweepTimeoutMs - unreferencedDurationMs);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// The node is still active. Ensure the inactive timer is running with the proper remaining duration.\n\t\tthis.inactiveTimer.restart(this.inactiveTimeoutMs - unreferencedDurationMs);\n\t}\n\n\tprivate clearTimers() {\n\t\tthis.inactiveTimer.clear();\n\t\tthis.sweepTimer.clear();\n\t}\n\n\t/** Stop tracking this node. Reset the unreferenced timers and state, if any. */\n\tpublic stopTracking() {\n\t\tthis.clearTimers();\n\t\tthis._state = UnreferencedState.Active;\n\t}\n}\n"]}
1
+ {"version":3,"file":"gcUnreferencedStateTracker.js","sourceRoot":"","sources":["../../src/gc/gcUnreferencedStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,+FAA+F;AAC/F,MAAM,yBAA0B,SAAQ,KAAK;IAC5C,YAA6B,QAAoB;QAChD,2FAA2F;QAC3F,KAAK,CAAC,CAAC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E,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;IACxC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Timer } from \"@fluidframework/core-utils\";\nimport { UnreferencedState } from \"./gcDefinitions\";\n\n/** A wrapper around common-utils Timer that requires the timeout when calling start/restart */\nclass TimerWithNoDefaultTimeout extends Timer {\n\tconstructor(private readonly callback: () => void) {\n\t\t// The default timeout/handlers will never be used since start/restart pass overrides below\n\t\tsuper(0, () => {\n\t\t\tthrow new Error(\"DefaultHandler should not be used\");\n\t\t});\n\t}\n\n\tstart(timeoutMs: number) {\n\t\tsuper.start(timeoutMs, this.callback);\n\t}\n\n\trestart(timeoutMs: number): void {\n\t\tsuper.restart(timeoutMs, this.callback);\n\t}\n}\n\n/**\n * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced and if it can\n * be deleted by the sweep phase.\n */\nexport class UnreferencedStateTracker {\n\tprivate _state: UnreferencedState = UnreferencedState.Active;\n\tpublic get state(): UnreferencedState {\n\t\treturn this._state;\n\t}\n\n\t/** Timer to indicate when an unreferenced object is considered Inactive */\n\tprivate readonly inactiveTimer: TimerWithNoDefaultTimeout;\n\t/** Timer to indicate when an unreferenced object is Sweep-Ready */\n\tprivate readonly sweepTimer: TimerWithNoDefaultTimeout;\n\n\tconstructor(\n\t\tpublic readonly unreferencedTimestampMs: number,\n\t\t/** The time after which node transitions to Inactive state. */\n\t\tprivate readonly inactiveTimeoutMs: number,\n\t\t/** The current reference timestamp used to track how long this node has been unreferenced for. */\n\t\tcurrentReferenceTimestampMs: number,\n\t\t/** The time after which node transitions to SweepReady state; undefined if session expiry is disabled. */\n\t\tprivate readonly sweepTimeoutMs: number | undefined,\n\t) {\n\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.inactiveTimeoutMs <= this.sweepTimeoutMs,\n\t\t\t\t0x3b0 /* inactive timeout must not be greater than the sweep timeout */,\n\t\t\t);\n\t\t}\n\n\t\tthis.sweepTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\tassert(\n\t\t\t\t!this.inactiveTimer.hasTimer,\n\t\t\t\t0x3b1 /* inactiveTimer still running after sweepTimer fired! */,\n\t\t\t);\n\t\t});\n\n\t\tthis.inactiveTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\n\t\t\t// After the node becomes inactive, start the sweep timer after which the node will be ready for sweep.\n\t\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\t\tthis.sweepTimer.restart(this.sweepTimeoutMs - this.inactiveTimeoutMs);\n\t\t\t}\n\t\t});\n\t\tthis.updateTracking(currentReferenceTimestampMs);\n\t}\n\n\t/* Updates the unreferenced state based on the provided timestamp. */\n\tpublic updateTracking(currentReferenceTimestampMs: number) {\n\t\tconst unreferencedDurationMs = currentReferenceTimestampMs - this.unreferencedTimestampMs;\n\n\t\t// If the node has been unreferenced for sweep timeout amount of time, update the state to SweepReady.\n\t\tif (this.sweepTimeoutMs !== undefined && unreferencedDurationMs >= this.sweepTimeoutMs) {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\tthis.clearTimers();\n\t\t\treturn;\n\t\t}\n\n\t\t// If the node has been unreferenced for inactive timeoutMs amount of time, update the state to inactive.\n\t\t// Also, start a timer for the sweep timeout.\n\t\tif (unreferencedDurationMs >= this.inactiveTimeoutMs) {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\t\t\tthis.inactiveTimer.clear();\n\n\t\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\t\tthis.sweepTimer.restart(this.sweepTimeoutMs - unreferencedDurationMs);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// The node is still active. Ensure the inactive timer is running with the proper remaining duration.\n\t\tthis.inactiveTimer.restart(this.inactiveTimeoutMs - unreferencedDurationMs);\n\t}\n\n\tprivate clearTimers() {\n\t\tthis.inactiveTimer.clear();\n\t\tthis.sweepTimer.clear();\n\t}\n\n\t/** Stop tracking this node. Reset the unreferenced timers and state, if any. */\n\tpublic stopTracking() {\n\t\tthis.clearTimers();\n\t\tthis._state = UnreferencedState.Active;\n\t}\n}\n"]}
package/lib/gc/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export { GarbageCollector } from "./garbageCollection";
6
6
  export { currentGCVersion, defaultInactiveTimeoutMs, defaultSessionExpiryDurationMs, disableSweepLogKey, GCNodeType, gcTestModeKey, gcTombstoneGenerationOptionName, gcSweepGenerationOptionName, GCFeatureMatrix, GCVersion, gcVersionUpgradeToV3Key, IGarbageCollectionRuntime, IGarbageCollector, IGarbageCollectorConfigs, IGarbageCollectorCreateParams, IGCMetadata, IGCResult, IGCRuntimeOptions, IGCStats, oneDayMs, runGCKey, runSessionExpiryKey, runSweepKey, stableGCVersion, sweepAttachmentBlobsKey, sweepDatastoresKey, throwOnTombstoneLoadKey, throwOnTombstoneUsageKey, UnreferencedState, } from "./gcDefinitions";
7
- export { cloneGCData, concatGarbageCollectionStates, getGCDataFromSnapshot, shouldAllowGcTombstoneEnforcement, shouldAllowGcSweep, trimLeadingAndTrailingSlashes, unpackChildNodesGCDetails, tagAsCodeArtifact, } from "./gcHelpers";
7
+ export { cloneGCData, concatGarbageCollectionStates, shouldAllowGcTombstoneEnforcement, shouldAllowGcSweep, trimLeadingAndTrailingSlashes, unpackChildNodesGCDetails, tagAsCodeArtifact, } from "./gcHelpers";
8
8
  export { runGarbageCollection } from "./gcReferenceGraphAlgorithm";
9
9
  export { IGarbageCollectionNodeData, IGarbageCollectionSnapshotData, IGarbageCollectionState, IGarbageCollectionSummaryDetailsLegacy, } from "./gcSummaryDefinitions";
10
10
  export { gcStateBlobKey, GCSummaryStateTracker, IGCSummaryTrackingData, } from "./gcSummaryStateTracker";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,+BAA+B,EAC/B,2BAA2B,EAC3B,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,6BAA6B,EAC7B,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,qBAAqB,EACrB,iCAAiC,EACjC,kBAAkB,EAClB,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,uBAAuB,EACvB,sCAAsC,GACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,cAAc,EACd,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,+BAA+B,EAC/B,2BAA2B,EAC3B,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,6BAA6B,EAC7B,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,iCAAiC,EACjC,kBAAkB,EAClB,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,uBAAuB,EACvB,sCAAsC,GACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,cAAc,EACd,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC"}
package/lib/gc/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export { GarbageCollector } from "./garbageCollection";
6
6
  export { currentGCVersion, defaultInactiveTimeoutMs, defaultSessionExpiryDurationMs, disableSweepLogKey, GCNodeType, gcTestModeKey, gcTombstoneGenerationOptionName, gcSweepGenerationOptionName, gcVersionUpgradeToV3Key, oneDayMs, runGCKey, runSessionExpiryKey, runSweepKey, stableGCVersion, sweepAttachmentBlobsKey, sweepDatastoresKey, throwOnTombstoneLoadKey, throwOnTombstoneUsageKey, UnreferencedState, } from "./gcDefinitions";
7
- export { cloneGCData, concatGarbageCollectionStates, getGCDataFromSnapshot, shouldAllowGcTombstoneEnforcement, shouldAllowGcSweep, trimLeadingAndTrailingSlashes, unpackChildNodesGCDetails, tagAsCodeArtifact, } from "./gcHelpers";
7
+ export { cloneGCData, concatGarbageCollectionStates, shouldAllowGcTombstoneEnforcement, shouldAllowGcSweep, trimLeadingAndTrailingSlashes, unpackChildNodesGCDetails, tagAsCodeArtifact, } from "./gcHelpers";
8
8
  export { runGarbageCollection } from "./gcReferenceGraphAlgorithm";
9
9
  export { gcStateBlobKey, GCSummaryStateTracker, } from "./gcSummaryStateTracker";
10
10
  export { GCTelemetryTracker, sendGCUnexpectedUsageEvent } from "./gcTelemetry";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,+BAA+B,EAC/B,2BAA2B,EAG3B,uBAAuB,EASvB,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,qBAAqB,EACrB,iCAAiC,EACjC,kBAAkB,EAClB,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAOnE,OAAO,EACN,cAAc,EACd,qBAAqB,GAErB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { GarbageCollector } from \"./garbageCollection\";\nexport {\n\tcurrentGCVersion,\n\tdefaultInactiveTimeoutMs,\n\tdefaultSessionExpiryDurationMs,\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tgcTestModeKey,\n\tgcTombstoneGenerationOptionName,\n\tgcSweepGenerationOptionName,\n\tGCFeatureMatrix,\n\tGCVersion,\n\tgcVersionUpgradeToV3Key,\n\tIGarbageCollectionRuntime,\n\tIGarbageCollector,\n\tIGarbageCollectorConfigs,\n\tIGarbageCollectorCreateParams,\n\tIGCMetadata,\n\tIGCResult,\n\tIGCRuntimeOptions,\n\tIGCStats,\n\toneDayMs,\n\trunGCKey,\n\trunSessionExpiryKey,\n\trunSweepKey,\n\tstableGCVersion,\n\tsweepAttachmentBlobsKey,\n\tsweepDatastoresKey,\n\tthrowOnTombstoneLoadKey,\n\tthrowOnTombstoneUsageKey,\n\tUnreferencedState,\n} from \"./gcDefinitions\";\nexport {\n\tcloneGCData,\n\tconcatGarbageCollectionStates,\n\tgetGCDataFromSnapshot,\n\tshouldAllowGcTombstoneEnforcement,\n\tshouldAllowGcSweep,\n\ttrimLeadingAndTrailingSlashes,\n\tunpackChildNodesGCDetails,\n\ttagAsCodeArtifact,\n} from \"./gcHelpers\";\nexport { runGarbageCollection } from \"./gcReferenceGraphAlgorithm\";\nexport {\n\tIGarbageCollectionNodeData,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tIGarbageCollectionSummaryDetailsLegacy,\n} from \"./gcSummaryDefinitions\";\nexport {\n\tgcStateBlobKey,\n\tGCSummaryStateTracker,\n\tIGCSummaryTrackingData,\n} from \"./gcSummaryStateTracker\";\nexport { GCTelemetryTracker, sendGCUnexpectedUsageEvent } from \"./gcTelemetry\";\nexport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,+BAA+B,EAC/B,2BAA2B,EAG3B,uBAAuB,EASvB,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,iCAAiC,EACjC,kBAAkB,EAClB,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAOnE,OAAO,EACN,cAAc,EACd,qBAAqB,GAErB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { GarbageCollector } from \"./garbageCollection\";\nexport {\n\tcurrentGCVersion,\n\tdefaultInactiveTimeoutMs,\n\tdefaultSessionExpiryDurationMs,\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tgcTestModeKey,\n\tgcTombstoneGenerationOptionName,\n\tgcSweepGenerationOptionName,\n\tGCFeatureMatrix,\n\tGCVersion,\n\tgcVersionUpgradeToV3Key,\n\tIGarbageCollectionRuntime,\n\tIGarbageCollector,\n\tIGarbageCollectorConfigs,\n\tIGarbageCollectorCreateParams,\n\tIGCMetadata,\n\tIGCResult,\n\tIGCRuntimeOptions,\n\tIGCStats,\n\toneDayMs,\n\trunGCKey,\n\trunSessionExpiryKey,\n\trunSweepKey,\n\tstableGCVersion,\n\tsweepAttachmentBlobsKey,\n\tsweepDatastoresKey,\n\tthrowOnTombstoneLoadKey,\n\tthrowOnTombstoneUsageKey,\n\tUnreferencedState,\n} from \"./gcDefinitions\";\nexport {\n\tcloneGCData,\n\tconcatGarbageCollectionStates,\n\tshouldAllowGcTombstoneEnforcement,\n\tshouldAllowGcSweep,\n\ttrimLeadingAndTrailingSlashes,\n\tunpackChildNodesGCDetails,\n\ttagAsCodeArtifact,\n} from \"./gcHelpers\";\nexport { runGarbageCollection } from \"./gcReferenceGraphAlgorithm\";\nexport {\n\tIGarbageCollectionNodeData,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tIGarbageCollectionSummaryDetailsLegacy,\n} from \"./gcSummaryDefinitions\";\nexport {\n\tgcStateBlobKey,\n\tGCSummaryStateTracker,\n\tIGCSummaryTrackingData,\n} from \"./gcSummaryStateTracker\";\nexport { GCTelemetryTracker, sendGCUnexpectedUsageEvent } from \"./gcTelemetry\";\nexport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\n"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  /* eslint-disable tsdoc/syntax */
6
6
  /* eslint-disable no-bitwise */
7
- import { assert } from "@fluidframework/common-utils";
7
+ import { assert } from "@fluidframework/core-utils";
8
8
  /**
9
9
  * A map in which entries are always added in key-sorted order.
10
10
  * Supports appending and searching.
@@ -1 +1 @@
1
- {"version":3,"file":"appendOnlySortedMap.js","sourceRoot":"","sources":["../../src/id-compressor/appendOnlySortedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iCAAiC;AACjC,+BAA+B;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAG/B;;OAEG;IACH,YAAsC,UAAkC;QAAlC,eAAU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U,CAAC;IACnD,CAAC;;AAlCD;;GAEG;AACoB,8BAAU,GAAG,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable tsdoc/syntax */\n/* eslint-disable no-bitwise */\nimport { assert } from \"@fluidframework/common-utils\";\n\n/**\n * A map in which entries are always added in key-sorted order.\n * Supports appending and searching.\n */\nexport class AppendOnlySortedMap<K, V> {\n\tprotected readonly elements: (K | V)[] = [];\n\n\t/**\n\t * @param comparator - a comparator for keys\n\t */\n\tpublic constructor(protected readonly comparator: (a: K, b: K) => number) {}\n\n\t/**\n\t * @returns the number of entries in this map\n\t */\n\tpublic get size(): number {\n\t\treturn this.elements.length / 2;\n\t}\n\n\t/**\n\t * @returns the min key in the map.\n\t */\n\tpublic minKey(): K | undefined {\n\t\treturn this.elements[0] as K | undefined;\n\t}\n\n\t/**\n\t * @returns the max key in the map.\n\t */\n\tpublic maxKey(): K | undefined {\n\t\treturn this.elements[this.elements.length - 2] as K | undefined;\n\t}\n\n\t/**\n\t * @returns the min value in the map.\n\t */\n\tpublic minValue(): V | undefined {\n\t\treturn this.elements[1] as V | undefined;\n\t}\n\n\t/**\n\t * @returns the min value in the map.\n\t */\n\tpublic maxValue(): V | undefined {\n\t\treturn this.elements[this.elements.length - 1] as V | undefined;\n\t}\n\n\t/**\n\t * @returns the min key in the map.\n\t */\n\tpublic first(): [K, V] | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [elements[0] as K, elements[1] as V];\n\t}\n\n\t/**\n\t * @returns the max key in the map.\n\t */\n\tpublic last(): [K, V] | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst lastKeyIndex = length - 2;\n\t\treturn [elements[lastKeyIndex] as K, elements[lastKeyIndex + 1] as V];\n\t}\n\n\t/**\n\t * Returns the element at the insertion index.\n\t */\n\tpublic getAtIndex(index: number): [K, V] | undefined {\n\t\tconst realIndex = index * 2;\n\t\tconst { elements } = this;\n\t\tif (realIndex < 0 || realIndex > elements.length - 1) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [elements[realIndex] as K, elements[realIndex + 1] as V];\n\t}\n\n\t/**\n\t * @returns an iterable of the entries in the map.\n\t */\n\tpublic *entries(): IterableIterator<readonly [K, V]> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield [elements[i] as K, elements[i + 1] as V];\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the keys in the map.\n\t */\n\tpublic *keys(): IterableIterator<K> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield elements[i] as K;\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the values in the map.\n\t */\n\tpublic *values(): IterableIterator<V> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield elements[i + 1] as V;\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the entries in the map, reversed.\n\t */\n\tpublic *entriesReversed(): IterableIterator<readonly [K, V]> {\n\t\tconst { elements } = this;\n\t\tfor (let i = elements.length - 2; i >= 0; i -= 2) {\n\t\t\tyield [elements[i] as K, elements[i + 1] as V];\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new key/value pair to the map. `key` must be > to all keys in the map.\n\t * @param key - the key to add.\n\t * @param value - the value to add.\n\t */\n\tpublic append(key: K, value: V): void {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length !== 0 && this.comparator(key, this.maxKey() as K) <= 0) {\n\t\t\tthrow new Error(\"Inserted key must be > all others in the map.\");\n\t\t}\n\t\telements.push(key);\n\t\telements.push(value);\n\t}\n\n\t/**\n\t * Replaces the last key/value pair with the given one. If the map is empty, it simply appends.\n\t * `key` must be > to all keys in the map prior to the one replaced.\n\t * @param key - the key to add.\n\t * @param value - the value to add.\n\t */\n\tpublic replaceLast(key: K, value: V): void {\n\t\tconst { elements, comparator } = this;\n\t\tconst { length } = elements;\n\t\tif (length !== 0) {\n\t\t\telements.pop();\n\t\t\telements.pop();\n\t\t\tif (comparator(key, this.maxKey() as K) <= 0) {\n\t\t\t\tthrow new Error(\"Inserted key must be > all others in the map.\");\n\t\t\t}\n\t\t}\n\t\telements.push(key);\n\t\telements.push(value);\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the value associated with `key` if such an entry exists, and undefined otherwise.\n\t */\n\tpublic get(key: K): V | undefined {\n\t\tconst index = AppendOnlySortedMap.keyIndexOf(this.elements, key, this.comparator);\n\t\tif (index < 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.elements[index + 1] as V;\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the entry associated with `key` if such an entry exists, the entry associated with the next lower key if such an entry\n\t * exists, and undefined otherwise.\n\t */\n\tpublic getPairOrNextLower(key: K): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextLowerBy(key, this.comparator);\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the entry associated with `key` if such an entry exists, the entry associated with the next higher key if such an entry\n\t * exists, and undefined otherwise.\n\t */\n\tpublic getPairOrNextHigher(key: K): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextHigherBy(key, this.comparator);\n\t}\n\n\t/**\n\t * Compares two `AppendOnlySortedMap`s.\n\t */\n\tpublic equals(\n\t\tother: AppendOnlySortedMap<K, V>,\n\t\tcompareValues: (a: V, b: V) => boolean,\n\t): boolean {\n\t\tif (other === this) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.elements.length !== other.elements.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let i = this.elements.length - 2; i >= 0; i -= 2) {\n\t\t\tconst keyThis = this.elements[i] as K;\n\t\t\tconst valueThis = this.elements[i + 1] as V;\n\t\t\tconst keyOther = other.elements[i] as K;\n\t\t\tconst valueOther = other.elements[i + 1] as V;\n\t\t\tif (this.comparator(keyThis, keyOther) !== 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!compareValues(valueThis, valueOther)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Test-only expensive assertions to check the internal validity of the data structure.\n\t */\n\tpublic assertValid(): void {\n\t\tlet prev: readonly [K, unknown] | undefined;\n\t\tfor (const kv of this.entries()) {\n\t\t\tif (prev !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.comparator(kv[0], prev[0]) > 0,\n\t\t\t\t\t0x752 /* Keys in map must be sorted. */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tprev = kv;\n\t\t}\n\t}\n\n\t/**\n\t * Queries a range of entries.\n\t * @param from - the key to start the range query at, inclusive.\n\t * @param to - the key to end the range query at, inclusive.\n\t * @returns the range of entries.\n\t */\n\tpublic *getRange(from: K, to: K): IterableIterator<readonly [K, V]> {\n\t\tconst keyIndexFrom = this.getKeyIndexOfOrNextHigher(from, this.comparator);\n\t\tif (keyIndexFrom === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst keyIndexTo = this.getKeyIndexOfOrNextLower(to, this.comparator);\n\t\tif (keyIndexTo === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let i = keyIndexFrom; i <= keyIndexTo; i += 2) {\n\t\t\tyield [this.elements[i] as K, this.elements[i + 1] as V];\n\t\t}\n\t}\n\n\tprotected getPairOrNextLowerBy<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): readonly [K, V] | undefined {\n\t\tconst keyIndex = this.getKeyIndexOfOrNextLower(search, comparator);\n\t\tif (keyIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn [this.elements[keyIndex] as K, this.elements[keyIndex + 1] as V];\n\t}\n\n\tprivate getKeyIndexOfOrNextLower<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): number | undefined {\n\t\tconst { elements } = this;\n\t\tif (elements.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);\n\t\tif (keyIndex < 0) {\n\t\t\tkeyIndex ^= AppendOnlySortedMap.failureXor;\n\t\t\tif (keyIndex > 0) {\n\t\t\t\treturn keyIndex - 2;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn keyIndex;\n\t}\n\n\tprotected getPairOrNextHigherBy<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): readonly [K, V] | undefined {\n\t\tconst keyIndex = this.getKeyIndexOfOrNextHigher(search, comparator);\n\t\tif (keyIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn [this.elements[keyIndex] as K, this.elements[keyIndex + 1] as V];\n\t}\n\n\tprivate getKeyIndexOfOrNextHigher<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): number | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);\n\t\tif (keyIndex < 0) {\n\t\t\tkeyIndex ^= AppendOnlySortedMap.failureXor;\n\t\t\tif (keyIndex < length) {\n\t\t\t\treturn keyIndex;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn keyIndex;\n\t}\n\n\t/**\n\t * The value xor'd with the result index when a search fails.\n\t */\n\tpublic static readonly failureXor = -1;\n\n\t/**\n\t * Performs a binary search on the sorted array.\n\t * @returns the index of the key for `search`, or (if not present) the index it would have been inserted into xor'd\n\t * with `failureXor`. Note that negating is not an adequate solution as that could result in -0.\n\t */\n\tpublic static keyIndexOf<T, K, V>(\n\t\telements: readonly (K | V)[],\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): number {\n\t\t// Low, high, and mid are addresses of [K,V] pairs and *not* key indices\n\t\tlet low = 0;\n\t\tlet high = elements.length / 2;\n\t\tlet mid = high >> 1;\n\t\twhile (low < high) {\n\t\t\tconst keyIndex = mid * 2;\n\t\t\tconst c = comparator(search, elements[keyIndex] as K, elements[keyIndex + 1] as V);\n\t\t\tif (c > 0) {\n\t\t\t\tlow = mid + 1;\n\t\t\t} else if (c < 0) {\n\t\t\t\thigh = mid;\n\t\t\t} else if (c === 0) {\n\t\t\t\treturn keyIndex;\n\t\t\t} else {\n\t\t\t\tthrow new Error(\"Invalid comparator.\");\n\t\t\t}\n\t\t\tmid = (low + high) >> 1;\n\t\t}\n\t\treturn (mid * 2) ^ AppendOnlySortedMap.failureXor;\n\t}\n}\n"]}
1
+ {"version":3,"file":"appendOnlySortedMap.js","sourceRoot":"","sources":["../../src/id-compressor/appendOnlySortedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iCAAiC;AACjC,+BAA+B;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAG/B;;OAEG;IACH,YAAsC,UAAkC;QAAlC,eAAU,GAAV,UAAU,CAAwB;QALrD,aAAQ,GAAc,EAAE,CAAC;IAK+B,CAAC;IAE5E;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAkB,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAkB,CAAC;IACjE,C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AU,CACvB,QAA4B,EAC5B,MAAS,EACT,UAAmD;QAEnD,wEAAwE;QACxE,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,IAAI,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/B,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC;QACpB,OAAO,GAAG,GAAG,IAAI,EAAE;YAClB,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC;YACzB,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAM,EAAE,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAM,CAAC,CAAC;YACnF,IAAI,CAAC,GAAG,CAAC,EAAE;gBACV,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;aACd;iBAAM,IAAI,CAAC,GAAG,CAAC,EAAE;gBACjB,IAAI,GAAG,GAAG,CAAC;aACX;iBAAM,IAAI,CAAC,KAAK,CAAC,EAAE;gBACnB,OAAO,QAAQ,CAAC;aAChB;iBAAM;gBACN,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;aACvC;YACD,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;SACxB;QACD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,mBAAmB,CAAC,UAAU,CAAC;IACnD,CAAC;;AAlCD;;GAEG;AACoB,8BAAU,GAAG,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable tsdoc/syntax */\n/* eslint-disable no-bitwise */\nimport { assert } from \"@fluidframework/core-utils\";\n\n/**\n * A map in which entries are always added in key-sorted order.\n * Supports appending and searching.\n */\nexport class AppendOnlySortedMap<K, V> {\n\tprotected readonly elements: (K | V)[] = [];\n\n\t/**\n\t * @param comparator - a comparator for keys\n\t */\n\tpublic constructor(protected readonly comparator: (a: K, b: K) => number) {}\n\n\t/**\n\t * @returns the number of entries in this map\n\t */\n\tpublic get size(): number {\n\t\treturn this.elements.length / 2;\n\t}\n\n\t/**\n\t * @returns the min key in the map.\n\t */\n\tpublic minKey(): K | undefined {\n\t\treturn this.elements[0] as K | undefined;\n\t}\n\n\t/**\n\t * @returns the max key in the map.\n\t */\n\tpublic maxKey(): K | undefined {\n\t\treturn this.elements[this.elements.length - 2] as K | undefined;\n\t}\n\n\t/**\n\t * @returns the min value in the map.\n\t */\n\tpublic minValue(): V | undefined {\n\t\treturn this.elements[1] as V | undefined;\n\t}\n\n\t/**\n\t * @returns the min value in the map.\n\t */\n\tpublic maxValue(): V | undefined {\n\t\treturn this.elements[this.elements.length - 1] as V | undefined;\n\t}\n\n\t/**\n\t * @returns the min key in the map.\n\t */\n\tpublic first(): [K, V] | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [elements[0] as K, elements[1] as V];\n\t}\n\n\t/**\n\t * @returns the max key in the map.\n\t */\n\tpublic last(): [K, V] | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst lastKeyIndex = length - 2;\n\t\treturn [elements[lastKeyIndex] as K, elements[lastKeyIndex + 1] as V];\n\t}\n\n\t/**\n\t * Returns the element at the insertion index.\n\t */\n\tpublic getAtIndex(index: number): [K, V] | undefined {\n\t\tconst realIndex = index * 2;\n\t\tconst { elements } = this;\n\t\tif (realIndex < 0 || realIndex > elements.length - 1) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [elements[realIndex] as K, elements[realIndex + 1] as V];\n\t}\n\n\t/**\n\t * @returns an iterable of the entries in the map.\n\t */\n\tpublic *entries(): IterableIterator<readonly [K, V]> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield [elements[i] as K, elements[i + 1] as V];\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the keys in the map.\n\t */\n\tpublic *keys(): IterableIterator<K> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield elements[i] as K;\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the values in the map.\n\t */\n\tpublic *values(): IterableIterator<V> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield elements[i + 1] as V;\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the entries in the map, reversed.\n\t */\n\tpublic *entriesReversed(): IterableIterator<readonly [K, V]> {\n\t\tconst { elements } = this;\n\t\tfor (let i = elements.length - 2; i >= 0; i -= 2) {\n\t\t\tyield [elements[i] as K, elements[i + 1] as V];\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new key/value pair to the map. `key` must be > to all keys in the map.\n\t * @param key - the key to add.\n\t * @param value - the value to add.\n\t */\n\tpublic append(key: K, value: V): void {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length !== 0 && this.comparator(key, this.maxKey() as K) <= 0) {\n\t\t\tthrow new Error(\"Inserted key must be > all others in the map.\");\n\t\t}\n\t\telements.push(key);\n\t\telements.push(value);\n\t}\n\n\t/**\n\t * Replaces the last key/value pair with the given one. If the map is empty, it simply appends.\n\t * `key` must be > to all keys in the map prior to the one replaced.\n\t * @param key - the key to add.\n\t * @param value - the value to add.\n\t */\n\tpublic replaceLast(key: K, value: V): void {\n\t\tconst { elements, comparator } = this;\n\t\tconst { length } = elements;\n\t\tif (length !== 0) {\n\t\t\telements.pop();\n\t\t\telements.pop();\n\t\t\tif (comparator(key, this.maxKey() as K) <= 0) {\n\t\t\t\tthrow new Error(\"Inserted key must be > all others in the map.\");\n\t\t\t}\n\t\t}\n\t\telements.push(key);\n\t\telements.push(value);\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the value associated with `key` if such an entry exists, and undefined otherwise.\n\t */\n\tpublic get(key: K): V | undefined {\n\t\tconst index = AppendOnlySortedMap.keyIndexOf(this.elements, key, this.comparator);\n\t\tif (index < 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.elements[index + 1] as V;\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the entry associated with `key` if such an entry exists, the entry associated with the next lower key if such an entry\n\t * exists, and undefined otherwise.\n\t */\n\tpublic getPairOrNextLower(key: K): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextLowerBy(key, this.comparator);\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the entry associated with `key` if such an entry exists, the entry associated with the next higher key if such an entry\n\t * exists, and undefined otherwise.\n\t */\n\tpublic getPairOrNextHigher(key: K): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextHigherBy(key, this.comparator);\n\t}\n\n\t/**\n\t * Compares two `AppendOnlySortedMap`s.\n\t */\n\tpublic equals(\n\t\tother: AppendOnlySortedMap<K, V>,\n\t\tcompareValues: (a: V, b: V) => boolean,\n\t): boolean {\n\t\tif (other === this) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.elements.length !== other.elements.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let i = this.elements.length - 2; i >= 0; i -= 2) {\n\t\t\tconst keyThis = this.elements[i] as K;\n\t\t\tconst valueThis = this.elements[i + 1] as V;\n\t\t\tconst keyOther = other.elements[i] as K;\n\t\t\tconst valueOther = other.elements[i + 1] as V;\n\t\t\tif (this.comparator(keyThis, keyOther) !== 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!compareValues(valueThis, valueOther)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Test-only expensive assertions to check the internal validity of the data structure.\n\t */\n\tpublic assertValid(): void {\n\t\tlet prev: readonly [K, unknown] | undefined;\n\t\tfor (const kv of this.entries()) {\n\t\t\tif (prev !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.comparator(kv[0], prev[0]) > 0,\n\t\t\t\t\t0x752 /* Keys in map must be sorted. */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tprev = kv;\n\t\t}\n\t}\n\n\t/**\n\t * Queries a range of entries.\n\t * @param from - the key to start the range query at, inclusive.\n\t * @param to - the key to end the range query at, inclusive.\n\t * @returns the range of entries.\n\t */\n\tpublic *getRange(from: K, to: K): IterableIterator<readonly [K, V]> {\n\t\tconst keyIndexFrom = this.getKeyIndexOfOrNextHigher(from, this.comparator);\n\t\tif (keyIndexFrom === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst keyIndexTo = this.getKeyIndexOfOrNextLower(to, this.comparator);\n\t\tif (keyIndexTo === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let i = keyIndexFrom; i <= keyIndexTo; i += 2) {\n\t\t\tyield [this.elements[i] as K, this.elements[i + 1] as V];\n\t\t}\n\t}\n\n\tprotected getPairOrNextLowerBy<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): readonly [K, V] | undefined {\n\t\tconst keyIndex = this.getKeyIndexOfOrNextLower(search, comparator);\n\t\tif (keyIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn [this.elements[keyIndex] as K, this.elements[keyIndex + 1] as V];\n\t}\n\n\tprivate getKeyIndexOfOrNextLower<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): number | undefined {\n\t\tconst { elements } = this;\n\t\tif (elements.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);\n\t\tif (keyIndex < 0) {\n\t\t\tkeyIndex ^= AppendOnlySortedMap.failureXor;\n\t\t\tif (keyIndex > 0) {\n\t\t\t\treturn keyIndex - 2;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn keyIndex;\n\t}\n\n\tprotected getPairOrNextHigherBy<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): readonly [K, V] | undefined {\n\t\tconst keyIndex = this.getKeyIndexOfOrNextHigher(search, comparator);\n\t\tif (keyIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn [this.elements[keyIndex] as K, this.elements[keyIndex + 1] as V];\n\t}\n\n\tprivate getKeyIndexOfOrNextHigher<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): number | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);\n\t\tif (keyIndex < 0) {\n\t\t\tkeyIndex ^= AppendOnlySortedMap.failureXor;\n\t\t\tif (keyIndex < length) {\n\t\t\t\treturn keyIndex;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn keyIndex;\n\t}\n\n\t/**\n\t * The value xor'd with the result index when a search fails.\n\t */\n\tpublic static readonly failureXor = -1;\n\n\t/**\n\t * Performs a binary search on the sorted array.\n\t * @returns the index of the key for `search`, or (if not present) the index it would have been inserted into xor'd\n\t * with `failureXor`. Note that negating is not an adequate solution as that could result in -0.\n\t */\n\tpublic static keyIndexOf<T, K, V>(\n\t\telements: readonly (K | V)[],\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number,\n\t): number {\n\t\t// Low, high, and mid are addresses of [K,V] pairs and *not* key indices\n\t\tlet low = 0;\n\t\tlet high = elements.length / 2;\n\t\tlet mid = high >> 1;\n\t\twhile (low < high) {\n\t\t\tconst keyIndex = mid * 2;\n\t\t\tconst c = comparator(search, elements[keyIndex] as K, elements[keyIndex + 1] as V);\n\t\t\tif (c > 0) {\n\t\t\t\tlow = mid + 1;\n\t\t\t} else if (c < 0) {\n\t\t\t\thigh = mid;\n\t\t\t} else if (c === 0) {\n\t\t\t\treturn keyIndex;\n\t\t\t} else {\n\t\t\t\tthrow new Error(\"Invalid comparator.\");\n\t\t\t}\n\t\t\tmid = (low + high) >> 1;\n\t\t}\n\t\treturn (mid * 2) ^ AppendOnlySortedMap.failureXor;\n\t}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert } from "@fluidframework/common-utils";
5
+ import { assert } from "@fluidframework/core-utils";
6
6
  import { clustersEqual, lastAllocatedFinal, lastFinalizedFinal } from "./sessions";
7
7
  /**
8
8
  * All IDs that have been finalized (acked), grouped into clusters sorted by their base final IDs.
@@ -1 +1 @@
1
- {"version":3,"file":"finalSpace.js","sourceRoot":"","sources":["../../src/id-compressor/finalSpace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAa,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAG9F;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAAvB;QACkB,gBAAW,GAAgB,EAAE,CAAC;IAmDhD,CAAC;IAjDA,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAEM,cAAc;QACpB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAEM,UAAU,CAAC,UAAqB;QACtC,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,MAAM,CACL,WAAW,KAAK,SAAS;YACxB,qEAAqE;YACrE,UAAU,CAAC,WAAW,KAAK,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC,QAAQ,EAC1E,KAAK,CAAC,oDAAoD,CAC1D,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,mBAAmB;QACzB,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,OAAO,WAAW,KAAK,SAAS;YAC/B,CAAC,CAAE,CAAuB;YAC1B,CAAC,CAAE,CAAE,kBAAkB,CAAC,WAAW,CAAY,GAAG,CAAC,CAAuB,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACI,mBAAmB;QACzB,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,OAAO,WAAW,KAAK,SAAS;YAC/B,CAAC,CAAE,CAAuB;YAC1B,CAAC,CAAE,CAAE,kBAAkB,CAAC,WAAW,CAAY,GAAG,CAAC,CAAuB,CAAC;IAC7E,CAAC;IAEM,MAAM,CAAC,KAAiB;QAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACjD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC9D,OAAO,KAAK,CAAC;aACb;SACD;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC;IAC7D,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IdCluster, clustersEqual, lastAllocatedFinal, lastFinalizedFinal } from \"./sessions\";\nimport { FinalCompressedId } from \"./identifiers\";\n\n/**\n * All IDs that have been finalized (acked), grouped into clusters sorted by their base final IDs.\n * These clusters span the positive integer space and are not sparse, meaning a cluster's base final\n * ID will always be one greater than the last final ID in the previous cluster (or 0 if there is not one).\n */\nexport class FinalSpace {\n\tprivate readonly clusterList: IdCluster[] = [];\n\n\tpublic get clusters(): readonly IdCluster[] {\n\t\treturn this.clusterList;\n\t}\n\n\tpublic getLastCluster(): IdCluster | undefined {\n\t\treturn this.clusterList[this.clusterList.length - 1];\n\t}\n\n\tpublic addCluster(newCluster: IdCluster) {\n\t\tconst lastCluster = this.getLastCluster();\n\t\tassert(\n\t\t\tlastCluster === undefined ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\t\t\t\tnewCluster.baseFinalId === lastCluster.baseFinalId + lastCluster.capacity,\n\t\t\t0x753 /* Cluster insert to final_space is out of order. */,\n\t\t);\n\t\tthis.clusterList.push(newCluster);\n\t}\n\n\t/**\n\t * @returns the upper bound (exclusive) of finalized IDs in final space, i.e. one greater than the last final ID in the last cluster.\n\t * Note: this does not include allocated but unfinalized space in clusters.\n\t */\n\tpublic getFinalizedIdLimit(): FinalCompressedId {\n\t\tconst lastCluster = this.getLastCluster();\n\t\treturn lastCluster === undefined\n\t\t\t? (0 as FinalCompressedId)\n\t\t\t: (((lastFinalizedFinal(lastCluster) as number) + 1) as FinalCompressedId);\n\t}\n\n\t/**\n\t * @returns the upper bound (exclusive) of allocated IDs in final space, i.e. one greater than the last final ID in the last cluster.\n\t * Note: this does includes all allocated IDs in clusters.\n\t */\n\tpublic getAllocatedIdLimit(): FinalCompressedId {\n\t\tconst lastCluster = this.getLastCluster();\n\t\treturn lastCluster === undefined\n\t\t\t? (0 as FinalCompressedId)\n\t\t\t: (((lastAllocatedFinal(lastCluster) as number) + 1) as FinalCompressedId);\n\t}\n\n\tpublic equals(other: FinalSpace): boolean {\n\t\tfor (let i = 0; i < this.clusterList.length; i++) {\n\t\t\tif (!clustersEqual(this.clusterList[i], other.clusterList[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn this.clusterList.length === other.clusterList.length;\n\t}\n}\n"]}
1
+ {"version":3,"file":"finalSpace.js","sourceRoot":"","sources":["../../src/id-compressor/finalSpace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iB;QAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACjD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC9D,OAAO,KAAK,CAAC;aACb;SACD;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC;IAC7D,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IdCluster, clustersEqual, lastAllocatedFinal, lastFinalizedFinal } from \"./sessions\";\nimport { FinalCompressedId } from \"./identifiers\";\n\n/**\n * All IDs that have been finalized (acked), grouped into clusters sorted by their base final IDs.\n * These clusters span the positive integer space and are not sparse, meaning a cluster's base final\n * ID will always be one greater than the last final ID in the previous cluster (or 0 if there is not one).\n */\nexport class FinalSpace {\n\tprivate readonly clusterList: IdCluster[] = [];\n\n\tpublic get clusters(): readonly IdCluster[] {\n\t\treturn this.clusterList;\n\t}\n\n\tpublic getLastCluster(): IdCluster | undefined {\n\t\treturn this.clusterList[this.clusterList.length - 1];\n\t}\n\n\tpublic addCluster(newCluster: IdCluster) {\n\t\tconst lastCluster = this.getLastCluster();\n\t\tassert(\n\t\t\tlastCluster === undefined ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\t\t\t\tnewCluster.baseFinalId === lastCluster.baseFinalId + lastCluster.capacity,\n\t\t\t0x753 /* Cluster insert to final_space is out of order. */,\n\t\t);\n\t\tthis.clusterList.push(newCluster);\n\t}\n\n\t/**\n\t * @returns the upper bound (exclusive) of finalized IDs in final space, i.e. one greater than the last final ID in the last cluster.\n\t * Note: this does not include allocated but unfinalized space in clusters.\n\t */\n\tpublic getFinalizedIdLimit(): FinalCompressedId {\n\t\tconst lastCluster = this.getLastCluster();\n\t\treturn lastCluster === undefined\n\t\t\t? (0 as FinalCompressedId)\n\t\t\t: (((lastFinalizedFinal(lastCluster) as number) + 1) as FinalCompressedId);\n\t}\n\n\t/**\n\t * @returns the upper bound (exclusive) of allocated IDs in final space, i.e. one greater than the last final ID in the last cluster.\n\t * Note: this does includes all allocated IDs in clusters.\n\t */\n\tpublic getAllocatedIdLimit(): FinalCompressedId {\n\t\tconst lastCluster = this.getLastCluster();\n\t\treturn lastCluster === undefined\n\t\t\t? (0 as FinalCompressedId)\n\t\t\t: (((lastAllocatedFinal(lastCluster) as number) + 1) as FinalCompressedId);\n\t}\n\n\tpublic equals(other: FinalSpace): boolean {\n\t\tfor (let i = 0; i < this.clusterList.length; i++) {\n\t\t\tif (!clustersEqual(this.clusterList[i], other.clusterList[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn this.clusterList.length === other.clusterList.length;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../../src/id-compressor/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EAEnB,mCAAmC,EACnC,wCAAwC,EACxC,SAAS,EACT,wBAAwB,EACxB,QAAQ,EAER,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAsCvE;;GAEG;AACH,qBAAa,YAAa,YAAW,aAAa,EAAE,iBAAiB;IAuCnE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAtCzB;;OAEG;IACH,gBAAuB,cAAc,SAAW;IAIhD,SAAgB,cAAc,EAAE,SAAS,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IACvC,OAAO,CAAC,QAAQ,CAAC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IAyBvD,OAAO,CAAC,mBAAmB;IAMpB,qBAAqB,IAAI,eAAe;IAkBxC,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAmF1D,OAAO,CAAC,eAAe;IAWhB,kBAAkB,CAAC,EAAE,EAAE,wBAAwB,GAAG,mBAAmB;IAerE,uBAAuB,CAC7B,EAAE,EAAE,mBAAmB,EACvB,eAAe,EAAE,SAAS,GACxB,wBAAwB;IA4CpB,UAAU,CAAC,EAAE,EAAE,wBAAwB,GAAG,QAAQ;IAwClD,UAAU,CAAC,YAAY,EAAE,QAAQ,GAAG,wBAAwB;IAQ5D,aAAa,CAAC,YAAY,EAAE,QAAQ,GAAG,wBAAwB,GAAG,SAAS;IAwC3E,SAAS,CAAC,WAAW,EAAE,IAAI,GAAG,wCAAwC;IACtE,SAAS,CAAC,WAAW,EAAE,KAAK,GAAG,mCAAmC;WAyE3D,WAAW,CAAC,UAAU,EAAE,wCAAwC,GAAG,YAAY;WAC/E,WAAW,CACxB,UAAU,EAAE,mCAAmC,EAC/C,YAAY,EAAE,SAAS,GACrB,YAAY;IA2ER,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,OAAO,GAAG,OAAO;CAiBvE"}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert, bufferToString, stringToBuffer } from "@fluidframework/common-utils";
5
+ import { assert } from "@fluidframework/core-utils";
6
+ import { bufferToString, stringToBuffer } from "@fluid-internal/client-utils";
6
7
  import { initialClusterCapacity, } from "@fluidframework/runtime-definitions";
7
8
  import { createChildLogger } from "@fluidframework/telemetry-utils";
8
9
  import { isFinalId } from "./identifiers";