mirror of https://github.com/apache/druid.git
Fix inefficient available segment cache population in SQLMetadataSegmentManager (#5878)
This commit is contained in:
parent
bc9da54e12
commit
24efbb054c
|
@ -85,6 +85,14 @@ public class DruidDataSource
|
|||
return new ImmutableDruidDataSource(name, properties, idToSegmentMap);
|
||||
}
|
||||
|
||||
// For performance reasons, make sure we check for the existence of a segment using containsSegment(),
|
||||
// which performs a key-based lookup, instead of calling contains() on the collection returned by
|
||||
// dataSource.getSegments(). In Map values collections, the contains() method is a linear scan.
|
||||
public boolean containsSegment(DataSegment segment)
|
||||
{
|
||||
return idToSegmentMap.containsKey(segment.getIdentifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -475,7 +475,10 @@ public class SQLMetadataSegmentManager implements MetadataSegmentManager
|
|||
}
|
||||
}
|
||||
|
||||
if (!dataSource.getSegments().contains(segment)) {
|
||||
// For performance reasons, make sure we check for the existence of a segment using containsSegment(),
|
||||
// which performs a key-based lookup, instead of calling contains() on the collection returned by
|
||||
// dataSource.getSegments(). In Map values collections, the contains() method is a linear scan.
|
||||
if (!dataSource.containsSegment(segment)) {
|
||||
dataSource.addSegment(segment);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue