dataply 0.0.26-alpha.11 → 0.0.26-alpha.13

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 (2) hide show
  1. package/dist/cjs/index.js +27 -20
  2. package/package.json +2 -2
package/dist/cjs/index.js CHANGED
@@ -2977,27 +2977,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
2977
2977
  static CheckConflicts(transactions) {
2978
2978
  return MVCCTransaction.CheckConflicts(transactions.map((tx) => tx.mvcc));
2979
2979
  }
2980
- /**
2981
- * Returns the ID of the root node.
2982
- * @returns The root node ID.
2983
- */
2984
2980
  getRootId() {
2985
2981
  return this.rootId;
2986
2982
  }
2987
- /**
2988
- * Returns the order of the B+Tree.
2989
- * @returns The order of the tree.
2990
- */
2991
2983
  getOrder() {
2992
2984
  return this.order;
2993
2985
  }
2994
- /**
2995
- * Verified if the value satisfies the condition.
2996
- *
2997
- * @param nodeValue The value to verify.
2998
- * @param condition The condition to verify against.
2999
- * @returns Returns true if the value satisfies the condition.
3000
- */
3001
2986
  verify(nodeValue, condition) {
3002
2987
  for (const key in condition) {
3003
2988
  const verify2 = this.verifierMap[key];
@@ -5008,9 +4993,14 @@ var BPTreePureSync = class {
5008
4993
  }
5009
4994
  _createReadOps() {
5010
4995
  const strategy = this.strategy;
4996
+ const readBuffer = /* @__PURE__ */ new Map();
5011
4997
  return {
5012
4998
  getNode(id) {
5013
- return strategy.read(id);
4999
+ const buffered = readBuffer.get(id);
5000
+ if (buffered) return buffered;
5001
+ const node = strategy.read(id);
5002
+ readBuffer.set(id, node);
5003
+ return node;
5014
5004
  },
5015
5005
  createNode(leaf, keys, values, parent = null, next = null, prev = null) {
5016
5006
  const id = strategy.id(leaf);
@@ -5030,6 +5020,7 @@ var BPTreePureSync = class {
5030
5020
  }
5031
5021
  _createBufferedOps() {
5032
5022
  const strategy = this.strategy;
5023
+ const readBuffer = /* @__PURE__ */ new Map();
5033
5024
  const writeBuffer = /* @__PURE__ */ new Map();
5034
5025
  const deleteBuffer = /* @__PURE__ */ new Set();
5035
5026
  let headBuffer = null;
@@ -5037,7 +5028,11 @@ var BPTreePureSync = class {
5037
5028
  getNode(id) {
5038
5029
  const buffered = writeBuffer.get(id);
5039
5030
  if (buffered) return buffered;
5040
- return strategy.read(id);
5031
+ const read = readBuffer.get(id);
5032
+ if (read) return read;
5033
+ const node = strategy.read(id);
5034
+ readBuffer.set(id, node);
5035
+ return node;
5041
5036
  },
5042
5037
  createNode(leaf, keys, values, parent = null, next = null, prev = null) {
5043
5038
  const id = strategy.id(leaf);
@@ -5070,6 +5065,10 @@ var BPTreePureSync = class {
5070
5065
  if (headBuffer) {
5071
5066
  strategy.writeHead(headBuffer);
5072
5067
  }
5068
+ readBuffer.clear();
5069
+ writeBuffer.clear();
5070
+ deleteBuffer.clear();
5071
+ headBuffer = null;
5073
5072
  }
5074
5073
  return { ops, flush };
5075
5074
  }
@@ -5251,6 +5250,7 @@ var BPTreePureAsync = class {
5251
5250
  }
5252
5251
  _createReadOps() {
5253
5252
  const strategy = this.strategy;
5253
+ let headBuffer = null;
5254
5254
  return {
5255
5255
  async getNode(id) {
5256
5256
  return await strategy.read(id);
@@ -5265,9 +5265,12 @@ var BPTreePureAsync = class {
5265
5265
  async deleteNode() {
5266
5266
  },
5267
5267
  async readHead() {
5268
- return await strategy.readHead();
5268
+ if (headBuffer) return headBuffer;
5269
+ headBuffer = await strategy.readHead();
5270
+ return headBuffer;
5269
5271
  },
5270
- async writeHead() {
5272
+ async writeHead(head) {
5273
+ headBuffer = head;
5271
5274
  }
5272
5275
  };
5273
5276
  }
@@ -5297,7 +5300,8 @@ var BPTreePureAsync = class {
5297
5300
  },
5298
5301
  async readHead() {
5299
5302
  if (headBuffer) return headBuffer;
5300
- return await strategy.readHead();
5303
+ headBuffer = await strategy.readHead();
5304
+ return headBuffer;
5301
5305
  },
5302
5306
  async writeHead(head) {
5303
5307
  headBuffer = head;
@@ -5313,6 +5317,9 @@ var BPTreePureAsync = class {
5313
5317
  if (headBuffer) {
5314
5318
  await strategy.writeHead(headBuffer);
5315
5319
  }
5320
+ writeBuffer.clear();
5321
+ deleteBuffer.clear();
5322
+ headBuffer = null;
5316
5323
  }
5317
5324
  return { ops, flush };
5318
5325
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dataply",
3
- "version": "0.0.26-alpha.11",
3
+ "version": "0.0.26-alpha.13",
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>",
@@ -49,6 +49,6 @@
49
49
  "hookall": "^2.2.0",
50
50
  "mvcc-api": "^1.3.7",
51
51
  "ryoiki": "^1.2.0",
52
- "serializable-bptree": "^9.0.4-alpha.0"
52
+ "serializable-bptree": "^9.0.4-alpha.2"
53
53
  }
54
54
  }