Skip to content
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

add rocksdb.swift #5 #40

Closed
wants to merge 7 commits into from
Closed

add rocksdb.swift #5 #40

wants to merge 7 commits into from

Conversation

RomeroYang
Copy link
Contributor

No description provided.

do {
db = try RocksDB(path: path, prefix: prefix)
} catch {
throw NSError(domain: Database.errorDomain, code: 2, userInfo: [NSLocalizedDescriptionKey: "Failed to init RocksDB: \(error)"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use NSError.
use something like

public enum Error: Swift.Error {
    case initFailed,
    case notOpen,
}

and throw Error. initFailed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but in this case, there is no need to do anything, just do catch it and let the error propagate will be fine

public class Database {
public let path: URL
public let prefix: String?
private var db: RocksDB?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to make db optional.

Comment on lines 39 to 43
do {
return try type.init(data: db.get(key: key))
} catch {
throw error
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to catch and throw

Comment on lines 58 to 59
keyType _: Key.Type,
valueType _: Value.Type,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are not used?

@@ -0,0 +1,7 @@
import XCTest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to have this, swift test should just work

@@ -0,0 +1,9 @@
import XCTest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to have this

Comment on lines 7 to 8
public let path: URL
public let prefix: String?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to have those

@xlc xlc mentioned this pull request Jul 25, 2024
@xlc xlc closed this in #42 Jul 25, 2024
@xlc xlc deleted the RocksDB-setup branch September 5, 2024 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants