@@ -118,8 +118,7 @@ private boolean compatibleDecimalType(Variant value, LogicalTypeAnnotation logic
118118 (LogicalTypeAnnotation .DecimalLogicalTypeAnnotation ) logicalType ;
119119
120120 BigDecimal decimal = value .getDecimal ();
121- return decimal .scale () == decimalType .getScale () &&
122- decimal .precision () <= decimalType .getPrecision ();
121+ return decimal .scale () == decimalType .getScale () && decimal .precision () <= decimalType .getPrecision ();
123122 }
124123
125124 private boolean isTypeCompatible (Variant .Type variantType , Type typedValueField , Variant value ) {
@@ -149,25 +148,28 @@ private boolean isTypeCompatible(Variant.Type variantType, Type typedValueField,
149148 && (logicalType == null
150149 || (logicalType instanceof LogicalTypeAnnotation .IntLogicalTypeAnnotation
151150 && ((LogicalTypeAnnotation .IntLogicalTypeAnnotation ) logicalType ).isSigned ()
152- && ((LogicalTypeAnnotation .IntLogicalTypeAnnotation ) logicalType ).getBitWidth () == 32 ));
151+ && ((LogicalTypeAnnotation .IntLogicalTypeAnnotation ) logicalType )
152+ .getBitWidth ()
153+ == 32 ));
153154 case LONG :
154155 return primitiveTypeName == PrimitiveType .PrimitiveTypeName .INT64
155156 && (logicalType == null
156157 || (logicalType instanceof LogicalTypeAnnotation .IntLogicalTypeAnnotation
157- && ((LogicalTypeAnnotation .IntLogicalTypeAnnotation ) logicalType ).isSigned ()));
158+ && ((LogicalTypeAnnotation .IntLogicalTypeAnnotation ) logicalType )
159+ .isSigned ()));
158160 case FLOAT :
159161 return primitiveTypeName == PrimitiveType .PrimitiveTypeName .FLOAT ;
160162 case DOUBLE :
161163 return primitiveTypeName == PrimitiveType .PrimitiveTypeName .DOUBLE ;
162164 case DECIMAL4 :
163- return primitiveTypeName == PrimitiveType .PrimitiveTypeName .INT32 &&
164- compatibleDecimalType (value , logicalType );
165+ return primitiveTypeName == PrimitiveType .PrimitiveTypeName .INT32
166+ && compatibleDecimalType (value , logicalType );
165167 case DECIMAL8 :
166- return primitiveTypeName == PrimitiveType .PrimitiveTypeName .INT64 &&
167- compatibleDecimalType (value , logicalType );
168+ return primitiveTypeName == PrimitiveType .PrimitiveTypeName .INT64
169+ && compatibleDecimalType (value , logicalType );
168170 case DECIMAL16 :
169- return primitiveTypeName == PrimitiveType .PrimitiveTypeName .BINARY &&
170- compatibleDecimalType (value , logicalType );
171+ return primitiveTypeName == PrimitiveType .PrimitiveTypeName .BINARY
172+ && compatibleDecimalType (value , logicalType );
171173 case DATE :
172174 return primitiveTypeName == PrimitiveType .PrimitiveTypeName .INT32
173175 && logicalType instanceof LogicalTypeAnnotation .DateLogicalTypeAnnotation ;
@@ -271,25 +273,26 @@ private void writeScalarValue(RecordConsumer recordConsumer, Variant variant, Pr
271273 }
272274
273275 private void writeArrayValue (RecordConsumer recordConsumer , Variant variant , GroupType arrayType ) {
274- Preconditions .checkArgument (variant .getType () == Variant .Type .ARRAY ,
276+ Preconditions .checkArgument (
277+ variant .getType () == Variant .Type .ARRAY ,
275278 "Cannot write variant type " + variant .getType () + " as array" );
276279
277280 // Validate that it's a 3-level array.
278- if (arrayType .getFieldCount () != 1 ||
279- arrayType .getRepetition () == Type .Repetition .REPEATED ||
280- arrayType .getType (0 ).isPrimitive () ||
281- !arrayType .getFieldName (0 ).equals (LIST_REPEATED_NAME )) {
282- throw new IllegalArgumentException ("Variant list must be a three-level list structure: " + arrayType );
281+ if (arrayType .getFieldCount () != 1
282+ || arrayType .getRepetition () == Type .Repetition .REPEATED
283+ || arrayType .getType (0 ).isPrimitive ()
284+ || !arrayType .getFieldName (0 ).equals (LIST_REPEATED_NAME )) {
285+ throw new IllegalArgumentException ("Variant list must be a three-level list structure: " + arrayType );
283286 }
284287
285288 // Get the element type from the array schema
286289 GroupType repeatedType = arrayType .getType (0 ).asGroupType ();
287290
288- if (repeatedType .getFieldCount () != 1 ||
289- repeatedType .getRepetition () != Type .Repetition .REPEATED ||
290- repeatedType .getType (0 ).isPrimitive () ||
291- !repeatedType .getFieldName (0 ).equals (LIST_ELEMENT_NAME )) {
292- throw new IllegalArgumentException ("Variant list must be a three-level list structure: " + arrayType );
291+ if (repeatedType .getFieldCount () != 1
292+ || repeatedType .getRepetition () != Type .Repetition .REPEATED
293+ || repeatedType .getType (0 ).isPrimitive ()
294+ || !repeatedType .getFieldName (0 ).equals (LIST_ELEMENT_NAME )) {
295+ throw new IllegalArgumentException ("Variant list must be a three-level list structure: " + arrayType );
293296 }
294297
295298 GroupType elementType = repeatedType .getType (0 ).asGroupType ();
0 commit comments