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

MINOR: [Java] Reduce enum array allocation #41533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
* A {@link ConnectionConfig} for the {@link ArrowFlightConnection}.
*/
public final class ArrowFlightConnectionConfigImpl extends ConnectionConfigImpl {
private static final ArrowFlightConnectionProperty[] ARROW_FLIGHT_CONNECTION_PROPERTY_VALUES
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) Maybe we can use a truly immutable type like EnumSet + Collections#unmodifiableSet() instead of an array.

= ArrowFlightConnectionProperty.values();

public ArrowFlightConnectionConfigImpl(final Properties properties) {
super(properties);
}
Expand Down Expand Up @@ -179,11 +182,10 @@ public CallOption toCallOption() {
*/
public Map<String, String> getHeaderAttributes() {
Map<String, String> headers = new HashMap<>();
ArrowFlightConnectionProperty[] builtInProperties = ArrowFlightConnectionProperty.values();
properties.forEach(
(key, val) -> {
// For built-in properties before adding new headers
if (Arrays.stream(builtInProperties)
if (Arrays.stream(ARROW_FLIGHT_CONNECTION_PROPERTY_VALUES)
.noneMatch(builtInProperty -> builtInProperty.camelName.equalsIgnoreCase(key.toString()))) {
headers.put(key.toString(), val.toString());
}
Expand Down