INNER CODE UNIT · Swift
loadIndex
ZachNagengast/similarity-search-kit · Sources/SimilaritySearchKit/Core/Index/SimilarityIndex.swift:337
func loadIndex(fromDirectory path: URL? = nil, name: String? = nil) throws -> [IndexItem]? {
if let indexPath = try getIndexPath(fromDirectory: path, name: name) {
indexItems = try vectorStore.loadIndex(from: indexPath)
return indexItems
}
return nil
}
/// This function returns the default location where the data from the loadIndex/saveIndex functions gets stored
/// gets stored.
/// - Parameters:
/// - fromDirectory: optional directory path where the file postfix is added to
/// - name: optional name
///
/// - Returns: an optional URL
func getIndexPath(fromDirectory path: URL? = nil, name: String? = nil) throws -> URL? {
let indexName = name ?? self.indexName