@fluidframework/container-runtime 2.0.0-internal.7.3.0 → 2.0.0-internal.7.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +9 -1
- package/api-report/container-runtime.api.md +124 -107
- package/dist/blobManager.d.ts +4 -4
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js.map +1 -1
- package/dist/container-runtime-alpha.d.ts +1473 -0
- package/dist/container-runtime-beta.d.ts +300 -0
- package/dist/container-runtime-public.d.ts +300 -0
- package/dist/container-runtime-untrimmed.d.ts +1836 -0
- package/dist/containerRuntime.d.ts +30 -30
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +62 -40
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreRegistry.d.ts +1 -1
- package/dist/dataStoreRegistry.js +1 -1
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/dataStores.d.ts +10 -15
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +77 -40
- package/dist/dataStores.js.map +1 -1
- package/dist/gc/garbageCollection.d.ts +41 -13
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +215 -78
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.d.ts.map +1 -1
- package/dist/gc/gcConfigs.js +34 -37
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +121 -46
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js +26 -18
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcHelpers.d.ts +18 -25
- package/dist/gc/gcHelpers.d.ts.map +1 -1
- package/dist/gc/gcHelpers.js +29 -45
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcTelemetry.d.ts +0 -5
- package/dist/gc/gcTelemetry.d.ts.map +1 -1
- package/dist/gc/gcTelemetry.js +14 -42
- package/dist/gc/gcTelemetry.js.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.d.ts +11 -5
- package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.js +43 -19
- package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/dist/gc/index.d.ts +1 -1
- package/dist/gc/index.d.ts.map +1 -1
- package/dist/gc/index.js +4 -5
- package/dist/gc/index.js.map +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/messageTypes.d.ts +15 -7
- package/dist/messageTypes.d.ts.map +1 -1
- package/dist/messageTypes.js +6 -1
- package/dist/messageTypes.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +1 -0
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +1 -0
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/summary/orderedClientElection.d.ts +1 -1
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/dist/summary/runWhileConnectedCoordinator.d.ts +2 -2
- package/dist/summary/runWhileConnectedCoordinator.js +1 -1
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/summary/summarizer.d.ts +1 -1
- package/dist/summary/summarizer.js +1 -1
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerTypes.d.ts +30 -30
- package/dist/summary/summarizerTypes.js.map +1 -1
- package/dist/summary/summaryCollection.d.ts +10 -10
- package/dist/summary/summaryCollection.js +1 -1
- package/dist/summary/summaryCollection.js.map +1 -1
- package/dist/summary/summaryFormat.d.ts +3 -3
- package/dist/summary/summaryFormat.js.map +1 -1
- package/lib/blobManager.d.ts +4 -4
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js.map +1 -1
- package/lib/container-runtime-alpha.d.ts +1473 -0
- package/lib/container-runtime-beta.d.ts +300 -0
- package/lib/container-runtime-public.d.ts +300 -0
- package/lib/container-runtime-untrimmed.d.ts +1836 -0
- package/lib/containerRuntime.d.ts +30 -30
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +64 -42
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreRegistry.d.ts +1 -1
- package/lib/dataStoreRegistry.js +1 -1
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/dataStores.d.ts +10 -15
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +80 -43
- package/lib/dataStores.js.map +1 -1
- package/lib/gc/garbageCollection.d.ts +41 -13
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +217 -80
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.d.ts.map +1 -1
- package/lib/gc/gcConfigs.js +37 -40
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +121 -46
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js +25 -17
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcHelpers.d.ts +18 -25
- package/lib/gc/gcHelpers.d.ts.map +1 -1
- package/lib/gc/gcHelpers.js +27 -43
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcTelemetry.d.ts +0 -5
- package/lib/gc/gcTelemetry.d.ts.map +1 -1
- package/lib/gc/gcTelemetry.js +15 -43
- package/lib/gc/gcTelemetry.js.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.d.ts +11 -5
- package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.js +43 -19
- package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/lib/gc/index.d.ts +1 -1
- package/lib/gc/index.d.ts.map +1 -1
- package/lib/gc/index.js +1 -1
- package/lib/gc/index.js.map +1 -1
- package/lib/index.d.ts +14 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -1
- package/lib/index.js.map +1 -1
- package/lib/messageTypes.d.ts +15 -7
- package/lib/messageTypes.d.ts.map +1 -1
- package/lib/messageTypes.js +6 -1
- package/lib/messageTypes.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +1 -0
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +1 -0
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/summary/orderedClientElection.d.ts +1 -1
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/lib/summary/runWhileConnectedCoordinator.d.ts +2 -2
- package/lib/summary/runWhileConnectedCoordinator.js +1 -1
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/summary/summarizer.d.ts +1 -1
- package/lib/summary/summarizer.js +1 -1
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerTypes.d.ts +30 -30
- package/lib/summary/summarizerTypes.js.map +1 -1
- package/lib/summary/summaryCollection.d.ts +10 -10
- package/lib/summary/summaryCollection.js +1 -1
- package/lib/summary/summaryCollection.js.map +1 -1
- package/lib/summary/summaryFormat.d.ts +3 -3
- package/lib/summary/summaryFormat.js.map +1 -1
- package/package.json +42 -19
- package/src/blobManager.ts +5 -5
- package/src/containerRuntime.ts +86 -56
- package/src/dataStoreRegistry.ts +1 -1
- package/src/dataStores.ts +140 -69
- package/src/gc/garbageCollection.md +14 -15
- package/src/gc/garbageCollection.ts +256 -96
- package/src/gc/gcConfigs.ts +50 -52
- package/src/gc/gcDefinitions.ts +137 -52
- package/src/gc/gcHelpers.ts +31 -52
- package/src/gc/gcTelemetry.ts +16 -57
- package/src/gc/gcUnreferencedStateTracker.ts +61 -22
- package/src/gc/index.ts +6 -4
- package/src/index.ts +19 -1
- package/src/messageTypes.ts +19 -4
- package/src/opLifecycle/definitions.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +1 -0
- package/src/summary/orderedClientElection.ts +1 -1
- package/src/summary/runWhileConnectedCoordinator.ts +2 -2
- package/src/summary/summarizer.ts +1 -1
- package/src/summary/summarizerTypes.ts +30 -30
- package/src/summary/summaryCollection.ts +10 -10
- package/src/summary/summaryFormat.ts +3 -3
- package/dist/id-compressor/appendOnlySortedMap.d.ts +0 -124
- package/dist/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
- package/dist/id-compressor/appendOnlySortedMap.js +0 -318
- package/dist/id-compressor/appendOnlySortedMap.js.map +0 -1
- package/dist/id-compressor/finalSpace.d.ts +0 -29
- package/dist/id-compressor/finalSpace.d.ts.map +0 -1
- package/dist/id-compressor/finalSpace.js +0 -62
- package/dist/id-compressor/finalSpace.js.map +0 -1
- package/dist/id-compressor/idCompressor.d.ts +0 -54
- package/dist/id-compressor/idCompressor.d.ts.map +0 -1
- package/dist/id-compressor/idCompressor.js +0 -495
- package/dist/id-compressor/idCompressor.js.map +0 -1
- package/dist/id-compressor/identifiers.d.ts +0 -32
- package/dist/id-compressor/identifiers.d.ts.map +0 -1
- package/dist/id-compressor/identifiers.js +0 -15
- package/dist/id-compressor/identifiers.js.map +0 -1
- package/dist/id-compressor/index.d.ts +0 -13
- package/dist/id-compressor/index.d.ts.map +0 -1
- package/dist/id-compressor/index.js +0 -32
- package/dist/id-compressor/index.js.map +0 -1
- package/dist/id-compressor/persistanceUtilities.d.ts +0 -22
- package/dist/id-compressor/persistanceUtilities.d.ts.map +0 -1
- package/dist/id-compressor/persistanceUtilities.js +0 -43
- package/dist/id-compressor/persistanceUtilities.js.map +0 -1
- package/dist/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
- package/dist/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
- package/dist/id-compressor/sessionSpaceNormalizer.js +0 -80
- package/dist/id-compressor/sessionSpaceNormalizer.js.map +0 -1
- package/dist/id-compressor/sessions.d.ts +0 -115
- package/dist/id-compressor/sessions.d.ts.map +0 -1
- package/dist/id-compressor/sessions.js +0 -305
- package/dist/id-compressor/sessions.js.map +0 -1
- package/dist/id-compressor/utilities.d.ts +0 -52
- package/dist/id-compressor/utilities.d.ts.map +0 -1
- package/dist/id-compressor/utilities.js +0 -169
- package/dist/id-compressor/utilities.js.map +0 -1
- package/lib/id-compressor/appendOnlySortedMap.d.ts +0 -124
- package/lib/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
- package/lib/id-compressor/appendOnlySortedMap.js +0 -314
- package/lib/id-compressor/appendOnlySortedMap.js.map +0 -1
- package/lib/id-compressor/finalSpace.d.ts +0 -29
- package/lib/id-compressor/finalSpace.d.ts.map +0 -1
- package/lib/id-compressor/finalSpace.js +0 -58
- package/lib/id-compressor/finalSpace.js.map +0 -1
- package/lib/id-compressor/idCompressor.d.ts +0 -54
- package/lib/id-compressor/idCompressor.d.ts.map +0 -1
- package/lib/id-compressor/idCompressor.js +0 -491
- package/lib/id-compressor/idCompressor.js.map +0 -1
- package/lib/id-compressor/identifiers.d.ts +0 -32
- package/lib/id-compressor/identifiers.d.ts.map +0 -1
- package/lib/id-compressor/identifiers.js +0 -11
- package/lib/id-compressor/identifiers.js.map +0 -1
- package/lib/id-compressor/index.d.ts +0 -13
- package/lib/id-compressor/index.d.ts.map +0 -1
- package/lib/id-compressor/index.js +0 -13
- package/lib/id-compressor/index.js.map +0 -1
- package/lib/id-compressor/persistanceUtilities.d.ts +0 -22
- package/lib/id-compressor/persistanceUtilities.d.ts.map +0 -1
- package/lib/id-compressor/persistanceUtilities.js +0 -34
- package/lib/id-compressor/persistanceUtilities.js.map +0 -1
- package/lib/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
- package/lib/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
- package/lib/id-compressor/sessionSpaceNormalizer.js +0 -76
- package/lib/id-compressor/sessionSpaceNormalizer.js.map +0 -1
- package/lib/id-compressor/sessions.d.ts +0 -115
- package/lib/id-compressor/sessions.d.ts.map +0 -1
- package/lib/id-compressor/sessions.js +0 -290
- package/lib/id-compressor/sessions.js.map +0 -1
- package/lib/id-compressor/utilities.d.ts +0 -52
- package/lib/id-compressor/utilities.d.ts.map +0 -1
- package/lib/id-compressor/utilities.js +0 -151
- package/lib/id-compressor/utilities.js.map +0 -1
- package/src/id-compressor/README.md +0 -3
- package/src/id-compressor/appendOnlySortedMap.ts +0 -366
- package/src/id-compressor/finalSpace.ts +0 -67
- package/src/id-compressor/idCompressor.ts +0 -630
- package/src/id-compressor/identifiers.ts +0 -42
- package/src/id-compressor/index.ts +0 -26
- package/src/id-compressor/persistanceUtilities.ts +0 -58
- package/src/id-compressor/sessionSpaceNormalizer.ts +0 -83
- package/src/id-compressor/sessions.ts +0 -405
- package/src/id-compressor/utilities.ts +0 -190
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.AppendOnlySortedMap = void 0;
|
|
8
|
-
/* eslint-disable tsdoc/syntax */
|
|
9
|
-
/* eslint-disable no-bitwise */
|
|
10
|
-
const core_utils_1 = require("@fluidframework/core-utils");
|
|
11
|
-
/**
|
|
12
|
-
* A map in which entries are always added in key-sorted order.
|
|
13
|
-
* Supports appending and searching.
|
|
14
|
-
*/
|
|
15
|
-
class AppendOnlySortedMap {
|
|
16
|
-
/**
|
|
17
|
-
* @param comparator - a comparator for keys
|
|
18
|
-
*/
|
|
19
|
-
constructor(comparator) {
|
|
20
|
-
this.comparator = comparator;
|
|
21
|
-
this.elements = [];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @returns the number of entries in this map
|
|
25
|
-
*/
|
|
26
|
-
get size() {
|
|
27
|
-
return this.elements.length / 2;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @returns the min key in the map.
|
|
31
|
-
*/
|
|
32
|
-
minKey() {
|
|
33
|
-
return this.elements[0];
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @returns the max key in the map.
|
|
37
|
-
*/
|
|
38
|
-
maxKey() {
|
|
39
|
-
return this.elements[this.elements.length - 2];
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @returns the min value in the map.
|
|
43
|
-
*/
|
|
44
|
-
minValue() {
|
|
45
|
-
return this.elements[1];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @returns the min value in the map.
|
|
49
|
-
*/
|
|
50
|
-
maxValue() {
|
|
51
|
-
return this.elements[this.elements.length - 1];
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @returns the min key in the map.
|
|
55
|
-
*/
|
|
56
|
-
first() {
|
|
57
|
-
const { elements } = this;
|
|
58
|
-
const { length } = elements;
|
|
59
|
-
if (length === 0) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
return [elements[0], elements[1]];
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* @returns the max key in the map.
|
|
66
|
-
*/
|
|
67
|
-
last() {
|
|
68
|
-
const { elements } = this;
|
|
69
|
-
const { length } = elements;
|
|
70
|
-
if (length === 0) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
const lastKeyIndex = length - 2;
|
|
74
|
-
return [elements[lastKeyIndex], elements[lastKeyIndex + 1]];
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Returns the element at the insertion index.
|
|
78
|
-
*/
|
|
79
|
-
getAtIndex(index) {
|
|
80
|
-
const realIndex = index * 2;
|
|
81
|
-
const { elements } = this;
|
|
82
|
-
if (realIndex < 0 || realIndex > elements.length - 1) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
return [elements[realIndex], elements[realIndex + 1]];
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @returns an iterable of the entries in the map.
|
|
89
|
-
*/
|
|
90
|
-
*entries() {
|
|
91
|
-
const { elements } = this;
|
|
92
|
-
for (let i = 0; i < elements.length; i += 2) {
|
|
93
|
-
yield [elements[i], elements[i + 1]];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* @returns an iterable of the keys in the map.
|
|
98
|
-
*/
|
|
99
|
-
*keys() {
|
|
100
|
-
const { elements } = this;
|
|
101
|
-
for (let i = 0; i < elements.length; i += 2) {
|
|
102
|
-
yield elements[i];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* @returns an iterable of the values in the map.
|
|
107
|
-
*/
|
|
108
|
-
*values() {
|
|
109
|
-
const { elements } = this;
|
|
110
|
-
for (let i = 0; i < elements.length; i += 2) {
|
|
111
|
-
yield elements[i + 1];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* @returns an iterable of the entries in the map, reversed.
|
|
116
|
-
*/
|
|
117
|
-
*entriesReversed() {
|
|
118
|
-
const { elements } = this;
|
|
119
|
-
for (let i = elements.length - 2; i >= 0; i -= 2) {
|
|
120
|
-
yield [elements[i], elements[i + 1]];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Adds a new key/value pair to the map. `key` must be > to all keys in the map.
|
|
125
|
-
* @param key - the key to add.
|
|
126
|
-
* @param value - the value to add.
|
|
127
|
-
*/
|
|
128
|
-
append(key, value) {
|
|
129
|
-
const { elements } = this;
|
|
130
|
-
const { length } = elements;
|
|
131
|
-
if (length !== 0 && this.comparator(key, this.maxKey()) <= 0) {
|
|
132
|
-
throw new Error("Inserted key must be > all others in the map.");
|
|
133
|
-
}
|
|
134
|
-
elements.push(key);
|
|
135
|
-
elements.push(value);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Replaces the last key/value pair with the given one. If the map is empty, it simply appends.
|
|
139
|
-
* `key` must be > to all keys in the map prior to the one replaced.
|
|
140
|
-
* @param key - the key to add.
|
|
141
|
-
* @param value - the value to add.
|
|
142
|
-
*/
|
|
143
|
-
replaceLast(key, value) {
|
|
144
|
-
const { elements, comparator } = this;
|
|
145
|
-
const { length } = elements;
|
|
146
|
-
if (length !== 0) {
|
|
147
|
-
elements.pop();
|
|
148
|
-
elements.pop();
|
|
149
|
-
if (comparator(key, this.maxKey()) <= 0) {
|
|
150
|
-
throw new Error("Inserted key must be > all others in the map.");
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
elements.push(key);
|
|
154
|
-
elements.push(value);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* @param key - the key to lookup.
|
|
158
|
-
* @returns the value associated with `key` if such an entry exists, and undefined otherwise.
|
|
159
|
-
*/
|
|
160
|
-
get(key) {
|
|
161
|
-
const index = AppendOnlySortedMap.keyIndexOf(this.elements, key, this.comparator);
|
|
162
|
-
if (index < 0) {
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
return this.elements[index + 1];
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* @param key - the key to lookup.
|
|
169
|
-
* @returns the entry associated with `key` if such an entry exists, the entry associated with the next lower key if such an entry
|
|
170
|
-
* exists, and undefined otherwise.
|
|
171
|
-
*/
|
|
172
|
-
getPairOrNextLower(key) {
|
|
173
|
-
return this.getPairOrNextLowerBy(key, this.comparator);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* @param key - the key to lookup.
|
|
177
|
-
* @returns the entry associated with `key` if such an entry exists, the entry associated with the next higher key if such an entry
|
|
178
|
-
* exists, and undefined otherwise.
|
|
179
|
-
*/
|
|
180
|
-
getPairOrNextHigher(key) {
|
|
181
|
-
return this.getPairOrNextHigherBy(key, this.comparator);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Compares two `AppendOnlySortedMap`s.
|
|
185
|
-
*/
|
|
186
|
-
equals(other, compareValues) {
|
|
187
|
-
if (other === this) {
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
if (this.elements.length !== other.elements.length) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
for (let i = this.elements.length - 2; i >= 0; i -= 2) {
|
|
194
|
-
const keyThis = this.elements[i];
|
|
195
|
-
const valueThis = this.elements[i + 1];
|
|
196
|
-
const keyOther = other.elements[i];
|
|
197
|
-
const valueOther = other.elements[i + 1];
|
|
198
|
-
if (this.comparator(keyThis, keyOther) !== 0) {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
if (!compareValues(valueThis, valueOther)) {
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return true;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Test-only expensive assertions to check the internal validity of the data structure.
|
|
209
|
-
*/
|
|
210
|
-
assertValid() {
|
|
211
|
-
let prev;
|
|
212
|
-
for (const kv of this.entries()) {
|
|
213
|
-
if (prev !== undefined) {
|
|
214
|
-
(0, core_utils_1.assert)(this.comparator(kv[0], prev[0]) > 0, 0x752 /* Keys in map must be sorted. */);
|
|
215
|
-
}
|
|
216
|
-
prev = kv;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Queries a range of entries.
|
|
221
|
-
* @param from - the key to start the range query at, inclusive.
|
|
222
|
-
* @param to - the key to end the range query at, inclusive.
|
|
223
|
-
* @returns the range of entries.
|
|
224
|
-
*/
|
|
225
|
-
*getRange(from, to) {
|
|
226
|
-
const keyIndexFrom = this.getKeyIndexOfOrNextHigher(from, this.comparator);
|
|
227
|
-
if (keyIndexFrom === undefined) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
const keyIndexTo = this.getKeyIndexOfOrNextLower(to, this.comparator);
|
|
231
|
-
if (keyIndexTo === undefined) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
for (let i = keyIndexFrom; i <= keyIndexTo; i += 2) {
|
|
235
|
-
yield [this.elements[i], this.elements[i + 1]];
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
getPairOrNextLowerBy(search, comparator) {
|
|
239
|
-
const keyIndex = this.getKeyIndexOfOrNextLower(search, comparator);
|
|
240
|
-
if (keyIndex === undefined) {
|
|
241
|
-
return undefined;
|
|
242
|
-
}
|
|
243
|
-
return [this.elements[keyIndex], this.elements[keyIndex + 1]];
|
|
244
|
-
}
|
|
245
|
-
getKeyIndexOfOrNextLower(search, comparator) {
|
|
246
|
-
const { elements } = this;
|
|
247
|
-
if (elements.length === 0) {
|
|
248
|
-
return undefined;
|
|
249
|
-
}
|
|
250
|
-
let keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);
|
|
251
|
-
if (keyIndex < 0) {
|
|
252
|
-
keyIndex ^= AppendOnlySortedMap.failureXor;
|
|
253
|
-
if (keyIndex > 0) {
|
|
254
|
-
return keyIndex - 2;
|
|
255
|
-
}
|
|
256
|
-
return undefined;
|
|
257
|
-
}
|
|
258
|
-
return keyIndex;
|
|
259
|
-
}
|
|
260
|
-
getPairOrNextHigherBy(search, comparator) {
|
|
261
|
-
const keyIndex = this.getKeyIndexOfOrNextHigher(search, comparator);
|
|
262
|
-
if (keyIndex === undefined) {
|
|
263
|
-
return undefined;
|
|
264
|
-
}
|
|
265
|
-
return [this.elements[keyIndex], this.elements[keyIndex + 1]];
|
|
266
|
-
}
|
|
267
|
-
getKeyIndexOfOrNextHigher(search, comparator) {
|
|
268
|
-
const { elements } = this;
|
|
269
|
-
const { length } = elements;
|
|
270
|
-
if (length === 0) {
|
|
271
|
-
return undefined;
|
|
272
|
-
}
|
|
273
|
-
let keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);
|
|
274
|
-
if (keyIndex < 0) {
|
|
275
|
-
keyIndex ^= AppendOnlySortedMap.failureXor;
|
|
276
|
-
if (keyIndex < length) {
|
|
277
|
-
return keyIndex;
|
|
278
|
-
}
|
|
279
|
-
return undefined;
|
|
280
|
-
}
|
|
281
|
-
return keyIndex;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Performs a binary search on the sorted array.
|
|
285
|
-
* @returns the index of the key for `search`, or (if not present) the index it would have been inserted into xor'd
|
|
286
|
-
* with `failureXor`. Note that negating is not an adequate solution as that could result in -0.
|
|
287
|
-
*/
|
|
288
|
-
static keyIndexOf(elements, search, comparator) {
|
|
289
|
-
// Low, high, and mid are addresses of [K,V] pairs and *not* key indices
|
|
290
|
-
let low = 0;
|
|
291
|
-
let high = elements.length / 2;
|
|
292
|
-
let mid = high >> 1;
|
|
293
|
-
while (low < high) {
|
|
294
|
-
const keyIndex = mid * 2;
|
|
295
|
-
const c = comparator(search, elements[keyIndex], elements[keyIndex + 1]);
|
|
296
|
-
if (c > 0) {
|
|
297
|
-
low = mid + 1;
|
|
298
|
-
}
|
|
299
|
-
else if (c < 0) {
|
|
300
|
-
high = mid;
|
|
301
|
-
}
|
|
302
|
-
else if (c === 0) {
|
|
303
|
-
return keyIndex;
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
throw new Error("Invalid comparator.");
|
|
307
|
-
}
|
|
308
|
-
mid = (low + high) >> 1;
|
|
309
|
-
}
|
|
310
|
-
return (mid * 2) ^ AppendOnlySortedMap.failureXor;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
exports.AppendOnlySortedMap = AppendOnlySortedMap;
|
|
314
|
-
/**
|
|
315
|
-
* The value xor'd with the result index when a search fails.
|
|
316
|
-
*/
|
|
317
|
-
AppendOnlySortedMap.failureXor = -1;
|
|
318
|
-
//# sourceMappingURL=appendOnlySortedMap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appendOnlySortedMap.js","sourceRoot":"","sources":["../../src/id-compressor/appendOnlySortedMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iCAAiC;AACjC,+BAA+B;AAC/B,2DAAoD;AAEpD;;;GAGG;AACH,MAAa,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,CAAC;IAED;;OAEG;IACI,QAAQ;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAkB,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,QAAQ;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAkB,CAAC;IACjE,CAAC;IAED;;OAEG;IACI,KAAK;QACX,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;QAC5B,IAAI,MAAM,KAAK,CAAC,EAAE;YACjB,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAAM,CAAC,CAAC;IAC7C,CAAC;IAED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,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;;AA/VF,kDAgWC;AAnCA;;GAEG;AACoB,8BAAU,GAAG,CAAC,CAAC,AAAL,CAAM","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"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { IdCluster } from "./sessions";
|
|
6
|
-
import { FinalCompressedId } from "./identifiers";
|
|
7
|
-
/**
|
|
8
|
-
* All IDs that have been finalized (acked), grouped into clusters sorted by their base final IDs.
|
|
9
|
-
* These clusters span the positive integer space and are not sparse, meaning a cluster's base final
|
|
10
|
-
* ID will always be one greater than the last final ID in the previous cluster (or 0 if there is not one).
|
|
11
|
-
*/
|
|
12
|
-
export declare class FinalSpace {
|
|
13
|
-
private readonly clusterList;
|
|
14
|
-
get clusters(): readonly IdCluster[];
|
|
15
|
-
getLastCluster(): IdCluster | undefined;
|
|
16
|
-
addCluster(newCluster: IdCluster): void;
|
|
17
|
-
/**
|
|
18
|
-
* @returns the upper bound (exclusive) of finalized IDs in final space, i.e. one greater than the last final ID in the last cluster.
|
|
19
|
-
* Note: this does not include allocated but unfinalized space in clusters.
|
|
20
|
-
*/
|
|
21
|
-
getFinalizedIdLimit(): FinalCompressedId;
|
|
22
|
-
/**
|
|
23
|
-
* @returns the upper bound (exclusive) of allocated IDs in final space, i.e. one greater than the last final ID in the last cluster.
|
|
24
|
-
* Note: this does includes all allocated IDs in clusters.
|
|
25
|
-
*/
|
|
26
|
-
getAllocatedIdLimit(): FinalCompressedId;
|
|
27
|
-
equals(other: FinalSpace): boolean;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=finalSpace.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finalSpace.d.ts","sourceRoot":"","sources":["../../src/id-compressor/finalSpace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAyD,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;;;GAIG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmB;IAE/C,IAAW,QAAQ,IAAI,SAAS,SAAS,EAAE,CAE1C;IAEM,cAAc,IAAI,SAAS,GAAG,SAAS;IAIvC,UAAU,CAAC,UAAU,EAAE,SAAS;IAWvC;;;OAGG;IACI,mBAAmB,IAAI,iBAAiB;IAO/C;;;OAGG;IACI,mBAAmB,IAAI,iBAAiB;IAOxC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;CAQzC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.FinalSpace = void 0;
|
|
8
|
-
const core_utils_1 = require("@fluidframework/core-utils");
|
|
9
|
-
const sessions_1 = require("./sessions");
|
|
10
|
-
/**
|
|
11
|
-
* All IDs that have been finalized (acked), grouped into clusters sorted by their base final IDs.
|
|
12
|
-
* These clusters span the positive integer space and are not sparse, meaning a cluster's base final
|
|
13
|
-
* ID will always be one greater than the last final ID in the previous cluster (or 0 if there is not one).
|
|
14
|
-
*/
|
|
15
|
-
class FinalSpace {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.clusterList = [];
|
|
18
|
-
}
|
|
19
|
-
get clusters() {
|
|
20
|
-
return this.clusterList;
|
|
21
|
-
}
|
|
22
|
-
getLastCluster() {
|
|
23
|
-
return this.clusterList[this.clusterList.length - 1];
|
|
24
|
-
}
|
|
25
|
-
addCluster(newCluster) {
|
|
26
|
-
const lastCluster = this.getLastCluster();
|
|
27
|
-
(0, core_utils_1.assert)(lastCluster === undefined ||
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
29
|
-
newCluster.baseFinalId === lastCluster.baseFinalId + lastCluster.capacity, 0x753 /* Cluster insert to final_space is out of order. */);
|
|
30
|
-
this.clusterList.push(newCluster);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @returns the upper bound (exclusive) of finalized IDs in final space, i.e. one greater than the last final ID in the last cluster.
|
|
34
|
-
* Note: this does not include allocated but unfinalized space in clusters.
|
|
35
|
-
*/
|
|
36
|
-
getFinalizedIdLimit() {
|
|
37
|
-
const lastCluster = this.getLastCluster();
|
|
38
|
-
return lastCluster === undefined
|
|
39
|
-
? 0
|
|
40
|
-
: ((0, sessions_1.lastFinalizedFinal)(lastCluster) + 1);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* @returns the upper bound (exclusive) of allocated IDs in final space, i.e. one greater than the last final ID in the last cluster.
|
|
44
|
-
* Note: this does includes all allocated IDs in clusters.
|
|
45
|
-
*/
|
|
46
|
-
getAllocatedIdLimit() {
|
|
47
|
-
const lastCluster = this.getLastCluster();
|
|
48
|
-
return lastCluster === undefined
|
|
49
|
-
? 0
|
|
50
|
-
: ((0, sessions_1.lastAllocatedFinal)(lastCluster) + 1);
|
|
51
|
-
}
|
|
52
|
-
equals(other) {
|
|
53
|
-
for (let i = 0; i < this.clusterList.length; i++) {
|
|
54
|
-
if (!(0, sessions_1.clustersEqual)(this.clusterList[i], other.clusterList[i])) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return this.clusterList.length === other.clusterList.length;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.FinalSpace = FinalSpace;
|
|
62
|
-
//# sourceMappingURL=finalSpace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finalSpace.js","sourceRoot":"","sources":["../../src/id-compressor/finalSpace.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,yCAA8F;AAG9F;;;;GAIG;AACH,MAAa,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,IAAA,mBAAM,EACL,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,IAAA,6BAAkB,EAAC,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,IAAA,6BAAkB,EAAC,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,IAAA,wBAAa,EAAC,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;AApDD,gCAoDC","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,54 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { IdCreationRange, IIdCompressor, IIdCompressorCore, OpSpaceCompressedId, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, SessionId, SessionSpaceCompressedId, StableId } from "@fluidframework/runtime-definitions";
|
|
6
|
-
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
|
-
/**
|
|
8
|
-
* See {@link IIdCompressor} and {@link IIdCompressorCore}
|
|
9
|
-
*/
|
|
10
|
-
export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
11
|
-
private readonly logger?;
|
|
12
|
-
/**
|
|
13
|
-
* Max allowed initial cluster size.
|
|
14
|
-
*/
|
|
15
|
-
static readonly maxClusterSize: number;
|
|
16
|
-
readonly localSessionId: SessionId;
|
|
17
|
-
private readonly localSession;
|
|
18
|
-
private readonly normalizer;
|
|
19
|
-
private localGenCount;
|
|
20
|
-
private nextRangeBaseGenCount;
|
|
21
|
-
private newClusterCapacity;
|
|
22
|
-
private readonly sessions;
|
|
23
|
-
private readonly finalSpace;
|
|
24
|
-
private telemetryLocalIdCount;
|
|
25
|
-
private telemetryEagerFinalIdCount;
|
|
26
|
-
private constructor();
|
|
27
|
-
static create(logger?: ITelemetryBaseLogger): IdCompressor;
|
|
28
|
-
static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IdCompressor;
|
|
29
|
-
/**
|
|
30
|
-
* The size of each newly created ID cluster.
|
|
31
|
-
*/
|
|
32
|
-
get clusterCapacity(): number;
|
|
33
|
-
/**
|
|
34
|
-
* Must only be set with a value upon which consensus has been reached. Value must be greater than zero and less than
|
|
35
|
-
* `IdCompressor.maxClusterSize`.
|
|
36
|
-
*/
|
|
37
|
-
set clusterCapacity(value: number);
|
|
38
|
-
generateCompressedId(): SessionSpaceCompressedId;
|
|
39
|
-
private generateNextLocalId;
|
|
40
|
-
takeNextCreationRange(): IdCreationRange;
|
|
41
|
-
finalizeCreationRange(range: IdCreationRange): void;
|
|
42
|
-
private addEmptyCluster;
|
|
43
|
-
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
44
|
-
normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
|
|
45
|
-
decompress(id: SessionSpaceCompressedId): StableId;
|
|
46
|
-
recompress(uncompressed: StableId): SessionSpaceCompressedId;
|
|
47
|
-
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
48
|
-
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
49
|
-
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
50
|
-
static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;
|
|
51
|
-
static deserialize(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IdCompressor;
|
|
52
|
-
equals(other: IdCompressor, includeLocalState: boolean): boolean;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=idCompressor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../../src/id-compressor/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,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,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