datafolder 1.0.34 → 1.0.35
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/ChangeLog.md +2 -0
- package/package.json +1 -1
- package/src/QyCache.js +13 -18
- package/src/QyDir.js +1 -1
- package/src/QyFile.js +24 -30
- package/src/QyItem.js +29 -36
- package/src/QyKVData.js +30 -35
- package/src/QyKVDataLoader.d.ts +1 -6
- package/src/QyKVDataLoader.js +13 -18
- package/src/QyLogger.d.ts +14 -8
- package/src/QyLogger.js +97 -86
- package/src/QyMessager.js +1 -1
- package/src/QySnapshotSaver_Worker.d.ts +1 -4
- package/src/QySnapshotSaver_Worker.js +32 -59
- package/src/QySnapshots.d.ts +1 -6
- package/src/QySnapshots.js +13 -18
package/ChangeLog.md
CHANGED
package/package.json
CHANGED
package/src/QyCache.js
CHANGED
|
@@ -23,9 +23,9 @@ import {
|
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
25
|
isString as C,
|
|
26
|
-
lockExclusiveFilePath as
|
|
26
|
+
lockExclusiveFilePath as q,
|
|
27
27
|
unlockExclusiveFilePath as o,
|
|
28
|
-
ensureDir as
|
|
28
|
+
ensureDir as x,
|
|
29
29
|
SpecialFilePaths as e
|
|
30
30
|
} from "./QyUtils.js";
|
|
31
31
|
|
|
@@ -63,10 +63,10 @@ import {
|
|
|
63
63
|
|
|
64
64
|
let {
|
|
65
65
|
HiddenFolderName: D,
|
|
66
|
-
IndexDirPath:
|
|
66
|
+
IndexDirPath: F,
|
|
67
67
|
TriggerDirPath: w,
|
|
68
68
|
RpcDirPath: E,
|
|
69
|
-
ExpireDirPath:
|
|
69
|
+
ExpireDirPath: y,
|
|
70
70
|
MetaFilePath: t,
|
|
71
71
|
HNSWDirPath: m,
|
|
72
72
|
InfoDirPath: f,
|
|
@@ -101,7 +101,7 @@ class i extends r {
|
|
|
101
101
|
t._subdirMap = {
|
|
102
102
|
[D]: a
|
|
103
103
|
}, a._subdirMap = {};
|
|
104
|
-
for ([ s, i ] of [ [
|
|
104
|
+
for ([ s, i ] of [ [ F, "indexRootDir" ], [ y, "expireRootDir" ], [ m, "hnswRootDir" ], [ f, "infoRootDir" ], [ Q, "recycleRootDir" ] ]) {
|
|
105
105
|
var s = s.at(-1), n = new l(s, !0, a);
|
|
106
106
|
a._subdirMap[s] = n, o[i] = n;
|
|
107
107
|
}
|
|
@@ -128,13 +128,8 @@ class i extends r {
|
|
|
128
128
|
} = this;
|
|
129
129
|
P.log("Starting at " + r);
|
|
130
130
|
try {
|
|
131
|
-
await
|
|
132
|
-
var [
|
|
133
|
-
maxChangeId: l,
|
|
134
|
-
loadedMaxAclNum: g,
|
|
135
|
-
qySnapshots: h,
|
|
136
|
-
aclKeyValueMap: d
|
|
137
|
-
} ] = await Promise.all([ ((r, e) => (r = new b(r, e)).load())(e, t), x(a) ]);
|
|
131
|
+
await x(e);
|
|
132
|
+
var [ [ l, g, h, d ] ] = await Promise.all([ ((r, e) => (r = new b(r, e)).load())(e, t), q(a) ]);
|
|
138
133
|
o.start(), i.start(l, g, h, d), await n.start();
|
|
139
134
|
} catch (r) {
|
|
140
135
|
throw o.stop(), n.stop(), r;
|
|
@@ -152,17 +147,17 @@ class i extends r {
|
|
|
152
147
|
var {
|
|
153
148
|
name: p,
|
|
154
149
|
fileContent: c
|
|
155
|
-
} = p, [ c, D,
|
|
156
|
-
u.insertTriggerToTree(p, c, D,
|
|
150
|
+
} = p, [ c, D, F ] = c;
|
|
151
|
+
u.insertTriggerToTree(p, c, D, F);
|
|
157
152
|
}
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
for (m of
|
|
153
|
+
var y = this;
|
|
154
|
+
y.rpcRootDir = y.rootDir.searchOrCreateSubdir(E);
|
|
155
|
+
for (m of y.rpcRootDir.fileList) {
|
|
161
156
|
var {
|
|
162
157
|
name: m,
|
|
163
158
|
fileContent: f
|
|
164
159
|
} = m;
|
|
165
|
-
C(f) &&
|
|
160
|
+
C(f) && y.insertRpc(m, f);
|
|
166
161
|
}
|
|
167
162
|
return t.dumpStructureAtStart && await O(v(r, "qystruct"), s), P.log("Started."),
|
|
168
163
|
this;
|
package/src/QyDir.js
CHANGED
|
@@ -36,7 +36,7 @@ class d extends e {
|
|
|
36
36
|
}
|
|
37
37
|
set created(e) {
|
|
38
38
|
var i;
|
|
39
|
-
this._created !==
|
|
39
|
+
this._created !== e && (this._created = e, i = this.parentDir, i) && (i._subdirCount += e ? 1 : -1,
|
|
40
40
|
++i.subdirMapChangeCount);
|
|
41
41
|
}
|
|
42
42
|
get fileCount() {
|
package/src/QyFile.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
SpecialOperators as t,
|
|
7
7
|
SpecialFilePaths as i,
|
|
8
8
|
getContentKey as n,
|
|
9
|
-
isNotNullObj as
|
|
9
|
+
isNotNullObj as a,
|
|
10
10
|
isSimpleType as h,
|
|
11
11
|
isEmptyObj as r,
|
|
12
12
|
getNowTime as s,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "./QyFileContentUtils.js";
|
|
19
19
|
|
|
20
20
|
import {
|
|
21
|
-
QyIndexPropTree as
|
|
21
|
+
QyIndexPropTree as l
|
|
22
22
|
} from "./QyIndexPropTree.js";
|
|
23
23
|
|
|
24
24
|
import {
|
|
@@ -30,19 +30,19 @@ let f = i.IndexPropPathsFileName, {
|
|
|
30
30
|
$clone: p
|
|
31
31
|
} = t;
|
|
32
32
|
|
|
33
|
-
class
|
|
33
|
+
class v extends e {
|
|
34
34
|
_fileContentKey;
|
|
35
35
|
_fileContent;
|
|
36
36
|
cChangeId = 0;
|
|
37
37
|
constructor(e, t = !1, i) {
|
|
38
|
-
super(e, t, i), t && i && (++i._fileCount, ++i.fileMapChangeCount);
|
|
38
|
+
super(e, t, i), t && void 0 !== i && (++i._fileCount, ++i.fileMapChangeCount);
|
|
39
39
|
}
|
|
40
40
|
get created() {
|
|
41
41
|
return this._created;
|
|
42
42
|
}
|
|
43
43
|
set created(e) {
|
|
44
44
|
var t;
|
|
45
|
-
this._created !==
|
|
45
|
+
this._created !== e && (this._created = e, t = this.parentDir, void 0 !== t) && (t._fileCount += e ? 1 : -1,
|
|
46
46
|
++t.fileMapChangeCount);
|
|
47
47
|
}
|
|
48
48
|
get fileContentKey() {
|
|
@@ -64,7 +64,7 @@ class c extends e {
|
|
|
64
64
|
} = this;
|
|
65
65
|
if (e && n && t === f) {
|
|
66
66
|
let e = this._qyIndexPropTree;
|
|
67
|
-
if (void 0 === e) for (var o in e = this._qyIndexPropTree = new
|
|
67
|
+
if (void 0 === e) for (var o in e = this._qyIndexPropTree = new l(r),
|
|
68
68
|
i) e.insertPropPath(JSON.parse(o));
|
|
69
69
|
return e;
|
|
70
70
|
}
|
|
@@ -74,7 +74,7 @@ class c extends e {
|
|
|
74
74
|
}
|
|
75
75
|
get contentAsText() {
|
|
76
76
|
var e = this.fileContent;
|
|
77
|
-
return void 0 === e ? "" :
|
|
77
|
+
return void 0 === e ? "" : a(e) ? JSON.stringify(e) : e.toString();
|
|
78
78
|
}
|
|
79
79
|
get clonedContent() {
|
|
80
80
|
return structuredClone(this.fileContent);
|
|
@@ -84,7 +84,7 @@ class c extends e {
|
|
|
84
84
|
_indexCount: e,
|
|
85
85
|
fileContent: t
|
|
86
86
|
} = this;
|
|
87
|
-
return void 0 !== e ? e : this._indexCount =
|
|
87
|
+
return void 0 !== e ? e : this._indexCount = null == t ? 0 : Object.keys(t).length;
|
|
88
88
|
}
|
|
89
89
|
set indexCount(e) {
|
|
90
90
|
this._indexCount = 0 <= e ? e : 0;
|
|
@@ -101,11 +101,11 @@ class c extends e {
|
|
|
101
101
|
u(r) && (r = Object.fromEntries(r.filter(e => e).map(e => [ e, 1 ])));
|
|
102
102
|
let s = u(n) ? [] : {};
|
|
103
103
|
let {
|
|
104
|
-
$all:
|
|
105
|
-
"**":
|
|
104
|
+
$all: l,
|
|
105
|
+
"**": a
|
|
106
106
|
} = r;
|
|
107
|
-
if (
|
|
108
|
-
let e = r[d] ??
|
|
107
|
+
if (void 0 !== l || void 0 !== a) for (var d in n) {
|
|
108
|
+
let e = r[d] ?? l ?? a;
|
|
109
109
|
e && (s[d] = t(i, n[d], e, o));
|
|
110
110
|
} else for (var f in r) {
|
|
111
111
|
let e = r[f];
|
|
@@ -129,19 +129,13 @@ class c extends e {
|
|
|
129
129
|
if (void 0 !== e && (this._fileContent = e.qyKVData.getValueSync(this.fileContentKey),
|
|
130
130
|
!this.underHiddenFolder)) {
|
|
131
131
|
var t, i, n = this;
|
|
132
|
-
!n.cExpireChecked && (n.cExpireChecked = !0, t = e.getExpireInfoFile(n.fullPathHash, "c")) && ({
|
|
133
|
-
expiredProps: t,
|
|
134
|
-
remainingExpireInfoObj: i
|
|
135
|
-
} = ((e, t = s()) => {
|
|
132
|
+
!n.cExpireChecked && (n.cExpireChecked = !0, t = e.getExpireInfoFile(n.fullPathHash, "c")) && ([ t, i ] = ((e, t = s()) => {
|
|
136
133
|
let i, n = {};
|
|
137
134
|
for (var r in e) {
|
|
138
135
|
var o = e[r];
|
|
139
136
|
o <= t ? void 0 === i ? i = [ r ] : i.push(r) : n[r] = o;
|
|
140
137
|
}
|
|
141
|
-
return
|
|
142
|
-
expiredProps: i,
|
|
143
|
-
remainingExpireInfoObj: n
|
|
144
|
-
};
|
|
138
|
+
return [ i, n ];
|
|
145
139
|
})(t.fileContent), t && d(e.qyDB, n, t), r(i) || e.monitorContentExpire(n, i));
|
|
146
140
|
}
|
|
147
141
|
}
|
|
@@ -149,25 +143,25 @@ class c extends e {
|
|
|
149
143
|
}
|
|
150
144
|
}
|
|
151
145
|
|
|
152
|
-
function
|
|
153
|
-
if (e) {
|
|
146
|
+
function c(e, t, i, n) {
|
|
147
|
+
if (void 0 !== e) {
|
|
154
148
|
e = e.getFile(t);
|
|
155
|
-
if (e) return e.view(i, n);
|
|
149
|
+
if (void 0 !== e) return e.view(i, n);
|
|
156
150
|
}
|
|
157
151
|
return t;
|
|
158
152
|
}
|
|
159
153
|
|
|
160
154
|
function y(e, t, i, n, r = !1) {
|
|
161
155
|
let o = e.qyCache.getDir(i);
|
|
162
|
-
if (u(t)) return t.map(e =>
|
|
163
|
-
if (
|
|
164
|
-
var s,
|
|
165
|
-
for (s in t)
|
|
166
|
-
return
|
|
156
|
+
if (u(t)) return t.map(e => c(o, e, n, r));
|
|
157
|
+
if (a(t)) {
|
|
158
|
+
var s, l = {};
|
|
159
|
+
for (s in t) l[s] = c(o, s, n, r);
|
|
160
|
+
return l;
|
|
167
161
|
}
|
|
168
|
-
return
|
|
162
|
+
return c(o, t, n, r);
|
|
169
163
|
}
|
|
170
164
|
|
|
171
165
|
export {
|
|
172
|
-
|
|
166
|
+
v as QyFile
|
|
173
167
|
};
|
package/src/QyItem.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
calHash as
|
|
2
|
+
calHash as a,
|
|
3
3
|
SpecialFilePaths as t
|
|
4
4
|
} from "./QyUtils.js";
|
|
5
5
|
|
|
6
|
-
let
|
|
6
|
+
let i = t.HiddenFolderName;
|
|
7
7
|
|
|
8
8
|
class e {
|
|
9
9
|
name;
|
|
10
10
|
parentDir;
|
|
11
11
|
flagInt;
|
|
12
|
-
constructor(t, e = !1,
|
|
13
|
-
this.name = t.toString(), this.parentDir =
|
|
14
|
-
t !==
|
|
12
|
+
constructor(t, e = !1, a) {
|
|
13
|
+
this.name = t.toString(), this.parentDir = a, this.flagInt = 0, this._created = e,
|
|
14
|
+
t !== i && (void 0 === a || a.name !== i && !a.underHiddenFolder) || (this.flagInt |= 2);
|
|
15
15
|
}
|
|
16
16
|
get qyCache() {
|
|
17
17
|
let t = this;
|
|
@@ -19,52 +19,52 @@ class e {
|
|
|
19
19
|
return t._qyCache;
|
|
20
20
|
}
|
|
21
21
|
get _created() {
|
|
22
|
-
return
|
|
22
|
+
return 0 != (1 & this.flagInt);
|
|
23
23
|
}
|
|
24
24
|
set _created(t) {
|
|
25
|
-
|
|
25
|
+
t ? this.flagInt |= 1 : this.flagInt &= -2;
|
|
26
26
|
}
|
|
27
27
|
get subdirMapLoaded() {
|
|
28
|
-
return
|
|
28
|
+
return 0 != (4 & this.flagInt);
|
|
29
29
|
}
|
|
30
30
|
set subdirMapLoaded(t) {
|
|
31
|
-
|
|
31
|
+
t ? this.flagInt |= 4 : this.flagInt &= -5;
|
|
32
32
|
}
|
|
33
33
|
get fileMapLoaded() {
|
|
34
|
-
return
|
|
34
|
+
return 0 != (8 & this.flagInt);
|
|
35
35
|
}
|
|
36
36
|
set fileMapLoaded(t) {
|
|
37
|
-
|
|
37
|
+
t ? this.flagInt |= 8 : this.flagInt &= -9;
|
|
38
38
|
}
|
|
39
39
|
get fileContentLoaded() {
|
|
40
|
-
return
|
|
40
|
+
return 0 != (16 & this.flagInt);
|
|
41
41
|
}
|
|
42
42
|
set fileContentLoaded(t) {
|
|
43
|
-
|
|
43
|
+
t ? this.flagInt |= 16 : this.flagInt &= -17;
|
|
44
44
|
}
|
|
45
45
|
get dExpireChecked() {
|
|
46
|
-
return
|
|
46
|
+
return 0 != (64 & this.flagInt);
|
|
47
47
|
}
|
|
48
48
|
set dExpireChecked(t) {
|
|
49
|
-
|
|
49
|
+
t ? this.flagInt |= 64 : this.flagInt &= -65;
|
|
50
50
|
}
|
|
51
51
|
get fExpireChecked() {
|
|
52
|
-
return
|
|
52
|
+
return 0 != (128 & this.flagInt);
|
|
53
53
|
}
|
|
54
54
|
set fExpireChecked(t) {
|
|
55
|
-
|
|
55
|
+
t ? this.flagInt |= 128 : this.flagInt &= -129;
|
|
56
56
|
}
|
|
57
57
|
get cExpireChecked() {
|
|
58
|
-
return
|
|
58
|
+
return 0 != (256 & this.flagInt);
|
|
59
59
|
}
|
|
60
60
|
set cExpireChecked(t) {
|
|
61
|
-
|
|
61
|
+
t ? this.flagInt |= 256 : this.flagInt &= -257;
|
|
62
62
|
}
|
|
63
63
|
get visited() {
|
|
64
|
-
return
|
|
64
|
+
return 0 != (32 & this.flagInt);
|
|
65
65
|
}
|
|
66
66
|
set visited(t) {
|
|
67
|
-
|
|
67
|
+
t ? this.flagInt |= 32 : this.flagInt &= -33;
|
|
68
68
|
}
|
|
69
69
|
get nameNum() {
|
|
70
70
|
var t = this._nameNum;
|
|
@@ -81,27 +81,28 @@ class e {
|
|
|
81
81
|
return void 0 === this._fullPath && ({
|
|
82
82
|
parentDir: t,
|
|
83
83
|
name: e
|
|
84
|
-
} = this, this._fullPath = t ? t.fullPath + "/" + e : e), this._fullPath;
|
|
84
|
+
} = this, this._fullPath = void 0 !== t ? t.fullPath + "/" + e : e), this._fullPath;
|
|
85
85
|
}
|
|
86
86
|
get fullPathHash() {
|
|
87
87
|
var t, e;
|
|
88
88
|
return void 0 === this._fullPathHash && ({
|
|
89
89
|
parentDir: t,
|
|
90
90
|
name: e
|
|
91
|
-
} = this, this._fullPathHash =
|
|
91
|
+
} = this, this._fullPathHash = a(void 0 !== t ? t.fullPathHash + e : e)),
|
|
92
|
+
this._fullPathHash;
|
|
92
93
|
}
|
|
93
94
|
get isItem() {
|
|
94
95
|
return !0;
|
|
95
96
|
}
|
|
96
97
|
get underHiddenFolder() {
|
|
97
|
-
return
|
|
98
|
+
return 0 != (2 & this.flagInt);
|
|
98
99
|
}
|
|
99
100
|
get parentList() {
|
|
100
101
|
if (void 0 === this._parentList) {
|
|
101
102
|
var e = this._parentList = [];
|
|
102
103
|
let t = this.parentDir;
|
|
103
104
|
if (void 0 !== t) {
|
|
104
|
-
for (;t.parentDir; ) e.push(t), t = t.parentDir;
|
|
105
|
+
for (;void 0 !== t.parentDir; ) e.push(t), t = t.parentDir;
|
|
105
106
|
e.reverse();
|
|
106
107
|
}
|
|
107
108
|
}
|
|
@@ -117,20 +118,12 @@ class e {
|
|
|
117
118
|
}
|
|
118
119
|
getRelativeNamePath(t = void 0) {
|
|
119
120
|
var e = [ this.name ];
|
|
120
|
-
let
|
|
121
|
-
for (;void 0 !==
|
|
122
|
-
if (
|
|
121
|
+
let a = this.parentDir;
|
|
122
|
+
for (;void 0 !== a && a !== t; ) e.push(a.name), a = a.parentDir;
|
|
123
|
+
if (a === t) return e.reverse();
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
function r(t, e) {
|
|
127
|
-
return 0 != (t.flagInt & e);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function s(t, e, i) {
|
|
131
|
-
i ? t.flagInt |= e : t.flagInt &= ~e;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
127
|
export {
|
|
135
128
|
e as QyItem
|
|
136
129
|
};
|
package/src/QyKVData.js
CHANGED
|
@@ -81,7 +81,7 @@ class t {
|
|
|
81
81
|
} = this, {
|
|
82
82
|
maxSnapshotNum: h,
|
|
83
83
|
snapshotMaxChangeId: c
|
|
84
|
-
} = o, s = (s.start(t, h, a, e), i.start(), r.start(), p.start(), setInterval(() =>
|
|
84
|
+
} = o, s = (s.start(t, h, a, e), i.start(), r.start(), p.start(), setInterval(() => l(this), n.compactSnapshotsInterval)), h = setInterval(() => (async o => {
|
|
85
85
|
if (!o.unloadingMemory) {
|
|
86
86
|
o.unloadingMemory = !0;
|
|
87
87
|
var {
|
|
@@ -91,8 +91,8 @@ class t {
|
|
|
91
91
|
let t = 0, a = 0;
|
|
92
92
|
if (e) {
|
|
93
93
|
var s, i = n.maxFileCountToUnload, n = e.rootDir;
|
|
94
|
-
a =
|
|
95
|
-
for (s of n.allLoadedSubdirs()) if ((a +=
|
|
94
|
+
a = m(o, n), t = a;
|
|
95
|
+
for (s of n.allLoadedSubdirs()) if ((a += m(o, s)) > i && (t += a,
|
|
96
96
|
a = 0, await d(0), o.isStopping)) break;
|
|
97
97
|
}
|
|
98
98
|
t += a, global.gc && global.gc(), o.unloadingMemory = !1;
|
|
@@ -114,9 +114,9 @@ class t {
|
|
|
114
114
|
for (a of Object.keys(o.numToSnapshotMap).sort((t, a) => a - t)) {
|
|
115
115
|
if (await async function s(i, r, p = void 0, h = void 0, c = void 0, d = void 0) {
|
|
116
116
|
if (i.isStopping) return void (d && d.close());
|
|
117
|
-
let
|
|
118
|
-
let
|
|
119
|
-
let v =
|
|
117
|
+
let l = i.qySnapshots;
|
|
118
|
+
let m = l.numToSnapshotMap;
|
|
119
|
+
let v = m[r];
|
|
120
120
|
if (void 0 === v) return void (d && d.close());
|
|
121
121
|
let {
|
|
122
122
|
info: u,
|
|
@@ -125,14 +125,14 @@ class t {
|
|
|
125
125
|
void 0 === p && (p = Object.keys(S).sort().reverse());
|
|
126
126
|
if (0 === p.length) return void (d && d.close());
|
|
127
127
|
if (void 0 === h || h !== u.pMVersion) return d && d.close(),
|
|
128
|
-
c =
|
|
128
|
+
c = l.getPMFilePath(v), s(i, r, p, u.pMVersion, c, await f(c));
|
|
129
129
|
for (;0 < p.length; ) {
|
|
130
130
|
let e = p.at(-1), n = S[e];
|
|
131
131
|
if (n) {
|
|
132
132
|
let [ t, a ] = n, o = await y(c, d, t, a);
|
|
133
|
-
if (i.isStopping || void 0 ===
|
|
133
|
+
if (i.isStopping || void 0 === m[r]) return void d.close();
|
|
134
134
|
if (h !== u.pMVersion) return d.close(), s(i, r, p);
|
|
135
|
-
e in S &&
|
|
135
|
+
e in S && l.loadPartialPosMapBuffer(v, e, o);
|
|
136
136
|
}
|
|
137
137
|
p.pop();
|
|
138
138
|
}
|
|
@@ -141,8 +141,8 @@ class t {
|
|
|
141
141
|
}(t, a), t.isStopping) break;
|
|
142
142
|
if (await d(0), t.isStopping) break;
|
|
143
143
|
}
|
|
144
|
-
console.timeEnd("bgLoadPosMaps"), !t.isStopping && e.compactAtStart &&
|
|
145
|
-
})(this) : n.compactAtStart &&
|
|
144
|
+
console.timeEnd("bgLoadPosMaps"), !t.isStopping && e.compactAtStart && l(t);
|
|
145
|
+
})(this) : n.compactAtStart && l(this), this;
|
|
146
146
|
}
|
|
147
147
|
async stop() {
|
|
148
148
|
this.isStopping = !0;
|
|
@@ -205,8 +205,8 @@ class t {
|
|
|
205
205
|
if (2 === this.compactState) {
|
|
206
206
|
var d = this, {
|
|
207
207
|
pMUpdates: t,
|
|
208
|
-
vLUpdates:
|
|
209
|
-
combinationUpdate:
|
|
208
|
+
vLUpdates: l,
|
|
209
|
+
combinationUpdate: m
|
|
210
210
|
} = t = t;
|
|
211
211
|
if (t) {
|
|
212
212
|
var a = t, o = d.qySnapshots.numToSnapshotMap;
|
|
@@ -226,8 +226,8 @@ class t {
|
|
|
226
226
|
})(s);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
if (
|
|
230
|
-
var p =
|
|
229
|
+
if (l) {
|
|
230
|
+
var p = l, h = (t = d).qySnapshots.numToSnapshotMap;
|
|
231
231
|
for (f in p) {
|
|
232
232
|
var c, v, {
|
|
233
233
|
posMap: u,
|
|
@@ -240,11 +240,11 @@ class t {
|
|
|
240
240
|
for (c in ++g.pMVersion, ++g.vLVersion, g.verList[0] = g.pMVersion + g.vLVersion,
|
|
241
241
|
y) y[c] = u[c];
|
|
242
242
|
for (v in C) C[v] = S[v];
|
|
243
|
-
|
|
243
|
+
V(f);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
if (
|
|
247
|
-
var M,
|
|
246
|
+
if (m) {
|
|
247
|
+
var M, l = m;
|
|
248
248
|
let e = d.qySnapshots, {
|
|
249
249
|
numToSnapshotMap: n,
|
|
250
250
|
keyToSnapshotMap: s
|
|
@@ -252,22 +252,22 @@ class t {
|
|
|
252
252
|
snapshotNum: t,
|
|
253
253
|
combinedSnapshotNumVerList: a,
|
|
254
254
|
posMap: i
|
|
255
|
-
} =
|
|
255
|
+
} = l, r = n[t], {
|
|
256
256
|
posMap: p,
|
|
257
257
|
info: o
|
|
258
258
|
} = r;
|
|
259
259
|
for (M in ++o.pMVersion, ++o.vLVersion, o.verList[0] = o.pMVersion + o.vLVersion,
|
|
260
260
|
p) p[M] = i[M];
|
|
261
|
-
|
|
261
|
+
V(r);
|
|
262
262
|
let h = o.totalCount, c = r.outdatedCount;
|
|
263
263
|
for (let [ o ] of a) {
|
|
264
|
-
var q,
|
|
264
|
+
var q, I = n[o];
|
|
265
265
|
let {
|
|
266
266
|
posMap: t,
|
|
267
267
|
info: a
|
|
268
|
-
} =
|
|
268
|
+
} = I;
|
|
269
269
|
for (q in t) p[q] = i[q], s[q] = r;
|
|
270
|
-
I
|
|
270
|
+
V(I), h += a.totalCount, c += I.outdatedCount, e.delSnapshot(I);
|
|
271
271
|
}
|
|
272
272
|
o.totalCount = h, r.outdatedCount = c;
|
|
273
273
|
}
|
|
@@ -288,7 +288,7 @@ class t {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
function
|
|
291
|
+
function V(t) {
|
|
292
292
|
var {
|
|
293
293
|
info: a,
|
|
294
294
|
compactOutedCount: o
|
|
@@ -297,29 +297,24 @@ function I(t) {
|
|
|
297
297
|
t.compactOutedCount = 0;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
function
|
|
300
|
+
function l(t) {
|
|
301
301
|
if (1 === t.compactState) {
|
|
302
302
|
var {
|
|
303
303
|
maxChangeId: a,
|
|
304
304
|
qySnapshots: o,
|
|
305
305
|
qySnapshotCompactor: e
|
|
306
|
-
} = t,
|
|
307
|
-
|
|
308
|
-
pMCompactSnapshotList: n,
|
|
309
|
-
vLCompactSnapshotList: s,
|
|
310
|
-
combiningSnapshotList: i
|
|
311
|
-
} = o.calOutdates();
|
|
312
|
-
if (0 < i.length || 0 < n.length || 0 < s.length) {
|
|
306
|
+
} = t, [ o, n, s, i ] = o.calOutdates();
|
|
307
|
+
if (0 < n.length || 0 < s.length || 0 < i.length) {
|
|
313
308
|
t.compactState = 2, t.compactMaxChangeId = a;
|
|
314
|
-
for (var r of [
|
|
315
|
-
e.compactSnapshots(
|
|
309
|
+
for (var r of [ s, i, n ]) for (var p of r) p.compactOutedCount = p.outdatedCount;
|
|
310
|
+
e.compactSnapshots(s, i, n);
|
|
316
311
|
}
|
|
317
312
|
0 < o.length && (t.emptySnapshotNumVerList.push(...o), t.snapshotSavedChangeId >= a ? c(t) : 1 === t.compactState && (t.compactState = 3,
|
|
318
313
|
t.compactMaxChangeId = a));
|
|
319
314
|
}
|
|
320
315
|
}
|
|
321
316
|
|
|
322
|
-
function
|
|
317
|
+
function m(t, a) {
|
|
323
318
|
var o = t.qySnapshots.snapshotMaxChangeId;
|
|
324
319
|
let e = 0;
|
|
325
320
|
if (a.fileMapLoaded) for (var n of a.fileList) ++e, n.cChangeId <= o && (n.visited ? n.visited = !1 : n.unloadFileContent());
|
package/src/QyKVDataLoader.d.ts
CHANGED
|
@@ -8,10 +8,5 @@ export declare class QyKVDataLoader {
|
|
|
8
8
|
aclKeyValueMap: any;
|
|
9
9
|
maxChangeId: number;
|
|
10
10
|
constructor(kvFolder: any, options?: any);
|
|
11
|
-
load(): Promise<
|
|
12
|
-
maxChangeId: number;
|
|
13
|
-
loadedMaxAclNum: number;
|
|
14
|
-
qySnapshots: any;
|
|
15
|
-
aclKeyValueMap: any;
|
|
16
|
-
}>;
|
|
11
|
+
load(): Promise<any[]>;
|
|
17
12
|
}
|
package/src/QyKVDataLoader.js
CHANGED
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
} from "node:path";
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
folderOrFileExists as
|
|
11
|
+
folderOrFileExists as F
|
|
12
12
|
} from "./QyUtils.js";
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
-
readAclBuffer as
|
|
15
|
+
readAclBuffer as g
|
|
16
16
|
} from "./QyAcl.js";
|
|
17
17
|
|
|
18
18
|
import {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "./QySnapshots.js";
|
|
21
21
|
|
|
22
22
|
import {
|
|
23
|
-
getDefaultOptions as
|
|
23
|
+
getDefaultOptions as r
|
|
24
24
|
} from "./QyDefaultOptions.js";
|
|
25
25
|
|
|
26
26
|
class a {
|
|
@@ -34,7 +34,7 @@ class a {
|
|
|
34
34
|
maxChangeId = 0;
|
|
35
35
|
constructor(a, o = void 0) {
|
|
36
36
|
o = {
|
|
37
|
-
...
|
|
37
|
+
...r("QyKVDataLoader"),
|
|
38
38
|
...o
|
|
39
39
|
};
|
|
40
40
|
var s = t(a, "snapshot");
|
|
@@ -48,22 +48,22 @@ class a {
|
|
|
48
48
|
}
|
|
49
49
|
async load() {
|
|
50
50
|
var a = this.qySnapshots, [ o ] = await Promise.all([ (async a => {
|
|
51
|
-
if (a = a.aclFolder, await
|
|
51
|
+
if (a = a.aclFolder, await F(a)) return (await x(a)).filter(a => /^[1-9]/.test(a)).map(a => parseInt(a));
|
|
52
52
|
})(this), a.loadSnapshotInfos() ]);
|
|
53
53
|
let {
|
|
54
54
|
maxSnapshotNum: s,
|
|
55
55
|
snapshotMaxChangeId: t
|
|
56
56
|
} = a;
|
|
57
57
|
if (this.maxChangeId = t, o) {
|
|
58
|
-
var e = this,
|
|
59
|
-
aclKeyValueMap:
|
|
60
|
-
qySnapshots:
|
|
58
|
+
var e = this, r = o.filter(a => a > s), {
|
|
59
|
+
aclKeyValueMap: l,
|
|
60
|
+
qySnapshots: i,
|
|
61
61
|
options: o
|
|
62
|
-
} = (
|
|
63
|
-
for (let a = 0; a <
|
|
64
|
-
var d =
|
|
62
|
+
} = (r.sort((a, o) => a - o), e), n = o.autoRepairAclFile, p = await Promise.all(r.map(async a => u(v(e, a))));
|
|
63
|
+
for (let a = 0; a < r.length; ++a) {
|
|
64
|
+
var d = r[a], m = v(e, d), m = await g(m, p[a], n, e.maxChangeId);
|
|
65
65
|
if (0 < m.length) {
|
|
66
|
-
for (var [ h, c ] of m)
|
|
66
|
+
for (var [ h, c ] of m) i.applyCmdObj(c, l), e.maxChangeId = h;
|
|
67
67
|
e.loadedMaxAclNum = d;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -74,12 +74,7 @@ class a {
|
|
|
74
74
|
loadedMaxAclNum: f,
|
|
75
75
|
aclKeyValueMap: y
|
|
76
76
|
} = this;
|
|
77
|
-
return
|
|
78
|
-
maxChangeId: o,
|
|
79
|
-
loadedMaxAclNum: f,
|
|
80
|
-
qySnapshots: a,
|
|
81
|
-
aclKeyValueMap: y
|
|
82
|
-
};
|
|
77
|
+
return [ o, f, a, y ];
|
|
83
78
|
}
|
|
84
79
|
}
|
|
85
80
|
|
package/src/QyLogger.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
export declare const ThreadMark: string;
|
|
2
|
-
declare class
|
|
2
|
+
declare class QyLoggerBase {
|
|
3
3
|
_level: number;
|
|
4
4
|
fileConsole: any;
|
|
5
5
|
stdout: any;
|
|
6
6
|
stderr: any;
|
|
7
|
-
outBuf: any[];
|
|
8
|
-
errBuf: any[];
|
|
9
|
-
mainBuf: any[];
|
|
10
|
-
constructor();
|
|
11
7
|
get level(): string;
|
|
12
8
|
set level(val: string);
|
|
13
9
|
info(...args: any[]): void;
|
|
@@ -15,10 +11,20 @@ declare class QyLogger {
|
|
|
15
11
|
debug(...args: any[]): void;
|
|
16
12
|
warn(...args: any[]): void;
|
|
17
13
|
error(...args: any[]): void;
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
}
|
|
15
|
+
declare class QyMainLogger extends QyLoggerBase {
|
|
16
|
+
outBuf: any[];
|
|
17
|
+
errBuf: any[];
|
|
18
|
+
mainBuf: any[];
|
|
20
19
|
closeFileConsole(): void;
|
|
21
20
|
setFileConsoleDateDirPath(dateDirPath: string, clearLogAtStart?: boolean): void;
|
|
21
|
+
handleStdOutMsg(msg: any): void;
|
|
22
|
+
handleStdErrMsg(msg: any): void;
|
|
23
|
+
}
|
|
24
|
+
declare class QyWorkerLogger extends QyLoggerBase {
|
|
25
|
+
constructor();
|
|
26
|
+
handleStdOutMsg(msg: any): void;
|
|
27
|
+
handleStdErrMsg(msg: any): void;
|
|
22
28
|
}
|
|
23
|
-
export declare const logger:
|
|
29
|
+
export declare const logger: QyMainLogger | QyWorkerLogger;
|
|
24
30
|
export {};
|
package/src/QyLogger.js
CHANGED
|
@@ -8,15 +8,15 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
parentPort as r,
|
|
11
|
-
isMainThread as
|
|
12
|
-
threadId as
|
|
11
|
+
isMainThread as e,
|
|
12
|
+
threadId as t
|
|
13
13
|
} from "node:worker_threads";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
|
-
Writable as
|
|
16
|
+
Writable as s
|
|
17
17
|
} from "node:stream";
|
|
18
18
|
|
|
19
|
-
let i =
|
|
19
|
+
let i = e ? "" : `W${t}:`, n = {
|
|
20
20
|
info: 1,
|
|
21
21
|
debug: 2,
|
|
22
22
|
log: 3,
|
|
@@ -25,25 +25,11 @@ let i = p ? "" : `W${e}:`, n = {
|
|
|
25
25
|
none: 6
|
|
26
26
|
}, o = Object.fromEntries(Object.entries(n).map(([ e, t ]) => [ t, e ]));
|
|
27
27
|
|
|
28
|
-
class
|
|
28
|
+
class l {
|
|
29
29
|
_level = n.debug;
|
|
30
30
|
fileConsole;
|
|
31
31
|
stdout;
|
|
32
32
|
stderr;
|
|
33
|
-
outBuf = [];
|
|
34
|
-
errBuf = [];
|
|
35
|
-
mainBuf = [];
|
|
36
|
-
constructor() {
|
|
37
|
-
var e, t;
|
|
38
|
-
p || (e = this.stdout = a("%o_"), t = this.stderr = a("%e_"), this.fileConsole = new c({
|
|
39
|
-
stdout: e,
|
|
40
|
-
stderr: t,
|
|
41
|
-
inspectOptions: {
|
|
42
|
-
depth: 3,
|
|
43
|
-
colors: !1
|
|
44
|
-
}
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
33
|
get level() {
|
|
48
34
|
return o[this._level];
|
|
49
35
|
}
|
|
@@ -51,112 +37,137 @@ class s {
|
|
|
51
37
|
this._level = n[e];
|
|
52
38
|
}
|
|
53
39
|
info(...e) {
|
|
54
|
-
|
|
40
|
+
h(this, "info", e);
|
|
55
41
|
}
|
|
56
42
|
log(...e) {
|
|
57
|
-
|
|
43
|
+
h(this, "log", e);
|
|
58
44
|
}
|
|
59
45
|
debug(...e) {
|
|
60
|
-
|
|
46
|
+
h(this, "debug", e);
|
|
61
47
|
}
|
|
62
48
|
warn(...e) {
|
|
63
|
-
|
|
49
|
+
h(this, "warn", e);
|
|
64
50
|
}
|
|
65
51
|
error(...e) {
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
handleOutMsg(e) {
|
|
69
|
-
var t, o;
|
|
70
|
-
p ? ({
|
|
71
|
-
stdout: t,
|
|
72
|
-
outBuf: o
|
|
73
|
-
} = this, void 0 !== t ? g(t, e) : o.push(e)) : r?.postMessage(e);
|
|
74
|
-
}
|
|
75
|
-
handleErrMsg(e) {
|
|
76
|
-
var t, o;
|
|
77
|
-
p ? ({
|
|
78
|
-
stderr: t,
|
|
79
|
-
errBuf: o
|
|
80
|
-
} = this, void 0 !== t ? g(t, e) : o.push(e)) : r?.postMessage(e);
|
|
52
|
+
h(this, "error", e);
|
|
81
53
|
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class a extends l {
|
|
57
|
+
outBuf = [];
|
|
58
|
+
errBuf = [];
|
|
59
|
+
mainBuf = [];
|
|
82
60
|
closeFileConsole() {
|
|
83
|
-
|
|
84
|
-
this.stderr
|
|
61
|
+
this.fileConsole = void 0, this.stdout && (this.stdout.close(), this.stdout = void 0),
|
|
62
|
+
this.stderr && (this.stderr.close(), this.stderr = void 0);
|
|
85
63
|
}
|
|
86
64
|
setFileConsoleDateDirPath(e, t = !1) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
colors: !1
|
|
99
|
-
}
|
|
100
|
-
}), s = o, r = e, i = t, {
|
|
101
|
-
outBuf: o,
|
|
102
|
-
errBuf: e,
|
|
103
|
-
mainBuf: t
|
|
104
|
-
} = o = this;
|
|
105
|
-
if (0 < o.length) {
|
|
106
|
-
for (var n of o) g(s, n);
|
|
107
|
-
o.length = 0;
|
|
108
|
-
}
|
|
109
|
-
if (0 < e.length) {
|
|
110
|
-
for (var l of e) g(r, l);
|
|
111
|
-
e.length = 0;
|
|
112
|
-
}
|
|
113
|
-
if (0 < t.length) {
|
|
114
|
-
for (var [ a, h, d ] of t) i[a](h, ...d);
|
|
115
|
-
t.length = 0;
|
|
65
|
+
this.closeFileConsole();
|
|
66
|
+
var t = {
|
|
67
|
+
flags: t ? "w" : "a",
|
|
68
|
+
flush: !0,
|
|
69
|
+
autoClose: !1
|
|
70
|
+
}, s = this.stdout = u.createWriteStream(f.join(e, "stdout.txt"), t), e = this.stderr = u.createWriteStream(f.join(e, "stderr.txt"), t), t = this.fileConsole = new c({
|
|
71
|
+
stdout: s,
|
|
72
|
+
stderr: e,
|
|
73
|
+
inspectOptions: {
|
|
74
|
+
depth: 3,
|
|
75
|
+
colors: !1
|
|
116
76
|
}
|
|
77
|
+
}), o = s, r = e, i = t, {
|
|
78
|
+
outBuf: s,
|
|
79
|
+
errBuf: e,
|
|
80
|
+
mainBuf: t
|
|
81
|
+
} = s = this;
|
|
82
|
+
if (0 < s.length) {
|
|
83
|
+
for (var n of s) g(o, n);
|
|
84
|
+
s.length = 0;
|
|
117
85
|
}
|
|
86
|
+
if (0 < e.length) {
|
|
87
|
+
for (var l of e) g(r, l);
|
|
88
|
+
e.length = 0;
|
|
89
|
+
}
|
|
90
|
+
if (0 < t.length) {
|
|
91
|
+
for (var [ a, d, h ] of t) i[a](d, ...h);
|
|
92
|
+
t.length = 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
handleStdOutMsg(e) {
|
|
96
|
+
var {
|
|
97
|
+
stdout: t,
|
|
98
|
+
outBuf: s
|
|
99
|
+
} = this;
|
|
100
|
+
void 0 !== t ? g(t, e) : s.push(e);
|
|
101
|
+
}
|
|
102
|
+
handleStdErrMsg(e) {
|
|
103
|
+
var {
|
|
104
|
+
stderr: t,
|
|
105
|
+
errBuf: s
|
|
106
|
+
} = this;
|
|
107
|
+
void 0 !== t ? g(t, e) : s.push(e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
class d extends l {
|
|
112
|
+
constructor() {
|
|
113
|
+
super();
|
|
114
|
+
var e = this.stdout = p("%o_"), t = this.stderr = p("%e_");
|
|
115
|
+
this.fileConsole = new c({
|
|
116
|
+
stdout: e,
|
|
117
|
+
stderr: t,
|
|
118
|
+
inspectOptions: {
|
|
119
|
+
depth: 3,
|
|
120
|
+
colors: !1
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
handleStdOutMsg(e) {
|
|
125
|
+
r?.postMessage(e);
|
|
126
|
+
}
|
|
127
|
+
handleStdErrMsg(e) {
|
|
128
|
+
r?.postMessage(e);
|
|
118
129
|
}
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
function g(e, t) {
|
|
122
|
-
var
|
|
133
|
+
var s, o;
|
|
123
134
|
e && ({
|
|
124
135
|
chunks: t,
|
|
125
|
-
chunk:
|
|
126
|
-
encoding:
|
|
127
|
-
} = t, t ? e.writev(t) : e.write(
|
|
136
|
+
chunk: s,
|
|
137
|
+
encoding: o
|
|
138
|
+
} = t, t ? e.writev(t) : e.write(s, o));
|
|
128
139
|
}
|
|
129
140
|
|
|
130
|
-
function
|
|
131
|
-
var
|
|
132
|
-
e._level <= n[t] && (
|
|
133
|
-
|
|
141
|
+
function h(e, t, s) {
|
|
142
|
+
var o, r;
|
|
143
|
+
e._level <= n[t] && (o = ((o = (o = new Error().stack?.split("\n")) && /([^/\\()]+)\)?$/.exec(o[3] ?? "")) && o[1]) ?? "",
|
|
144
|
+
o = `${new Date().toISOString()} ${i}${o}:${t}:`, {
|
|
134
145
|
fileConsole: e,
|
|
135
146
|
mainBuf: r
|
|
136
|
-
} = (console[t](
|
|
147
|
+
} = (console[t](o, ...s), e), void 0 !== e ? e[t](o, ...s) : r.push([ t, o, s ]));
|
|
137
148
|
}
|
|
138
149
|
|
|
139
|
-
function
|
|
140
|
-
return new
|
|
141
|
-
write(e, t,
|
|
150
|
+
function p(o) {
|
|
151
|
+
return new s({
|
|
152
|
+
write(e, t, s) {
|
|
142
153
|
return r?.postMessage({
|
|
143
|
-
opName:
|
|
154
|
+
opName: o,
|
|
144
155
|
chunk: e,
|
|
145
156
|
encoding: t
|
|
146
|
-
}),
|
|
157
|
+
}), s && s(), !0;
|
|
147
158
|
},
|
|
148
159
|
writev(e, t) {
|
|
149
160
|
return r?.postMessage({
|
|
150
|
-
opName:
|
|
161
|
+
opName: o,
|
|
151
162
|
chunks: e
|
|
152
163
|
}), t && t(), !0;
|
|
153
164
|
}
|
|
154
165
|
});
|
|
155
166
|
}
|
|
156
167
|
|
|
157
|
-
var
|
|
168
|
+
var v = new (e ? a : d)();
|
|
158
169
|
|
|
159
170
|
export {
|
|
160
171
|
i as ThreadMark,
|
|
161
|
-
|
|
172
|
+
v as logger
|
|
162
173
|
};
|
package/src/QyMessager.js
CHANGED
|
@@ -71,7 +71,7 @@ class r {
|
|
|
71
71
|
ack: o,
|
|
72
72
|
result: s
|
|
73
73
|
} = e;
|
|
74
|
-
void 0 !== r ? "%o_" === r ? n.
|
|
74
|
+
void 0 !== r ? "%o_" === r ? n.handleStdOutMsg(e) : "%e_" === r ? n.handleStdErrMsg(e) : (e = e.args || [],
|
|
75
75
|
t[r](...e)) : a[o]?.shift().resolve(s);
|
|
76
76
|
}), i.on("exit", e => {
|
|
77
77
|
for (var r in i.removeAllListeners(), 0 !== e ? n.warn(`Worker ${s} stopped with exitCode ` + e) : n.info(`Worker ${s} stopped.`),
|
|
@@ -16,8 +16,5 @@ export default class QySnapshotSaver_Worker extends QyMessageWorker {
|
|
|
16
16
|
saveSnapshot(maxSnapshotNum: any): Promise<void>;
|
|
17
17
|
releaseSnapshot(snapshotNum: any): void;
|
|
18
18
|
_op_stop(): Promise<number>;
|
|
19
|
-
_op_waitForSnapshotSaved(
|
|
20
|
-
saveMaxSnapshotInfoPromise: any;
|
|
21
|
-
outdates: any;
|
|
22
|
-
}): Promise<void>;
|
|
19
|
+
_op_waitForSnapshotSaved([saveMaxSnapshotInfoPromise, outdates]: [any, any]): Promise<void>;
|
|
23
20
|
}
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./QyKVDataCleaner.js";
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
-
logger as
|
|
22
|
+
logger as d
|
|
23
23
|
} from "./QyLogger.js";
|
|
24
24
|
|
|
25
25
|
export default class extends a {
|
|
@@ -79,31 +79,20 @@ export default class extends a {
|
|
|
79
79
|
} = this;
|
|
80
80
|
return a.closeAllFDs(), await s.stop(), e;
|
|
81
81
|
}
|
|
82
|
-
async _op_waitForSnapshotSaved({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}) {
|
|
86
|
-
var e, {
|
|
87
|
-
snapshotNum: a,
|
|
88
|
-
maxChangeId: t
|
|
89
|
-
} = await a, {
|
|
90
|
-
emptySnapshotNumVerList: s,
|
|
91
|
-
pMChangeList: o,
|
|
92
|
-
vLChange: n,
|
|
93
|
-
snapshotInfoMap: p,
|
|
94
|
-
promises: h
|
|
95
|
-
} = (this.snapshotSavedChangeId = t, s), {
|
|
82
|
+
async _op_waitForSnapshotSaved([ a, s ]) {
|
|
83
|
+
var e, [ a, t ] = await a, [ s, o, n, p, h ] = (this.snapshotSavedChangeId = t,
|
|
84
|
+
s), {
|
|
96
85
|
qyKVDataCleaner: r,
|
|
97
|
-
qySnapshots:
|
|
98
|
-
options:
|
|
86
|
+
qySnapshots: l,
|
|
87
|
+
options: i
|
|
99
88
|
} = this;
|
|
100
89
|
for (e in r.cleanAclFiles(a), 0 < h.length && (await Promise.all(h), h.length = 0),
|
|
101
|
-
p) h.push(
|
|
90
|
+
p) h.push(l.saveSnapshotInfo(e, p[e]));
|
|
102
91
|
0 < h.length && (await Promise.all(h), h.length = 0), 0 < s.length && r.removeSnapshotsFiles(s),
|
|
103
92
|
0 < o.length && r.cleanPMFiles(o), 0 < n.length && r.cleanVLFiles(n[0], n[1]);
|
|
104
93
|
let u;
|
|
105
|
-
a =
|
|
106
|
-
0 < a && a >=
|
|
94
|
+
a = l.snapshotCount;
|
|
95
|
+
0 < a && a >= i.maxInMemSnapshotCount && (delete (s = (a => {
|
|
107
96
|
let s = a.qySnapshots.numToSnapshotMap, e;
|
|
108
97
|
for (var t in s) {
|
|
109
98
|
var o = s[t];
|
|
@@ -112,55 +101,45 @@ export default class extends a {
|
|
|
112
101
|
return e;
|
|
113
102
|
})(this)).prefixPM, delete (u = {
|
|
114
103
|
...s
|
|
115
|
-
}).keyValueMap, delete s.posMap, s.isOut = !0,
|
|
104
|
+
}).keyValueMap, delete s.posMap, s.isOut = !0, d.info("Sending snapshot " + s.snapshotNum)),
|
|
116
105
|
this.postParent("onSnapshotSavedChangeId", t, u);
|
|
117
106
|
}
|
|
118
107
|
}
|
|
119
108
|
|
|
120
109
|
function h(a, s, e, t) {
|
|
121
110
|
var o = (a => {
|
|
122
|
-
var s, e = a.qySnapshots, {
|
|
123
|
-
emptySnapshotNumVerList: t,
|
|
124
|
-
combiningSnapshotList: a,
|
|
125
|
-
pMCompactSnapshotList: o
|
|
126
|
-
} = e.calOutdates(), n = {}, p = [], h = [], r = [];
|
|
111
|
+
var s, e = a.qySnapshots, [ t, a, o ] = e.calOutdates(), n = {}, p = [], h = [], r = [];
|
|
127
112
|
for (s of o) {
|
|
128
113
|
var {
|
|
129
|
-
snapshotNum:
|
|
130
|
-
info:
|
|
114
|
+
snapshotNum: l,
|
|
115
|
+
info: i
|
|
131
116
|
} = s;
|
|
132
|
-
p.push(e.savePosMap(s)), h.push([
|
|
133
|
-
...
|
|
117
|
+
p.push(e.savePosMap(s)), h.push([ l, i.pMVersion ]), n[l] = {
|
|
118
|
+
...i
|
|
134
119
|
};
|
|
135
120
|
}
|
|
136
|
-
let u = a.length,
|
|
121
|
+
let u = a.length, d;
|
|
137
122
|
if (0 < u) {
|
|
138
|
-
var
|
|
139
|
-
keyValueMap:
|
|
123
|
+
var y, S = e.keyToSnapshotMap, {
|
|
124
|
+
keyValueMap: v,
|
|
140
125
|
info: o,
|
|
141
|
-
snapshotNum:
|
|
142
|
-
} =
|
|
143
|
-
for (
|
|
126
|
+
snapshotNum: m
|
|
127
|
+
} = d = e.getMaxCombinedSnapshot(a);
|
|
128
|
+
for (y of a) if (d !== y) {
|
|
144
129
|
var g, {
|
|
145
|
-
keyValueMap:
|
|
146
|
-
snapshotNum:
|
|
147
|
-
info:
|
|
148
|
-
} =
|
|
149
|
-
for (g in
|
|
150
|
-
e.delSnapshot(
|
|
130
|
+
keyValueMap: f,
|
|
131
|
+
snapshotNum: M,
|
|
132
|
+
info: V
|
|
133
|
+
} = y;
|
|
134
|
+
for (g in f) v[g] = f[g], S[g] = d;
|
|
135
|
+
e.delSnapshot(y), t.push([ M, V.verList[0] ]);
|
|
151
136
|
}
|
|
152
|
-
p.push(e.saveKeyValueMap(
|
|
153
|
-
n[
|
|
137
|
+
p.push(e.saveKeyValueMap(d)), h.push([ m, o.pMVersion ]), r.push(m, o.vLVersion),
|
|
138
|
+
n[m] = {
|
|
154
139
|
...o
|
|
155
140
|
};
|
|
156
141
|
}
|
|
157
|
-
return
|
|
158
|
-
emptySnapshotNumVerList: t,
|
|
159
|
-
pMChangeList: h,
|
|
160
|
-
vLChange: r,
|
|
161
|
-
snapshotInfoMap: n,
|
|
162
|
-
promises: p
|
|
163
|
-
};
|
|
142
|
+
return [ t, h, r, n, p ];
|
|
164
143
|
})(a), s = {
|
|
165
144
|
snapshotNum: s,
|
|
166
145
|
keyValueMap: t,
|
|
@@ -177,13 +156,7 @@ function h(a, s, e, t) {
|
|
|
177
156
|
snapshotNum: s,
|
|
178
157
|
info: e
|
|
179
158
|
} = s;
|
|
180
|
-
return await a.saveSnapshotInfo(s, e),
|
|
181
|
-
snapshotNum: s,
|
|
182
|
-
maxChangeId: e.maxChangeId
|
|
183
|
-
};
|
|
159
|
+
return await a.saveSnapshotInfo(s, e), d.log("Created snapshot " + s), [ s, e.maxChangeId ];
|
|
184
160
|
})(a, s));
|
|
185
|
-
return
|
|
186
|
-
saveMaxSnapshotInfoPromise: t,
|
|
187
|
-
outdates: o
|
|
188
|
-
};
|
|
161
|
+
return [ t, o ];
|
|
189
162
|
}
|
package/src/QySnapshots.d.ts
CHANGED
|
@@ -20,12 +20,7 @@ export declare class QySnapshots {
|
|
|
20
20
|
getValueSync(key: any): any;
|
|
21
21
|
loadPartialPosMapBuffer(snapshot: any, prefix: any, buffer: any): void;
|
|
22
22
|
delSnapshot(snapshot: any): void;
|
|
23
|
-
calOutdates():
|
|
24
|
-
emptySnapshotNumVerList: any[];
|
|
25
|
-
combiningSnapshotList: any[];
|
|
26
|
-
pMCompactSnapshotList: any[];
|
|
27
|
-
vLCompactSnapshotList: any[];
|
|
28
|
-
};
|
|
23
|
+
calOutdates(): any[][];
|
|
29
24
|
getMaxCombinedSnapshot(snapshotList: any): any;
|
|
30
25
|
getPMFilePath(snapshot: any): string;
|
|
31
26
|
getVLFilePath(snapshot: any): string;
|
package/src/QySnapshots.js
CHANGED
|
@@ -20,10 +20,10 @@ import {
|
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
22
|
Hash_Key_Length as p,
|
|
23
|
-
folderOrFileExists as
|
|
23
|
+
folderOrFileExists as v,
|
|
24
24
|
listToMap as f,
|
|
25
25
|
isEmptyObj as u,
|
|
26
|
-
isString as
|
|
26
|
+
isString as m,
|
|
27
27
|
isArray as M,
|
|
28
28
|
isUint8Array as y,
|
|
29
29
|
readBufferFromFD as h
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
logger as F
|
|
49
49
|
} from "./QyLogger.js";
|
|
50
50
|
|
|
51
|
-
let J = Buffer.from("\n"),
|
|
51
|
+
let J = Buffer.from("\n"), O = Buffer.from("'"), L = Buffer.from("z"), b = Buffer.from("vect"), K = O[0], _ = L[0], A = b[0];
|
|
52
52
|
|
|
53
53
|
class t {
|
|
54
54
|
snapshotFolder;
|
|
@@ -81,7 +81,7 @@ class t {
|
|
|
81
81
|
qyJsonSaver: r,
|
|
82
82
|
numToSnapshotMap: n
|
|
83
83
|
} = this;
|
|
84
|
-
if (await
|
|
84
|
+
if (await v(t)) {
|
|
85
85
|
var o = await (async (t, o) => {
|
|
86
86
|
var a = {};
|
|
87
87
|
for (r of await l(o)) {
|
|
@@ -129,8 +129,8 @@ class t {
|
|
|
129
129
|
for (o of n) {
|
|
130
130
|
var l = e[o];
|
|
131
131
|
let t;
|
|
132
|
-
null == l ? t = q : (h = Buffer.isBuffer(l) ? (u = l, 0) :
|
|
133
|
-
d.zstdCompressSync(l)) : (r.save(
|
|
132
|
+
null == l ? t = q : (h = Buffer.isBuffer(l) ? (u = l, 0) : m(l) ? (u = l.length >= a ? (r.save(L),
|
|
133
|
+
d.zstdCompressSync(l)) : (r.save(O), Buffer.from(l)), 1) : y(l) ? (r.save(b),
|
|
134
134
|
u = Buffer.from(l.buffer, l.byteOffset, l.byteLength), 4) : (u = Buffer.from(JSON.stringify(I(o) && !M(l) ? Object.keys(l) : l)),
|
|
135
135
|
0), r.save([ u, J ]), l = h + u.length, t = [ p, l ], p += l + 1), i[o] = t,
|
|
136
136
|
++f;
|
|
@@ -183,7 +183,7 @@ class t {
|
|
|
183
183
|
posMap: r,
|
|
184
184
|
prefixPM: n
|
|
185
185
|
} = o;
|
|
186
|
-
if (n = n[a]) return [ n, e ] = n, s = t.getPMFilePath(o), s = h(
|
|
186
|
+
if (n = n[a]) return [ n, e ] = n, s = t.getPMFilePath(o), s = h(w(t, s), s, n, e),
|
|
187
187
|
t.loadPartialPosMapBuffer(o, a, s), r;
|
|
188
188
|
})(t, s, r);
|
|
189
189
|
if (i && o in i) return s;
|
|
@@ -200,7 +200,7 @@ class t {
|
|
|
200
200
|
var [ e, a ] = a;
|
|
201
201
|
if (0 !== a) {
|
|
202
202
|
var s = this;
|
|
203
|
-
if (o = s.getVLFilePath(o), s = h(
|
|
203
|
+
if (o = s.getVLFilePath(o), s = h(w(s, o), o, e, a)) return (o = s[0]) === K ? s.toString("utf8", 1) : o === _ ? d.zstdDecompressSync(s.subarray(1)).toString() : o === A ? new Uint8Array(s.buffer, s.byteOffset + 4, s.byteLength - 4) : (e = JSON.parse(s),
|
|
204
204
|
I(t) ? f(e) : e);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -234,12 +234,7 @@ class t {
|
|
|
234
234
|
}
|
|
235
235
|
1 === s.length && D(s[0]) < u && (s.length = 0);
|
|
236
236
|
for ([ o, a ] of [ [ "pMCompacts", r ], [ "vLCompacts", n ], [ "combiningSnapshots", s ] ]) 0 < a.length && F.log(o + ":" + a.map(t => t.snapshotNum + "." + t.info.verList[0]));
|
|
237
|
-
return
|
|
238
|
-
emptySnapshotNumVerList: e,
|
|
239
|
-
combiningSnapshotList: s,
|
|
240
|
-
pMCompactSnapshotList: r,
|
|
241
|
-
vLCompactSnapshotList: n
|
|
242
|
-
};
|
|
237
|
+
return [ e, s, r, n ];
|
|
243
238
|
}
|
|
244
239
|
getMaxCombinedSnapshot(t) {
|
|
245
240
|
let o, a;
|
|
@@ -324,7 +319,7 @@ function V(o, a) {
|
|
|
324
319
|
async function j(t) {
|
|
325
320
|
var o = await n(t), a = o.length, e = {};
|
|
326
321
|
for (let t = 0; t < a; ) {
|
|
327
|
-
var s = t +
|
|
322
|
+
var s = t + N, r = e[o.toString("latin1", t, s)] = [];
|
|
328
323
|
t = c(o, s, r);
|
|
329
324
|
}
|
|
330
325
|
return e;
|
|
@@ -346,7 +341,7 @@ function T(t, o) {
|
|
|
346
341
|
return r(t.snapshotFolder, "" + o, a.pMVersion + "_prefixPM.txt");
|
|
347
342
|
}
|
|
348
343
|
|
|
349
|
-
function
|
|
344
|
+
function w(t, o) {
|
|
350
345
|
t = t.fDMap;
|
|
351
346
|
let a = t[o];
|
|
352
347
|
if (!a) {
|
|
@@ -365,10 +360,10 @@ function o(t, o) {
|
|
|
365
360
|
void 0 !== a && (e(a), delete t[o]);
|
|
366
361
|
}
|
|
367
362
|
|
|
368
|
-
let q = [ 0, 0 ],
|
|
363
|
+
let q = [ 0, 0 ], N = 3;
|
|
369
364
|
|
|
370
365
|
function k(t) {
|
|
371
|
-
return t.substring(0,
|
|
366
|
+
return t.substring(0, N);
|
|
372
367
|
}
|
|
373
368
|
|
|
374
369
|
function I(t) {
|