This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 64aebb5621b MINOR: remove unused FlattenedIterator (#20067)
64aebb5621b is described below

commit 64aebb5621bd27ee9f2c4ab4506f32dcff267963
Author: Jhen-Yung Hsu <[email protected]>
AuthorDate: Mon Jun 30 20:02:08 2025 +0800

    MINOR: remove unused FlattenedIterator (#20067)
    
    Remove FlattenedIterator. It’s no longer used anywhere after
    https://github.com/apache/kafka/pull/20037.
    
    Reviewers: TengYao Chi <[email protected]>, Lan Ding
     <[email protected]>, Chia-Ping Tsai <[email protected]>
---
 .../kafka/common/utils/FlattenedIterator.java      |  45 --------
 .../kafka/common/utils/FlattenedIteratorTest.java  | 116 ---------------------
 2 files changed, 161 deletions(-)

diff --git 
a/clients/src/main/java/org/apache/kafka/common/utils/FlattenedIterator.java 
b/clients/src/main/java/org/apache/kafka/common/utils/FlattenedIterator.java
deleted file mode 100644
index 4e28bb35c66..00000000000
--- a/clients/src/main/java/org/apache/kafka/common/utils/FlattenedIterator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.kafka.common.utils;
-
-import java.util.Iterator;
-import java.util.function.Function;
-
-/**
- * Provides a flattened iterator over the inner elements of an outer iterator.
- */
-public final class FlattenedIterator<O, I> extends AbstractIterator<I> {
-    private final Iterator<O> outerIterator;
-    private final Function<O, Iterator<I>> innerIteratorFunction;
-    private Iterator<I> innerIterator;
-
-    public FlattenedIterator(Iterator<O> outerIterator, Function<O, 
Iterator<I>> innerIteratorFunction) {
-        this.outerIterator = outerIterator;
-        this.innerIteratorFunction = innerIteratorFunction;
-    }
-
-    @Override
-    protected I makeNext() {
-        while (innerIterator == null || !innerIterator.hasNext()) {
-            if (outerIterator.hasNext())
-                innerIterator = 
innerIteratorFunction.apply(outerIterator.next());
-            else
-                return allDone();
-        }
-        return innerIterator.next();
-    }
-}
diff --git 
a/clients/src/test/java/org/apache/kafka/common/utils/FlattenedIteratorTest.java
 
b/clients/src/test/java/org/apache/kafka/common/utils/FlattenedIteratorTest.java
deleted file mode 100644
index 057b6118e07..00000000000
--- 
a/clients/src/test/java/org/apache/kafka/common/utils/FlattenedIteratorTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.kafka.common.utils;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static java.util.Arrays.asList;
-import static java.util.Collections.emptyList;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class FlattenedIteratorTest {
-
-    @Test
-    public void testNestedLists() {
-        List<List<String>> list = asList(
-            asList("foo", "a", "bc"),
-            Collections.singletonList("ddddd"),
-            asList("", "bar2", "baz45"));
-
-        Iterable<String> flattenedIterable = () -> new 
FlattenedIterator<>(list.iterator(), List::iterator);
-        List<String> flattened = new ArrayList<>();
-        flattenedIterable.forEach(flattened::add);
-
-        
assertEquals(list.stream().flatMap(Collection::stream).collect(Collectors.toList()),
 flattened);
-
-        // Ensure we can iterate multiple times
-        List<String> flattened2 = new ArrayList<>();
-        flattenedIterable.forEach(flattened2::add);
-
-        assertEquals(flattened, flattened2);
-    }
-
-    @Test
-    public void testEmptyList() {
-        List<List<String>> list = emptyList();
-
-        Iterable<String> flattenedIterable = () -> new 
FlattenedIterator<>(list.iterator(), List::iterator);
-        List<String> flattened = new ArrayList<>();
-        flattenedIterable.forEach(flattened::add);
-
-        assertEquals(emptyList(), flattened);
-    }
-
-    @Test
-    public void testNestedSingleEmptyList() {
-        List<List<String>> list = Collections.singletonList(emptyList());
-
-        Iterable<String> flattenedIterable = () -> new 
FlattenedIterator<>(list.iterator(), List::iterator);
-        List<String> flattened = new ArrayList<>();
-        flattenedIterable.forEach(flattened::add);
-
-        assertEquals(emptyList(), flattened);
-    }
-
-    @Test
-    public void testEmptyListFollowedByNonEmpty() {
-        List<List<String>> list = asList(
-            emptyList(),
-            asList("boo", "b", "de"));
-
-        Iterable<String> flattenedIterable = () -> new 
FlattenedIterator<>(list.iterator(), List::iterator);
-        List<String> flattened = new ArrayList<>();
-        flattenedIterable.forEach(flattened::add);
-
-        
assertEquals(list.stream().flatMap(Collection::stream).collect(Collectors.toList()),
 flattened);
-    }
-
-    @Test
-    public void testEmptyListInBetweenNonEmpty() {
-        List<List<String>> list = asList(
-            Collections.singletonList("aadwdwdw"),
-            emptyList(),
-            asList("ee", "aa", "dd"));
-
-        Iterable<String> flattenedIterable = () -> new 
FlattenedIterator<>(list.iterator(), List::iterator);
-        List<String> flattened = new ArrayList<>();
-        flattenedIterable.forEach(flattened::add);
-
-        
assertEquals(list.stream().flatMap(Collection::stream).collect(Collectors.toList()),
 flattened);
-    }
-
-    @Test
-    public void testEmptyListAtTheEnd() {
-        List<List<String>> list = asList(
-            asList("ee", "dd"),
-            Collections.singletonList("e"),
-            emptyList());
-
-        Iterable<String> flattenedIterable = () -> new 
FlattenedIterator<>(list.iterator(), List::iterator);
-        List<String> flattened = new ArrayList<>();
-        flattenedIterable.forEach(flattened::add);
-
-        
assertEquals(list.stream().flatMap(Collection::stream).collect(Collectors.toList()),
 flattened);
-    }
-
-}

Reply via email to