Copilot commented on code in PR #4452:
URL: https://github.com/apache/arrow-adbc/pull/4452#discussion_r3503507410
##########
java/driver/jni/src/main/java/org/apache/arrow/adbc/driver/jni/JniDriver.java:
##########
@@ -99,4 +99,53 @@ public AdbcDatabase open(Map<String, Object> parameters)
throws AdbcException {
NativeDatabaseHandle handle =
JniLoader.INSTANCE.openDatabase(nativeParameters);
return new JniDatabase(allocator, handle);
}
+
+ /** Fluent builder-style interface for loading a driver and establishing a
connection. */
+ public Builder load() {
+ return new Builder();
+ }
+
+ /** Fluent builder-style interface for loading a driver and establishing a
connection. */
+ public final class Builder {
+ Map<String, String> nativeParameters;
+
+ Builder() {
+ this.nativeParameters = new HashMap<>();
+ }
+
+ /** Load the given driver. */
+ public Builder driver(String driver) {
+ nativeParameters.put("driver", driver);
+ return this;
+ }
+
+ /** Load the given profile. */
+ public Builder profile(String profile) {
+ nativeParameters.put("profile", profile);
+ return this;
+ }
+
+ /** Connect to the given URI. */
+ public Builder uri(String uri) {
+ nativeParameters.put("uri", uri);
+ return this;
+ }
+
+ /** Set an arbitrary parameter. */
+ public Builder param(String key, String value) {
+ nativeParameters.put(key, value);
+ return this;
+ }
Review Comment:
Builder.param(TypedKey<String>, …) currently forwards the full key string
(e.g., "jni.additional_profile_search_path_list") into the native parameter
map. The existing open(Map<String,Object>) API strips the "jni." prefix before
passing options to the native driver manager, which expects unprefixed keys
(e.g., "additional_profile_search_path_list"). As a result, fluent usage like
`.param(JniDriver.PARAM_PROFILE_SEARCH_PATH, ...)` will send an unrecognized
option to native code.
##########
java/driver/jni/src/main/java/org/apache/arrow/adbc/driver/jni/JniDriver.java:
##########
@@ -99,4 +99,53 @@ public AdbcDatabase open(Map<String, Object> parameters)
throws AdbcException {
NativeDatabaseHandle handle =
JniLoader.INSTANCE.openDatabase(nativeParameters);
return new JniDatabase(allocator, handle);
}
+
+ /** Fluent builder-style interface for loading a driver and establishing a
connection. */
+ public Builder load() {
+ return new Builder();
+ }
+
+ /** Fluent builder-style interface for loading a driver and establishing a
connection. */
+ public final class Builder {
+ Map<String, String> nativeParameters;
+
+ Builder() {
+ this.nativeParameters = new HashMap<>();
+ }
Review Comment:
Builder.nativeParameters is currently package-private and non-final. Since
Builder is a public API, keeping its internal state encapsulated (private) and
non-reassignable (final) helps prevent accidental misuse and makes the class
easier to reason about.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]