@delali/narsil 0.3.1-next.140 → 0.3.1-next.143

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.
Files changed (104) hide show
  1. package/dist/{analysis-change-JN23AZQP.mjs → analysis-change-HQUT2Z3I.mjs} +13 -13
  2. package/dist/{analysis-change-entry-5JSIMEKG.mjs → analysis-change-entry-TZTG4AZB.mjs} +1 -1
  3. package/dist/browser/{analysis-change-57MIRJWR.mjs → analysis-change-JPV775LR.mjs} +407 -6
  4. package/dist/browser/{analysis-change-entry-ICGRR3IN.mjs → analysis-change-entry-7HR4LWL3.mjs} +1 -1
  5. package/dist/browser/chunk-3ZBJYAS4.mjs +19 -0
  6. package/dist/browser/{chunk-ZAIZQOTM.mjs → chunk-5DB2VDGI.mjs} +951 -1134
  7. package/dist/browser/chunk-6RHTAVZX.mjs +656 -0
  8. package/dist/browser/chunk-CCOAOO73.mjs +86 -0
  9. package/dist/browser/{chunk-3EYDURFD.mjs → chunk-HKX2G6WH.mjs} +1615 -2266
  10. package/dist/browser/{chunk-CGVBGHBX.mjs → chunk-KTOK275N.mjs} +531 -830
  11. package/dist/browser/{chunk-5LYWZJE2.mjs → chunk-LVY2LI35.mjs} +1 -1
  12. package/dist/browser/chunk-MVM33ZUL.mjs +993 -0
  13. package/dist/browser/chunk-MWUK3DA5.mjs +2634 -0
  14. package/dist/browser/{chunk-67KSBUYR.mjs → chunk-R4WUDZQV.mjs} +8 -5
  15. package/dist/browser/{chunk-6BSB4N6B.mjs → chunk-TCLEOZ4P.mjs} +2 -2
  16. package/dist/browser/chunk-VFYMPCOV.mjs +212 -0
  17. package/dist/browser/chunk-WCFCHIBB.mjs +177 -0
  18. package/dist/browser/{chunk-E5SFTOQR.mjs → chunk-XNWPP5NS.mjs} +2 -2
  19. package/dist/browser/{chunk-QHNNULPW.mjs → chunk-ZEV26AQ6.mjs} +5 -0
  20. package/dist/browser/cold-module-MJMKNUYJ.mjs +745 -0
  21. package/dist/browser/{durability-wiring-MTIAN6VT.mjs → durability-wiring-SNOWIT6Z.mjs} +231 -51
  22. package/dist/browser/{import-Q7MXD6BS.mjs → import-TLB2A5LJ.mjs} +6 -5
  23. package/dist/browser/module-BUFNZMEU.mjs +12 -0
  24. package/dist/browser/{module-5J3PEUEB.mjs → module-BVP4TKZU.mjs} +395 -108
  25. package/dist/{restore-queue-RYSRRFS4.mjs → browser/restore-queue-ONYNYUDE.mjs} +2 -2
  26. package/dist/browser/{snapshot-YBJ5MF2M.mjs → snapshot-QXBKHJAG.mjs} +108 -25
  27. package/dist/browser/{write-RTWI5MXL.mjs → write-WHFBDWQS.mjs} +63 -91
  28. package/dist/{capabilities-DXAmysqJ.d.ts → capabilities-BCdUwK_L.d.ts} +2 -2
  29. package/dist/{chunk-HMDT3I63.mjs → chunk-46NZOPHS.mjs} +2 -2
  30. package/dist/{chunk-XXKWEG53.mjs → chunk-5WYVUPGD.mjs} +1 -1
  31. package/dist/chunk-6SNBQESJ.mjs +214 -0
  32. package/dist/chunk-7AUASRE7.mjs +653 -0
  33. package/dist/{chunk-4GCN34JV.mjs → chunk-AST3SHFA.mjs} +26 -24
  34. package/dist/chunk-BOJZGUS6.mjs +177 -0
  35. package/dist/{chunk-IP4HJOGC.mjs → chunk-BRUUBXCB.mjs} +4 -3
  36. package/dist/{chunk-J3EHATEZ.mjs → chunk-DQNKVOJ2.mjs} +63 -63
  37. package/dist/chunk-FOCV4CBZ.mjs +87 -0
  38. package/dist/{chunk-FFVLPCLH.mjs → chunk-GLZHNSGB.mjs} +1 -1
  39. package/dist/chunk-GWOS5DYC.mjs +2637 -0
  40. package/dist/{chunk-W2XDK66Z.mjs → chunk-IO5F7ZBE.mjs} +112 -438
  41. package/dist/{chunk-P36MUFEJ.mjs → chunk-JDDXV6UF.mjs} +2 -1
  42. package/dist/{chunk-LLDFIKGP.mjs → chunk-KEIYVZUX.mjs} +4 -4
  43. package/dist/{chunk-UBXJQJII.mjs → chunk-KGOXHLLZ.mjs} +5 -1
  44. package/dist/{chunk-FKARMUWH.mjs → chunk-KZL72VTC.mjs} +68 -16
  45. package/dist/{chunk-TCWQJL7O.mjs → chunk-L76W3IZJ.mjs} +5 -0
  46. package/dist/{chunk-CPCGEIOM.mjs → chunk-LA4WNDHL.mjs} +83 -799
  47. package/dist/{chunk-PNNVTKMT.mjs → chunk-NJJCPFXN.mjs} +2 -2
  48. package/dist/chunk-NN33CZRE.mjs +86 -0
  49. package/dist/chunk-NRUXBYPH.mjs +121 -0
  50. package/dist/{chunk-UJWGQIXU.mjs → chunk-QHPYS427.mjs} +1 -0
  51. package/dist/{chunk-VSUYTPME.mjs → chunk-RHKRTYGO.mjs} +13 -4
  52. package/dist/{chunk-UEV53BBO.mjs → chunk-SRJBFG2T.mjs} +406 -5
  53. package/dist/{chunk-K3AQOZVM.mjs → chunk-TNBIK2LQ.mjs} +1638 -1644
  54. package/dist/chunk-UUZCQQG2.mjs +209 -0
  55. package/dist/{chunk-XMQNOD5V.mjs → chunk-VEFN6X6Q.mjs} +2 -2
  56. package/dist/{chunk-LK3MOTXF.mjs → chunk-VJEGOELZ.mjs} +8 -5
  57. package/dist/chunk-W2COJ5AH.mjs +148 -0
  58. package/dist/{chunk-IBATGS3J.mjs → chunk-WJGO5PGV.mjs} +241 -124
  59. package/dist/{chunk-CCCGEPJM.mjs → chunk-XZ3SRNDJ.mjs} +24 -63
  60. package/dist/{chunk-MTQTX4BP.mjs → chunk-YHUTF6EA.mjs} +400 -92
  61. package/dist/{chunk-B5I3IL4H.mjs → chunk-YLNSJQLX.mjs} +4 -4
  62. package/dist/{chunk-6VHWXAOI.mjs → chunk-Z4HFMYNX.mjs} +29 -24
  63. package/dist/{chunk-U4X4AWKL.mjs → chunk-ZPWS2SKJ.mjs} +293 -270
  64. package/dist/{client-DApBeLbk.d.ts → client-B12YFALP.d.ts} +3 -3
  65. package/dist/client.d.ts +7 -7
  66. package/dist/cold-module-4X7WJCFM.mjs +783 -0
  67. package/dist/{config-B0H-vp4U.d.ts → config-BhZxIeb1.d.ts} +6 -1
  68. package/dist/{config-Brysl9NO.d.ts → config-CIG5yDyg.d.ts} +2 -2
  69. package/dist/{direct-executor-J5UDLPL3.mjs → direct-executor-7XOQ7VQP.mjs} +5 -5
  70. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  71. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  72. package/dist/distribution.d.ts +7 -7
  73. package/dist/distribution.mjs +123 -42
  74. package/dist/{durability-wiring-AYOTAPNQ.mjs → durability-wiring-324D2DDD.mjs} +213 -40
  75. package/dist/{engine-CuLMbH1-.d.ts → engine-CtzbHOmG.d.ts} +2 -2
  76. package/dist/{import-QRZAQ5RH.mjs → import-OOBUW3RR.mjs} +14 -13
  77. package/dist/{index-HYnqS1SE.d.ts → index-DsEurhSl.d.ts} +1 -1
  78. package/dist/index.browser.mjs +3 -3
  79. package/dist/index.d.ts +6 -6
  80. package/dist/index.mjs +11 -11
  81. package/dist/{long-query-thread-U7K5A72G.mjs → long-query-thread-4SW7RWDE.mjs} +8 -8
  82. package/dist/{module-L2OZO5PQ.mjs → module-DXSJ5LT2.mjs} +374 -83
  83. package/dist/module-IYPLWHGC.mjs +48 -0
  84. package/dist/paged-partition-archive-HFP45PLU.mjs +269 -0
  85. package/dist/partial-words.mjs +2 -2
  86. package/dist/persistence/durability/checkpoint-worker.d.ts +5 -1
  87. package/dist/persistence/durability/checkpoint-worker.mjs +17 -15
  88. package/dist/react.d.ts +9 -9
  89. package/dist/{browser/restore-queue-DISFECE4.mjs → restore-queue-FEYAC4SB.mjs} +2 -2
  90. package/dist/{schema-BTXbHCqA.d.ts → schema-B-Runv0n.d.ts} +7 -0
  91. package/dist/server.d.ts +10 -10
  92. package/dist/server.mjs +8 -7
  93. package/dist/{snapshot-BTRZ3MZK.mjs → snapshot-CGM65VCD.mjs} +60 -25
  94. package/dist/{tasks-DjGjK70Y.d.ts → tasks-CjRJRGTb.d.ts} +6 -4
  95. package/dist/{thread-USB3GOPY.mjs → thread-KGNAIKPD.mjs} +8 -8
  96. package/dist/vector/search-worker.d.ts +1 -1
  97. package/dist/vector/search-worker.mjs +3 -2
  98. package/dist/workers/entry.mjs +7 -7
  99. package/dist/{write-GHTA56OW.mjs → write-2DZPEQL2.mjs} +70 -98
  100. package/openapi.json +13 -0
  101. package/package.json +12 -8
  102. package/dist/browser/chunk-XVMOQQ34.mjs +0 -384
  103. package/dist/chunk-BDIDUW2B.mjs +0 -387
  104. package/dist/browser/{chunk-4MFH226Q.mjs → chunk-D33A5VMU.mjs} +15 -15
@@ -1,5 +1,5 @@
1
- import { sanitizeSurfaceForms, patternIndexesFromWire, dropStoredVectorValues } from './chunk-MTQTX4BP.mjs';
2
- import { requireValidFieldTypes } from './chunk-UBXJQJII.mjs';
1
+ import { sanitizeSurfaceForms, patternIndexesFromWire, dropStoredVectorValues } from './chunk-YHUTF6EA.mjs';
2
+ import { requireValidFieldTypes } from './chunk-KGOXHLLZ.mjs';
3
3
  import { VALID_HNSW_METRICS } from './chunk-U476IXKQ.mjs';
4
4
  import { decode } from '@msgpack/msgpack';
5
5
 
@@ -0,0 +1,86 @@
1
+ import { NUMBER_TAG, DATE_TAG, BYTES_TAG, encodeBase64, startsWithTagPrefix, OBJECT_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND } from './chunk-BOJZGUS6.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-HNHCNTVG.mjs';
3
+
4
+ // src/engine/export/json-line.ts
5
+ function refuse(path, kind, docId) {
6
+ throw new NarsilError(
7
+ ErrorCodes.DOC_VALIDATION_FAILED,
8
+ `Document "${docId}" holds ${kind} at "${path || "(document)"}", which a document export cannot carry as JSON`,
9
+ { docId, field: path }
10
+ );
11
+ }
12
+ function encodeNumber(value, path, target) {
13
+ if (Number.isFinite(value)) return Object.is(value, -0) ? "-0" : JSON.stringify(value);
14
+ if (!target.tagged) refuse(path, String(value), target.docId);
15
+ return `{"${NUMBER_TAG}":"${String(value)}"}`;
16
+ }
17
+ function encodeDate(value, path, target) {
18
+ const milliseconds = value.getTime();
19
+ if (!target.tagged || Number.isNaN(milliseconds)) refuse(path, "a date", target.docId);
20
+ const seconds = Math.floor(milliseconds / MILLISECONDS_PER_SECOND);
21
+ const nanoseconds = (milliseconds - seconds * MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND;
22
+ return `{"${DATE_TAG}":[${seconds},${nanoseconds}]}`;
23
+ }
24
+ function encodeBytes(value, path, target) {
25
+ if (!target.tagged) refuse(path, "bytes", target.docId);
26
+ return `{"${BYTES_TAG}":"${encodeBase64(value)}"}`;
27
+ }
28
+ function encodeList(value, path, target) {
29
+ target.parts.push("[");
30
+ for (let at = 0; at < value.length; at++) {
31
+ if (at > 0) target.parts.push(",");
32
+ encodeValue(value[at], `${path}[${at}]`, target);
33
+ }
34
+ target.parts.push("]");
35
+ }
36
+ function encodeMap(value, path, target) {
37
+ const proto = Object.getPrototypeOf(value);
38
+ if (proto !== Object.prototype && proto !== null) refuse(path, "a value other than a plain object", target.docId);
39
+ const entries = Object.entries(value).filter(([, entry]) => entry !== void 0);
40
+ const wrapped = target.tagged && entries.length === 1 && startsWithTagPrefix(entries[0][0]);
41
+ target.parts.push(wrapped ? `{"${OBJECT_TAG}":{` : "{");
42
+ for (let at = 0; at < entries.length; at++) {
43
+ const [key, entry] = entries[at];
44
+ if (at > 0) target.parts.push(",");
45
+ target.parts.push(JSON.stringify(key), ":");
46
+ encodeValue(entry, path === "" ? key : `${path}.${key}`, target);
47
+ }
48
+ target.parts.push(wrapped ? "}}" : "}");
49
+ }
50
+ function encodeValue(value, path, target) {
51
+ if (value === null) {
52
+ target.parts.push("null");
53
+ return;
54
+ }
55
+ switch (typeof value) {
56
+ case "string":
57
+ target.parts.push(JSON.stringify(value));
58
+ return;
59
+ case "boolean":
60
+ target.parts.push(value ? "true" : "false");
61
+ return;
62
+ case "number":
63
+ target.parts.push(encodeNumber(value, path, target));
64
+ return;
65
+ case "object":
66
+ break;
67
+ default:
68
+ refuse(path, `a ${typeof value}`, target.docId);
69
+ }
70
+ if (Array.isArray(value)) encodeList(value, path, target);
71
+ else if (value instanceof Date) target.parts.push(encodeDate(value, path, target));
72
+ else if (value instanceof Uint8Array) target.parts.push(encodeBytes(value, path, target));
73
+ else encodeMap(value, path, target);
74
+ }
75
+ function encodeExactJson(value, docId) {
76
+ const target = { docId, tagged: false, parts: [] };
77
+ encodeValue(value, "", target);
78
+ return target.parts.join("");
79
+ }
80
+ function encodeDocumentJson(document, docId) {
81
+ const target = { docId, tagged: true, parts: [] };
82
+ encodeValue(document, "", target);
83
+ return target.parts.join("");
84
+ }
85
+
86
+ export { encodeDocumentJson, encodeExactJson };
@@ -0,0 +1,121 @@
1
+ import { decodeVectorGraphPartPayload, assembleGraphParts, decodeVectorFilePayload, countDead } from './chunk-ICW45TTU.mjs';
2
+ import { readListedFile, requireListedChecksum, requireListedSize } from './chunk-UUZCQQG2.mjs';
3
+ import { HEADER_SIZE, openChecksummedEnvelope } from './chunk-IO5F7ZBE.mjs';
4
+ import { NarsilError, ErrorCodes } from './chunk-HNHCNTVG.mjs';
5
+ import { decode } from '@msgpack/msgpack';
6
+
7
+ var VECTOR_FILE_ENVELOPE_VERSION = 2;
8
+ var GRAPH_PART_ENVELOPE_VERSION = 2;
9
+ function liveVectorsOf(ref) {
10
+ let live = 0;
11
+ for (const file of ref.files) live += file.count - countDead(file.dead, file.count);
12
+ return live;
13
+ }
14
+ async function openListedFile(store, ref, what, allowsCompression) {
15
+ const bytes = await readListedFile(store, ref.key, { bytes: ref.bytes, what });
16
+ const { header, payload } = await openChecksummedEnvelope(bytes, {
17
+ envelopeFormatVersion: VECTOR_FILE_ENVELOPE_VERSION,
18
+ what: `${what} "${ref.key}"`,
19
+ allowsCompression
20
+ });
21
+ requireListedChecksum(what, ref.key, header.checksum, ref.checksum);
22
+ return { payload, payloadLength: header.payloadLength };
23
+ }
24
+ async function readGraphParts(store, ref) {
25
+ if (ref.graphParts.length === 0) return null;
26
+ const parts = [];
27
+ for (const part of ref.graphParts) {
28
+ const { payload } = await openListedFile(store, part, "graph part", true);
29
+ const decoded = decodeVectorGraphPartPayload(decode(payload));
30
+ if (decoded.fieldName !== ref.fieldPath) {
31
+ throw new NarsilError(
32
+ ErrorCodes.PERSISTENCE_LOAD_FAILED,
33
+ `The graph part "${part.key}" names field "${decoded.fieldName}" where the manifest lists "${ref.fieldPath}"`,
34
+ { key: part.key }
35
+ );
36
+ }
37
+ parts.push(decoded);
38
+ }
39
+ return assembleGraphParts(parts);
40
+ }
41
+ async function readVectorFile(store, file, fieldPath) {
42
+ const { payload: bytes, payloadLength } = await openListedFile(store, file, "vector file", false);
43
+ const payload = decodeVectorFilePayload(decode(bytes));
44
+ if (payload.docIds.length !== file.count) {
45
+ throw new NarsilError(
46
+ ErrorCodes.PERSISTENCE_LOAD_FAILED,
47
+ `The vector file "${file.key}" holds ${payload.docIds.length} vectors where the manifest counts ${file.count}`,
48
+ { key: file.key, held: payload.docIds.length, count: file.count }
49
+ );
50
+ }
51
+ if (payload.fieldName !== fieldPath) {
52
+ throw new NarsilError(
53
+ ErrorCodes.PERSISTENCE_LOAD_FAILED,
54
+ `The vector file "${file.key}" names field "${payload.fieldName}" where the manifest lists "${fieldPath}"`,
55
+ { key: file.key }
56
+ );
57
+ }
58
+ return { payload, payloadLength };
59
+ }
60
+ function holdsEveryHead(ref) {
61
+ if (ref.graphParts.length === 0 || ref.files.length === 0) return false;
62
+ return [...ref.files, ...ref.graphParts].every((file) => file.headOffset !== void 0);
63
+ }
64
+ async function loadFieldOnDemand(store, ref, vectorIndex, resolvePartition) {
65
+ const { pathOf } = store;
66
+ if (pathOf === void 0 || vectorIndex.storage !== "disk" || !holdsEveryHead(ref)) return false;
67
+ const { loadFilesByParts, openColdVectorField, osqBitsOf, waitBeforeColdLoad } = await import('./cold-module-4X7WJCFM.mjs');
68
+ await Promise.all([
69
+ ...ref.files.map((file) => requireListedSize(store, file.key, { bytes: file.bytes, what: "vector file" })),
70
+ ...ref.graphParts.map((part) => requireListedSize(store, part.key, { bytes: part.bytes, what: "graph part" }))
71
+ ]);
72
+ const files = await Promise.all(
73
+ ref.files.map(async (file) => ({ ref: file, path: await pathOf.call(store, file.key) }))
74
+ );
75
+ const graphParts = await Promise.all(
76
+ ref.graphParts.map(async (part) => ({ ref: part, path: await pathOf.call(store, part.key) }))
77
+ );
78
+ const field = openColdVectorField({
79
+ fieldPath: ref.fieldPath,
80
+ dimension: vectorIndex.dimension,
81
+ metric: vectorIndex.metric,
82
+ codeBits: osqBitsOf(vectorIndex.quantization),
83
+ files,
84
+ graphParts,
85
+ resolvePartition
86
+ });
87
+ if (field === null) return false;
88
+ vectorIndex.openColdField(field, async (beginRestore, stillWanted, firstSearchAnswered) => {
89
+ await waitBeforeColdLoad(firstSearchAnswered);
90
+ if (!stillWanted()) return;
91
+ const graph = await readGraphParts(store, ref);
92
+ if (!stillWanted()) return;
93
+ const restore = beginRestore({ liveVectors: liveVectorsOf(ref), holdsGraph: true, graph });
94
+ await loadFilesByParts(files, restore, ref.fieldPath, vectorIndex.dimension, stillWanted);
95
+ });
96
+ return true;
97
+ }
98
+ async function loadVectorField(store, ref, vectorIndex, resolvePartition = null) {
99
+ if (resolvePartition !== null && await loadFieldOnDemand(store, ref, vectorIndex, resolvePartition)) return;
100
+ const restore = vectorIndex.restoreCheckpoint({
101
+ liveVectors: liveVectorsOf(ref),
102
+ holdsGraph: ref.graphParts.length > 0,
103
+ graph: await readGraphParts(store, ref)
104
+ });
105
+ for (const file of ref.files) {
106
+ const { payload, payloadLength } = await readVectorFile(store, file, ref.fieldPath);
107
+ restore.addFile({
108
+ id: file.id,
109
+ key: file.key,
110
+ payload,
111
+ dead: file.dead,
112
+ location: store.pathOf === void 0 ? null : {
113
+ path: await store.pathOf(file.key),
114
+ vectorsOffset: HEADER_SIZE + payloadLength - payload.vectors.byteLength
115
+ }
116
+ });
117
+ }
118
+ restore.finish();
119
+ }
120
+
121
+ export { GRAPH_PART_ENVELOPE_VERSION, VECTOR_FILE_ENVELOPE_VERSION, loadVectorField, readGraphParts, readVectorFile };
@@ -29,6 +29,7 @@ var KNOWN_ACTION_TYPES = [
29
29
  "compactSegments",
30
30
  "swapSegments",
31
31
  "freezeLiveTail",
32
+ "adoptDiskSegments",
32
33
  "memoryReport",
33
34
  "bootstrap",
34
35
  "shutdown"
@@ -1,8 +1,15 @@
1
- import { readMetadataEnvelope } from './chunk-MTQTX4BP.mjs';
2
- import { readWalSegments, durableRecordMissing, checkpointLastSeqNo, SEGMENT_HEADER_SIZE } from './chunk-CPCGEIOM.mjs';
3
- import { applyDeleteEntry, applyIndexEntry } from './chunk-LLDFIKGP.mjs';
1
+ import { readMetadataEnvelope } from './chunk-YHUTF6EA.mjs';
2
+ import { nextSegmentKey, readWalSegments, durableRecordMissing, checkpointLastSeqNo, SEGMENT_HEADER_SIZE } from './chunk-LA4WNDHL.mjs';
3
+ import { applyDeleteEntry, applyIndexEntry } from './chunk-KEIYVZUX.mjs';
4
4
 
5
5
  // src/persistence/durability/recovery.ts
6
+ async function removeLeftoverRewriteFiles(directory, names) {
7
+ for (const indexName of names) {
8
+ for (const place of ["rebuilt", "received"]) {
9
+ for (const key of await directory.list(`${indexName}/${place}/`)) await directory.remove(key);
10
+ }
11
+ }
12
+ }
6
13
  async function listPersistedIndexes(directory) {
7
14
  const metaKeys = await directory.list("");
8
15
  const names = [];
@@ -22,6 +29,7 @@ async function loadMetadata(directory, indexName) {
22
29
  return metadata;
23
30
  }
24
31
  async function replayWal(directory, indexName, partitionId, fromSeqNoExclusive, deps) {
32
+ await directory.remove(nextSegmentKey(indexName, partitionId));
25
33
  const read = await readWalSegments(directory, indexName, partitionId);
26
34
  if (read === null) {
27
35
  return { highestSeqNo: fromSeqNoExclusive, highestPrimaryTerm: 0 };
@@ -55,6 +63,7 @@ async function replayWal(directory, indexName, partitionId, fromSeqNoExclusive,
55
63
  return { highestSeqNo, highestPrimaryTerm };
56
64
  }
57
65
  async function replaySyncedWal(directory, indexName, partitionId, fromSeqNoExclusive, deps) {
66
+ await directory.remove(nextSegmentKey(indexName, partitionId));
58
67
  const read = await readWalSegments(directory, indexName, partitionId);
59
68
  if (read === null) {
60
69
  return { highestSeqNo: fromSeqNoExclusive, highestPrimaryTerm: 0 };
@@ -142,4 +151,4 @@ async function drainIndexStateForUnload(indexState, pendingMetadataWrite, closeW
142
151
  }
143
152
  }
144
153
 
145
- export { closePartitionWriter, drainIndexStateForUnload, listPersistedIndexes, loadMetadata, replaySyncedWal, replayWal, snapshotCheckpointFor };
154
+ export { closePartitionWriter, drainIndexStateForUnload, listPersistedIndexes, loadMetadata, removeLeftoverRewriteFiles, replaySyncedWal, replayWal, snapshotCheckpointFor };