Package io.deephaven.parquet.base
Class BigDecimalParquetBytesCodec
java.lang.Object
io.deephaven.parquet.base.BigDecimalParquetBytesCodec
- All Implemented Interfaces:
ObjectCodec<BigDecimal>,ObjectDecoder<BigDecimal>
-
Field Summary
Fields inherited from interface io.deephaven.util.codec.ObjectDecoder
VARIABLE_WIDTH_SENTINEL -
Constructor Summary
ConstructorsConstructorDescriptionBigDecimalParquetBytesCodec(int precision, int scale) BigDecimalParquetBytesCodec(int precision, int scale, int encodedSizeInBytes) BigDecimalParquetBytesCodec(int precision, int scale, int encodedSizeInBytes, RoundingMode roundingMode) -
Method Summary
Modifier and TypeMethodDescription@Nullable BigDecimaldecode(@org.jetbrains.annotations.NotNull byte[] input, int offset, int length) Decode an object from an array of bytes.@org.jetbrains.annotations.NotNull byte[]encode(@Nullable BigDecimal input) Encode the specified input as an array of bytes.intWhat width byte array does this ObjectCodec expect to encode and decode?intIf applicable, the maximum encodable precision.intgetScale()If applicable, the maximum encodable scale.booleanDoes this codec support encoding of null values?static voidverifyPrecisionAndScale(int precision, int scale) Verify that the precision and scale are valid.static voidverifyPrecisionAndScale(int precision, int scale, org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName primitiveType) Verify that the precision and scale are valid for the given primitive type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.deephaven.util.codec.ObjectDecoder
checkWidth, decode
-
Constructor Details
-
BigDecimalParquetBytesCodec
public BigDecimalParquetBytesCodec(int precision, int scale, int encodedSizeInBytes, RoundingMode roundingMode) - Parameters:
precision-scale-encodedSizeInBytes- encoded size in bytes, if fixed size, or -1 if variable size. note that according to the parquet spec, the minimum number of bytes required to represent the unscaled value should be used for a variable sized (binary) encoding; in any case, the maximum encoded bytes is implicitly limited by precision.
-
BigDecimalParquetBytesCodec
public BigDecimalParquetBytesCodec(int precision, int scale, int encodedSizeInBytes) -
BigDecimalParquetBytesCodec
public BigDecimalParquetBytesCodec(int precision, int scale)
-
-
Method Details
-
verifyPrecisionAndScale
public static void verifyPrecisionAndScale(int precision, int scale) Verify that the precision and scale are valid.- Throws:
IllegalArgumentException- if the provided precision and/or scale is invalid
-
verifyPrecisionAndScale
public static void verifyPrecisionAndScale(int precision, int scale, org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName primitiveType) Verify that the precision and scale are valid for the given primitive type.- Throws:
IllegalArgumentException- if the provided precision and/or scale is invalid
-
isNullable
public boolean isNullable()Description copied from interface:ObjectCodecDoes this codec support encoding of null values?- Specified by:
isNullablein interfaceObjectCodec<BigDecimal>- Returns:
- if null values are supported
-
getPrecision
public int getPrecision()Description copied from interface:ObjectCodecIf applicable, the maximum encodable precision. If precision is not applicable (i.e. for non-numeric types) this method should return zero.- Specified by:
getPrecisionin interfaceObjectCodec<BigDecimal>- Returns:
- the numeric precision supported by this codec
-
getScale
public int getScale()Description copied from interface:ObjectCodecIf applicable, the maximum encodable scale. If scale is not applicable (i.e. for non-numeric types) this method should return zero.- Specified by:
getScalein interfaceObjectCodec<BigDecimal>- Returns:
- the numeric scale (digits after the decimal point) supported by this codec
-
encode
@NotNull public @org.jetbrains.annotations.NotNull byte[] encode(@Nullable @Nullable BigDecimal input) Description copied from interface:ObjectCodecEncode the specified input as an array of bytes. Note that it is up to the implementation how to encode null inputs. The use of a zero-length byte array is strongly encouraged.- Specified by:
encodein interfaceObjectCodec<BigDecimal>- Parameters:
input- The input object, possibly null- Returns:
- The output byte array
-
decode
@Nullable public @Nullable BigDecimal decode(@NotNull @org.jetbrains.annotations.NotNull byte[] input, int offset, int length) Description copied from interface:ObjectDecoderDecode an object from an array of bytes.- Specified by:
decodein interfaceObjectDecoder<BigDecimal>- Parameters:
input- The input byte array containing bytes to decodeoffset- The offset into the byte array to start decoding fromlength- The number of bytes to decode, starting at the offset- Returns:
- The output object, possibly null
-
expectedObjectWidth
public int expectedObjectWidth()Description copied from interface:ObjectDecoderWhat width byte array does this ObjectCodec expect to encode and decode?- Specified by:
expectedObjectWidthin interfaceObjectDecoder<BigDecimal>- Returns:
- VARIABLE_WIDTH_SENTINEL if the codec must encode and decode variable width columns, otherwise the fixed size of byte array that must be decoded and encoded.
-