public static List<List<StreamDataBlock>> groupStreamDataBlocks(List<StreamDataBlock> streamDataBlocks,
        Predicate<StreamDataBlock> predicate) {
        List<List<StreamDataBlock>> groupedStreamDataBlocks = new ArrayList<>();
        List<StreamDataBlock> currGroup = new ArrayList<>();
        for (StreamDataBlock streamDataBlock : streamDataBlocks) {
            if (predicate.test(streamDataBlock)) {
                currGroup.add(streamDataBlock);
            } else if (!currGroup.isEmpty()) {
                groupedStreamDataBlocks.add(currGroup);
                currGroup = new ArrayList<>();
                currGroup.add(streamDataBlock);
            }
        }
        if (!currGroup.isEmpty()) {
            groupedStreamDataBlocks.add(currGroup);
        }
        return groupedStreamDataBlocks;
    }
Group stream data blocks by certain conditions.

@param streamDataBlocks stream data blocks to be grouped
@param predicate        the predicate to check whether a stream data block should be grouped with the previous one
@return grouped stream data blocks
s3stream/src/main/java/com/automq/stream/s3/compact/utils/CompactionUtils.java