Skip to content

Commit

Permalink
ISPN-4116 Upgrade Apache Avro to 1.7.5, and so converge the dependenc…
Browse files Browse the repository at this point in the history
…y usage

Also improve our implementation a bit by using the new Factory static helpers
  • Loading branch information
Sanne committed Mar 14, 2014
1 parent 6878262 commit 647d608
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/hotrod-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<scope>provided</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import org.apache.avro.io.BinaryEncoder;
import org.apache.avro.io.Decoder;
import org.apache.avro.io.DecoderFactory;
import org.apache.avro.io.DirectBinaryEncoder;
import org.apache.avro.io.Encoder;
import org.apache.avro.io.EncoderFactory;
import org.apache.avro.util.Utf8;
import org.infinispan.commons.CacheException;
import org.infinispan.commons.io.ByteBuffer;
Expand Down Expand Up @@ -74,6 +76,9 @@ public class ApacheAvroMarshaller extends AbstractMarshaller {
private static final MarshallableType DOUBLE_ARRAY_TYPE = new ArrayMarshallableType<Double>(DOUBLE_ARRAY_SCHEMA, Double.class, 11);
private static final MarshallableType FLOAT_ARRAY_TYPE = new ArrayMarshallableType<Float>(FLOAT_ARRAY_SCHEMA, Float.class, 12);
private static final MarshallableType BOOLEAN_ARRAY_TYPE = new ArrayMarshallableType<Boolean>(BOOLEAN_ARRAY_SCHEMA, Boolean.class, 13);
private static final EncoderFactory AVRO_ENCODER_FACTORY = EncoderFactory.get();
private static final DecoderFactory AVRO_DECODER_FACTORY = DecoderFactory.get();

private final MarshallableType listType = new ListMarshallableType(14, this);
private final MarshallableType mapType = new MapMarshallableType(15, this);
private final MarshallableType setType = new SetMarshallableType(16, this);
Expand Down Expand Up @@ -104,7 +109,7 @@ private MarshallableType getType(int type) {
@Override
protected ByteBuffer objectToBuffer(Object o, int estimatedSize) throws IOException {
ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(estimatedSize);
Encoder encoder = new BinaryEncoder(baos);
Encoder encoder = AVRO_ENCODER_FACTORY.directBinaryEncoder(baos, null);
objectToBuffer(o, encoder);
return new ByteBufferImpl(baos.getRawBuffer(), 0, baos.size());
}
Expand Down Expand Up @@ -140,9 +145,7 @@ private void objectToBuffer(Object o, Encoder encoder) throws IOException {

@Override
public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException {
DecoderFactory factory = new DecoderFactory(); // TODO: Could this be cached?
InputStream is = new ByteArrayInputStream(buf, offset, length);
Decoder decoder = factory.createBinaryDecoder(is, null);
Decoder decoder = AVRO_DECODER_FACTORY.binaryDecoder(buf, offset, length, null);
return objectFromByteBuffer(decoder);
}

Expand Down
4 changes: 2 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<version.arquillian>1.0.3.Final</version.arquillian>
<version.arquillian.container.managed>8.0.0.Beta1</version.arquillian.container.managed>
<version.arquillian.container.weld>1.0.0.CR3</version.arquillian.container.weld>
<version.avro>1.3.3</version.avro>
<version.avro>1.7.5</version.avro>
<version.c3p0>0.9.1.2</version.c3p0>
<version.cdi>1.0-SP4</version.cdi>
<version.com.intellij.forms_rt>6.0.5</version.com.intellij.forms_rt>
Expand Down Expand Up @@ -452,7 +452,7 @@
<version>${version.commons.math}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>${version.avro}</version>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
</exclusions>
Expand Down

0 comments on commit 647d608

Please sign in to comment.