Skip to content

Trim to size lists created in source fetchers #130521

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 4 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions docs/changelog/130521.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 130521
summary: Trim to size lists created in source fetchers
area: Search
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ArraySourceValueFetcher(Set<String> sourcePaths, Object nullValue) {

@Override
public List<Object> fetchValues(Source source, int doc, List<Object> ignoredValues) {
List<Object> values = new ArrayList<>();
ArrayList<Object> values = new ArrayList<>();
for (String path : sourcePaths) {
Object sourceValue = source.extractValue(path, nullValue);
if (sourceValue == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't directly related to your changes. Still, it appears that the code exits early on the first null value, potentially skipping other paths that may contain valid data. Do you happen to know if that behavior is intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has always been like that so I would say it is intentional.

Expand All @@ -70,6 +70,7 @@ public List<Object> fetchValues(Source source, int doc, List<Object> ignoredValu
ignoredValues.add(sourceValue);
}
}
values.trimToSize();
return values;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public SourceValueFetcher(Set<String> sourcePaths, Object nullValue) {

@Override
public List<Object> fetchValues(Source source, int doc, List<Object> ignoredValues) {
List<Object> values = new ArrayList<>();
ArrayList<Object> values = new ArrayList<>();
for (String path : sourcePaths) {
Object sourceValue = source.extractValue(path, nullValue);
if (sourceValue == null) {
Expand Down Expand Up @@ -92,6 +92,7 @@ public List<Object> fetchValues(Source source, int doc, List<Object> ignoredValu
}
}
}
values.trimToSize();
return values;
}

Expand Down
Loading