-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement logical types conversion for serializer/deserializer
- Loading branch information
Showing
12 changed files
with
134 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...aws/services/schemaregistry/deserializers/avro/GenericDataWithLogicalTypesConversion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.amazonaws.services.schemaregistry.deserializers.avro; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.avro.Conversions; | ||
import org.apache.avro.data.TimeConversions; | ||
import org.apache.avro.generic.GenericData; | ||
|
||
@Slf4j | ||
public class GenericDataWithLogicalTypesConversion { | ||
private static final GenericData INSTANCE = new GenericData(); | ||
|
||
static { | ||
INSTANCE.addLogicalTypeConversion(new Conversions.DecimalConversion()); | ||
INSTANCE.addLogicalTypeConversion(new Conversions.UUIDConversion()); | ||
INSTANCE.addLogicalTypeConversion(new TimeConversions.DateConversion()); | ||
INSTANCE.addLogicalTypeConversion(new TimeConversions.TimeMillisConversion()); | ||
INSTANCE.addLogicalTypeConversion(new TimeConversions.TimeMicrosConversion()); | ||
INSTANCE.addLogicalTypeConversion(new TimeConversions.LocalTimestampMillisConversion()); | ||
INSTANCE.addLogicalTypeConversion(new TimeConversions.LocalTimestampMicrosConversion()); | ||
INSTANCE.addLogicalTypeConversion(new TimeConversions.TimestampMillisConversion()); | ||
INSTANCE.addLogicalTypeConversion(new TimeConversions.TimestampMicrosConversion()); | ||
} | ||
|
||
public static GenericData getInstance() { | ||
return INSTANCE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
.../test/java/com/amazonaws/services/schemaregistry/serializers/avro/AvroSerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
serializer-deserializer/src/test/resources/avro/user4.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"namespace": "com.amazonaws.services.schemaregistry.serializers.avro", | ||
"type": "record", | ||
"name": "User4", | ||
"fields": [ | ||
{"name": "name", "type": "string" }, | ||
{"name": "dateOfBirth", "type": { "type": "int", "logicalType": "date"} }, | ||
{"name": "age", "type": { "type": "bytes", "logicalType": "decimal", "precision": 12, "scale": 2 } } | ||
] | ||
} |