This is an automated email from the ASF dual-hosted git repository.
clolov 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 3884062d254 KAFKA-20297 Remove MappedIterator and test (#21719)
3884062d254 is described below
commit 3884062d2541baaed2349e5914337ec4b22bdc5f
Author: Xuan-Zhang Gong <[email protected]>
AuthorDate: Fri Mar 13 23:44:02 2026 +0800
KAFKA-20297 Remove MappedIterator and test (#21719)
MappedIterator and related tests are no longer needed
Reviewers: Chia-Ping Tsai <[email protected]>, Nilesh Kumar
<[email protected]>, Ken Huang <[email protected]>
---
.../apache/kafka/common/utils/MappedIterator.java | 44 ----------------
.../kafka/common/utils/MappedIteratorTest.java | 61 ----------------------
2 files changed, 105 deletions(-)
diff --git
a/clients/src/main/java/org/apache/kafka/common/utils/MappedIterator.java
b/clients/src/main/java/org/apache/kafka/common/utils/MappedIterator.java
deleted file mode 100644
index b03610d128e..00000000000
--- a/clients/src/main/java/org/apache/kafka/common/utils/MappedIterator.java
+++ /dev/null
@@ -1,44 +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;
-
-/**
- * An iterator that maps another iterator's elements from type `F` to type `T`.
- */
-public final class MappedIterator<F, T> implements Iterator<T> {
- private final Iterator<? extends F> underlyingIterator;
- private final Function<F, T> mapper;
-
- public MappedIterator(Iterator<? extends F> underlyingIterator,
Function<F, T> mapper) {
- this.underlyingIterator = underlyingIterator;
- this.mapper = mapper;
- }
-
- @Override
- public boolean hasNext() {
- return underlyingIterator.hasNext();
- }
-
- @Override
- public T next() {
- return mapper.apply(underlyingIterator.next());
- }
-
-}
diff --git
a/clients/src/test/java/org/apache/kafka/common/utils/MappedIteratorTest.java
b/clients/src/test/java/org/apache/kafka/common/utils/MappedIteratorTest.java
deleted file mode 100644
index 12b4367b029..00000000000
---
a/clients/src/test/java/org/apache/kafka/common/utils/MappedIteratorTest.java
+++ /dev/null
@@ -1,61 +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.List;
-import java.util.function.Function;
-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 MappedIteratorTest {
-
- @Test
- public void testStringToInteger() {
- List<String> list = asList("foo", "", "bar2", "baz45");
- Function<String, Integer> mapper = String::length;
-
- Iterable<Integer> mappedIterable = () -> new
MappedIterator<>(list.iterator(), mapper);
- List<Integer> mapped = new ArrayList<>();
- mappedIterable.forEach(mapped::add);
-
- assertEquals(list.stream().map(mapper).collect(Collectors.toList()),
mapped);
-
- // Ensure that we can iterate a second time
- List<Integer> mapped2 = new ArrayList<>();
- mappedIterable.forEach(mapped2::add);
- assertEquals(mapped, mapped2);
- }
-
- @Test
- public void testEmptyList() {
- List<String> list = emptyList();
- Function<String, Integer> mapper = String::length;
-
- Iterable<Integer> mappedIterable = () -> new
MappedIterator<>(list.iterator(), mapper);
- List<Integer> mapped = new ArrayList<>();
- mappedIterable.forEach(mapped::add);
-
- assertEquals(emptyList(), mapped);
- }
-
-}