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 <rleidle@tesla.com>
This commit is contained in:
parent
e93ce84cd5
commit
30db947c77
1 changed files with 10 additions and 19 deletions
|
|
@ -129,29 +129,20 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
|
|||
}
|
||||
|
||||
// Add tag
|
||||
const addContents = await Promise.all(
|
||||
results.addTag.map(({ path }) => this.readFile(path)),
|
||||
);
|
||||
for (let i = 0; i < results.addTag.length; i++) {
|
||||
const item = results.addTag[i];
|
||||
|
||||
// Insert chunks
|
||||
if (contents.length) {
|
||||
for await (const chunk of chunkDocument({
|
||||
filepath: item.path,
|
||||
contents: contents[i],
|
||||
maxChunkSize: this.maxChunkSize,
|
||||
digest: item.cacheKey,
|
||||
})) {
|
||||
handleChunk(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of results.addTag) {
|
||||
await db.run(
|
||||
`
|
||||
INSERT INTO chunk_tags (chunkId, tag)
|
||||
SELECT id, ? FROM chunks
|
||||
WHERE cacheKey = ? AND path = ?
|
||||
`,
|
||||
[tagString, item.cacheKey, item.path],
|
||||
);
|
||||
markComplete([item], IndexResultType.AddTag);
|
||||
accumulatedProgress += 1 / results.addTag.length / 4;
|
||||
yield {
|
||||
progress: accumulatedProgress,
|
||||
desc: `Chunking ${getBasename(item.path)}`,
|
||||
desc: `Adding ${getBasename(item.path)}`,
|
||||
status: "indexing",
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue