Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ public class FastDeserializerGenerator<T> extends FastDeserializerGeneratorBase<
private Map<String, JMethod> skipMethodMap = new HashMap<>();
private Map<JMethod, Set<Class<? extends Exception>>> exceptionFromMethodMap = new HashMap<>();

FastDeserializerGenerator(boolean useGenericTypes, Schema writer, Schema reader, File destination,
public FastDeserializerGenerator(boolean useGenericTypes, Schema writer, Schema reader, File destination,
ClassLoader classLoader, String compileClassPath) {
super(useGenericTypes, writer, reader, destination, classLoader, compileClassPath);
}

public FastDeserializerGenerator(boolean useGenericTypes, Schema writer, Schema reader, File destination,
ClassLoader classLoader, String compileClassPath, Class defaultStringClass) {
super(useGenericTypes, writer, reader, destination, classLoader, compileClassPath, defaultStringClass);
}

public FastDeserializer<T> generateDeserializer() {
String className = getClassName(writer, reader, useGenericTypes ? "Generic" : "Specific");
JPackage classPackage = codeModel._package(generatedPackageName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ public abstract class FastDeserializerGeneratorBase<T> extends FastSerdeBase {
protected final Schema writer;
protected final Schema reader;

FastDeserializerGeneratorBase(boolean useGenericTypes, Schema writer, Schema reader, File destination, ClassLoader classLoader,
public FastDeserializerGeneratorBase(boolean useGenericTypes, Schema writer, Schema reader, File destination, ClassLoader classLoader,
String compileClassPath) {
super("deserialization", useGenericTypes, Utf8.class, destination, classLoader, compileClassPath, false);
this(useGenericTypes, writer, reader, destination, classLoader, compileClassPath, Utf8.class);
}

public FastDeserializerGeneratorBase(boolean useGenericTypes, Schema writer, Schema reader, File destination, ClassLoader classLoader,
String compileClassPath, Class defaultStringClass) {
super("deserialization", useGenericTypes, defaultStringClass, destination, classLoader, compileClassPath, false);
this.writer = writer;
this.reader = reader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.avro.io.Encoder;
import org.apache.avro.specific.SpecificDatumReader;
import org.apache.avro.specific.SpecificDatumWriter;
import org.apache.avro.util.Utf8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -66,6 +67,8 @@ public final class FastSerdeCache {

private Optional<String> compileClassPath;

private Class defaultStringClass = Utf8.class;

/**
*
* @param compileClassPathSupplier
Expand Down Expand Up @@ -123,6 +126,11 @@ public FastSerdeCache(Executor executorService) {
this.compileClassPath = Optional.empty();
}

public FastSerdeCache(Executor executorService, Class defaultStringClass) {
this(executorService);
this.defaultStringClass = defaultStringClass;
}

private FastSerdeCache() {
this((Executor) null);
}
Expand Down Expand Up @@ -355,7 +363,7 @@ private static String getSchemaKey(Schema writerSchema, Schema readerSchema) {
public FastDeserializer<?> buildFastSpecificDeserializer(Schema writerSchema, Schema readerSchema) {
FastSpecificDeserializerGenerator<?> generator =
new FastSpecificDeserializerGenerator<>(writerSchema, readerSchema, classesDir, classLoader,
compileClassPath.orElse(null));
compileClassPath.orElse(null), defaultStringClass);
FastDeserializer<?> fastDeserializer = generator.generateDeserializer();

if (LOGGER.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

import java.io.File;
import org.apache.avro.Schema;
import org.apache.avro.util.Utf8;


public final class FastSpecificDeserializerGenerator<T> extends FastDeserializerGenerator<T> {
public class FastSpecificDeserializerGenerator<T> extends FastDeserializerGenerator<T> {

FastSpecificDeserializerGenerator(Schema writer, Schema reader, File destination, ClassLoader classLoader,
public FastSpecificDeserializerGenerator(Schema writer, Schema reader, File destination, ClassLoader classLoader,
String compileClassPath) {
super(false, writer, reader, destination, classLoader, compileClassPath);
this(writer, reader, destination, classLoader, compileClassPath, Utf8.class);
}

public FastSpecificDeserializerGenerator(Schema writer, Schema reader, File destination, ClassLoader classLoader,
String compileClassPath, Class defaultStringClass) {
super(false, writer, reader, destination, classLoader, compileClassPath, defaultStringClass);
}
}