-
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.
Checking in samples of fast-avro code gen, to ease future reviews.
The goal of this change is to have the output of the fast-avro code gen under version control, so that it can be diffed easily during pull requests, and so that historical changes are easier to track. Given the complexity of analyzing meta-code changes, the hope is that this will allow a more streamlined and robust workflow. In order to facilitate this, the main code is changed as such: - The algorithm for naming the generated classes has been tweaked, so that it's more easily recognizable. In particular, collection types now specify the type of their element in the class name, e.g. - Array_of_record - Array_of_LONG - Map_of_UNION - The package name for generated classes is also tweaked, such that it includes the Avro version in it, e.g. - com/linkedin/avro/fastserde/generated/deserialization/AVRO_1_4 - com/linkedin/avro/fastserde/generated/serialization/AVRO_1_8 Furthermore, the build and tests are more significantly altered: - A new src directory called codegen is created. It is confgured as a source set in the build with proper dependencies, in order to make the generated code easy to navigate in the IDE. - FastGenericDeserializerGeneratorTest and FGSerializerGeneratorTest are modified as such: - Instead of using a temporary directory for generated serde classes, they now write to the new codegen directory. - The names of all top level record schemas is changed to include the class and function name, in order to facilitate the identification of which serde class maps to which test. This is figured out automatically via a new utility function in FastSerdeTestsSupport. - FastGenericDeserializerGeneratorTest now includes 4 new primitive array tests which were previously untested: boolean, double, int and long. - The avro-fastserde build now deletes the content of the codegen directory before running, to ensure that if test schemas change, older serde classes that aren't used anymore will get purged. At the end of the build, .class files are also deleted.
- Loading branch information
Showing
113 changed files
with
10,747 additions
and
113 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
53 changes: 53 additions & 0 deletions
53
...VRO_1_4/Array_of_BOOLEAN_GenericDeserializer_5988037297456147388_5988037297456147388.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,53 @@ | ||
|
||
package com.linkedin.avro.fastserde.generated.deserialization.AVRO_1_4; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import com.linkedin.avro.fastserde.FastDeserializer; | ||
import org.apache.avro.Schema; | ||
import org.apache.avro.generic.GenericArray; | ||
import org.apache.avro.io.Decoder; | ||
|
||
public class Array_of_BOOLEAN_GenericDeserializer_5988037297456147388_5988037297456147388 | ||
implements FastDeserializer<List<Boolean>> | ||
{ | ||
|
||
private final Schema readerSchema; | ||
|
||
public Array_of_BOOLEAN_GenericDeserializer_5988037297456147388_5988037297456147388(Schema readerSchema) { | ||
this.readerSchema = readerSchema; | ||
} | ||
|
||
public List<Boolean> deserialize(List<Boolean> reuse, Decoder decoder) | ||
throws IOException | ||
{ | ||
List<Boolean> array738 = null; | ||
long chunkLen739 = (decoder.readArrayStart()); | ||
if (chunkLen739 > 0) { | ||
List<Boolean> arrayReuse740 = null; | ||
if ((reuse) instanceof List) { | ||
arrayReuse740 = ((List)(reuse)); | ||
} | ||
if (arrayReuse740 != (null)) { | ||
arrayReuse740 .clear(); | ||
array738 = arrayReuse740; | ||
} else { | ||
array738 = new org.apache.avro.generic.GenericData.Array<Boolean>(((int) chunkLen739), readerSchema); | ||
} | ||
do { | ||
for (int counter741 = 0; (counter741 <chunkLen739); counter741 ++) { | ||
Object arrayArrayElementReuseVar742 = null; | ||
if ((reuse) instanceof GenericArray) { | ||
arrayArrayElementReuseVar742 = ((GenericArray)(reuse)).peek(); | ||
} | ||
array738 .add((decoder.readBoolean())); | ||
} | ||
chunkLen739 = (decoder.arrayNext()); | ||
} while (chunkLen739 > 0); | ||
} else { | ||
array738 = new org.apache.avro.generic.GenericData.Array<Boolean>(0, readerSchema); | ||
} | ||
return array738; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...AVRO_1_4/Array_of_DOUBLE_GenericDeserializer_6064316435611861740_6064316435611861740.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,53 @@ | ||
|
||
package com.linkedin.avro.fastserde.generated.deserialization.AVRO_1_4; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import com.linkedin.avro.fastserde.FastDeserializer; | ||
import org.apache.avro.Schema; | ||
import org.apache.avro.generic.GenericArray; | ||
import org.apache.avro.io.Decoder; | ||
|
||
public class Array_of_DOUBLE_GenericDeserializer_6064316435611861740_6064316435611861740 | ||
implements FastDeserializer<List<Double>> | ||
{ | ||
|
||
private final Schema readerSchema; | ||
|
||
public Array_of_DOUBLE_GenericDeserializer_6064316435611861740_6064316435611861740(Schema readerSchema) { | ||
this.readerSchema = readerSchema; | ||
} | ||
|
||
public List<Double> deserialize(List<Double> reuse, Decoder decoder) | ||
throws IOException | ||
{ | ||
List<Double> array743 = null; | ||
long chunkLen744 = (decoder.readArrayStart()); | ||
if (chunkLen744 > 0) { | ||
List<Double> arrayReuse745 = null; | ||
if ((reuse) instanceof List) { | ||
arrayReuse745 = ((List)(reuse)); | ||
} | ||
if (arrayReuse745 != (null)) { | ||
arrayReuse745 .clear(); | ||
array743 = arrayReuse745; | ||
} else { | ||
array743 = new org.apache.avro.generic.GenericData.Array<Double>(((int) chunkLen744), readerSchema); | ||
} | ||
do { | ||
for (int counter746 = 0; (counter746 <chunkLen744); counter746 ++) { | ||
Object arrayArrayElementReuseVar747 = null; | ||
if ((reuse) instanceof GenericArray) { | ||
arrayArrayElementReuseVar747 = ((GenericArray)(reuse)).peek(); | ||
} | ||
array743 .add((decoder.readDouble())); | ||
} | ||
chunkLen744 = (decoder.arrayNext()); | ||
} while (chunkLen744 > 0); | ||
} else { | ||
array743 = new org.apache.avro.generic.GenericData.Array<Double>(0, readerSchema); | ||
} | ||
return array743; | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
.../AVRO_1_4/Array_of_FLOAT_GenericDeserializer_7282396011446356583_7282396011446356583.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,29 @@ | ||
|
||
package com.linkedin.avro.fastserde.generated.deserialization.AVRO_1_4; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import com.linkedin.avro.fastserde.ByteBufferBackedPrimitiveFloatList; | ||
import com.linkedin.avro.fastserde.FastDeserializer; | ||
import org.apache.avro.Schema; | ||
import org.apache.avro.io.Decoder; | ||
|
||
public class Array_of_FLOAT_GenericDeserializer_7282396011446356583_7282396011446356583 | ||
implements FastDeserializer<List<Float>> | ||
{ | ||
|
||
private final Schema readerSchema; | ||
|
||
public Array_of_FLOAT_GenericDeserializer_7282396011446356583_7282396011446356583(Schema readerSchema) { | ||
this.readerSchema = readerSchema; | ||
} | ||
|
||
public List<Float> deserialize(List<Float> reuse, Decoder decoder) | ||
throws IOException | ||
{ | ||
List<Float> array748 = null; | ||
array748 = ((List<Float> ) ByteBufferBackedPrimitiveFloatList.readPrimitiveFloatArray((reuse), (decoder))); | ||
return array748; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...on/AVRO_1_4/Array_of_INT_GenericDeserializer_3343716480540445685_3343716480540445685.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,53 @@ | ||
|
||
package com.linkedin.avro.fastserde.generated.deserialization.AVRO_1_4; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import com.linkedin.avro.fastserde.FastDeserializer; | ||
import org.apache.avro.Schema; | ||
import org.apache.avro.generic.GenericArray; | ||
import org.apache.avro.io.Decoder; | ||
|
||
public class Array_of_INT_GenericDeserializer_3343716480540445685_3343716480540445685 | ||
implements FastDeserializer<List<Integer>> | ||
{ | ||
|
||
private final Schema readerSchema; | ||
|
||
public Array_of_INT_GenericDeserializer_3343716480540445685_3343716480540445685(Schema readerSchema) { | ||
this.readerSchema = readerSchema; | ||
} | ||
|
||
public List<Integer> deserialize(List<Integer> reuse, Decoder decoder) | ||
throws IOException | ||
{ | ||
List<Integer> array749 = null; | ||
long chunkLen750 = (decoder.readArrayStart()); | ||
if (chunkLen750 > 0) { | ||
List<Integer> arrayReuse751 = null; | ||
if ((reuse) instanceof List) { | ||
arrayReuse751 = ((List)(reuse)); | ||
} | ||
if (arrayReuse751 != (null)) { | ||
arrayReuse751 .clear(); | ||
array749 = arrayReuse751; | ||
} else { | ||
array749 = new org.apache.avro.generic.GenericData.Array<Integer>(((int) chunkLen750), readerSchema); | ||
} | ||
do { | ||
for (int counter752 = 0; (counter752 <chunkLen750); counter752 ++) { | ||
Object arrayArrayElementReuseVar753 = null; | ||
if ((reuse) instanceof GenericArray) { | ||
arrayArrayElementReuseVar753 = ((GenericArray)(reuse)).peek(); | ||
} | ||
array749 .add((decoder.readInt())); | ||
} | ||
chunkLen750 = (decoder.arrayNext()); | ||
} while (chunkLen750 > 0); | ||
} else { | ||
array749 = new org.apache.avro.generic.GenericData.Array<Integer>(0, readerSchema); | ||
} | ||
return array749; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...n/AVRO_1_4/Array_of_LONG_GenericDeserializer_2055015354772118358_2055015354772118358.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,53 @@ | ||
|
||
package com.linkedin.avro.fastserde.generated.deserialization.AVRO_1_4; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import com.linkedin.avro.fastserde.FastDeserializer; | ||
import org.apache.avro.Schema; | ||
import org.apache.avro.generic.GenericArray; | ||
import org.apache.avro.io.Decoder; | ||
|
||
public class Array_of_LONG_GenericDeserializer_2055015354772118358_2055015354772118358 | ||
implements FastDeserializer<List<Long>> | ||
{ | ||
|
||
private final Schema readerSchema; | ||
|
||
public Array_of_LONG_GenericDeserializer_2055015354772118358_2055015354772118358(Schema readerSchema) { | ||
this.readerSchema = readerSchema; | ||
} | ||
|
||
public List<Long> deserialize(List<Long> reuse, Decoder decoder) | ||
throws IOException | ||
{ | ||
List<Long> array754 = null; | ||
long chunkLen755 = (decoder.readArrayStart()); | ||
if (chunkLen755 > 0) { | ||
List<Long> arrayReuse756 = null; | ||
if ((reuse) instanceof List) { | ||
arrayReuse756 = ((List)(reuse)); | ||
} | ||
if (arrayReuse756 != (null)) { | ||
arrayReuse756 .clear(); | ||
array754 = arrayReuse756; | ||
} else { | ||
array754 = new org.apache.avro.generic.GenericData.Array<Long>(((int) chunkLen755), readerSchema); | ||
} | ||
do { | ||
for (int counter757 = 0; (counter757 <chunkLen755); counter757 ++) { | ||
Object arrayArrayElementReuseVar758 = null; | ||
if ((reuse) instanceof GenericArray) { | ||
arrayArrayElementReuseVar758 = ((GenericArray)(reuse)).peek(); | ||
} | ||
array754 .add((decoder.readLong())); | ||
} | ||
chunkLen755 = (decoder.arrayNext()); | ||
} while (chunkLen755 > 0); | ||
} else { | ||
array754 = new org.apache.avro.generic.GenericData.Array<Long>(0, readerSchema); | ||
} | ||
return array754; | ||
} | ||
|
||
} |
90 changes: 90 additions & 0 deletions
90
...on/AVRO_1_4/Array_of_UNION_GenericDeserializer_585074122056792963_585074122056792963.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,90 @@ | ||
|
||
package com.linkedin.avro.fastserde.generated.deserialization.AVRO_1_4; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import com.linkedin.avro.fastserde.FastDeserializer; | ||
import org.apache.avro.Schema; | ||
import org.apache.avro.generic.GenericArray; | ||
import org.apache.avro.generic.IndexedRecord; | ||
import org.apache.avro.io.Decoder; | ||
import org.apache.avro.util.Utf8; | ||
|
||
public class Array_of_UNION_GenericDeserializer_585074122056792963_585074122056792963 | ||
implements FastDeserializer<List<IndexedRecord>> | ||
{ | ||
|
||
private final Schema readerSchema; | ||
private final Schema arrayArrayElemSchema772; | ||
private final Schema arrayElemOptionSchema775; | ||
private final Schema field777; | ||
|
||
public Array_of_UNION_GenericDeserializer_585074122056792963_585074122056792963(Schema readerSchema) { | ||
this.readerSchema = readerSchema; | ||
this.arrayArrayElemSchema772 = readerSchema.getElementType(); | ||
this.arrayElemOptionSchema775 = arrayArrayElemSchema772 .getTypes().get(1); | ||
this.field777 = arrayElemOptionSchema775 .getField("field").schema(); | ||
} | ||
|
||
public List<IndexedRecord> deserialize(List<IndexedRecord> reuse, Decoder decoder) | ||
throws IOException | ||
{ | ||
List<IndexedRecord> array768 = null; | ||
long chunkLen769 = (decoder.readArrayStart()); | ||
if (chunkLen769 > 0) { | ||
List<IndexedRecord> arrayReuse770 = null; | ||
if ((reuse) instanceof List) { | ||
arrayReuse770 = ((List)(reuse)); | ||
} | ||
if (arrayReuse770 != (null)) { | ||
arrayReuse770 .clear(); | ||
array768 = arrayReuse770; | ||
} else { | ||
array768 = new org.apache.avro.generic.GenericData.Array<IndexedRecord>(((int) chunkLen769), readerSchema); | ||
} | ||
do { | ||
for (int counter771 = 0; (counter771 <chunkLen769); counter771 ++) { | ||
Object arrayArrayElementReuseVar773 = null; | ||
if ((reuse) instanceof GenericArray) { | ||
arrayArrayElementReuseVar773 = ((GenericArray)(reuse)).peek(); | ||
} | ||
int unionIndex774 = (decoder.readIndex()); | ||
if (unionIndex774 == 0) { | ||
decoder.readNull(); | ||
} | ||
if (unionIndex774 == 1) { | ||
array768 .add(deserializerecord776(arrayArrayElementReuseVar773, (decoder))); | ||
} | ||
} | ||
chunkLen769 = (decoder.arrayNext()); | ||
} while (chunkLen769 > 0); | ||
} else { | ||
array768 = new org.apache.avro.generic.GenericData.Array<IndexedRecord>(0, readerSchema); | ||
} | ||
return array768; | ||
} | ||
|
||
public IndexedRecord deserializerecord776(Object reuse, Decoder decoder) | ||
throws IOException | ||
{ | ||
IndexedRecord record; | ||
if ((((reuse)!= null)&&((reuse) instanceof IndexedRecord))&&(((IndexedRecord)(reuse)).getSchema() == arrayElemOptionSchema775)) { | ||
record = ((IndexedRecord)(reuse)); | ||
} else { | ||
record = new org.apache.avro.generic.GenericData.Record(arrayElemOptionSchema775); | ||
} | ||
int unionIndex778 = (decoder.readIndex()); | ||
if (unionIndex778 == 0) { | ||
decoder.readNull(); | ||
} | ||
if (unionIndex778 == 1) { | ||
if (record.get(0) instanceof Utf8) { | ||
record.put(0, (decoder).readString(((Utf8) record.get(0)))); | ||
} else { | ||
record.put(0, (decoder).readString(null)); | ||
} | ||
} | ||
return record; | ||
} | ||
|
||
} |
Oops, something went wrong.