Package com.linkedin.venice.serializer
Class AvroSerializer<K>
- java.lang.Object
-
- com.linkedin.venice.serializer.AvroSerializer<K>
-
- All Implemented Interfaces:
RecordSerializer<K>
- Direct Known Subclasses:
FastAvroSerializer
,MapOrderPreservingFastSerializer
,MapOrderPreservingSerializer
,VsonAvroGenericSerializer
public class AvroSerializer<K> extends java.lang.Object implements RecordSerializer<K>
AvroSerializer
provides the functionality to serialize objects by using Avro.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AvroSerializer(org.apache.avro.io.DatumWriter<K> genericDatumWriter, org.apache.avro.io.DatumWriter<K> specificDatumWriter)
protected
AvroSerializer(org.apache.avro.io.DatumWriter<K> genericDatumWriter, org.apache.avro.io.DatumWriter<K> specificDatumWriter, boolean buffered)
AvroSerializer(org.apache.avro.Schema schema)
AvroSerializer(org.apache.avro.Schema schema, boolean buffered)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
serialize(K object)
byte[]
serializeObjects(java.lang.Iterable<K> objects)
byte[]
serializeObjects(java.lang.Iterable<K> objects, java.nio.ByteBuffer prefix)
Serialize a list of objects and put the prefix before the serialized objects.protected byte[]
serializeObjects(java.lang.Iterable<K> objects, org.apache.avro.io.BinaryEncoder reusedEncoder, java.io.ByteArrayOutputStream outputStream)
protected void
write(K object, org.apache.avro.io.Encoder encoder)
-
-
-
Constructor Detail
-
AvroSerializer
public AvroSerializer(org.apache.avro.Schema schema)
-
AvroSerializer
public AvroSerializer(org.apache.avro.Schema schema, boolean buffered)
-
AvroSerializer
protected AvroSerializer(org.apache.avro.io.DatumWriter<K> genericDatumWriter, org.apache.avro.io.DatumWriter<K> specificDatumWriter)
-
-
Method Detail
-
serialize
public byte[] serialize(K object) throws VeniceException
- Specified by:
serialize
in interfaceRecordSerializer<K>
- Throws:
VeniceException
-
serializeObjects
public byte[] serializeObjects(java.lang.Iterable<K> objects) throws VeniceException
- Specified by:
serializeObjects
in interfaceRecordSerializer<K>
- Throws:
VeniceException
-
serializeObjects
public byte[] serializeObjects(java.lang.Iterable<K> objects, java.nio.ByteBuffer prefix) throws VeniceException
Serialize a list of objects and put the prefix before the serialized objects. This function could avoid unnecessary byte array copy when you want to serialize two different kinds of objects together. Essentially, the {@param prefix} will be the serialized byte array of the first kind of objects.- Specified by:
serializeObjects
in interfaceRecordSerializer<K>
- Parameters:
objects
-prefix
-- Returns:
- Throws:
VeniceException
-
serializeObjects
protected byte[] serializeObjects(java.lang.Iterable<K> objects, org.apache.avro.io.BinaryEncoder reusedEncoder, java.io.ByteArrayOutputStream outputStream) throws VeniceException
- Throws:
VeniceException
-
write
protected void write(K object, org.apache.avro.io.Encoder encoder) throws java.io.IOException
- Throws:
java.io.IOException
-
-