Skip to content

Commit 30db947

Browse files
spewRob Leidle
and
Rob Leidle
authored
Change ChunkCodebaseIndex to add a tag for known chunks rather than rechunking the file (#1926)
Note that the prior logic referenced the wrong file contents so it was likely impacting the accuracy of portions of the index that use the chunks table. Co-authored-by: Rob Leidle <[email protected]>
1 parent e93ce84 commit 30db947

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

core/indexing/chunk/ChunkCodebaseIndex.ts

+10-19
Original file line numberDiff line numberDiff line change
@@ -129,29 +129,20 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
129129
}
130130

131131
// Add tag
132-
const addContents = await Promise.all(
133-
results.addTag.map(({ path }) => this.readFile(path)),
134-
);
135-
for (let i = 0; i < results.addTag.length; i++) {
136-
const item = results.addTag[i];
137-
138-
// Insert chunks
139-
if (contents.length) {
140-
for await (const chunk of chunkDocument({
141-
filepath: item.path,
142-
contents: contents[i],
143-
maxChunkSize: this.maxChunkSize,
144-
digest: item.cacheKey,
145-
})) {
146-
handleChunk(chunk);
147-
}
148-
}
149-
132+
for (const item of results.addTag) {
133+
await db.run(
134+
`
135+
INSERT INTO chunk_tags (chunkId, tag)
136+
SELECT id, ? FROM chunks
137+
WHERE cacheKey = ? AND path = ?
138+
`,
139+
[tagString, item.cacheKey, item.path],
140+
);
150141
markComplete([item], IndexResultType.AddTag);
151142
accumulatedProgress += 1 / results.addTag.length / 4;
152143
yield {
153144
progress: accumulatedProgress,
154-
desc: `Chunking ${getBasename(item.path)}`,
145+
desc: `Adding ${getBasename(item.path)}`,
155146
status: "indexing",
156147
};
157148
}

0 commit comments

Comments
 (0)