Skip to content

Commit

Permalink
"Refactor loadIndex method to directly assign loaded index items to i…
Browse files Browse the repository at this point in the history
…ndexItems and print the count and path of the loaded items."
  • Loading branch information
buhe committed Feb 14, 2024
1 parent eef5ab0 commit b8d134a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Sources/SimilaritySearchKit/Core/Index/SimilarityIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,9 @@ extension SimilarityIndex {

public func loadIndex(fromDirectory path: URL? = nil, name: String? = nil) throws -> [IndexItem]? {
if let indexPath = try getIndexPath(fromDirectory: path, name: name) {
let loadedIndexItems = try vectorStore.loadIndex(from: indexPath)
addItems(loadedIndexItems) {[self] in
print("Loaded \(indexItems.count) index items from \(indexPath.absoluteString)")
}
return loadedIndexItems
indexItems = try vectorStore.loadIndex(from: indexPath)
print("Loaded \(indexItems.count) index items from \(indexPath.absoluteString)")
return indexItems
}

return nil
Expand Down

0 comments on commit b8d134a

Please sign in to comment.