Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
public class AvroToArrowConfig {

private final BufferAllocator allocator;

/**
* The maximum rowCount to read each time when partially convert data. Default value is 1024 and
* -1 means read all data into one vector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private static Consumer createConsumer(
break;
case STRING:
arrowType = new ArrowType.Utf8();
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType = new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroStringConsumer((VarCharVector) vector);
break;
Expand All @@ -195,7 +195,7 @@ private static Consumer createConsumer(
arrowType = createDecimalArrowType((LogicalTypes.Decimal) logicalType);
fieldType =
new FieldType(
nullable, arrowType, /*dictionary=*/ null, getMetaData(schema, extProps));
nullable, arrowType, /* dictionary= */ null, getMetaData(schema, extProps));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer =
new AvroDecimalConsumer.FixedDecimalConsumer(
Expand All @@ -204,87 +204,96 @@ private static Consumer createConsumer(
arrowType = new ArrowType.FixedSizeBinary(schema.getFixedSize());
fieldType =
new FieldType(
nullable, arrowType, /*dictionary=*/ null, getMetaData(schema, extProps));
nullable, arrowType, /* dictionary= */ null, getMetaData(schema, extProps));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroFixedConsumer((FixedSizeBinaryVector) vector, schema.getFixedSize());
}
break;
case INT:
if (logicalType instanceof LogicalTypes.Date) {
arrowType = new ArrowType.Date(DateUnit.DAY);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroDateConsumer((DateDayVector) vector);
} else if (logicalType instanceof LogicalTypes.TimeMillis) {
arrowType = new ArrowType.Time(TimeUnit.MILLISECOND, 32);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroTimeMillisConsumer((TimeMilliVector) vector);
} else {
arrowType = new ArrowType.Int(32, /*isSigned=*/ true);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
arrowType = new ArrowType.Int(32, /* isSigned= */ true);
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroIntConsumer((IntVector) vector);
}
break;
case BOOLEAN:
arrowType = new ArrowType.Bool();
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType = new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroBooleanConsumer((BitVector) vector);
break;
case LONG:
if (logicalType instanceof LogicalTypes.TimeMicros) {
arrowType = new ArrowType.Time(TimeUnit.MICROSECOND, 64);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroTimeMicroConsumer((TimeMicroVector) vector);
} else if (logicalType instanceof LogicalTypes.TimestampMillis) {
arrowType = new ArrowType.Timestamp(TimeUnit.MILLISECOND, null);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroTimestampMillisConsumer((TimeStampMilliVector) vector);
} else if (logicalType instanceof LogicalTypes.TimestampMicros) {
arrowType = new ArrowType.Timestamp(TimeUnit.MICROSECOND, null);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroTimestampMicrosConsumer((TimeStampMicroVector) vector);
} else {
arrowType = new ArrowType.Int(64, /*isSigned=*/ true);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
arrowType = new ArrowType.Int(64, /* isSigned= */ true);
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroLongConsumer((BigIntVector) vector);
}
break;
case FLOAT:
arrowType = new ArrowType.FloatingPoint(SINGLE);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType = new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroFloatConsumer((Float4Vector) vector);
break;
case DOUBLE:
arrowType = new ArrowType.FloatingPoint(DOUBLE);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType = new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroDoubleConsumer((Float8Vector) vector);
break;
case BYTES:
if (logicalType instanceof LogicalTypes.Decimal) {
arrowType = createDecimalArrowType((LogicalTypes.Decimal) logicalType);
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroDecimalConsumer.BytesDecimalConsumer((DecimalVector) vector);
} else {
arrowType = new ArrowType.Binary();
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
fieldType =
new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = createVector(consumerVector, fieldType, name, allocator);
consumer = new AvroBytesConsumer((VarBinaryVector) vector);
}
break;
case NULL:
arrowType = new ArrowType.Null();
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/ null, getMetaData(schema));
vector = fieldType.createNewSingleVector(name, allocator, /*schemaCallBack=*/ null);
fieldType = new FieldType(nullable, arrowType, /* dictionary= */ null, getMetaData(schema));
vector = fieldType.createNewSingleVector(name, allocator, /* schemaCallBack= */ null);
consumer = new AvroNullConsumer((NullVector) vector);
break;
default:
Expand Down Expand Up @@ -462,17 +471,17 @@ private static Field avroSchemaToField(
case MAP:
// MapVector internal struct field and key field should be non-nullable
FieldType keyFieldType =
new FieldType(/*nullable=*/ false, new ArrowType.Utf8(), /*dictionary=*/ null);
Field keyField = new Field("key", keyFieldType, /*children=*/ null);
new FieldType(/* nullable= */ false, new ArrowType.Utf8(), /* dictionary= */ null);
Field keyField = new Field("key", keyFieldType, /* children= */ null);
Field valueField = avroSchemaToField(schema.getValueType(), "value", config);

FieldType structFieldType =
new FieldType(false, new ArrowType.Struct(), /*dictionary=*/ null);
new FieldType(false, new ArrowType.Struct(), /* dictionary= */ null);
Field structField =
new Field("internal", structFieldType, Arrays.asList(keyField, valueField));
children.add(structField);
fieldType =
createFieldType(new ArrowType.Map(/*keysSorted=*/ false), schema, externalProps);
createFieldType(new ArrowType.Map(/* keysSorted= */ false), schema, externalProps);
break;
case RECORD:
final Set<String> skipFieldNames = config.getSkipFieldNames();
Expand Down Expand Up @@ -506,7 +515,7 @@ private static Field avroSchemaToField(
indexType,
schema,
externalProps,
new DictionaryEncoding(current, /*ordered=*/ false, /*indexType=*/ indexType));
new DictionaryEncoding(current, /* ordered= */ false, /* indexType= */ indexType));
break;

case STRING:
Expand All @@ -528,7 +537,7 @@ private static Field avroSchemaToField(
} else if (logicalType instanceof LogicalTypes.TimeMillis) {
intArrowType = new ArrowType.Time(TimeUnit.MILLISECOND, 32);
} else {
intArrowType = new ArrowType.Int(32, /*isSigned=*/ true);
intArrowType = new ArrowType.Int(32, /* isSigned= */ true);
}
fieldType = createFieldType(intArrowType, schema, externalProps);
break;
Expand All @@ -544,7 +553,7 @@ private static Field avroSchemaToField(
} else if (logicalType instanceof LogicalTypes.TimestampMicros) {
longArrowType = new ArrowType.Timestamp(TimeUnit.MICROSECOND, null);
} else {
longArrowType = new ArrowType.Int(64, /*isSigned=*/ true);
longArrowType = new ArrowType.Int(64, /* isSigned= */ true);
}
fieldType = createFieldType(longArrowType, schema, externalProps);
break;
Expand Down Expand Up @@ -806,7 +815,7 @@ private static Map<String, String> createExternalProps(Schema schema) {

private static FieldType createFieldType(
ArrowType arrowType, Schema schema, Map<String, String> externalProps) {
return createFieldType(arrowType, schema, externalProps, /*dictionary=*/ null);
return createFieldType(arrowType, schema, externalProps, /* dictionary= */ null);
}

private static FieldType createFieldType(
Expand All @@ -816,7 +825,7 @@ private static FieldType createFieldType(
DictionaryEncoding dictionary) {

return new FieldType(
/*nullable=*/ false, arrowType, dictionary, getMetaData(schema, externalProps));
/* nullable= */ false, arrowType, dictionary, getMetaData(schema, externalProps));
}

private static String convertAliases(Set<String> aliases) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static class Builder {
/** Bind each column to the corresponding parameter in order. */
public Builder bindAll() {
for (int i = 0; i < root.getFieldVectors().size(); i++) {
bind(/*parameterIndex=*/ i + 1, /*columnIndex=*/ i);
bind(/* parameterIndex= */ i + 1, /* columnIndex= */ i);
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public final class JdbcToArrowConfig {
private final Map<String, String> schemaMetadata;
private final Map<Integer, Map<String, String>> columnMetadataByColumnIndex;
private final RoundingMode bigDecimalRoundingMode;

/**
* The maximum rowCount to read each time when partially convert data. Default value is 1024 and
* -1 means disable partial read. default is -1 which means disable partial read. Note that this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static Schema jdbcToArrowSchema(
final int scale = parameterMetaData.getScale(parameterCounter);
final ArrowType arrowType =
getArrowTypeFromJdbcType(new JdbcFieldInfo(jdbcDataType, precision, scale), calendar);
final FieldType fieldType = new FieldType(arrowIsNullable, arrowType, /*dictionary=*/ null);
final FieldType fieldType = new FieldType(arrowIsNullable, arrowType, /* dictionary= */ null);
parameterFields.add(new Field(null, fieldType, null));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ void bindOrder() throws SQLException {
final VectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator)) {
final JdbcParameterBinder binder =
JdbcParameterBinder.builder(statement, root)
.bind(/*parameterIndex=*/ 1, /*columnIndex=*/ 2)
.bind(/*parameterIndex=*/ 2, /*columnIndex=*/ 0)
.bind(/* parameterIndex= */ 1, /* columnIndex= */ 2)
.bind(/* parameterIndex= */ 2, /* columnIndex= */ 0)
.build();
assertThat(binder.next()).isFalse();

Expand Down Expand Up @@ -166,7 +166,7 @@ void customBinder() throws SQLException {
final JdbcParameterBinder binder =
JdbcParameterBinder.builder(statement, root)
.bind(
/*parameterIndex=*/ 1,
/* parameterIndex= */ 1,
new ColumnBinder() {
private final IntVector vector = (IntVector) root.getVector(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ public void testIncorrectNullability(boolean reuseVectorSchemaRoot) throws Excep
final Schema notNullSchema =
new Schema(
Collections.singletonList(
Field.notNullable(/*name=*/ null, new ArrowType.Int(32, true))));
Field.notNullable(/* name= */ null, new ArrowType.Int(32, true))));
final Schema nullSchema =
new Schema(
Collections.singletonList(Field.nullable(/*name=*/ null, new ArrowType.Int(32, true))));
Collections.singletonList(
Field.nullable(/* name= */ null, new ArrowType.Int(32, true))));

try (final ResultSet rs = resultSetBuilder.build()) {
JdbcToArrowConfig config =
Expand Down
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ under the License.
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.30.0</version>
<version>2.44.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private ArrowBuf maybeImportBitmap(ArrowType type) {
if (buffers[0] == NULL) {
return null;
}
return importFixedBits(type, 0, /*bitsPerSlot=*/ 1);
return importFixedBits(type, 0, /* bitsPerSlot= */ 1);
}

@Override
Expand Down Expand Up @@ -205,7 +205,7 @@ public List<ArrowBuf> visit(ArrowType.FloatingPoint type) {
switch (type.getPrecision()) {
case HALF:
return Arrays.asList(
maybeImportBitmap(type), importFixedBytes(type, 1, /*bytesPerSlot=*/ 2));
maybeImportBitmap(type), importFixedBytes(type, 1, /* bytesPerSlot= */ 2));
case SINGLE:
return Arrays.asList(
maybeImportBitmap(type), importFixedBytes(type, 1, Float4Vector.TYPE_WIDTH));
Expand Down Expand Up @@ -333,7 +333,7 @@ public List<ArrowBuf> visit(ArrowType.FixedSizeBinary type) {

@Override
public List<ArrowBuf> visit(ArrowType.Bool type) {
return Arrays.asList(maybeImportBitmap(type), importFixedBits(type, 1, /*bitsPerSlot=*/ 1));
return Arrays.asList(maybeImportBitmap(type), importFixedBits(type, 1, /* bitsPerSlot= */ 1));
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions c/src/test/java/org/apache/arrow/c/StreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void roundtripDictionary() throws Exception {
Collections.singletonList(
new Field(
"dict",
new FieldType(/*nullable=*/ true, indexType, encoding),
new FieldType(/* nullable= */ true, indexType, encoding),
Collections.emptyList())));
final List<ArrowRecordBatch> batches = new ArrayList<>();
try (final CDataDictionaryProvider provider = new CDataDictionaryProvider();
Expand Down Expand Up @@ -362,7 +362,8 @@ void roundtrip(Schema schema, List<ArrowRecordBatch> batches) throws Exception {
private static void assertVectorsEqual(FieldVector expected, FieldVector actual) {
assertThat(actual.getField().getType()).isEqualTo(expected.getField().getType());
assertThat(actual.getValueCount()).isEqualTo(expected.getValueCount());
final Range range = new Range(/*leftStart=*/ 0, /*rightStart=*/ 0, expected.getValueCount());
final Range range =
new Range(/* leftStart= */ 0, /* rightStart= */ 0, expected.getValueCount());
assertThat(new RangeEqualsVisitor(expected, actual).rangeEquals(range))
.as("Vectors were not equal.\nExpected: %s\nGot: %s", expected, actual)
.isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected ArrowBuf doCompress(BufferAllocator allocator, ArrowBuf uncompressedBu
Integer.MAX_VALUE);

byte[] inBytes = new byte[(int) uncompressedBuffer.writerIndex()];
uncompressedBuffer.getBytes(/*index=*/ 0, inBytes);
uncompressedBuffer.getBytes(/* index= */ 0, inBytes);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (InputStream in = new ByteArrayInputStream(inBytes);
OutputStream out = new FramedLZ4CompressorOutputStream(baos)) {
Expand Down Expand Up @@ -81,7 +81,7 @@ protected ArrowBuf doDecompress(BufferAllocator allocator, ArrowBuf compressedBu

byte[] outBytes = out.toByteArray();
ArrowBuf decompressedBuffer = allocator.buffer(outBytes.length);
decompressedBuffer.setBytes(/*index=*/ 0, outBytes);
decompressedBuffer.setBytes(/* index= */ 0, outBytes);
decompressedBuffer.writerIndex(decompressedLength);
return decompressedBuffer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ protected ArrowBuf doCompress(BufferAllocator allocator, ArrowBuf uncompressedBu
compressedBuffer.memoryAddress() + CompressionUtil.SIZE_OF_UNCOMPRESSED_LENGTH,
dstSize,
/*src*/ uncompressedBuffer.memoryAddress(),
/*srcSize=*/ uncompressedBuffer.writerIndex(),
/*level=*/ this.compressionLevel);
/* srcSize= */ uncompressedBuffer.writerIndex(),
/* level= */ this.compressionLevel);
if (Zstd.isError(bytesWritten)) {
compressedBuffer.close();
throw new RuntimeException("Error compressing: " + Zstd.getErrorName(bytesWritten));
Expand All @@ -64,7 +64,8 @@ protected ArrowBuf doDecompress(BufferAllocator allocator, ArrowBuf compressedBu
Zstd.decompressUnsafe(
uncompressedBuffer.memoryAddress(),
decompressedLength,
/*src=*/ compressedBuffer.memoryAddress() + CompressionUtil.SIZE_OF_UNCOMPRESSED_LENGTH,
/* src= */ compressedBuffer.memoryAddress()
+ CompressionUtil.SIZE_OF_UNCOMPRESSED_LENGTH,
compressedBuffer.writerIndex() - CompressionUtil.SIZE_OF_UNCOMPRESSED_LENGTH);
if (Zstd.isError(decompressedSize)) {
uncompressedBuffer.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private Dictionary createDictionary(VarCharVector dictionaryVector) {

return new Dictionary(
dictionaryVector,
new DictionaryEncoding(/*id=*/ 1L, /*ordered=*/ false, /*indexType=*/ null));
new DictionaryEncoding(/* id= */ 1L, /* ordered= */ false, /* indexType= */ null));
}

@Test
Expand Down
Loading
Loading