dataply 0.0.24-alpha.7 → 0.0.24-alpha.9

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 CHANGED
@@ -1650,7 +1650,7 @@ var BPTreeTransaction = class _BPTreeTransaction {
1650
1650
  },
1651
1651
  primaryGt: {
1652
1652
  asc: {
1653
- start: (tx, v) => tx.insertableNodeByPrimary(v[0]),
1653
+ start: (tx, v) => tx.insertableRightestEndNodeByPrimary(v[0]),
1654
1654
  end: () => null,
1655
1655
  direction: 1,
1656
1656
  earlyTerminate: false
@@ -2189,7 +2189,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
2189
2189
  return this.getNode(node.next);
2190
2190
  }
2191
2191
  insertableEndNode(value, direction) {
2192
- const insertableNode = this.insertableNode(value);
2192
+ const insertableNode = direction === -1 ? this.insertableNodeByPrimary(value) : this.insertableRightestNodeByPrimary(value);
2193
2193
  let key;
2194
2194
  switch (direction) {
2195
2195
  case -1:
@@ -3317,7 +3317,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
3317
3317
  return await this.getNode(node.next);
3318
3318
  }
3319
3319
  async insertableEndNode(value, direction) {
3320
- const insertableNode = await this.insertableNode(value);
3320
+ const insertableNode = direction === -1 ? await this.insertableNodeByPrimary(value) : await this.insertableRightestNodeByPrimary(value);
3321
3321
  let key;
3322
3322
  switch (direction) {
3323
3323
  case -1:
@@ -8177,9 +8177,6 @@ var PageMVCCStrategy = class {
8177
8177
  */
8178
8178
  async write(pageId, data) {
8179
8179
  const pageStartPos = pageId * this.pageSize;
8180
- if (pageStartPos + this.pageSize > 512 * 1024 * 1024) {
8181
- throw new Error(`[Safety Limit] File write exceeds 512MB limit at position ${pageStartPos}`);
8182
- }
8183
8180
  const dataCopy = new Uint8Array(this.pageSize);
8184
8181
  dataCopy.set(data);
8185
8182
  this.dirtyPages.set(pageId, dataCopy);
@@ -8206,6 +8203,22 @@ var PageMVCCStrategy = class {
8206
8203
  this.dirtyPages.delete(pageId);
8207
8204
  }
8208
8205
  }
8206
+ /**
8207
+ * 지정된 페이지들만 디스크에 기록합니다.
8208
+ * WAL 없이 트랜잭션 커밋 시, 해당 트랜잭션의 dirty pages만 선택적으로 flush합니다.
8209
+ * @param pages 기록할 페이지 맵 (PageID -> PageData)
8210
+ */
8211
+ async flushPages(pages) {
8212
+ if (pages.size === 0) {
8213
+ return;
8214
+ }
8215
+ const sortedPageIds = Array.from(pages.keys()).sort((a, b) => a - b);
8216
+ for (const pageId of sortedPageIds) {
8217
+ const data = pages.get(pageId);
8218
+ const position = pageId * this.pageSize;
8219
+ await this._writeToDisk(data, position);
8220
+ }
8221
+ }
8209
8222
  /**
8210
8223
  * 메인 DB 파일의 물리적 동기화를 수행합니다 (fsync).
8211
8224
  */
@@ -9581,7 +9594,9 @@ var Transaction = class {
9581
9594
  for (const [pageId, data] of this.dirtyPages) {
9582
9595
  await this.pageStrategy.write(pageId, data);
9583
9596
  }
9584
- if (this.pfs.wal) {
9597
+ if (!this.pfs.wal) {
9598
+ await this.pfs.strategy.flushPages(this.dirtyPages);
9599
+ } else {
9585
9600
  this.pfs.wal.incrementWrittenPages(this.dirtyPages.size);
9586
9601
  if (this.pfs.wal.shouldCheckpoint(this.pfs.options.walCheckpointThreshold)) {
9587
9602
  shouldTriggerCheckpoint = true;
@@ -33,6 +33,12 @@ export declare class PageMVCCStrategy {
33
33
  * WAL 체크포인트 시점에 호출되어야 합니다.
34
34
  */
35
35
  flush(): Promise<void>;
36
+ /**
37
+ * 지정된 페이지들만 디스크에 기록합니다.
38
+ * WAL 없이 트랜잭션 커밋 시, 해당 트랜잭션의 dirty pages만 선택적으로 flush합니다.
39
+ * @param pages 기록할 페이지 맵 (PageID -> PageData)
40
+ */
41
+ flushPages(pages: Map<number, Uint8Array>): Promise<void>;
36
42
  /**
37
43
  * 메인 DB 파일의 물리적 동기화를 수행합니다 (fsync).
38
44
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dataply",
3
- "version": "0.0.24-alpha.7",
3
+ "version": "0.0.24-alpha.9",
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.4",
51
51
  "ryoiki": "^1.2.0",
52
- "serializable-bptree": "^8.3.2"
52
+ "serializable-bptree": "^8.3.3"
53
53
  }
54
54
  }