Copilot commented on code in PR #18434:
URL: https://github.com/apache/pinot/pull/18434#discussion_r3199670241
##########
pinot-plugins/pinot-input-format/pinot-arrow/src/test/java/org/apache/pinot/plugin/inputformat/arrow/ArrowRecordReaderTest.java:
##########
@@ -38,72 +36,64 @@
import org.apache.arrow.vector.types.FloatingPointPrecision;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
-import org.apache.arrow.vector.types.pojo.FieldType;
import org.apache.arrow.vector.types.pojo.Schema;
-import org.apache.pinot.spi.data.FieldSpec;
import org.apache.pinot.spi.data.readers.AbstractRecordReaderTest;
-import org.apache.pinot.spi.data.readers.GenericRow;
-import org.apache.pinot.spi.data.readers.PrimaryKey;
import org.apache.pinot.spi.data.readers.RecordReader;
-import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.Test;
+import static org.apache.arrow.vector.types.pojo.FieldType.nullable;
+
public class ArrowRecordReaderTest extends AbstractRecordReaderTest {
private static final int ROWS_PER_BATCH = 1000;
@Override
protected RecordReader createRecordReader(File file)
- throws Exception {
+ throws IOException {
ArrowRecordReader recordReader = new ArrowRecordReader();
recordReader.init(file, _sourceFields, null);
return recordReader;
}
@Override
protected void writeRecordsToFile(List<Map<String, Object>> recordsToWrite)
- throws Exception {
+ throws IOException {
// Single-value fields
- Field dimSvInt = new Field("dim_sv_int", FieldType.nullable(new
ArrowType.Int(32, true)), null);
- Field dimSvLong = new Field("dim_sv_long", FieldType.nullable(new
ArrowType.Int(64, true)), null);
+ Field dimSvInt = new Field("dim_sv_int", nullable(new ArrowType.Int(32,
true)), null);
+ Field dimSvLong = new Field("dim_sv_long", nullable(new ArrowType.Int(64,
true)), null);
Field dimSvFloat =
- new Field("dim_sv_float", FieldType.nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)), null);
+ new Field("dim_sv_float", nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)), null);
Field dimSvDouble =
- new Field("dim_sv_double", FieldType.nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE)),
- null);
- Field dimSvString = new Field("dim_sv_string", FieldType.nullable(new
ArrowType.Utf8()), null);
+ new Field("dim_sv_double", nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE)), null);
+ Field dimSvString = new Field("dim_sv_string", nullable(new
ArrowType.Utf8()), null);
// Multi-value fields (List vectors)
- Field dimMvInt = new Field("dim_mv_int", FieldType.nullable(new
ArrowType.List()),
- Arrays.asList(new Field("$data$", FieldType.nullable(new
ArrowType.Int(32, true)), null)));
- Field dimMvLong = new Field("dim_mv_long", FieldType.nullable(new
ArrowType.List()),
- Arrays.asList(new Field("$data$", FieldType.nullable(new
ArrowType.Int(64, true)), null)));
- Field dimMvFloat = new Field("dim_mv_float", FieldType.nullable(new
ArrowType.List()),
- Arrays.asList(
- new Field("$data$", FieldType.nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)), null)));
- Field dimMvDouble = new Field("dim_mv_double", FieldType.nullable(new
ArrowType.List()),
- Arrays.asList(
- new Field("$data$", FieldType.nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE)), null)));
- Field dimMvString = new Field("dim_mv_string", FieldType.nullable(new
ArrowType.List()),
- Arrays.asList(new Field("$data$", FieldType.nullable(new
ArrowType.Utf8()), null)));
+ Field dimMvInt = new Field("dim_mv_int", nullable(new ArrowType.List()),
+ List.of(new Field("$data$", nullable(new ArrowType.Int(32, true)),
null)));
+ Field dimMvLong = new Field("dim_mv_long", nullable(new ArrowType.List()),
+ List.of(new Field("$data$", nullable(new ArrowType.Int(64, true)),
null)));
+ Field dimMvFloat = new Field("dim_mv_float", nullable(new
ArrowType.List()),
+ List.of(new Field("$data$", nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)), null)));
+ Field dimMvDouble = new Field("dim_mv_double", nullable(new
ArrowType.List()),
+ List.of(new Field("$data$", nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE)), null)));
+ Field dimMvString = new Field("dim_mv_string", nullable(new
ArrowType.List()),
+ List.of(new Field("$data$", nullable(new ArrowType.Utf8()), null)));
// Metric fields
- Field metInt = new Field("met_int", FieldType.nullable(new
ArrowType.Int(32, true)), null);
- Field metLong = new Field("met_long", FieldType.nullable(new
ArrowType.Int(64, true)), null);
- Field metFloat =
- new Field("met_float", FieldType.nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)), null);
+ Field metInt = new Field("met_int", nullable(new ArrowType.Int(32, true)),
null);
+ Field metLong = new Field("met_long", nullable(new ArrowType.Int(64,
true)), null);
+ Field metFloat = new Field("met_float", nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)), null);
Field metDouble =
- new Field("met_double", FieldType.nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE)), null);
+ new Field("met_double", nullable(new
ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE)), null);
Schema schema = new Schema(
- Arrays.asList(dimSvInt, dimSvLong, dimSvFloat, dimSvDouble,
dimSvString, dimMvInt, dimMvLong, dimMvFloat,
- dimMvDouble, dimMvString, metInt, metLong, metFloat, metDouble));
+ List.of(dimSvInt, dimSvLong, dimSvFloat, dimSvDouble, dimSvString,
dimMvInt, dimMvLong, dimMvFloat, dimMvDouble,
+ dimMvString, metInt, metLong, metFloat, metDouble));
try (RootAllocator allocator = new RootAllocator();
VectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator);
- FileOutputStream fos = new FileOutputStream(_dataFile);
- FileChannel channel = fos.getChannel();
+ FileOutputStream fos = new FileOutputStream(_dataFile); FileChannel
channel = fos.getChannel();
Review Comment:
In the try-with-resources header, `FileOutputStream fos = ...; FileChannel
channel = fos.getChannel();` is written as two resource declarations on a
single line. This is hard to read and may violate the project's
formatting/checkstyle rules for one-statement-per-line in resource lists.
Please split `fos` and `channel` into separate entries (each on its own line)
within the try-with-resources declaration.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]