datafolder 1.0.18 → 1.0.19
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/README.md +2 -0
- package/package.json +1 -1
- package/sample.js +9 -0
- package/scripts/fastify.js +1 -0
- package/scripts/hnsw.js +39 -0
- package/src/QyAcl.js +1 -1
- package/src/QyBatch.d.ts +2 -1
- package/src/QyBatch.js +142 -101
- package/src/QyBinWriter.d.ts +5 -9
- package/src/QyBinWriter.js +36 -45
- package/src/QyCD.d.ts +1 -1
- package/src/QyCD.js +66 -64
- package/src/QyCache.d.ts +11 -9
- package/src/QyCache.js +125 -121
- package/src/QyDB.js +1 -4
- package/src/QyDefaultOptions.js +8 -0
- package/src/QyEmbeddingWriter.d.ts +12 -0
- package/src/QyEmbeddingWriter.js +55 -0
- package/src/QyEmbeddings.d.ts +15 -0
- package/src/QyEmbeddings.js +128 -0
- package/src/QyFileContentUtils.js +123 -111
- package/src/QyHNSW.d.ts +5 -8
- package/src/QyHNSW.js +36 -44
- package/src/QySnapshots.js +177 -184
- package/src/QyUtils.d.ts +5 -3
- package/src/QyUtils.js +130 -114
- package/static/codemirror.bundle/editor.bundle.js +16 -9
package/src/QySnapshots.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
close as e,
|
|
3
|
-
|
|
4
|
-
openSync as p
|
|
3
|
+
openSync as s
|
|
5
4
|
} from "node:fs";
|
|
6
5
|
|
|
7
6
|
import {
|
|
8
7
|
readdir as l,
|
|
9
|
-
readFile as
|
|
8
|
+
readFile as r
|
|
10
9
|
} from "node:fs/promises";
|
|
11
10
|
|
|
12
11
|
import {
|
|
13
|
-
join as
|
|
12
|
+
join as n
|
|
14
13
|
} from "node:path";
|
|
15
14
|
|
|
16
15
|
import m from "node:zlib";
|
|
17
16
|
|
|
18
17
|
import {
|
|
19
|
-
getDefaultOptions as
|
|
18
|
+
getDefaultOptions as i
|
|
20
19
|
} from "./QyDefaultOptions.js";
|
|
21
20
|
|
|
22
21
|
import {
|
|
23
|
-
Hash_Key_Length as
|
|
22
|
+
Hash_Key_Length as p,
|
|
24
23
|
folderOrFileExists as d,
|
|
25
|
-
listToMap as
|
|
26
|
-
isEmptyObj as
|
|
24
|
+
listToMap as f,
|
|
25
|
+
isEmptyObj as u,
|
|
27
26
|
isString as v,
|
|
28
27
|
isArray as M,
|
|
29
|
-
|
|
28
|
+
isUint8Array as y,
|
|
29
|
+
readBufferFromFD as h
|
|
30
30
|
} from "./QyUtils.js";
|
|
31
31
|
|
|
32
32
|
import {
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
logger as F
|
|
49
49
|
} from "./QyLogger.js";
|
|
50
50
|
|
|
51
|
-
let
|
|
51
|
+
let J = Buffer.from("\n"), L = Buffer.from("'"), O = Buffer.from("z"), b = Buffer.from("vect"), K = L[0], _ = O[0], A = b[0];
|
|
52
52
|
|
|
53
53
|
class t {
|
|
54
54
|
snapshotFolder;
|
|
@@ -62,55 +62,55 @@ class t {
|
|
|
62
62
|
snapshotMaxChangeId = 0;
|
|
63
63
|
maxSnapshotNum = 0;
|
|
64
64
|
snapshotCount = 0;
|
|
65
|
-
constructor(t,
|
|
66
|
-
(
|
|
67
|
-
...
|
|
68
|
-
...
|
|
69
|
-
}).vLOutdatedPercent = 2 *
|
|
70
|
-
var
|
|
65
|
+
constructor(t, o = void 0) {
|
|
66
|
+
(o = {
|
|
67
|
+
...i("QySnapshots"),
|
|
68
|
+
...o
|
|
69
|
+
}).vLOutdatedPercent = 2 * o.pMOutdatedPercent;
|
|
70
|
+
var a = n(t, "info");
|
|
71
71
|
Object.assign(this, {
|
|
72
72
|
snapshotFolder: t,
|
|
73
|
-
snapshotInfoFolder:
|
|
74
|
-
options:
|
|
75
|
-
qyJsonSaver: new x(
|
|
73
|
+
snapshotInfoFolder: a,
|
|
74
|
+
options: o,
|
|
75
|
+
qyJsonSaver: new x(a, o)
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
async loadSnapshotInfos() {
|
|
79
79
|
let {
|
|
80
80
|
snapshotInfoFolder: t,
|
|
81
|
-
qyJsonSaver:
|
|
82
|
-
numToSnapshotMap:
|
|
81
|
+
qyJsonSaver: n,
|
|
82
|
+
numToSnapshotMap: r
|
|
83
83
|
} = this;
|
|
84
84
|
if (await d(t)) {
|
|
85
|
-
var
|
|
86
|
-
var
|
|
87
|
-
for (
|
|
88
|
-
var e, s,
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
var o = await (async (t, o) => {
|
|
86
|
+
var a = {};
|
|
87
|
+
for (n of await l(o)) {
|
|
88
|
+
var e, s, n = /^([1-9][0-9]*)(_([0-9]+))*\.json/.exec(n);
|
|
89
|
+
n && (e = +n[1], n = n[3], n = n ? +n : 2, null == (s = a[e]) ? a[e] = n : (t.removeFile(Q(e, Math.min(s, n))),
|
|
90
|
+
a[e] = Math.max(s, n)));
|
|
91
91
|
}
|
|
92
|
-
return Object.entries(
|
|
93
|
-
})(
|
|
92
|
+
return Object.entries(a).map(([ t, o ]) => [ +t, o ]).sort((t, o) => t[0] - o[0]);
|
|
93
|
+
})(n, t);
|
|
94
94
|
let e = 0, s = 0;
|
|
95
|
-
await Promise.all(
|
|
96
|
-
var
|
|
95
|
+
await Promise.all(o.map(async ([ t, o ]) => {
|
|
96
|
+
var a = await n.loadFromFile(Q(t, o)), o = (a.verList = [ o ], r[t] = {
|
|
97
97
|
snapshotNum: t,
|
|
98
|
-
info:
|
|
98
|
+
info: a,
|
|
99
99
|
posMap: {},
|
|
100
100
|
outdatedCount: 0
|
|
101
|
-
}), t = (++this.snapshotCount, t > e && (e = t, s =
|
|
102
|
-
this),
|
|
103
|
-
t =
|
|
101
|
+
}), t = (++this.snapshotCount, t > e && (e = t, s = a.maxChangeId),
|
|
102
|
+
this), a = o;
|
|
103
|
+
t = T(t, a), F.info("Loading " + t), a.prefixPM = await V(t);
|
|
104
104
|
})), Object.assign(this, {
|
|
105
105
|
maxSnapshotNum: e,
|
|
106
106
|
snapshotMaxChangeId: s
|
|
107
107
|
});
|
|
108
108
|
var {
|
|
109
|
-
numToSnapshotMap:
|
|
109
|
+
numToSnapshotMap: a,
|
|
110
110
|
prefixMap: i
|
|
111
111
|
} = this;
|
|
112
|
-
for ([ u ] of
|
|
113
|
-
var p, f =
|
|
112
|
+
for ([ u ] of o) {
|
|
113
|
+
var p, f = a[u], u = f.prefixPM;
|
|
114
114
|
for (p in u) {
|
|
115
115
|
var h = i[p];
|
|
116
116
|
h ? h.push(f) : i[p] = [ f ];
|
|
@@ -119,23 +119,23 @@ class t {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
closeAllFDs() {
|
|
122
|
-
var t,
|
|
123
|
-
for (t in
|
|
122
|
+
var t, o = this.fDMap;
|
|
123
|
+
for (t in o) e(o[t]), delete o[t];
|
|
124
124
|
}
|
|
125
125
|
saveKeyValueMap(t) {
|
|
126
|
-
var
|
|
126
|
+
var o, a = this.options.minLenToCompress, {
|
|
127
127
|
keyValueMap: e,
|
|
128
128
|
info: s
|
|
129
|
-
} = t,
|
|
129
|
+
} = t, n = (++s.vLVersion, new g()), r = (n.start(this.getVLFilePath(t)),
|
|
130
130
|
Object.keys(e).sort()), i = {};
|
|
131
131
|
let p = 0, f = 0, u, h;
|
|
132
|
-
for (
|
|
133
|
-
var l = e[
|
|
132
|
+
for (o of r) {
|
|
133
|
+
var l = e[o];
|
|
134
134
|
let t;
|
|
135
|
-
null == l ? t =
|
|
136
|
-
m.zstdCompressSync(l)) : (
|
|
137
|
-
u = Buffer.from(l.buffer, l.byteOffset, l.byteLength), 4) : (u = Buffer.from(JSON.stringify(I(
|
|
138
|
-
0),
|
|
135
|
+
null == l ? t = q : (h = Buffer.isBuffer(l) ? (u = l, 0) : v(l) ? (u = l.length >= a ? (n.save(O),
|
|
136
|
+
m.zstdCompressSync(l)) : (n.save(L), Buffer.from(l)), 1) : y(l) ? (n.save(b),
|
|
137
|
+
u = Buffer.from(l.buffer, l.byteOffset, l.byteLength), 4) : (u = Buffer.from(JSON.stringify(I(o) && !M(l) ? Object.keys(l) : l)),
|
|
138
|
+
0), n.save([ u, J ]), l = h + u.length, t = [ p, l ], p += l + 1), i[o] = t,
|
|
139
139
|
++f;
|
|
140
140
|
}
|
|
141
141
|
return Object.assign(t, {
|
|
@@ -144,93 +144,93 @@ class t {
|
|
|
144
144
|
}), Object.assign(s, {
|
|
145
145
|
totalCount: f,
|
|
146
146
|
outdatedCount: 0
|
|
147
|
-
}), Promise.all([ this.savePosMap(t,
|
|
147
|
+
}), Promise.all([ this.savePosMap(t, r), n.stop() ]);
|
|
148
148
|
}
|
|
149
149
|
addMaxSnapshot(t) {
|
|
150
|
-
var
|
|
151
|
-
numToSnapshotMap:
|
|
150
|
+
var o, {
|
|
151
|
+
numToSnapshotMap: a,
|
|
152
152
|
keyToSnapshotMap: e
|
|
153
153
|
} = this, {
|
|
154
154
|
posMap: s,
|
|
155
|
-
keyValueMap:
|
|
156
|
-
snapshotNum:
|
|
155
|
+
keyValueMap: n,
|
|
156
|
+
snapshotNum: r,
|
|
157
157
|
info: i
|
|
158
158
|
} = t, i = i.maxChangeId, i = (Object.assign(this, {
|
|
159
|
-
maxSnapshotNum:
|
|
159
|
+
maxSnapshotNum: r,
|
|
160
160
|
snapshotMaxChangeId: i
|
|
161
|
-
}),
|
|
162
|
-
for (
|
|
163
|
-
|
|
161
|
+
}), n || s);
|
|
162
|
+
for (o in i) e[o] = t;
|
|
163
|
+
a[r] = t, ++this.snapshotCount;
|
|
164
164
|
}
|
|
165
165
|
removeKey(t) {
|
|
166
|
-
var
|
|
167
|
-
if (
|
|
166
|
+
var o = this.keyToSnapshotMap, a = o[t];
|
|
167
|
+
if (a) return this.removeKeyFromSnapshot(a, t), delete o[t], !0;
|
|
168
168
|
}
|
|
169
|
-
applyCmdObj(t,
|
|
170
|
-
if (null !=
|
|
171
|
-
var e =
|
|
169
|
+
applyCmdObj(t, o, a) {
|
|
170
|
+
if (null != a) {
|
|
171
|
+
var e = a.length;
|
|
172
172
|
for (let t = 0; t < e; t += 2) {
|
|
173
|
-
var s =
|
|
174
|
-
|
|
173
|
+
var s = a[t], n = a[t + 1];
|
|
174
|
+
o[s] = null != n && I(s) ? f(n) : n;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
P(t, t => {
|
|
178
|
-
t in
|
|
179
|
-
}), C(
|
|
178
|
+
t in o || (o[t] = this.getValueSync(t)), this.removeKey(t);
|
|
179
|
+
}), C(o, t);
|
|
180
180
|
}
|
|
181
181
|
getValueSync(t) {
|
|
182
|
-
var
|
|
182
|
+
var o = ((t, o) => {
|
|
183
183
|
let {
|
|
184
|
-
keyToSnapshotMap:
|
|
184
|
+
keyToSnapshotMap: a,
|
|
185
185
|
prefixMap: e
|
|
186
|
-
} = t, s = o
|
|
186
|
+
} = t, s = a[o];
|
|
187
187
|
if (s) return s;
|
|
188
|
-
var
|
|
189
|
-
if (
|
|
190
|
-
s =
|
|
191
|
-
var i = ((t,
|
|
192
|
-
var e, {
|
|
193
|
-
posMap:
|
|
188
|
+
var n = k(o), r = e[n];
|
|
189
|
+
if (r) for (;0 < r.length; ) {
|
|
190
|
+
s = r.pop();
|
|
191
|
+
var i = ((t, o, a) => {
|
|
192
|
+
var e, s, {
|
|
193
|
+
posMap: n,
|
|
194
194
|
prefixPM: r
|
|
195
|
-
} =
|
|
196
|
-
if (r = r[
|
|
197
|
-
t.loadPartialPosMapBuffer(
|
|
198
|
-
})(t, s,
|
|
199
|
-
if (i &&
|
|
195
|
+
} = o;
|
|
196
|
+
if (r = r[a]) return [ r, e ] = r, s = t.getPMFilePath(o), s = h(N(t, s), s, r, e),
|
|
197
|
+
t.loadPartialPosMapBuffer(o, a, s), n;
|
|
198
|
+
})(t, s, n);
|
|
199
|
+
if (i && o in i) return s;
|
|
200
200
|
}
|
|
201
201
|
})(this, t);
|
|
202
|
-
if (
|
|
202
|
+
if (o) {
|
|
203
203
|
var {
|
|
204
|
-
keyValueMap:
|
|
204
|
+
keyValueMap: a,
|
|
205
205
|
posMap: e
|
|
206
|
-
} =
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
var [ e,
|
|
211
|
-
if (0 !=
|
|
206
|
+
} = o;
|
|
207
|
+
if (a) return a[t];
|
|
208
|
+
a = e[t];
|
|
209
|
+
if (a) {
|
|
210
|
+
var [ e, a ] = a;
|
|
211
|
+
if (0 != a) {
|
|
212
212
|
var s = this;
|
|
213
|
-
if (
|
|
214
|
-
I(t) ?
|
|
213
|
+
if (o = s.getVLFilePath(o), s = h(N(s, o), o, e, a)) return (o = s[0]) == K ? s.toString("utf8", 1) : o == _ ? m.zstdDecompressSync(s.subarray(1)).toString() : o == A ? new Uint8Array(s.buffer, s.byteOffset + 4, s.byteLength - 4) : (e = JSON.parse(s),
|
|
214
|
+
I(t) ? f(e) : e);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
loadPartialPosMapBuffer(
|
|
219
|
+
loadPartialPosMapBuffer(a, t, o) {
|
|
220
220
|
let {
|
|
221
221
|
posMap: e,
|
|
222
222
|
prefixPM: s
|
|
223
|
-
} =
|
|
224
|
-
j(
|
|
225
|
-
t in
|
|
223
|
+
} = a, n = (delete s[t], this).keyToSnapshotMap;
|
|
224
|
+
j(o, (t, o) => {
|
|
225
|
+
t in n ? ++a.outdatedCount : (e[t] = o, n[t] = a);
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
228
|
delSnapshot(t) {
|
|
229
|
-
delete this.numToSnapshotMap[t.snapshotNum], --this.snapshotCount,
|
|
230
|
-
|
|
229
|
+
delete this.numToSnapshotMap[t.snapshotNum], --this.snapshotCount, o(this, this.getVLFilePath(t)),
|
|
230
|
+
o(this, this.getPMFilePath(t));
|
|
231
231
|
}
|
|
232
232
|
calOutdates() {
|
|
233
|
-
var t,
|
|
233
|
+
var t, o, a, e = [], s = [], n = [], r = [], {
|
|
234
234
|
options: i,
|
|
235
235
|
numToSnapshotMap: p
|
|
236
236
|
} = this, {
|
|
@@ -239,150 +239,143 @@ class t {
|
|
|
239
239
|
} = i;
|
|
240
240
|
for (t in p) {
|
|
241
241
|
var h, l = p[t];
|
|
242
|
-
l.isOut || (100 == (h =
|
|
243
|
-
l.info.totalCount < h.options.minSnapshotKeyCount &&
|
|
242
|
+
l.isOut || (100 == (h = D(l)) ? (this.delSnapshot(l), e.push([ t, l.info.verList[0] ])) : u < h ? (B(l) ? s : r).push(l) : Math.floor(l.outdatedCount / l.info.totalCount * 100) > f ? n.push(l) : (h = this,
|
|
243
|
+
l.info.totalCount < h.options.minSnapshotKeyCount && B(l) && s.push(l)));
|
|
244
244
|
}
|
|
245
|
-
1 == s.length &&
|
|
246
|
-
for ([
|
|
245
|
+
1 == s.length && D(s[0]) < u && (s.length = 0);
|
|
246
|
+
for ([ o, a ] of [ [ "pMCompacts", n ], [ "vLCompacts", r ], [ "combiningSnapshots", s ] ]) 0 < a.length && F.log(o + ":" + a.map(t => t.snapshotNum + "." + t.info.verList[0]));
|
|
247
247
|
return {
|
|
248
248
|
emptySnapshotNumVerList: e,
|
|
249
249
|
combiningSnapshotList: s,
|
|
250
|
-
pMCompactSnapshotList:
|
|
251
|
-
vLCompactSnapshotList:
|
|
250
|
+
pMCompactSnapshotList: n,
|
|
251
|
+
vLCompactSnapshotList: r
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
254
|
getMaxCombinedSnapshot(t) {
|
|
255
|
-
let
|
|
255
|
+
let o, a;
|
|
256
256
|
for (var e of t) {
|
|
257
257
|
var s = e.snapshotNum;
|
|
258
|
-
(!
|
|
258
|
+
(!a || a < s) && (o = e, a = s);
|
|
259
259
|
}
|
|
260
|
-
return
|
|
260
|
+
return o;
|
|
261
261
|
}
|
|
262
262
|
getPMFilePath(t) {
|
|
263
263
|
var {
|
|
264
264
|
snapshotNum: t,
|
|
265
|
-
info:
|
|
265
|
+
info: o
|
|
266
266
|
} = t;
|
|
267
|
-
return
|
|
267
|
+
return n(this.snapshotFolder, "" + t, o.pMVersion + "_pM.txt");
|
|
268
268
|
}
|
|
269
269
|
getVLFilePath(t) {
|
|
270
270
|
var {
|
|
271
271
|
snapshotNum: t,
|
|
272
|
-
info:
|
|
272
|
+
info: o
|
|
273
273
|
} = t;
|
|
274
|
-
return
|
|
274
|
+
return n(this.snapshotFolder, "" + t, o.vLVersion + "_vL.txt");
|
|
275
275
|
}
|
|
276
|
-
async saveSnapshotInfo(t,
|
|
277
|
-
var
|
|
276
|
+
async saveSnapshotInfo(t, o) {
|
|
277
|
+
var a = this.qyJsonSaver, {
|
|
278
278
|
pMVersion: e,
|
|
279
279
|
vLVersion: s,
|
|
280
|
-
verList:
|
|
281
|
-
outdatedCount:
|
|
280
|
+
verList: n,
|
|
281
|
+
outdatedCount: r,
|
|
282
282
|
totalCount: i
|
|
283
|
-
} =
|
|
284
|
-
return
|
|
285
|
-
!!await
|
|
286
|
-
...
|
|
283
|
+
} = o, p = n[0], n = n[0] = e + s;
|
|
284
|
+
return o.outdated = Math.floor(100 * r / i) + "%", F.log(`Saving snapshotInfo:${p ? t + `.${p}->` : ""}${t}.` + n),
|
|
285
|
+
!!await a.saveToFile({
|
|
286
|
+
...o,
|
|
287
287
|
verList: void 0
|
|
288
|
-
},
|
|
288
|
+
}, Q(t, n), !0) && (null != p && a.removeFile(Q(t, p)), !0);
|
|
289
289
|
}
|
|
290
|
-
savePosMap(t,
|
|
291
|
-
var
|
|
290
|
+
savePosMap(t, o) {
|
|
291
|
+
var a, {
|
|
292
292
|
outdatedCount: e,
|
|
293
293
|
info: s,
|
|
294
|
-
posMap:
|
|
295
|
-
} = t,
|
|
294
|
+
posMap: n
|
|
295
|
+
} = t, r = (s.outdatedCount += e, t.outdatedCount = 0, ++s.pMVersion, new g()), i = (r.start(this.getPMFilePath(t)),
|
|
296
296
|
t.prefixPM = {});
|
|
297
297
|
let p = 0, f = 0, u;
|
|
298
|
-
for (
|
|
299
|
-
null == u ? u = k(
|
|
298
|
+
for (a of o = o || Object.keys(n).sort()) {
|
|
299
|
+
null == u ? u = k(a) : a.startsWith(u) || (i[u] = [ p, f ], u = k(a),
|
|
300
300
|
p += f, f = 0);
|
|
301
|
-
var h = Buffer.from(
|
|
302
|
-
|
|
301
|
+
var h = Buffer.from(a), l = S(n[a]);
|
|
302
|
+
r.save([ h, l ]), f += h.length + l.length;
|
|
303
303
|
}
|
|
304
|
-
return null != u && (i[u] = [ p, f ]), Promise.all([
|
|
305
|
-
var
|
|
306
|
-
for (
|
|
304
|
+
return null != u && (i[u] = [ p, f ]), Promise.all([ r.stop(), ((t, o) => {
|
|
305
|
+
var a, e = new g(), s = (e.start(T(t, o)), o).prefixPM;
|
|
306
|
+
for (a in s) e.save([ Buffer.from(a), S(s[a]) ]);
|
|
307
307
|
return e.stop();
|
|
308
308
|
})(this, t) ]);
|
|
309
309
|
}
|
|
310
310
|
isEmptySnapshot(t) {
|
|
311
311
|
var {
|
|
312
312
|
info: t,
|
|
313
|
-
outdatedCount:
|
|
313
|
+
outdatedCount: o
|
|
314
314
|
} = t;
|
|
315
|
-
return
|
|
315
|
+
return o + t.outdatedCount == t.totalCount;
|
|
316
316
|
}
|
|
317
|
-
removeKeyFromSnapshot(t,
|
|
317
|
+
removeKeyFromSnapshot(t, o) {
|
|
318
318
|
var {
|
|
319
|
-
posMap:
|
|
319
|
+
posMap: a,
|
|
320
320
|
keyValueMap: e
|
|
321
321
|
} = t;
|
|
322
|
-
e && delete e[
|
|
322
|
+
e && delete e[o], a && delete a[o], ++t.outdatedCount;
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
function j(
|
|
327
|
-
var e =
|
|
326
|
+
function j(o, a) {
|
|
327
|
+
var e = o.length;
|
|
328
328
|
for (let t = 0; t < e; ) {
|
|
329
|
-
var s = t +
|
|
330
|
-
t = c(
|
|
329
|
+
var s = t + p, n = o.toString("latin1", t, s), r = [];
|
|
330
|
+
t = c(o, s, r), a(n, r);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
async function V(t) {
|
|
335
|
-
var
|
|
336
|
-
for (let t = 0; t <
|
|
337
|
-
var s = t + w,
|
|
338
|
-
t = c(
|
|
335
|
+
var o = await r(t), a = o.length, e = {};
|
|
336
|
+
for (let t = 0; t < a; ) {
|
|
337
|
+
var s = t + w, n = e[o.toString("latin1", t, s)] = [];
|
|
338
|
+
t = c(o, s, n);
|
|
339
339
|
}
|
|
340
340
|
return e;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
function B(t
|
|
344
|
-
var s = ((t, a) => {
|
|
345
|
-
let o = t.fDMap, e = o[a];
|
|
346
|
-
if (!e) {
|
|
347
|
-
F.info("Opening " + a);
|
|
348
|
-
try {
|
|
349
|
-
e = o[a] = p(a, "r");
|
|
350
|
-
} catch (t) {
|
|
351
|
-
throw F.error(`Opening ${a} failed:`, t), t;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
return e;
|
|
355
|
-
})(t, a), r = Buffer.allocUnsafe(e);
|
|
356
|
-
for (let t = 0; t < e; ) {
|
|
357
|
-
var n = i(s, r, t, e - t, o + t);
|
|
358
|
-
if (0 == n) return void F.error(`readSync ${a} at ${o + t} returning 0 byte`);
|
|
359
|
-
t += n;
|
|
360
|
-
}
|
|
361
|
-
return r;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function T(t) {
|
|
343
|
+
function B(t) {
|
|
365
344
|
var {
|
|
366
|
-
keyValueMap:
|
|
367
|
-
prefixPM:
|
|
345
|
+
keyValueMap: o,
|
|
346
|
+
prefixPM: a
|
|
368
347
|
} = t;
|
|
369
|
-
return
|
|
348
|
+
return o || null == a || u(t.prefixPM);
|
|
370
349
|
}
|
|
371
350
|
|
|
372
|
-
function
|
|
351
|
+
function T(t, o) {
|
|
373
352
|
var {
|
|
374
|
-
snapshotNum:
|
|
375
|
-
info:
|
|
376
|
-
} =
|
|
377
|
-
return
|
|
353
|
+
snapshotNum: o,
|
|
354
|
+
info: a
|
|
355
|
+
} = o;
|
|
356
|
+
return n(t.snapshotFolder, "" + o, a.pMVersion + "_prefixPM.txt");
|
|
378
357
|
}
|
|
379
358
|
|
|
380
|
-
function
|
|
381
|
-
|
|
382
|
-
|
|
359
|
+
function N(t, o) {
|
|
360
|
+
t = t.fDMap;
|
|
361
|
+
let a = t[o];
|
|
362
|
+
if (!a) {
|
|
363
|
+
F.info("Opening " + o);
|
|
364
|
+
try {
|
|
365
|
+
a = t[o] = s(o, "r");
|
|
366
|
+
} catch (t) {
|
|
367
|
+
throw F.error(`Opening ${o} failed:`, t), t;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return a;
|
|
383
371
|
}
|
|
384
372
|
|
|
385
|
-
|
|
373
|
+
function o(t, o) {
|
|
374
|
+
var t = t.fDMap, a = t[o];
|
|
375
|
+
null != a && (e(a), delete t[o]);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
let q = [ 0, 0 ], w = 3;
|
|
386
379
|
|
|
387
380
|
function k(t) {
|
|
388
381
|
return t.substring(0, w);
|
|
@@ -392,21 +385,21 @@ function I(t) {
|
|
|
392
385
|
return !t.startsWith("c");
|
|
393
386
|
}
|
|
394
387
|
|
|
395
|
-
function
|
|
388
|
+
function D(t) {
|
|
396
389
|
var {
|
|
397
390
|
outdatedCount: t,
|
|
398
|
-
info:
|
|
399
|
-
} = t,
|
|
400
|
-
return t ==
|
|
391
|
+
info: o
|
|
392
|
+
} = t, a = o.totalCount, t = t + o.outdatedCount;
|
|
393
|
+
return t == a ? 100 : Math.floor(t / a * 100);
|
|
401
394
|
}
|
|
402
395
|
|
|
403
|
-
function
|
|
404
|
-
return t + (2 <
|
|
396
|
+
function Q(t, o) {
|
|
397
|
+
return t + (2 < o ? "_" + o : "") + ".json";
|
|
405
398
|
}
|
|
406
399
|
|
|
407
400
|
export {
|
|
408
401
|
t as QySnapshots,
|
|
409
402
|
j as iterPMBuffer,
|
|
410
403
|
V as loadPrefixPMFile,
|
|
411
|
-
|
|
404
|
+
Q as getInfoFileName
|
|
412
405
|
};
|
package/src/QyUtils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import util from "node:util";
|
|
2
2
|
export declare const isArray: (arg: any) => arg is any[];
|
|
3
|
-
export declare const isDate: typeof util.types.isDate, isFloat32Array: typeof util.types.isFloat32Array;
|
|
3
|
+
export declare const isDate: typeof util.types.isDate, isFloat32Array: typeof util.types.isFloat32Array, isUint8Array: typeof util.types.isUint8Array;
|
|
4
4
|
export declare const __dirname: string;
|
|
5
5
|
export declare const SpecialOperators: {
|
|
6
6
|
[k: string]: string;
|
|
@@ -11,8 +11,9 @@ export declare const SpecialFilePaths: {
|
|
|
11
11
|
RpcDirPath: string[];
|
|
12
12
|
IndexDirPath: string[];
|
|
13
13
|
ExpireDirPath: string[];
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
HNSWDirPath: string[];
|
|
15
|
+
InfoDirPath: string[];
|
|
16
|
+
RecycleDirPath: string[];
|
|
16
17
|
MetaFilePath: string[];
|
|
17
18
|
IndexPropPathsFileName: string;
|
|
18
19
|
};
|
|
@@ -58,4 +59,5 @@ export declare function loadFileList(fileList: any, preloadCount?: number): Asyn
|
|
|
58
59
|
}, void, unknown>;
|
|
59
60
|
export declare function getNowTime(now?: Date): number;
|
|
60
61
|
export declare function getNowRounded(now?: Date): number;
|
|
62
|
+
export declare function readBufferFromFD(fd: any, filePath: any, start: any, length: any): Buffer<ArrayBuffer> | undefined;
|
|
61
63
|
export * as default from "./QyUtils.ts";
|