document-dataply 0.0.10 → 0.0.11

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
@@ -11789,11 +11789,11 @@ var DeadlineChunker = class {
11789
11789
  * EWMA 평활화 계수
11790
11790
  */
11791
11791
  alpha;
11792
- constructor(targetMs = 5) {
11792
+ constructor(startChunkSize = 0, targetMs = 5, alpha = 0.5) {
11793
+ this.chunkSize = startChunkSize;
11793
11794
  this.targetMs = targetMs;
11794
- this.chunkSize = 50;
11795
+ this.alpha = alpha;
11795
11796
  this.ewmaMs = null;
11796
- this.alpha = 0.3;
11797
11797
  }
11798
11798
  /**
11799
11799
  * EWMA 평활화 계수를 사용하여 평균 처리 시간을 업데이트합니다.
@@ -11808,7 +11808,7 @@ var DeadlineChunker = class {
11808
11808
  nextChunkSize() {
11809
11809
  if (!this.ewmaMs || this.ewmaMs === 0) return this.chunkSize;
11810
11810
  const next = Math.floor(this.targetMs / this.ewmaMs);
11811
- return Math.max(1, Math.min(next, 5e3));
11811
+ return Math.max(1, next);
11812
11812
  }
11813
11813
  /**
11814
11814
  * 주어진 items를 chunk로 분할하여 처리합니다.
@@ -11816,6 +11816,9 @@ var DeadlineChunker = class {
11816
11816
  async processInChunks(items, processFn) {
11817
11817
  let i = 0;
11818
11818
  let len = items.length;
11819
+ if (this.chunkSize === 0) {
11820
+ this.chunkSize = Math.floor(items.length / 100 * 5);
11821
+ }
11819
11822
  while (i < len) {
11820
11823
  const chunk = items.slice(i, i + this.chunkSize);
11821
11824
  const count = chunk.length;
@@ -11899,7 +11902,12 @@ var MutationManager = class {
11899
11902
  flattenedData.push({ pk: -1, data: flattenDocument });
11900
11903
  ids.push(id);
11901
11904
  }
11902
- const pks = await this.api.insertBatch(dataplyDocuments, true, tx2);
11905
+ const pks = [];
11906
+ const documentChunker = new DeadlineChunker(1e4);
11907
+ await documentChunker.processInChunks(dataplyDocuments, async (chunk) => {
11908
+ const res = await this.api.insertBatch(chunk, true, tx2);
11909
+ pks.push(...res);
11910
+ });
11903
11911
  for (let i = 0, len = pks.length; i < len; i++) {
11904
11912
  flattenedData[i].pk = pks[i];
11905
11913
  }
@@ -11929,7 +11937,8 @@ var MutationManager = class {
11929
11937
  batchInsertData.push([item.pk, { k: item.pk, v: indexVal }]);
11930
11938
  }
11931
11939
  }
11932
- const chunker = new DeadlineChunker();
11940
+ const chunker = new DeadlineChunker(3e4);
11941
+ console.log(batchInsertData.length);
11933
11942
  await chunker.processInChunks(batchInsertData, async (chunk) => {
11934
11943
  const [error] = await catchPromise(treeTx.batchInsert(chunk));
11935
11944
  if (error) {
@@ -18,7 +18,7 @@ export declare class DeadlineChunker {
18
18
  * EWMA 평활화 계수
19
19
  */
20
20
  private alpha;
21
- constructor(targetMs?: number);
21
+ constructor(startChunkSize?: number, targetMs?: number, alpha?: number);
22
22
  /**
23
23
  * EWMA 평활화 계수를 사용하여 평균 처리 시간을 업데이트합니다.
24
24
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-dataply",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Simple and powerful JSON document database supporting complex queries and flexible indexing policies.",
5
5
  "license": "MIT",
6
6
  "author": "izure <admin@izure.org>",