Skip to content

Commit

Permalink
Fixups.
Browse files Browse the repository at this point in the history
  • Loading branch information
gianm committed Oct 30, 2023
1 parent e08e762 commit d5b9e6e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.druid.data.input.InputSourceReader;
import org.apache.druid.data.input.InputStats;
import org.apache.druid.data.input.impl.systemfield.SystemFieldDecoratorFactory;
import org.apache.druid.java.util.common.CloseableIterators;
import org.apache.druid.java.util.common.parsers.CloseableIterator;

import java.io.File;
Expand Down Expand Up @@ -72,7 +71,7 @@ public CloseableIterator<InputRow> read(InputStats inputStats)
try {
final InputEntity entityToRead = inputStats == null ? entity : new BytesCountingInputEntity(entity, inputStats);
final InputEntityReader reader = inputFormat.createReader(inputRowSchema, entityToRead, temporaryDirectory);
return CloseableIterators.transform(reader.read(), systemFieldDecorator);
return reader.read().map(systemFieldDecorator);
}
catch (IOException e) {
throw new RuntimeException(entity.getUri() != null ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public String getFieldName()
/**
* Type of this system field.
*/
@SuppressWarnings("unused") // Not used, but still useful for signifying intent
public ColumnType getColumnType()
{
return columnType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;

public class CloseableIterators
{
Expand All @@ -58,37 +57,6 @@ public static <T> CloseableIterator<T> mergeSorted(
return wrap(innerIterator, closer);
}

public static <T, R> CloseableIterator<R> transform(CloseableIterator<T> iterator, Function<T, R> fn)
{
if (Function.identity().equals(fn)) {
//noinspection unchecked
return (CloseableIterator<R>) iterator;
}

class TransformedCloseableIterator implements CloseableIterator<R>
{
@Override
public boolean hasNext()
{
return iterator.hasNext();
}

@Override
public R next()
{
return fn.apply(iterator.next());
}

@Override
public void close() throws IOException
{
iterator.close();
}
}

return new TransformedCloseableIterator();
}

public static <T> CloseableIterator<T> wrap(Iterator<T> innerIterator, @Nullable Closeable closeable)
{
return new CloseableIterator<T>()
Expand Down

0 comments on commit d5b9e6e

Please sign in to comment.