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

Allow parallel TableLocation factory invocation in AbstractTableLocationProvider #5432

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private void maybeAddLocations(@NotNull final Collection<ImmutableTableLocationK
return;
}
filterLocationKeys(locationKeys)
.parallelStream()
.forEach(lk -> columnSourceManager.addLocation(locationProvider.getTableLocation(lk)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,18 @@ public TableLocation getTableLocationIfPresent(@NotNull final TableLocationKey t
// See JavaDoc on tableLocations for background.
// The intent is to create a TableLocation exactly once to replace the TableLocationKey placeholder that was
// added in handleTableLocationKey.
if (current instanceof TableLocation) {
return (TableLocation) current;
}
synchronized (tableLocations) {
current = tableLocations.get(tableLocationKey);
if (current instanceof TableLocation) {
return (TableLocation) current;
while (!(current instanceof TableLocation)) {
final TableLocationKey immutableKey = (TableLocationKey) current;
// noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (immutableKey) {
devinrsmith marked this conversation as resolved.
Show resolved Hide resolved
current = tableLocations.get(immutableKey);
if (immutableKey == current) {
// Note, this may contend for the lock on tableLocations
tableLocations.add(current = makeTableLocation(immutableKey));
rcaudy marked this conversation as resolved.
Show resolved Hide resolved
}
}
final TableLocation result = makeTableLocation((TableLocationKey) current);
tableLocations.add(result);
return result;
}
return (TableLocation) current;
devinrsmith marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Loading