Skip to content

Revert "Package collections: improve search performance" #3212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Basics/ConcurrencyHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public final class ThreadSafeArrayStore<Value> {
}
}

/// Thread-safe value boxing structure
/// Thread-safe value boxing structure
public final class ThreadSafeBox<Value> {
private var underlying: Value?
private let lock = Lock()
Expand Down
1 change: 0 additions & 1 deletion Sources/PackageCollections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ add_library(PackageCollections
Storage/PackageCollectionsSourcesStorage.swift
Storage/PackageCollectionsStorage.swift
Storage/SQLitePackageCollectionsStorage.swift
Storage/Trie.swift
API.swift
PackageCollections.swift
PackageCollections+Configuration.swift
Expand Down
6 changes: 1 addition & 5 deletions Sources/PackageCollections/Model/TargetListResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,11 @@ extension PackageCollectionsModel.TargetListResult {

extension PackageCollectionsModel.TargetListResult {
/// Represents a package version
public struct PackageVersion: Hashable, Encodable, Comparable {
public struct PackageVersion: Hashable, Encodable {
/// The version
public let version: TSCUtility.Version

/// Package name
public let packageName: String

public static func < (lhs: PackageVersion, rhs: PackageVersion) -> Bool {
lhs.version < rhs.version
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public protocol PackageCollectionsStorage {
query: String,
callback: @escaping (Result<PackageCollectionsModel.PackageSearchResult, Error>) -> Void)

/// Returns `PackageSearchResult.Item` for the given package identity.
/// Returns optional `PackageSearchResult.Item` for the given package identity.
///
/// - Parameters:
/// - identifier: The package identifier
Expand Down

Large diffs are not rendered by default.

253 changes: 0 additions & 253 deletions Sources/PackageCollections/Storage/Trie.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -196,37 +196,4 @@ class PackageCollectionsStorageTests: XCTestCase {
_ = try tsc_await { callback in storage.put(collection: mockCollections.last!, callback: callback) }
XCTAssertEqual(list.count, mockCollections.count)
}

func testPopulateTargetTrie() throws {
try testWithTemporaryDirectory { tmpPath in
let path = tmpPath.appending(component: "test.db")
let storage = SQLitePackageCollectionsStorage(path: path)
defer { XCTAssertNoThrow(try storage.close()) }

let mockCollections = makeMockCollections(count: 3)
try mockCollections.forEach { collection in
_ = try tsc_await { callback in storage.put(collection: collection, callback: callback) }
}

let targetName = mockCollections.last!.packages.last!.versions.last!.targets.last!.name

do {
let searchResult = try tsc_await { callback in storage.searchTargets(query: targetName, type: .exactMatch, callback: callback) }
XCTAssert(searchResult.items.count > 0, "should get results")
}

// Create another instance, which should read existing data and populate target trie with it.
// Since we are not calling `storage2.put`, there is no other way for target trie to get populated.
let storage2 = SQLitePackageCollectionsStorage(path: path)
defer { XCTAssertNoThrow(try storage2.close()) }

// populateTargetTrie is called in `.init`; call it again explicitly so we know when it's finished
try tsc_await { callback in storage2.populateTargetTrie(callback: callback) }

do {
let searchResult = try tsc_await { callback in storage2.searchTargets(query: targetName, type: .exactMatch, callback: callback) }
XCTAssert(searchResult.items.count > 0, "should get results")
}
}
}
}
Loading