document-dataply 0.0.10 → 0.0.12
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.
|
|
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,
|
|
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 =
|
|
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,11 @@ var MutationManager = class {
|
|
|
11929
11937
|
batchInsertData.push([item.pk, { k: item.pk, v: indexVal }]);
|
|
11930
11938
|
}
|
|
11931
11939
|
}
|
|
11932
|
-
const
|
|
11940
|
+
const initChunkSize = Math.min(
|
|
11941
|
+
5e4,
|
|
11942
|
+
Math.max(1, Math.floor(batchInsertData.length / 100 * 5))
|
|
11943
|
+
);
|
|
11944
|
+
const chunker = new DeadlineChunker(initChunkSize);
|
|
11933
11945
|
await chunker.processInChunks(batchInsertData, async (chunk) => {
|
|
11934
11946
|
const [error] = await catchPromise(treeTx.batchInsert(chunk));
|
|
11935
11947
|
if (error) {
|
package/package.json
CHANGED