-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an option to control utf8Encoding of strings. (#567)
* Adding config option to disable utf8 encoding * Cleanup * Cleanup of comments * Cleanup of stale comments * Resolved comments. PTAL. * Fixing build error. * Throws an exception if utf8Encoding is set to true without setting methodStringRepresentation and stringRepresentation to CharSequence.
- Loading branch information
1 parent
997baf1
commit 17a828a
Showing
13 changed files
with
458 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2022 LinkedIn Corp. | ||
* Licensed under the BSD 2-Clause License (the "License"). | ||
* See License in the project root for license information. | ||
*/ | ||
|
||
plugins { | ||
id "java-library" | ||
} | ||
|
||
configurations { | ||
codegen | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDir 'src/main/java' | ||
srcDir "$buildDir/generated/sources/avro/java/main" | ||
} | ||
resources { | ||
srcDirs = [ | ||
"src/main/avro" | ||
] | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
codegen project(":avro-builder:builder") | ||
} | ||
|
||
task runOwnCodegen { | ||
description = 'generate specific classes using own codegen utility' | ||
|
||
dependsOn configurations.codegen | ||
|
||
doLast { | ||
javaexec { | ||
classpath configurations.codegen | ||
main = 'com.linkedin.avroutil1.builder.SchemaBuilder' | ||
args = [ | ||
"--input", "$projectDir/src/main/avro", | ||
"--output", "$buildDir/generated/sources/avro/java/main", | ||
"--generator", "AVRO_UTIL", | ||
"--stringRepresentation", "CharSequence", | ||
"--methodStringRepresentation", "CharSequence", | ||
"--enableUtf8Encoding", "false" | ||
] | ||
} | ||
} | ||
} | ||
|
||
compileJava.dependsOn runOwnCodegen | ||
|
||
dependencies { | ||
codegen project(":avro-builder:builder") | ||
|
||
implementation("org.apache.avro:avro:1.4.1") { | ||
exclude group: "org.mortbay.jetty" | ||
exclude group: "org.apache.velocity" | ||
exclude group: "commons-lang" | ||
exclude group: "org.jboss.netty" | ||
exclude group: "com.thoughtworks.paranamer", module: "paranamer-ant" | ||
} | ||
//required because generated code depends on the helper | ||
implementation project(":helper:helper") | ||
} |
15 changes: 15 additions & 0 deletions
15
...lder/tests/codegen-no-utf8-encoding/src/main/avro/noUtf8Encoding/ArrayOfStringRecord.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,15 @@ | ||
{ | ||
"type": "record", | ||
"namespace": "noutf8encoding", | ||
"name": "ArrayOfStringRecord", | ||
"doc": "Array of String Record", | ||
"fields": [ | ||
{ | ||
"name": "arOfRec", | ||
"type": { | ||
"type":"array", | ||
"items": "string" | ||
} | ||
} | ||
] | ||
} |
23 changes: 23 additions & 0 deletions
23
...uilder/tests/codegen-no-utf8-encoding/src/main/avro/noUtf8Encoding/HasNoSimpleString.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,23 @@ | ||
{ | ||
"type": "record", | ||
"namespace": "noutf8encoding", | ||
"name": "HasNoSimpleString", | ||
"fields": [ | ||
{ | ||
"name": "one", | ||
"type": "float" | ||
}, | ||
{ | ||
"name": "two", | ||
"type": ["string"] | ||
}, | ||
{ | ||
"name": "three", | ||
"type": "int" | ||
}, | ||
{ | ||
"name": "four", | ||
"type": "boolean" | ||
} | ||
] | ||
} |
95 changes: 95 additions & 0 deletions
95
...-builder/tests/codegen-no-utf8-encoding/src/main/avro/noUtf8Encoding/TestCollections.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,95 @@ | ||
{ | ||
"name": "TestCollections", | ||
"namespace": "noutf8encoding", | ||
"fields": [ | ||
{ | ||
"name": "str", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "strAr", | ||
"type": { | ||
"type": "array", | ||
"items": "string" | ||
} | ||
}, | ||
{ | ||
"name": "strArAr", | ||
"type": { | ||
"type": "array", | ||
"items": { | ||
"type": "array", | ||
"items": "string" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "unionOfArray", | ||
"type": [ | ||
"null", | ||
{ | ||
"type": "array", | ||
"items": "string" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "arOfMap", | ||
"type": { | ||
"type": "array", | ||
"items": { | ||
"type": "map", | ||
"values": "string" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "unionOfMap", | ||
"type": [ | ||
"null", | ||
{ | ||
"type": "map", | ||
"values": "string" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "arOfUnionOfStr", | ||
"type": { | ||
"type": "array", | ||
"items": ["null", "string"] | ||
} | ||
}, | ||
{ | ||
"name": "arOfMapOfUnionOfArray", | ||
"type": { | ||
"type": "array", | ||
"items": { | ||
"type": "map", | ||
"values": ["null", { | ||
"type": "array", | ||
"items": "string" | ||
}] | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "intAr", | ||
"type": { | ||
"type": "array", | ||
"items": "int" | ||
} | ||
}, | ||
{ | ||
"name": "unionOfIntMap", | ||
"type": [ | ||
"null", | ||
{ | ||
"type": "map", | ||
"values": "int" | ||
} | ||
] | ||
} | ||
], | ||
"type": "record" | ||
} |
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
Oops, something went wrong.