Skip to content

Commit

Permalink
Some minor code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisso-rtb committed Jan 15, 2024
1 parent 1097b2d commit 0db5b43
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import com.linkedin.avro.fastserde.FastDeserializer;
import com.linkedin.avro.fastserde.FastGenericDeserializerGenerator;
import com.linkedin.avro.fastserde.FastGenericSerializerGenerator;
import com.linkedin.avro.fastserde.FastSerdeCache;
import com.linkedin.avro.fastserde.FastSerializer;
import com.linkedin.avro.fastserde.FastSpecificDeserializerGenerator;
import com.linkedin.avro.fastserde.FastSpecificSerializerGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.linkedin.avro.fastserde.customized.DatumReaderCustomization;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.avro.io.Decoder;

import static com.linkedin.avro.fastserde.customized.DatumReaderCustomization.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public T read(T reuse, Decoder in) throws IOException {
fastDeserializer = getFastDeserializerFromCache(cache, writerSchema, readerSchema, modelData, customization);
if (fastDeserializer.hasDynamicClassGenerationDone()) {
if (fastDeserializer.isBackedByGeneratedClass()) {
/**
/*
* Runtime class generation is done successfully, so cache it.
*/
cachedFastDeserializer.compareAndSet(null, fastDeserializer);
Expand All @@ -108,7 +108,7 @@ public T read(T reuse, Decoder in) throws IOException {
+ readerSchema + "], writer schema: [" + writerSchema + "]");
}
} else {
/**
/*
* Runtime class generation fails, so this class will cache a newly generated cold deserializer, which will
* honer {@link FastSerdeCache#isFailFast()}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
import org.apache.avro.generic.CustomizedSpecificDatumWriter;
import com.linkedin.avro.fastserde.customized.DatumReaderCustomization;
import com.linkedin.avro.fastserde.customized.DatumWriterCustomization;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.IOException;
import org.apache.avro.Schema;
import org.apache.avro.generic.ColdGenericDatumReader;
import org.apache.avro.generic.ColdSpecificDatumReader;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.io.DatumWriter;
import org.apache.avro.io.Decoder;
import org.apache.avro.io.Encoder;
import org.apache.avro.specific.SpecificData;
Expand Down Expand Up @@ -50,7 +46,7 @@ public FastDeserializerWithAvroSpecificImpl(Schema writerSchema, Schema readerSc
SpecificData modelData, DatumReaderCustomization customization, boolean failFast, boolean runtimeClassGenerationDone) {
this.customization = customization == null ? DatumReaderCustomization.DEFAULT_DATUM_READER_CUSTOMIZATION : customization;
this.customizedDatumReader = Utils.isAvro14() ?
new CustomizedSpecificDatumReaderForAvro14(writerSchema, readerSchema, this.customization) :
new CustomizedSpecificDatumReaderForAvro14<>(writerSchema, readerSchema, this.customization) :
new CustomizedSpecificDatumReader<>(writerSchema, readerSchema, modelData, this.customization);
this.failFast = failFast;
this.runtimeClassGenerationDone = runtimeClassGenerationDone;
Expand Down Expand Up @@ -100,7 +96,7 @@ public FastDeserializerWithAvroGenericImpl(Schema writerSchema, Schema readerSch
GenericData modelData, DatumReaderCustomization customization, boolean failFast, boolean runtimeClassGenerationDone) {
this.customization = customization == null ? DatumReaderCustomization.DEFAULT_DATUM_READER_CUSTOMIZATION : customization;
this.customizedDatumReader = Utils.isAvro14() ?
new CustomizedGenericDatumReaderForAvro14(writerSchema, readerSchema, this.customization) :
new CustomizedGenericDatumReaderForAvro14<>(writerSchema, readerSchema, this.customization) :
new CustomizedGenericDatumReader<>(writerSchema, readerSchema, modelData, this.customization);

this.failFast = failFast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private <T> T instantiate(Class<T> clazz, Schema of) {
//TODO - look for both old and new SchemaConstructable ctrs 1st
try {
Constructor<T> noArgCtr = clazz.getDeclaredConstructor(NO_ARGS);
return noArgCtr.newInstance(NO_ARGS);
return noArgCtr.newInstance();
} catch (Exception e) {
throw new IllegalStateException("while trying to instantiate a(n) " + clazz.getName(), e);
}
Expand Down

0 comments on commit 0db5b43

Please sign in to comment.