Skip to content

Commit

Permalink
fix bug with initial indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
joseplayero committed Sep 7, 2024
1 parent 7253c03 commit 1a9efbc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 5 additions & 4 deletions electron/main/vector-database/lanceTableWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LanceDBTableWrapper {
await this.deleteDBItemsByFilePaths(data.map((x) => x.notepath))

const recordEntry: Record<string, unknown>[] = data as unknown as Record<string, unknown>[]
const numberOfChunksToIndexAtOnce = 50
const numberOfChunksToIndexAtOnce = process.platform === 'darwin' ? 50 : 40
const chunks = []
for (let i = 0; i < recordEntry.length; i += numberOfChunksToIndexAtOnce) {
chunks.push(recordEntry.slice(i, i + numberOfChunksToIndexAtOnce))
Expand All @@ -54,15 +54,16 @@ class LanceDBTableWrapper {
if (chunks.length === 0) return

const totalChunks = chunks.length
chunks.forEach(async (chunk, index) => {

await chunks.reduce(async (previousPromise, chunk, index) => {
await previousPromise
const arrowTableOfChunk = makeArrowTable(chunk)
await this.lanceTable.add(arrowTableOfChunk)

const progress = (index + 1) / totalChunks
if (onProgress) {
onProgress(progress)
}
})
}, Promise.resolve())
}

async deleteDBItemsByFilePaths(filePaths: string[]): Promise<void> {
Expand Down
3 changes: 0 additions & 3 deletions electron/main/vector-database/tableHelperFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ export const RepopulateTableWithMissingItems = async (
return
}

const filePathsToDelete = dbItemsToAdd.map((x) => x[0].notepath)
await table.deleteDBItemsByFilePaths(filePathsToDelete)

const flattenedItemsToAdd = dbItemsToAdd.flat()
await table.add(flattenedItemsToAdd, onProgress)

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a9efbc

Please sign in to comment.