Skip to content

Commit

Permalink
Make avro-fastserde depend on helper module instead of avro-migration…
Browse files Browse the repository at this point in the history
…-helper module (#33)

Also renamed 3 Avro19SchemaNormalization files to SchemaNormalization, deleted 3 SchemaNormalization classes and merged them into helper:helper-common module. The implementation in SchemaNormalization is also overrided by the implementation in apache avro 1.9.

Co-authored-by: Min Huang <mnhuang@linkedin.com>
  • Loading branch information
huangminchn and huangminchn authored Mar 23, 2020
1 parent a29abb9 commit 9c499da
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 488 deletions.
4 changes: 2 additions & 2 deletions avro-fastserde/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (USE_AVRO_14) {
}

dependencies {
compile project(":avro-migration-helper")
compile project(":helper:helper")

compile "org.slf4j:slf4j-log4j12:1.7.14"
compile "org.apache.commons:commons-lang3:3.4"
Expand Down Expand Up @@ -82,7 +82,7 @@ for (String avroVersion : avroVersions) {
}

classpath = project.sourceSets.test.runtimeClasspath.filter {
File file -> !(file.name.contains("avro") && !file.name.contains("avro-migration-helper"))
File file -> !(file.name.contains("avro") && !file.name.contains("helper"))
}.plus (configurations."avro${avroVersion}")

def gradleIsFun = avroVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avro.compatibility.AvroVersion;
import com.linkedin.avro.compatibility.SchemaNormalization;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import com.linkedin.avroutil1.compatibility.AvroVersion;
import com.linkedin.avroutil1.compatibility.SchemaNormalization;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avro.fastserde.generated.avro.TestEnum;
import com.linkedin.avro.fastserde.generated.avro.TestRecord;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.avro.Schema;
Expand Down Expand Up @@ -36,7 +36,7 @@ public void shouldCreateSpecificDatumWriter() throws IOException, InterruptedExc

// when
fastSpecificDatumWriter.write(testRecord,
AvroCompatibilityHelper.newBufferedBinaryEncoder(new ByteArrayOutputStream()));
AvroCompatibilityHelper.newBinaryEncoder(new ByteArrayOutputStream(), true, null));

// then
FastSerializer<TestRecord> fastSpecificSerializer =
Expand All @@ -58,7 +58,7 @@ public void shouldCreateGenericDatumReader() throws IOException, InterruptedExce
record.put("test", "test");

// when
fastGenericDatumReader.write(record, AvroCompatibilityHelper.newBufferedBinaryEncoder(new ByteArrayOutputStream()));
fastGenericDatumReader.write(record, AvroCompatibilityHelper.newBinaryEncoder(new ByteArrayOutputStream(), true, null));

// then
FastSerializer<GenericRecord> fastGenericSerializer =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avro.fastserde.generated.avro.DefaultsEnum;
import com.linkedin.avro.fastserde.generated.avro.DefaultsFixed;
import com.linkedin.avro.fastserde.generated.avro.DefaultsNewEnum;
import com.linkedin.avro.fastserde.generated.avro.DefaultsSubRecord;
import com.linkedin.avro.fastserde.generated.avro.DefaultsTestRecord;
import com.linkedin.avro.fastserde.generated.avro.TestRecord;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -127,7 +127,7 @@ private static Decoder getDecoder(byte[] bytes) {

private static byte[] serialize(GenericRecord record, Schema schema) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Encoder encoder = AvroCompatibilityHelper.newBufferedBinaryEncoder(baos);
Encoder encoder = AvroCompatibilityHelper.newBinaryEncoder(baos, true, null);
DatumWriter datumWriter = new GenericDatumWriter(schema);
datumWriter.write(record, encoder);
encoder.flush();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.File;
import java.io.IOException;
import java.net.URL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.net.URL;
Expand Down Expand Up @@ -408,7 +408,7 @@ public <T extends GenericContainer> Decoder dataAsBinaryDecoder(T data) {

public <T> Decoder dataAsBinaryDecoder(T data, Schema schema) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Encoder binaryEncoder = AvroCompatibilityHelper.newBufferedBinaryEncoder(baos); //new BinaryEncoder(baos);
Encoder binaryEncoder = AvroCompatibilityHelper.newBinaryEncoder(baos, true, null); //new BinaryEncoder(baos);

try {
FastGenericSerializerGenerator<T> fastGenericSerializerGenerator =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -101,7 +101,7 @@ public static <T extends GenericContainer> Decoder genericDataAsDecoder(T data)

public static <T> Decoder genericDataAsDecoder(T data, Schema schema) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Encoder binaryEncoder = AvroCompatibilityHelper.newBufferedBinaryEncoder(baos);
Encoder binaryEncoder = AvroCompatibilityHelper.newBinaryEncoder(baos, true, null);

try {
GenericDatumWriter<T> writer = new GenericDatumWriter<>(schema);
Expand All @@ -120,7 +120,7 @@ public static <T extends SpecificRecord> Decoder specificDataAsDecoder(T record)

public static <T> Decoder specificDataAsDecoder(T record, Schema schema) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Encoder binaryEncoder = AvroCompatibilityHelper.newBufferedBinaryEncoder(baos);
Encoder binaryEncoder = AvroCompatibilityHelper.newBinaryEncoder(baos, true, null);

try {
SpecificDatumWriter<T> writer = new SpecificDatumWriter<>(schema);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avro.fastserde.generated.avro.SubRecord;
import com.linkedin.avro.fastserde.generated.avro.TestEnum;
import com.linkedin.avro.fastserde.generated.avro.TestFixed;
import com.linkedin.avro.fastserde.generated.avro.TestRecord;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.File;
import java.io.IOException;
import java.net.URL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avro.fastserde.generated.avro.SubRecord;
import com.linkedin.avro.fastserde.generated.avro.TestEnum;
import com.linkedin.avro.fastserde.generated.avro.TestFixed;
import com.linkedin.avro.fastserde.generated.avro.TestRecord;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.net.URL;
Expand Down Expand Up @@ -361,7 +361,7 @@ public <T extends GenericContainer> Decoder dataAsDecoder(T data) {

public <T> Decoder dataAsDecoder(T data, Schema schema) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Encoder binaryEncoder = AvroCompatibilityHelper.newBufferedBinaryEncoder(baos);
Encoder binaryEncoder = AvroCompatibilityHelper.newBinaryEncoder(baos, true, null);

try {
FastSpecificSerializerGenerator<T> fastSpecificSerializerGenerator =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.linkedin.avro.fastserde;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avro.fastserde.generated.avro.AnotherSubRecord;
import com.linkedin.avro.fastserde.generated.avro.StringableRecord;
import com.linkedin.avro.fastserde.generated.avro.StringableSubRecord;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -189,7 +189,7 @@ public void deserializeStringableFields(Boolean whetherUseFastDeserializer)

public <T> Decoder writeWithFastAvro(T data, Schema schema) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Encoder binaryEncoder = AvroCompatibilityHelper.newBufferedBinaryEncoder(baos);
Encoder binaryEncoder = AvroCompatibilityHelper.newBinaryEncoder(baos, true, null);

try {
FastSpecificSerializerGenerator<T> fastSpecificSerializerGenerator =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.avro.fastserde.micro.benchmark;

import com.linkedin.avro.compatibility.AvroCompatibilityHelper;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.avro.Schema;
Expand All @@ -22,7 +22,7 @@ protected AvroGenericSerializer(DatumWriter datumWriter) {

public byte[] serialize(K object) throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
Encoder encoder = AvroCompatibilityHelper.newBufferedBinaryEncoder(output);
Encoder encoder = AvroCompatibilityHelper.newBinaryEncoder(output, true, null);
try {
datumWriter.write(object, encoder);
encoder.flush();
Expand All @@ -45,7 +45,7 @@ public byte[] serializeObjects(Iterable<K> objects) throws Exception {
}

private byte[] serializeObjects(Iterable<K> objects, ByteArrayOutputStream output) throws Exception {
Encoder encoder = AvroCompatibilityHelper.newBufferedBinaryEncoder(output);
Encoder encoder = AvroCompatibilityHelper.newBinaryEncoder(output, true, null);
try {
objects.forEach(object -> {
try {
Expand Down
Loading

0 comments on commit 9c499da

Please sign in to comment.