Refactor code to improve di pipeline performance (#17820)

This commit is contained in:
IceS2 2024-09-13 11:18:22 +02:00 committed by GitHub
parent dbbd932cf7
commit 4ae318f11b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,7 +7,6 @@ import static org.openmetadata.service.workflows.searchIndex.ReindexingUtil.ENTI
import static org.openmetadata.service.workflows.searchIndex.ReindexingUtil.TIMESTAMP_KEY; import static org.openmetadata.service.workflows.searchIndex.ReindexingUtil.TIMESTAMP_KEY;
import static org.openmetadata.service.workflows.searchIndex.ReindexingUtil.getUpdatedStats; import static org.openmetadata.service.workflows.searchIndex.ReindexingUtil.getUpdatedStats;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -52,11 +51,14 @@ public class DataInsightsEntityEnricherProcessor
try { try {
enrichedMaps = enrichedMaps =
input.getData().stream() input.getData().stream()
.map(entity -> getEntityVersions(entity, contextData)) .flatMap(
.flatMap(Collection::stream) entity ->
.map(entityVersionMap -> enrichEntity(entityVersionMap, contextData)) getEntityVersions(entity, contextData).stream()
.map(this::generateDailyEntitySnapshots) .flatMap(
.flatMap(Collection::stream) entityVersionMap ->
generateDailyEntitySnapshots(
enrichEntity(entityVersionMap, contextData))
.stream()))
.toList(); .toList();
updateStats(input.getData().size(), 0); updateStats(input.getData().size(), 0);
} catch (Exception e) { } catch (Exception e) {