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.
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  close as e,
3
- readSync as i,
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 n
8
+ readFile as r
10
9
  } from "node:fs/promises";
11
10
 
12
11
  import {
13
- join as s
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 r
18
+ getDefaultOptions as i
20
19
  } from "./QyDefaultOptions.js";
21
20
 
22
21
  import {
23
- Hash_Key_Length as f,
22
+ Hash_Key_Length as p,
24
23
  folderOrFileExists as d,
25
- listToMap as u,
26
- isEmptyObj as h,
24
+ listToMap as f,
25
+ isEmptyObj as u,
27
26
  isString as v,
28
27
  isArray as M,
29
- isFloat32Array as y
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 D = Buffer.from("\n"), L = Buffer.from("'"), O = Buffer.from("z"), b = Buffer.from("vect"), E = L[0], J = O[0], K = b[0];
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, a = void 0) {
66
- (a = {
67
- ...r("QySnapshots"),
68
- ...a
69
- }).vLOutdatedPercent = 2 * a.pMOutdatedPercent;
70
- var o = s(t, "info");
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: o,
74
- options: a,
75
- qyJsonSaver: new x(o, a)
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: r,
82
- numToSnapshotMap: n
81
+ qyJsonSaver: n,
82
+ numToSnapshotMap: r
83
83
  } = this;
84
84
  if (await d(t)) {
85
- var a = await (async (t, a) => {
86
- var o = {};
87
- for (r of await l(a)) {
88
- var e, s, r = /^([1-9][0-9]*)(_([0-9]+))*\.json/.exec(r);
89
- r && (e = +r[1], r = r[3], r = r ? +r : 2, null == (s = o[e]) ? o[e] = r : (t.removeFile(_(e, Math.min(s, r))),
90
- o[e] = Math.max(s, r)));
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(o).map(([ t, a ]) => [ +t, a ]).sort((t, a) => t[0] - a[0]);
93
- })(r, t);
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(a.map(async ([ t, a ]) => {
96
- var o = await r.loadFromFile(_(t, a)), a = (o.verList = [ a ], n[t] = {
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: o,
98
+ info: a,
99
99
  posMap: {},
100
100
  outdatedCount: 0
101
- }), t = (++this.snapshotCount, t > e && (e = t, s = o.maxChangeId),
102
- this), o = a;
103
- t = N(t, o), F.info("Loading " + t), o.prefixPM = await V(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: o,
109
+ numToSnapshotMap: a,
110
110
  prefixMap: i
111
111
  } = this;
112
- for ([ u ] of a) {
113
- var p, f = o[u], u = f.prefixPM;
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, a = this.fDMap;
123
- for (t in a) e(a[t]), delete a[t];
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 a, o = this.options.minLenToCompress, {
126
+ var o, a = this.options.minLenToCompress, {
127
127
  keyValueMap: e,
128
128
  info: s
129
- } = t, r = (++s.vLVersion, new g()), n = (r.start(this.getVLFilePath(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 (a of n) {
133
- var l = e[a];
132
+ for (o of r) {
133
+ var l = e[o];
134
134
  let t;
135
- null == l ? t = A : (h = Buffer.isBuffer(l) ? (u = l, 0) : v(l) ? (u = l.length >= o ? (r.save(O),
136
- m.zstdCompressSync(l)) : (r.save(L), Buffer.from(l)), 1) : y(l) ? (r.save(b),
137
- u = Buffer.from(l.buffer, l.byteOffset, l.byteLength), 4) : (u = Buffer.from(JSON.stringify(I(a) && !M(l) ? Object.keys(l) : l)),
138
- 0), r.save([ u, D ]), l = h + u.length, t = [ p, l ], p += l + 1), i[a] = t,
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, n), r.stop() ]);
147
+ }), Promise.all([ this.savePosMap(t, r), n.stop() ]);
148
148
  }
149
149
  addMaxSnapshot(t) {
150
- var a, {
151
- numToSnapshotMap: o,
150
+ var o, {
151
+ numToSnapshotMap: a,
152
152
  keyToSnapshotMap: e
153
153
  } = this, {
154
154
  posMap: s,
155
- keyValueMap: r,
156
- snapshotNum: n,
155
+ keyValueMap: n,
156
+ snapshotNum: r,
157
157
  info: i
158
158
  } = t, i = i.maxChangeId, i = (Object.assign(this, {
159
- maxSnapshotNum: n,
159
+ maxSnapshotNum: r,
160
160
  snapshotMaxChangeId: i
161
- }), r || s);
162
- for (a in i) e[a] = t;
163
- o[n] = t, ++this.snapshotCount;
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 a = this.keyToSnapshotMap, o = a[t];
167
- if (o) return this.removeKeyFromSnapshot(o, t), delete a[t], !0;
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, a, o) {
170
- if (null != o) {
171
- var e = o.length;
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 = o[t], r = o[t + 1];
174
- a[s] = null != r && I(s) ? u(r) : r;
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 a || (a[t] = this.getValueSync(t)), this.removeKey(t);
179
- }), C(a, t);
178
+ t in o || (o[t] = this.getValueSync(t)), this.removeKey(t);
179
+ }), C(o, t);
180
180
  }
181
181
  getValueSync(t) {
182
- var a = ((t, a) => {
182
+ var o = ((t, o) => {
183
183
  let {
184
- keyToSnapshotMap: o,
184
+ keyToSnapshotMap: a,
185
185
  prefixMap: e
186
- } = t, s = o[a];
186
+ } = t, s = a[o];
187
187
  if (s) return s;
188
- var r = k(a), n = e[r];
189
- if (n) for (;0 < n.length; ) {
190
- s = n.pop();
191
- var i = ((t, a, o) => {
192
- var e, {
193
- posMap: s,
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
- } = a;
196
- if (r = r[o]) return [ r, e ] = r, r = B(t, t.getPMFilePath(a), r, e),
197
- t.loadPartialPosMapBuffer(a, o, r), s;
198
- })(t, s, r);
199
- if (i && a in i) return s;
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 (a) {
202
+ if (o) {
203
203
  var {
204
- keyValueMap: o,
204
+ keyValueMap: a,
205
205
  posMap: e
206
- } = a;
207
- if (o) return o[t];
208
- o = e[t];
209
- if (o) {
210
- var [ e, o ] = o;
211
- if (0 != o) {
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 (a = s.getVLFilePath(a), s = B(s, a, e, o)) return (a = s[0]) == E ? s.toString("utf8", 1) : a == J ? m.zstdDecompressSync(s.subarray(1)).toString() : a == K ? new Float32Array(s.buffer, s.byteOffset + 4, s.byteLength / Float32Array.BYTES_PER_ELEMENT - 1) : (e = JSON.parse(s),
214
- I(t) ? u(e) : e);
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(o, t, a) {
219
+ loadPartialPosMapBuffer(a, t, o) {
220
220
  let {
221
221
  posMap: e,
222
222
  prefixPM: s
223
- } = o, r = (delete s[t], this).keyToSnapshotMap;
224
- j(a, (t, a) => {
225
- t in r ? ++o.outdatedCount : (e[t] = a, r[t] = o);
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, a(this, this.getVLFilePath(t)),
230
- a(this, this.getPMFilePath(t));
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, a, o, e = [], s = [], r = [], n = [], {
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 = Q(l)) ? (this.delSnapshot(l), e.push([ t, l.info.verList[0] ])) : u < h ? (T(l) ? s : n).push(l) : Math.floor(l.outdatedCount / l.info.totalCount * 100) > f ? r.push(l) : (h = this,
243
- l.info.totalCount < h.options.minSnapshotKeyCount && T(l) && s.push(l)));
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 && Q(s[0]) < u && (s.length = 0);
246
- for ([ a, o ] of [ [ "pMCompacts", r ], [ "vLCompacts", n ], [ "combiningSnapshots", s ] ]) 0 < o.length && F.log(a + ":" + o.map(t => t.snapshotNum + "." + t.info.verList[0]));
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: r,
251
- vLCompactSnapshotList: n
250
+ pMCompactSnapshotList: n,
251
+ vLCompactSnapshotList: r
252
252
  };
253
253
  }
254
254
  getMaxCombinedSnapshot(t) {
255
- let a, o;
255
+ let o, a;
256
256
  for (var e of t) {
257
257
  var s = e.snapshotNum;
258
- (!o || o < s) && (a = e, o = s);
258
+ (!a || a < s) && (o = e, a = s);
259
259
  }
260
- return a;
260
+ return o;
261
261
  }
262
262
  getPMFilePath(t) {
263
263
  var {
264
264
  snapshotNum: t,
265
- info: a
265
+ info: o
266
266
  } = t;
267
- return s(this.snapshotFolder, "" + t, a.pMVersion + "_pM.txt");
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: a
272
+ info: o
273
273
  } = t;
274
- return s(this.snapshotFolder, "" + t, a.vLVersion + "_vL.txt");
274
+ return n(this.snapshotFolder, "" + t, o.vLVersion + "_vL.txt");
275
275
  }
276
- async saveSnapshotInfo(t, a) {
277
- var o = this.qyJsonSaver, {
276
+ async saveSnapshotInfo(t, o) {
277
+ var a = this.qyJsonSaver, {
278
278
  pMVersion: e,
279
279
  vLVersion: s,
280
- verList: r,
281
- outdatedCount: n,
280
+ verList: n,
281
+ outdatedCount: r,
282
282
  totalCount: i
283
- } = a, p = r[0], r = r[0] = e + s;
284
- return a.outdated = Math.floor(100 * n / i) + "%", F.log(`Saving snapshotInfo:${p ? t + `.${p}->` : ""}${t}.` + r),
285
- !!await o.saveToFile({
286
- ...a,
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
- }, _(t, r), !0) && (null != p && o.removeFile(_(t, p)), !0);
288
+ }, Q(t, n), !0) && (null != p && a.removeFile(Q(t, p)), !0);
289
289
  }
290
- savePosMap(t, a) {
291
- var o, {
290
+ savePosMap(t, o) {
291
+ var a, {
292
292
  outdatedCount: e,
293
293
  info: s,
294
- posMap: r
295
- } = t, n = (s.outdatedCount += e, t.outdatedCount = 0, ++s.pMVersion, new g()), i = (n.start(this.getPMFilePath(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 (o of a = a || Object.keys(r).sort()) {
299
- null == u ? u = k(o) : o.startsWith(u) || (i[u] = [ p, f ], u = k(o),
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(o), l = S(r[o]);
302
- n.save([ h, l ]), f += h.length + l.length;
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([ n.stop(), ((t, a) => {
305
- var o, e = new g(), s = (e.start(N(t, a)), a).prefixPM;
306
- for (o in s) e.save([ Buffer.from(o), S(s[o]) ]);
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: a
313
+ outdatedCount: o
314
314
  } = t;
315
- return a + t.outdatedCount == t.totalCount;
315
+ return o + t.outdatedCount == t.totalCount;
316
316
  }
317
- removeKeyFromSnapshot(t, a) {
317
+ removeKeyFromSnapshot(t, o) {
318
318
  var {
319
- posMap: o,
319
+ posMap: a,
320
320
  keyValueMap: e
321
321
  } = t;
322
- e && delete e[a], o && delete o[a], ++t.outdatedCount;
322
+ e && delete e[o], a && delete a[o], ++t.outdatedCount;
323
323
  }
324
324
  }
325
325
 
326
- function j(a, o) {
327
- var e = a.length;
326
+ function j(o, a) {
327
+ var e = o.length;
328
328
  for (let t = 0; t < e; ) {
329
- var s = t + f, r = a.toString("latin1", t, s), n = [];
330
- t = c(a, s, n), o(r, n);
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 a = await n(t), o = a.length, e = {};
336
- for (let t = 0; t < o; ) {
337
- var s = t + w, r = e[a.toString("latin1", t, s)] = [];
338
- t = c(a, s, r);
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, a, o, e) {
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: a,
367
- prefixPM: o
345
+ keyValueMap: o,
346
+ prefixPM: a
368
347
  } = t;
369
- return a || null == o || h(t.prefixPM);
348
+ return o || null == a || u(t.prefixPM);
370
349
  }
371
350
 
372
- function N(t, a) {
351
+ function T(t, o) {
373
352
  var {
374
- snapshotNum: a,
375
- info: o
376
- } = a;
377
- return s(t.snapshotFolder, "" + a, o.pMVersion + "_prefixPM.txt");
353
+ snapshotNum: o,
354
+ info: a
355
+ } = o;
356
+ return n(t.snapshotFolder, "" + o, a.pMVersion + "_prefixPM.txt");
378
357
  }
379
358
 
380
- function a(t, a) {
381
- var t = t.fDMap, o = t[a];
382
- null != o && (e(o), delete t[a]);
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
- let A = [ 0, 0 ], w = 3;
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 Q(t) {
388
+ function D(t) {
396
389
  var {
397
390
  outdatedCount: t,
398
- info: a
399
- } = t, o = a.totalCount, t = t + a.outdatedCount;
400
- return t == o ? 100 : Math.floor(t / o * 100);
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 _(t, a) {
404
- return t + (2 < a ? "_" + a : "") + ".json";
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
- _ as getInfoFileName
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
- EmbeddingDirPath: string[];
15
- H2FDirPath: string[];
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";