Source:
<code>public SamzaSqlApplicationConfig(Config staticConfig) { sql = fetchSqlFromConfig(staticConfig); queryInfo = fetchQueryInfo(sql); ioResolver = createIOResolver(staticConfig); udfResolver = createUdfResolver(staticConfig); udfMetadata = udfResolver.getUdfs(); inputSystemStreamConfigBySource = queryInfo.stream() .map(QueryInfo::getSources) .flatMap(Collection::stream) <START> .collect(Collectors.toMap(Function.identity(), ioResolver::fetchSourceInfo, (src1, src2) -> src1)); <END> Set<SqlIOConfig> systemStreamConfigs = new HashSet<>(inputSystemStreamConfigBySource.values()); outputSystemStreamConfigsBySource = queryInfo.stream() .map(QueryInfo::getSink) .collect(Collectors.toMap(Function.identity(), ioResolver::fetchSinkInfo, (src1, src2) -> src1)); systemStreamConfigs.addAll(outputSystemStreamConfigsBySource.values()); relSchemaProvidersBySource = systemStreamConfigs.stream() .collect(Collectors.toMap(SqlIOConfig::getSource, x -> initializePlugin("RelSchemaProvider", x.getRelSchemaProviderName(), staticConfig, CFG_FMT_REL_SCHEMA_PROVIDER_DOMAIN, (o, c) -> ((RelSchemaProviderFactory) o).create(x.getSystemStream(), c)))); samzaRelConvertersBySource = systemStreamConfigs.stream() .collect(Collectors.toMap(SqlIOConfig::getSource, x -> initializePlugin("SamzaRelConverter", x.getSamzaRelConverterName(), staticConfig, CFG_FMT_SAMZA_REL_CONVERTER_DOMAIN, (o, c) -> ((SamzaRelConverterFactory) o).create(x.getSystemStream(), relSchemaProvidersBySource.get(x.getSource()), c)))); windowDurationMs = staticConfig.getLong(CFG_GROUPBY_WINDOW_DURATION_MS, DEFAULT_GROUPBY_WINDOW_DURATION_MS); }</code><technical_language>distinct() collect() save some resolver calls fetch source information</technical_language>

Target:
public SamzaSqlApplicationConfig(Config staticConfig) { sql = fetchSqlFromConfig(staticConfig); queryInfo = fetchQueryInfo(sql); ioResolver = createIOResolver(staticConfig); udfResolver = createUdfResolver(staticConfig); udfMetadata = udfResolver.getUdfs(); inputSystemStreamConfigBySource = queryInfo.stream() .map(QueryInfo::getSources) .flatMap(Collection::stream) .distinct() .collect(Collectors.toMap(Function.identity(), ioResolver::fetchSourceInfo)); Set<SqlIOConfig> systemStreamConfigs = new HashSet<>(inputSystemStreamConfigBySource.values()); outputSystemStreamConfigsBySource = queryInfo.stream() .map(QueryInfo::getSink) .distinct() .collect(Collectors.toMap(Function.identity(), ioResolver::fetchSinkInfo)); systemStreamConfigs.addAll(outputSystemStreamConfigsBySource.values()); relSchemaProvidersBySource = systemStreamConfigs.stream() .collect(Collectors.toMap(SqlIOConfig::getSource, x -> initializePlugin("RelSchemaProvider", x.getRelSchemaProviderName(), staticConfig, CFG_FMT_REL_SCHEMA_PROVIDER_DOMAIN, (o, c) -> ((RelSchemaProviderFactory) o).create(x.getSystemStream(), c)))); samzaRelConvertersBySource = systemStreamConfigs.stream() .collect(Collectors.toMap(SqlIOConfig::getSource, x -> initializePlugin("SamzaRelConverter", x.getSamzaRelConverterName(), staticConfig, CFG_FMT_SAMZA_REL_CONVERTER_DOMAIN, (o, c) -> ((SamzaRelConverterFactory) o).create(x.getSystemStream(), relSchemaProvidersBySource.get(x.getSource()), c)))); windowDurationMs = staticConfig.getLong(CFG_GROUPBY_WINDOW_DURATION_MS, DEFAULT_GROUPBY_WINDOW_DURATION_MS); }