reuse DataSegment object when a segment found on another server (#10715)

This commit is contained in:
kaijianding 2021-01-08 13:55:25 +08:00 committed by GitHub
parent c7f2d3fbb5
commit 01e25f1e69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -124,7 +124,7 @@ public class BatchServerInventoryView extends AbstractCuratorServerInventoryView
Pair<DruidServerMetadata, DataSegment> input
)
{
return input.rhs;
return DataSegmentInterner.intern(input.rhs);
}
}
));

View File

@ -586,18 +586,19 @@ public class HttpServerInventoryView implements ServerInventoryView, FilteredSer
};
}
private void addSegment(final DataSegment segment)
private void addSegment(DataSegment segment)
{
if (finalPredicate.apply(Pair.of(druidServer.getMetadata(), segment))) {
if (druidServer.getSegment(segment.getId()) == null) {
druidServer.addDataSegment(segment);
DataSegment theSegment = DataSegmentInterner.intern(segment);
druidServer.addDataSegment(theSegment);
runSegmentCallbacks(
new Function<SegmentCallback, CallbackAction>()
{
@Override
public CallbackAction apply(SegmentCallback input)
{
return input.segmentAdded(druidServer.getMetadata(), segment);
return input.segmentAdded(druidServer.getMetadata(), theSegment);
}
}
);

View File

@ -81,7 +81,7 @@ public class SingleServerInventoryView extends AbstractCuratorServerInventoryVie
Predicates.or(segmentPredicates.values())
);
if (predicate.apply(Pair.of(container.getMetadata(), inventory))) {
addSingleInventory(container, inventory);
addSingleInventory(container, DataSegmentInterner.intern(inventory));
}
return container;
}