Map<Long, List<StreamDataBlock>> filterBlocksToCompact(Map<Long, List<StreamDataBlock>> streamDataBlocksMap) {
        // group stream data blocks by stream id, key: stream id, value: ids of objects that contains this stream
        Map<Long, Set<Long>> streamToObjectIds = streamDataBlocksMap.values().stream()
            .flatMap(Collection::stream)
            .collect(Collectors.groupingBy(StreamDataBlock::getStreamId, Collectors.mapping(StreamDataBlock::getObjectId, Collectors.toSet())));
        Set<Long> objectIdsToCompact = streamToObjectIds
            .entrySet().stream()
            .filter(e -> e.getValue().size() > 1)
            .flatMap(e -> e.getValue().stream())
            .collect(Collectors.toSet());
        return streamDataBlocksMap.entrySet().stream()
            .filter(e -> objectIdsToCompact.contains(e.getKey()))
            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    }
Filter out objects that have at least one stream data block which can be compacted with other objects.

@param streamDataBlocksMap stream data blocks map, key: object id, value: stream data blocks
@return filtered stream data blocks map
s3stream/src/main/java/com/automq/stream/s3/compact/CompactionAnalyzer.java