datafolder 1.0.33 → 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 +4 -0
- package/package.json +1 -1
- package/src/QyBatch.js +26 -21
- package/src/QyCache.js +13 -18
- package/src/QyDir.d.ts +1 -1
- package/src/QyDir.js +98 -31
- package/src/QyFile.d.ts +3 -1
- package/src/QyFile.js +70 -67
- package/src/QyIntersectNode.js +28 -26
- package/src/QyItem.js +32 -38
- 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 +99 -85
- 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/src/QyUnionNode.d.ts +1 -1
- package/src/QyUnionNode.js +4 -4
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,109 +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}:`, {
|
|
145
|
+
fileConsole: e,
|
|
146
|
+
mainBuf: r
|
|
147
|
+
} = (console[t](o, ...s), e), void 0 !== e ? e[t](o, ...s) : r.push([ t, o, s ]));
|
|
134
148
|
}
|
|
135
149
|
|
|
136
|
-
function
|
|
137
|
-
return new
|
|
138
|
-
write(e, t,
|
|
150
|
+
function p(o) {
|
|
151
|
+
return new s({
|
|
152
|
+
write(e, t, s) {
|
|
139
153
|
return r?.postMessage({
|
|
140
|
-
opName:
|
|
154
|
+
opName: o,
|
|
141
155
|
chunk: e,
|
|
142
156
|
encoding: t
|
|
143
|
-
}),
|
|
157
|
+
}), s && s(), !0;
|
|
144
158
|
},
|
|
145
159
|
writev(e, t) {
|
|
146
160
|
return r?.postMessage({
|
|
147
|
-
opName:
|
|
161
|
+
opName: o,
|
|
148
162
|
chunks: e
|
|
149
163
|
}), t && t(), !0;
|
|
150
164
|
}
|
|
151
165
|
});
|
|
152
166
|
}
|
|
153
167
|
|
|
154
|
-
var
|
|
168
|
+
var v = new (e ? a : d)();
|
|
155
169
|
|
|
156
170
|
export {
|
|
157
171
|
i as ThreadMark,
|
|
158
|
-
|
|
172
|
+
v as logger
|
|
159
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) {
|
package/src/QyUnionNode.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class QueryCounter {
|
|
|
10
10
|
countOne(): true | undefined;
|
|
11
11
|
}
|
|
12
12
|
export declare class QyQueryNode {
|
|
13
|
-
|
|
13
|
+
indexCount: number;
|
|
14
14
|
nodeList: any;
|
|
15
15
|
constructor();
|
|
16
16
|
encounterOne(resultMap: any, fileName: any, queryCounter: any): true | undefined;
|