Skip to content

Commit

Permalink
Use nCopies where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Aug 8, 2023
1 parent 16f98a1 commit 5062ed1
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.stream.IntStream;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.trino.plugin.hive.HiveSessionProperties.getTimestampPrecision;
import static java.util.Collections.nCopies;

public class TextHeaderWriter
{
Expand All @@ -52,7 +52,7 @@ public void write(OutputStream compressedOutput, int rowSeparator)
try {
ObjectInspector stringObjectInspector = HiveWriteUtils.getRowColumnInspector(headerType);
List<Text> headers = fileColumnNames.stream().map(Text::new).collect(toImmutableList());
List<ObjectInspector> inspectors = IntStream.range(0, fileColumnNames.size()).mapToObj(ignored -> stringObjectInspector).collect(toImmutableList());
List<ObjectInspector> inspectors = nCopies(fileColumnNames.size(), stringObjectInspector);
StandardStructObjectInspector headerStructObjectInspectors = ObjectInspectorFactory.getStandardStructObjectInspector(fileColumnNames, inspectors);
BinaryComparable binary = (BinaryComparable) serializer.serialize(headers, headerStructObjectInspectors);
compressedOutput.write(binary.getBytes(), 0, binary.getLength());
Expand Down

0 comments on commit 5062ed1

Please sign in to comment.