Skip to content

Commit

Permalink
[fastserde] Logical types are now supported for avro version 1.9+ (#516)
Browse files Browse the repository at this point in the history
A modelData parameter (GenericData or SpecificData instance) is passed to 
FastSerdeBase, FastSerdeCache and everything else in-between. The
behavior is unchanged if the modelData is not passed in.
  • Loading branch information
krisso-rtb authored Sep 27, 2023
1 parent 917b1b9 commit 73acd3c
Show file tree
Hide file tree
Showing 61 changed files with 2,240 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* To run this benchmark:
* <code>
* ./gradlew :avro-fastserde:jmh -PUSE_AVRO_14/17/18
* ./gradlew :fastserde:avro-fastserde-jmh:jmh -PUSE_AVRO_14/17/18/19/110/111
* </code>
*
* You also can test by your own AVRO schema by replacing the contents in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*
* To run this benchmark:
* <code>
* ./gradlew :avro-fastserde:jmh -PUSE_AVRO_18
* ./gradlew :fastserde:avro-fastserde-jmh:jmh -PUSE_AVRO_18
* </code>
*
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"type": "record",
"name": "FastSerdeLogicalTypesDefined",
"namespace": "com.linkedin.avro.fastserde.generated.avro",
"doc": "Used in tests to confirm fast-serde supports logical-types",
"fields": [
{
"name": "timeMillisField",
"type": {
"type": "int",
"logicalType": "time-millis"
}
},
{
"name": "dateField",
"type": {
"type": "int",
"logicalType": "date"
}
},
{
"name": "arrayOfUnionOfDateAndTimestampMillis",
"type": {
"type": "array",
"items": [
{
"type": "int",
"logicalType": "date"
},
{
"type": "long",
"logicalType": "timestamp-millis"
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"type": "record",
"name": "FastSerdeLogicalTypesTest1",
"namespace": "com.linkedin.avro.fastserde.generated.avro",
"doc": "Used in tests to confirm fast-serde supports logical-types",
"fields": [
{
"name": "unionOfArrayAndMap",
"type": [
{
"type": "array",
"items": {
"type": "int",
"logicalType": "time-millis"
}
},
{
"type": "map",
"values": {
"type": "int",
"logicalType": "date"
}
}
]
},
{
"name": "mapOfUnionsOfDateAndTimestampMillis",
"type": {
"type": "map",
"values": [
{
"type": "int",
"logicalType": "date"
},
{
"type": "long",
"logicalType": "timestamp-millis"
}
]
}
},
{
"name": "timestampMillisMap",
"type": {
"type": "map",
"values": {
"type": "long",
"logicalType": "timestamp-millis"
}
}
},
{
"name": "nullableArrayOfDates",
"type": [
"null",
{
"type": "array",
"items": {
"type": "int",
"logicalType": "date"
}
}
],
"default": null
},
{
"name": "arrayOfDates",
"type": {
"type": "array",
"items": {
"type": "int",
"logicalType": "date"
}
}
},
{
"name": "unionOfDecimalOrDate",
"type": [
{
"type": "bytes",
"logicalType": "decimal",
"precision": 4,
"scale": 2
},
{
"type": "int",
"logicalType": "date"
}
]
},
{
"name": "uuidField",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "timestampMillisField",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
}
},
{
"name": "timestampMicrosField",
"type": {
"type": "long",
"logicalType": "timestamp-micros"
}
},
{
"name": "timeMillisField",
"type": {
"type": "int",
"logicalType": "time-millis"
}
},
{
"name": "timeMicrosField",
"type": {
"type": "long",
"logicalType": "time-micros"
}
},
{
"name": "dateField",
"type": {
"type": "int",
"logicalType": "date"
}
},
{
"name": "nestedLocalTimestampMillis",
"type": {
"name": "LocalTimestampRecord",
"type": "record",
"fields": [
{
"name": "nestedTimestamp",
"type": {
"type": "long",
"logicalType": "local-timestamp-millis"
}
},
{
"name": "nullableNestedTimestamp",
"type": [
"null",
{
"type": "long",
"logicalType": "local-timestamp-millis"
}
]
},
{
"name": "nullableUnionOfDateAndLocalTimestamp",
"type": [
"null",
{
"type": "int",
"logicalType": "date"
},
{
"type": "long",
"logicalType": "local-timestamp-millis"
}
]
},
{
"name": "unionOfDateAndLocalTimestamp",
"type": [
{
"type": "int",
"logicalType": "date"
},
{
"type": "long",
"logicalType": "local-timestamp-millis"
}
]
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"type": "record",
"name": "FastSerdeLogicalTypesUndefined",
"namespace": "com.linkedin.avro.fastserde.generated.avro",
"doc": "Used in tests to confirm fast-serde supports logical-types",
"fields": [
{
"name": "timeMillisField",
"type": {
"type": "int"
}
},
{
"name": "dateField",
"type": {
"type": "int"
}
},
{
"name": "arrayOfUnionOfDateAndTimestampMillis",
"type": {
"type": "array",
"items": [
{
"type": "int"
},
{
"type": "long"
}
]
}
}
]
}
Loading

0 comments on commit 73acd3c

Please sign in to comment.