Package org.apache.cassandra.cdc.avro
Interface TypeConversion<T>
-
- Type Parameters:
T- target type
- All Known Implementing Classes:
TypeConversion.DateConversion,TypeConversion.DecimalConversion,TypeConversion.InetAddressConversion,TypeConversion.ListConversion,TypeConversion.MapConversion,TypeConversion.SetConversion,TypeConversion.TimestampConversion,TypeConversion.UdtConversion,TypeConversion.UUIDConversion,TypeConversion.VarIntConversion
public interface TypeConversion<T>Type conversion from the source type to the target type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classTypeConversion.DateConversionConverts date value inIntegertoLocalDate.static classTypeConversion.DecimalConversionConvertsGenericFixedtoBigDecimal.static classTypeConversion.InetAddressConversionstatic classTypeConversion.ListConversionConvertsGenericData.Array(, which is aList,) intoListThe conversion is identity.static classTypeConversion.MapConversionConvertsGenericData.Array(, which is aList,) ofGenericRecordintoMapThe containedGenericRecordshould be an avro key-value record.static interfaceTypeConversion.RegistryRegistry forTypeConversionto perform register and lookupstatic classTypeConversion.SetConversionConvertsGenericData.Array(, which is aList,) intoSetThe conversion is done recursively, meaning the elements of the input are converted too.static classTypeConversion.TimestampConversionConvertsLongtoDate.static classTypeConversion.TypeMappingA simple data class that represents the type mapping between the source type and target type.static classTypeConversion.UdtConversionConverts a UDTGenericRecordintoMapTheGenericRecordshould be an avro key-value record.static classTypeConversion.UUIDConversionConverts eitherStringorUtf8toUUID.static classTypeConversion.VarIntConversionConvertsGenericFixedtoBigInteger.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Tconvert(org.apache.avro.Schema fieldSchema, java.lang.Object fieldValue)Convert value from the source type to the target type.static voidensureInputValueType(java.lang.String conversionName, java.lang.Object input, java.lang.Class<?> expectedType)Validate the input is the expected typestatic byte[]getArray(java.nio.ByteBuffer buffer)static byte[]getArray(java.nio.ByteBuffer buffer, int position, int length)TypeConversion.TypeMappingtypeMapping()Type mapping from the source type to the target type.
-
-
-
Method Detail
-
typeMapping
TypeConversion.TypeMapping typeMapping()
Type mapping from the source type to the target type.- Returns:
- the type mapping.
-
convert
T convert(org.apache.avro.Schema fieldSchema, @NotNull java.lang.Object fieldValue)
Convert value from the source type to the target type. Runtime exceptions are thrown on invalid argument or conversion failure.- Parameters:
fieldSchema- avro schema to loop up the source schemafieldValue- value in the source type. The value cannot be null.- Returns:
- the converted value
-
ensureInputValueType
static void ensureInputValueType(java.lang.String conversionName, java.lang.Object input, java.lang.Class<?> expectedType)Validate the input is the expected type- Parameters:
conversionName- class name of typeinput- value to convertexpectedType- expected class of type- Throws:
java.lang.IllegalArgumentException- if type mismatches
-
getArray
static byte[] getArray(java.nio.ByteBuffer buffer)
-
getArray
static byte[] getArray(java.nio.ByteBuffer buffer, int position, int length)
-
-