Skip to content

Commit

Permalink
Replace stream with normal iteration
Browse files Browse the repository at this point in the history
The QualifiedName constructor is used for every identifier during analysis phase
and may take significant part of wall time for huge queries.
  • Loading branch information
skrzypo987 authored and kokosing committed Dec 16, 2022
1 parent ec78212 commit 667194e
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public static QualifiedName of(Iterable<Identifier> originalParts)
private QualifiedName(List<Identifier> originalParts)
{
this.originalParts = originalParts;
this.parts = originalParts.stream()
.map(QualifiedName::mapIdentifier)
.collect(toImmutableList());
// Iteration instead of stream for performance reasons
ImmutableList.Builder partsBuilder = ImmutableList.builderWithExpectedSize(originalParts.size());
for (Identifier identifier : originalParts) {
partsBuilder.add(mapIdentifier(identifier));
}
this.parts = partsBuilder.build();
this.name = String.join(".", parts);

if (originalParts.size() == 1) {
Expand Down

0 comments on commit 667194e

Please sign in to comment.