mvcc-api 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.cjs
CHANGED
|
@@ -42,6 +42,8 @@ var MVCCTransaction = class {
|
|
|
42
42
|
// create()로 생성된 키 추적
|
|
43
43
|
deletedValues;
|
|
44
44
|
// delete 시 삭제 전 값 저장
|
|
45
|
+
originallyExisted;
|
|
46
|
+
// 트랜잭션 시작 시점에 디스크에 존재했던 키 (deleted 결과 필터링용)
|
|
45
47
|
// Nested Transaction Properties
|
|
46
48
|
parent;
|
|
47
49
|
localVersion;
|
|
@@ -61,6 +63,7 @@ var MVCCTransaction = class {
|
|
|
61
63
|
this.deleteBuffer = /* @__PURE__ */ new Set();
|
|
62
64
|
this.createdKeys = /* @__PURE__ */ new Set();
|
|
63
65
|
this.deletedValues = /* @__PURE__ */ new Map();
|
|
66
|
+
this.originallyExisted = /* @__PURE__ */ new Set();
|
|
64
67
|
this.committed = false;
|
|
65
68
|
this.parent = parent;
|
|
66
69
|
this.keyVersions = /* @__PURE__ */ new Map();
|
|
@@ -87,6 +90,7 @@ var MVCCTransaction = class {
|
|
|
87
90
|
this.writeBuffer.set(key, value);
|
|
88
91
|
this.createdKeys.add(key);
|
|
89
92
|
this.deleteBuffer.delete(key);
|
|
93
|
+
this.originallyExisted.delete(key);
|
|
90
94
|
this.keyVersions.set(key, this.localVersion);
|
|
91
95
|
}
|
|
92
96
|
_bufferWrite(key, value) {
|
|
@@ -119,6 +123,7 @@ var MVCCTransaction = class {
|
|
|
119
123
|
}
|
|
120
124
|
const deleted = [];
|
|
121
125
|
for (const key of this.deleteBuffer) {
|
|
126
|
+
if (!this.originallyExisted.has(key)) continue;
|
|
122
127
|
const data = this.deletedValues.get(key);
|
|
123
128
|
if (data !== void 0) {
|
|
124
129
|
deleted.push({ key, data });
|
|
@@ -128,6 +133,7 @@ var MVCCTransaction = class {
|
|
|
128
133
|
this.deleteBuffer.clear();
|
|
129
134
|
this.createdKeys.clear();
|
|
130
135
|
this.deletedValues.clear();
|
|
136
|
+
this.originallyExisted.clear();
|
|
131
137
|
this.committed = true;
|
|
132
138
|
if (this.root !== this) {
|
|
133
139
|
this.root.activeTransactions.delete(this);
|
|
@@ -161,8 +167,10 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
161
167
|
delete(key) {
|
|
162
168
|
if (this.committed) throw new Error("Transaction already committed");
|
|
163
169
|
let valueToDelete = null;
|
|
170
|
+
let wasInWriteBuffer = false;
|
|
164
171
|
if (this.writeBuffer.has(key)) {
|
|
165
172
|
valueToDelete = this.writeBuffer.get(key);
|
|
173
|
+
wasInWriteBuffer = true;
|
|
166
174
|
} else if (!this.deleteBuffer.has(key)) {
|
|
167
175
|
valueToDelete = this.read(key);
|
|
168
176
|
}
|
|
@@ -170,6 +178,9 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
170
178
|
throw new Error(`Key not found: ${key}`);
|
|
171
179
|
}
|
|
172
180
|
this.deletedValues.set(key, valueToDelete);
|
|
181
|
+
if (!wasInWriteBuffer || !this.createdKeys.has(key)) {
|
|
182
|
+
this.originallyExisted.add(key);
|
|
183
|
+
}
|
|
173
184
|
this._bufferDelete(key);
|
|
174
185
|
return this;
|
|
175
186
|
}
|
|
@@ -226,6 +237,7 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
226
237
|
}
|
|
227
238
|
const deleted = [];
|
|
228
239
|
for (const key of this.deleteBuffer) {
|
|
240
|
+
if (!this.originallyExisted.has(key)) continue;
|
|
229
241
|
const data = this.deletedValues.get(key);
|
|
230
242
|
if (data !== void 0) {
|
|
231
243
|
deleted.push({ key, data });
|
|
@@ -247,6 +259,7 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
247
259
|
this.deleteBuffer.clear();
|
|
248
260
|
this.createdKeys.clear();
|
|
249
261
|
this.deletedValues.clear();
|
|
262
|
+
this.originallyExisted.clear();
|
|
250
263
|
this.keyVersions.clear();
|
|
251
264
|
this.localVersion = 0;
|
|
252
265
|
}
|
|
@@ -285,6 +298,9 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
285
298
|
if (deletedValue !== void 0) {
|
|
286
299
|
this.deletedValues.set(key, deletedValue);
|
|
287
300
|
}
|
|
301
|
+
if (child.originallyExisted.has(key)) {
|
|
302
|
+
this.originallyExisted.add(key);
|
|
303
|
+
}
|
|
288
304
|
}
|
|
289
305
|
this.localVersion = newLocalVersion;
|
|
290
306
|
this.root.activeTransactions.delete(child);
|
|
@@ -703,8 +719,10 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
703
719
|
async delete(key) {
|
|
704
720
|
if (this.committed) throw new Error("Transaction already committed");
|
|
705
721
|
let valueToDelete = null;
|
|
722
|
+
let wasInWriteBuffer = false;
|
|
706
723
|
if (this.writeBuffer.has(key)) {
|
|
707
724
|
valueToDelete = this.writeBuffer.get(key);
|
|
725
|
+
wasInWriteBuffer = true;
|
|
708
726
|
} else if (!this.deleteBuffer.has(key)) {
|
|
709
727
|
valueToDelete = await this.read(key);
|
|
710
728
|
}
|
|
@@ -712,6 +730,9 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
712
730
|
throw new Error(`Key not found: ${key}`);
|
|
713
731
|
}
|
|
714
732
|
this.deletedValues.set(key, valueToDelete);
|
|
733
|
+
if (!wasInWriteBuffer || !this.createdKeys.has(key)) {
|
|
734
|
+
this.originallyExisted.add(key);
|
|
735
|
+
}
|
|
715
736
|
this._bufferDelete(key);
|
|
716
737
|
return this;
|
|
717
738
|
}
|
|
@@ -769,6 +790,7 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
769
790
|
}
|
|
770
791
|
const deleted = [];
|
|
771
792
|
for (const key of this.deleteBuffer) {
|
|
793
|
+
if (!this.originallyExisted.has(key)) continue;
|
|
772
794
|
const data = this.deletedValues.get(key);
|
|
773
795
|
if (data !== void 0) {
|
|
774
796
|
deleted.push({ key, data });
|
|
@@ -790,6 +812,7 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
790
812
|
this.deleteBuffer.clear();
|
|
791
813
|
this.createdKeys.clear();
|
|
792
814
|
this.deletedValues.clear();
|
|
815
|
+
this.originallyExisted.clear();
|
|
793
816
|
this.keyVersions.clear();
|
|
794
817
|
this.localVersion = 0;
|
|
795
818
|
}
|
|
@@ -830,6 +853,9 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
830
853
|
if (deletedValue !== void 0) {
|
|
831
854
|
this.deletedValues.set(key, deletedValue);
|
|
832
855
|
}
|
|
856
|
+
if (child.originallyExisted.has(key)) {
|
|
857
|
+
this.originallyExisted.add(key);
|
|
858
|
+
}
|
|
833
859
|
}
|
|
834
860
|
this.localVersion = newLocalVersion;
|
|
835
861
|
this.root.activeTransactions.delete(child);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -13,6 +13,8 @@ var MVCCTransaction = class {
|
|
|
13
13
|
// create()로 생성된 키 추적
|
|
14
14
|
deletedValues;
|
|
15
15
|
// delete 시 삭제 전 값 저장
|
|
16
|
+
originallyExisted;
|
|
17
|
+
// 트랜잭션 시작 시점에 디스크에 존재했던 키 (deleted 결과 필터링용)
|
|
16
18
|
// Nested Transaction Properties
|
|
17
19
|
parent;
|
|
18
20
|
localVersion;
|
|
@@ -32,6 +34,7 @@ var MVCCTransaction = class {
|
|
|
32
34
|
this.deleteBuffer = /* @__PURE__ */ new Set();
|
|
33
35
|
this.createdKeys = /* @__PURE__ */ new Set();
|
|
34
36
|
this.deletedValues = /* @__PURE__ */ new Map();
|
|
37
|
+
this.originallyExisted = /* @__PURE__ */ new Set();
|
|
35
38
|
this.committed = false;
|
|
36
39
|
this.parent = parent;
|
|
37
40
|
this.keyVersions = /* @__PURE__ */ new Map();
|
|
@@ -58,6 +61,7 @@ var MVCCTransaction = class {
|
|
|
58
61
|
this.writeBuffer.set(key, value);
|
|
59
62
|
this.createdKeys.add(key);
|
|
60
63
|
this.deleteBuffer.delete(key);
|
|
64
|
+
this.originallyExisted.delete(key);
|
|
61
65
|
this.keyVersions.set(key, this.localVersion);
|
|
62
66
|
}
|
|
63
67
|
_bufferWrite(key, value) {
|
|
@@ -90,6 +94,7 @@ var MVCCTransaction = class {
|
|
|
90
94
|
}
|
|
91
95
|
const deleted = [];
|
|
92
96
|
for (const key of this.deleteBuffer) {
|
|
97
|
+
if (!this.originallyExisted.has(key)) continue;
|
|
93
98
|
const data = this.deletedValues.get(key);
|
|
94
99
|
if (data !== void 0) {
|
|
95
100
|
deleted.push({ key, data });
|
|
@@ -99,6 +104,7 @@ var MVCCTransaction = class {
|
|
|
99
104
|
this.deleteBuffer.clear();
|
|
100
105
|
this.createdKeys.clear();
|
|
101
106
|
this.deletedValues.clear();
|
|
107
|
+
this.originallyExisted.clear();
|
|
102
108
|
this.committed = true;
|
|
103
109
|
if (this.root !== this) {
|
|
104
110
|
this.root.activeTransactions.delete(this);
|
|
@@ -132,8 +138,10 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
132
138
|
delete(key) {
|
|
133
139
|
if (this.committed) throw new Error("Transaction already committed");
|
|
134
140
|
let valueToDelete = null;
|
|
141
|
+
let wasInWriteBuffer = false;
|
|
135
142
|
if (this.writeBuffer.has(key)) {
|
|
136
143
|
valueToDelete = this.writeBuffer.get(key);
|
|
144
|
+
wasInWriteBuffer = true;
|
|
137
145
|
} else if (!this.deleteBuffer.has(key)) {
|
|
138
146
|
valueToDelete = this.read(key);
|
|
139
147
|
}
|
|
@@ -141,6 +149,9 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
141
149
|
throw new Error(`Key not found: ${key}`);
|
|
142
150
|
}
|
|
143
151
|
this.deletedValues.set(key, valueToDelete);
|
|
152
|
+
if (!wasInWriteBuffer || !this.createdKeys.has(key)) {
|
|
153
|
+
this.originallyExisted.add(key);
|
|
154
|
+
}
|
|
144
155
|
this._bufferDelete(key);
|
|
145
156
|
return this;
|
|
146
157
|
}
|
|
@@ -197,6 +208,7 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
197
208
|
}
|
|
198
209
|
const deleted = [];
|
|
199
210
|
for (const key of this.deleteBuffer) {
|
|
211
|
+
if (!this.originallyExisted.has(key)) continue;
|
|
200
212
|
const data = this.deletedValues.get(key);
|
|
201
213
|
if (data !== void 0) {
|
|
202
214
|
deleted.push({ key, data });
|
|
@@ -218,6 +230,7 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
218
230
|
this.deleteBuffer.clear();
|
|
219
231
|
this.createdKeys.clear();
|
|
220
232
|
this.deletedValues.clear();
|
|
233
|
+
this.originallyExisted.clear();
|
|
221
234
|
this.keyVersions.clear();
|
|
222
235
|
this.localVersion = 0;
|
|
223
236
|
}
|
|
@@ -256,6 +269,9 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
256
269
|
if (deletedValue !== void 0) {
|
|
257
270
|
this.deletedValues.set(key, deletedValue);
|
|
258
271
|
}
|
|
272
|
+
if (child.originallyExisted.has(key)) {
|
|
273
|
+
this.originallyExisted.add(key);
|
|
274
|
+
}
|
|
259
275
|
}
|
|
260
276
|
this.localVersion = newLocalVersion;
|
|
261
277
|
this.root.activeTransactions.delete(child);
|
|
@@ -674,8 +690,10 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
674
690
|
async delete(key) {
|
|
675
691
|
if (this.committed) throw new Error("Transaction already committed");
|
|
676
692
|
let valueToDelete = null;
|
|
693
|
+
let wasInWriteBuffer = false;
|
|
677
694
|
if (this.writeBuffer.has(key)) {
|
|
678
695
|
valueToDelete = this.writeBuffer.get(key);
|
|
696
|
+
wasInWriteBuffer = true;
|
|
679
697
|
} else if (!this.deleteBuffer.has(key)) {
|
|
680
698
|
valueToDelete = await this.read(key);
|
|
681
699
|
}
|
|
@@ -683,6 +701,9 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
683
701
|
throw new Error(`Key not found: ${key}`);
|
|
684
702
|
}
|
|
685
703
|
this.deletedValues.set(key, valueToDelete);
|
|
704
|
+
if (!wasInWriteBuffer || !this.createdKeys.has(key)) {
|
|
705
|
+
this.originallyExisted.add(key);
|
|
706
|
+
}
|
|
686
707
|
this._bufferDelete(key);
|
|
687
708
|
return this;
|
|
688
709
|
}
|
|
@@ -740,6 +761,7 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
740
761
|
}
|
|
741
762
|
const deleted = [];
|
|
742
763
|
for (const key of this.deleteBuffer) {
|
|
764
|
+
if (!this.originallyExisted.has(key)) continue;
|
|
743
765
|
const data = this.deletedValues.get(key);
|
|
744
766
|
if (data !== void 0) {
|
|
745
767
|
deleted.push({ key, data });
|
|
@@ -761,6 +783,7 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
761
783
|
this.deleteBuffer.clear();
|
|
762
784
|
this.createdKeys.clear();
|
|
763
785
|
this.deletedValues.clear();
|
|
786
|
+
this.originallyExisted.clear();
|
|
764
787
|
this.keyVersions.clear();
|
|
765
788
|
this.localVersion = 0;
|
|
766
789
|
}
|
|
@@ -801,6 +824,9 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
801
824
|
if (deletedValue !== void 0) {
|
|
802
825
|
this.deletedValues.set(key, deletedValue);
|
|
803
826
|
}
|
|
827
|
+
if (child.originallyExisted.has(key)) {
|
|
828
|
+
this.originallyExisted.add(key);
|
|
829
|
+
}
|
|
804
830
|
}
|
|
805
831
|
this.localVersion = newLocalVersion;
|
|
806
832
|
this.root.activeTransactions.delete(child);
|
|
@@ -16,6 +16,7 @@ export declare abstract class MVCCTransaction<S extends MVCCStrategy<K, T>, K, T
|
|
|
16
16
|
readonly deleteBuffer: Set<K>;
|
|
17
17
|
readonly createdKeys: Set<K>;
|
|
18
18
|
readonly deletedValues: Map<K, T>;
|
|
19
|
+
readonly originallyExisted: Set<K>;
|
|
19
20
|
readonly parent?: MVCCTransaction<S, K, T>;
|
|
20
21
|
localVersion: number;
|
|
21
22
|
readonly keyVersions: Map<K, number>;
|