dataply 0.0.26-alpha.2 → 0.0.26-alpha.4
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.js +57 -39
- package/dist/types/index.d.ts +2 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -49,6 +49,8 @@ __export(src_exports, {
|
|
|
49
49
|
IndexPageManager: () => IndexPageManager,
|
|
50
50
|
InvertedWeakMap: () => InvertedWeakMap,
|
|
51
51
|
LRUMap: () => LRUMap2,
|
|
52
|
+
Logger: () => Logger,
|
|
53
|
+
LoggerManager: () => LoggerManager,
|
|
52
54
|
MVCCStrategy: () => MVCCStrategy2,
|
|
53
55
|
MVCCTransaction: () => MVCCTransaction2,
|
|
54
56
|
MetadataPageManager: () => MetadataPageManager,
|
|
@@ -445,11 +447,7 @@ var MVCCTransaction = class {
|
|
|
445
447
|
*/
|
|
446
448
|
rollback() {
|
|
447
449
|
const { created, updated, deleted } = this.getResultEntries();
|
|
448
|
-
this.
|
|
449
|
-
this.deleteBuffer.clear();
|
|
450
|
-
this.createdKeys.clear();
|
|
451
|
-
this.deletedValues.clear();
|
|
452
|
-
this.originallyExisted.clear();
|
|
450
|
+
this._cleanupAll();
|
|
453
451
|
this.committed = true;
|
|
454
452
|
if (this.root !== this) {
|
|
455
453
|
this.root.activeTransactions.delete(this);
|
|
@@ -485,6 +483,19 @@ var MVCCTransaction = class {
|
|
|
485
483
|
}
|
|
486
484
|
return Array.from(conflicts);
|
|
487
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* Cleans up all buffers and history.
|
|
488
|
+
* This method is called by the commit method.
|
|
489
|
+
*/
|
|
490
|
+
_cleanupAll() {
|
|
491
|
+
this.writeBuffer.clear();
|
|
492
|
+
this.deleteBuffer.clear();
|
|
493
|
+
this.createdKeys.clear();
|
|
494
|
+
this.deletedValues.clear();
|
|
495
|
+
this.originallyExisted.clear();
|
|
496
|
+
this.keyVersions.clear();
|
|
497
|
+
this.bufferHistory.clear();
|
|
498
|
+
}
|
|
488
499
|
/**
|
|
489
500
|
* Cleans up both deletedCache and versionIndex based on minActiveVersion.
|
|
490
501
|
* Root transactions call this after commit to reclaim memory.
|
|
@@ -676,6 +687,7 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
676
687
|
if (this.parent) {
|
|
677
688
|
const failure = this.parent._merge(this);
|
|
678
689
|
if (failure) {
|
|
690
|
+
this.rollback();
|
|
679
691
|
return {
|
|
680
692
|
label,
|
|
681
693
|
success: false,
|
|
@@ -686,11 +698,13 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
686
698
|
deleted
|
|
687
699
|
};
|
|
688
700
|
}
|
|
701
|
+
this._cleanupAll();
|
|
689
702
|
this.committed = true;
|
|
690
703
|
} else {
|
|
691
704
|
if (this.writeBuffer.size > 0 || this.deleteBuffer.size > 0) {
|
|
692
705
|
const failure = this._merge(this);
|
|
693
706
|
if (failure) {
|
|
707
|
+
this.rollback();
|
|
694
708
|
return {
|
|
695
709
|
label,
|
|
696
710
|
success: false,
|
|
@@ -701,13 +715,7 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
701
715
|
deleted: []
|
|
702
716
|
};
|
|
703
717
|
}
|
|
704
|
-
this.
|
|
705
|
-
this.deleteBuffer.clear();
|
|
706
|
-
this.createdKeys.clear();
|
|
707
|
-
this.deletedValues.clear();
|
|
708
|
-
this.originallyExisted.clear();
|
|
709
|
-
this.keyVersions.clear();
|
|
710
|
-
this.bufferHistory.clear();
|
|
718
|
+
this._cleanupAll();
|
|
711
719
|
this.localVersion = 0;
|
|
712
720
|
this.snapshotVersion = this.version;
|
|
713
721
|
}
|
|
@@ -1341,6 +1349,7 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
1341
1349
|
if (this.parent) {
|
|
1342
1350
|
const failure = await this.parent._merge(this);
|
|
1343
1351
|
if (failure) {
|
|
1352
|
+
this.rollback();
|
|
1344
1353
|
return {
|
|
1345
1354
|
label,
|
|
1346
1355
|
success: false,
|
|
@@ -1351,11 +1360,13 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
1351
1360
|
deleted
|
|
1352
1361
|
};
|
|
1353
1362
|
}
|
|
1363
|
+
this._cleanupAll();
|
|
1354
1364
|
this.committed = true;
|
|
1355
1365
|
} else {
|
|
1356
1366
|
if (this.writeBuffer.size > 0 || this.deleteBuffer.size > 0) {
|
|
1357
1367
|
const failure = await this._merge(this);
|
|
1358
1368
|
if (failure) {
|
|
1369
|
+
this.rollback();
|
|
1359
1370
|
return {
|
|
1360
1371
|
label,
|
|
1361
1372
|
success: false,
|
|
@@ -1366,13 +1377,7 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
1366
1377
|
deleted: []
|
|
1367
1378
|
};
|
|
1368
1379
|
}
|
|
1369
|
-
this.
|
|
1370
|
-
this.deleteBuffer.clear();
|
|
1371
|
-
this.createdKeys.clear();
|
|
1372
|
-
this.deletedValues.clear();
|
|
1373
|
-
this.originallyExisted.clear();
|
|
1374
|
-
this.keyVersions.clear();
|
|
1375
|
-
this.bufferHistory.clear();
|
|
1380
|
+
this._cleanupAll();
|
|
1376
1381
|
this.localVersion = 0;
|
|
1377
1382
|
this.snapshotVersion = this.version;
|
|
1378
1383
|
}
|
|
@@ -2927,8 +2932,12 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2927
2932
|
result = this.rootTx.commit(label);
|
|
2928
2933
|
if (result.success) {
|
|
2929
2934
|
this.rootTx.rootId = this.rootId;
|
|
2935
|
+
} else {
|
|
2936
|
+
this.mvcc.rollback();
|
|
2930
2937
|
}
|
|
2931
2938
|
}
|
|
2939
|
+
} else {
|
|
2940
|
+
this.mvcc.rollback();
|
|
2932
2941
|
}
|
|
2933
2942
|
return result;
|
|
2934
2943
|
}
|
|
@@ -4129,8 +4138,12 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
4129
4138
|
result = await this.rootTx.commit(label);
|
|
4130
4139
|
if (result.success) {
|
|
4131
4140
|
this.rootTx.rootId = this.rootId;
|
|
4141
|
+
} else {
|
|
4142
|
+
this.mvcc.rollback();
|
|
4132
4143
|
}
|
|
4133
4144
|
}
|
|
4145
|
+
} else {
|
|
4146
|
+
this.mvcc.rollback();
|
|
4134
4147
|
}
|
|
4135
4148
|
return result;
|
|
4136
4149
|
}
|
|
@@ -5401,11 +5414,7 @@ var MVCCTransaction2 = class {
|
|
|
5401
5414
|
*/
|
|
5402
5415
|
rollback() {
|
|
5403
5416
|
const { created, updated, deleted } = this.getResultEntries();
|
|
5404
|
-
this.
|
|
5405
|
-
this.deleteBuffer.clear();
|
|
5406
|
-
this.createdKeys.clear();
|
|
5407
|
-
this.deletedValues.clear();
|
|
5408
|
-
this.originallyExisted.clear();
|
|
5417
|
+
this._cleanupAll();
|
|
5409
5418
|
this.committed = true;
|
|
5410
5419
|
if (this.root !== this) {
|
|
5411
5420
|
this.root.activeTransactions.delete(this);
|
|
@@ -5441,6 +5450,19 @@ var MVCCTransaction2 = class {
|
|
|
5441
5450
|
}
|
|
5442
5451
|
return Array.from(conflicts);
|
|
5443
5452
|
}
|
|
5453
|
+
/**
|
|
5454
|
+
* Cleans up all buffers and history.
|
|
5455
|
+
* This method is called by the commit method.
|
|
5456
|
+
*/
|
|
5457
|
+
_cleanupAll() {
|
|
5458
|
+
this.writeBuffer.clear();
|
|
5459
|
+
this.deleteBuffer.clear();
|
|
5460
|
+
this.createdKeys.clear();
|
|
5461
|
+
this.deletedValues.clear();
|
|
5462
|
+
this.originallyExisted.clear();
|
|
5463
|
+
this.keyVersions.clear();
|
|
5464
|
+
this.bufferHistory.clear();
|
|
5465
|
+
}
|
|
5444
5466
|
/**
|
|
5445
5467
|
* Cleans up both deletedCache and versionIndex based on minActiveVersion.
|
|
5446
5468
|
* Root transactions call this after commit to reclaim memory.
|
|
@@ -5632,6 +5654,7 @@ var SyncMVCCTransaction2 = class _SyncMVCCTransaction2 extends MVCCTransaction2
|
|
|
5632
5654
|
if (this.parent) {
|
|
5633
5655
|
const failure = this.parent._merge(this);
|
|
5634
5656
|
if (failure) {
|
|
5657
|
+
this.rollback();
|
|
5635
5658
|
return {
|
|
5636
5659
|
label,
|
|
5637
5660
|
success: false,
|
|
@@ -5642,11 +5665,13 @@ var SyncMVCCTransaction2 = class _SyncMVCCTransaction2 extends MVCCTransaction2
|
|
|
5642
5665
|
deleted
|
|
5643
5666
|
};
|
|
5644
5667
|
}
|
|
5668
|
+
this._cleanupAll();
|
|
5645
5669
|
this.committed = true;
|
|
5646
5670
|
} else {
|
|
5647
5671
|
if (this.writeBuffer.size > 0 || this.deleteBuffer.size > 0) {
|
|
5648
5672
|
const failure = this._merge(this);
|
|
5649
5673
|
if (failure) {
|
|
5674
|
+
this.rollback();
|
|
5650
5675
|
return {
|
|
5651
5676
|
label,
|
|
5652
5677
|
success: false,
|
|
@@ -5657,13 +5682,7 @@ var SyncMVCCTransaction2 = class _SyncMVCCTransaction2 extends MVCCTransaction2
|
|
|
5657
5682
|
deleted: []
|
|
5658
5683
|
};
|
|
5659
5684
|
}
|
|
5660
|
-
this.
|
|
5661
|
-
this.deleteBuffer.clear();
|
|
5662
|
-
this.createdKeys.clear();
|
|
5663
|
-
this.deletedValues.clear();
|
|
5664
|
-
this.originallyExisted.clear();
|
|
5665
|
-
this.keyVersions.clear();
|
|
5666
|
-
this.bufferHistory.clear();
|
|
5685
|
+
this._cleanupAll();
|
|
5667
5686
|
this.localVersion = 0;
|
|
5668
5687
|
this.snapshotVersion = this.version;
|
|
5669
5688
|
}
|
|
@@ -6297,6 +6316,7 @@ var AsyncMVCCTransaction2 = class _AsyncMVCCTransaction2 extends MVCCTransaction
|
|
|
6297
6316
|
if (this.parent) {
|
|
6298
6317
|
const failure = await this.parent._merge(this);
|
|
6299
6318
|
if (failure) {
|
|
6319
|
+
this.rollback();
|
|
6300
6320
|
return {
|
|
6301
6321
|
label,
|
|
6302
6322
|
success: false,
|
|
@@ -6307,11 +6327,13 @@ var AsyncMVCCTransaction2 = class _AsyncMVCCTransaction2 extends MVCCTransaction
|
|
|
6307
6327
|
deleted
|
|
6308
6328
|
};
|
|
6309
6329
|
}
|
|
6330
|
+
this._cleanupAll();
|
|
6310
6331
|
this.committed = true;
|
|
6311
6332
|
} else {
|
|
6312
6333
|
if (this.writeBuffer.size > 0 || this.deleteBuffer.size > 0) {
|
|
6313
6334
|
const failure = await this._merge(this);
|
|
6314
6335
|
if (failure) {
|
|
6336
|
+
this.rollback();
|
|
6315
6337
|
return {
|
|
6316
6338
|
label,
|
|
6317
6339
|
success: false,
|
|
@@ -6322,13 +6344,7 @@ var AsyncMVCCTransaction2 = class _AsyncMVCCTransaction2 extends MVCCTransaction
|
|
|
6322
6344
|
deleted: []
|
|
6323
6345
|
};
|
|
6324
6346
|
}
|
|
6325
|
-
this.
|
|
6326
|
-
this.deleteBuffer.clear();
|
|
6327
|
-
this.createdKeys.clear();
|
|
6328
|
-
this.deletedValues.clear();
|
|
6329
|
-
this.originallyExisted.clear();
|
|
6330
|
-
this.keyVersions.clear();
|
|
6331
|
-
this.bufferHistory.clear();
|
|
6347
|
+
this._cleanupAll();
|
|
6332
6348
|
this.localVersion = 0;
|
|
6333
6349
|
this.snapshotVersion = this.version;
|
|
6334
6350
|
}
|
|
@@ -9982,10 +9998,10 @@ var Transaction = class {
|
|
|
9982
9998
|
if (shouldTriggerCheckpoint) {
|
|
9983
9999
|
await this.pfs.checkpoint();
|
|
9984
10000
|
}
|
|
10001
|
+
} finally {
|
|
9985
10002
|
this.dirtyPages.clear();
|
|
9986
10003
|
this.undoPages.clear();
|
|
9987
10004
|
this.releaseAllLocks();
|
|
9988
|
-
} finally {
|
|
9989
10005
|
if (this._writeLockRelease) {
|
|
9990
10006
|
this._writeLockRelease();
|
|
9991
10007
|
this._writeLockRelease = null;
|
|
@@ -10722,6 +10738,8 @@ var GlobalTransaction = class {
|
|
|
10722
10738
|
IndexPageManager,
|
|
10723
10739
|
InvertedWeakMap,
|
|
10724
10740
|
LRUMap,
|
|
10741
|
+
Logger,
|
|
10742
|
+
LoggerManager,
|
|
10725
10743
|
MVCCStrategy,
|
|
10726
10744
|
MVCCTransaction,
|
|
10727
10745
|
MetadataPageManager,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ export * from 'serializable-bptree';
|
|
|
2
2
|
export * from 'ryoiki';
|
|
3
3
|
export * from 'cache-entanglement';
|
|
4
4
|
export * from 'mvcc-api';
|
|
5
|
-
export type { DataplyOptions } from './types';
|
|
5
|
+
export type { DataplyOptions, LogLevel } from './types';
|
|
6
6
|
export * from './core/Page';
|
|
7
7
|
export { Dataply } from './core/Dataply';
|
|
8
8
|
export { DataplyAPI } from './core/DataplyAPI';
|
|
9
9
|
export { Transaction } from './core/transaction/Transaction';
|
|
10
10
|
export { GlobalTransaction } from './core/transaction/GlobalTransaction';
|
|
11
|
+
export { Logger, LoggerManager } from './core/Logger';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dataply",
|
|
3
|
-
"version": "0.0.26-alpha.
|
|
3
|
+
"version": "0.0.26-alpha.4",
|
|
4
4
|
"description": "A lightweight storage engine for Node.js with support for MVCC, WAL.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "izure <admin@izure.org>",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"cache-entanglement": "^1.7.1",
|
|
49
49
|
"hookall": "^2.2.0",
|
|
50
|
-
"mvcc-api": "^1.3.
|
|
50
|
+
"mvcc-api": "^1.3.6",
|
|
51
51
|
"ryoiki": "^1.2.0",
|
|
52
|
-
"serializable-bptree": "^8.4.
|
|
52
|
+
"serializable-bptree": "^8.4.1"
|
|
53
53
|
}
|
|
54
54
|
}
|