java.lang.Object
com.gpudb.Avro
Utility class containing static methods for encoding and decoding Avro binary objects.
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tdecode(Object typeDescriptor, ByteBuffer encodedObject) Decodes an Avro binary object.static <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> encodedObjects) Decodes a homogeneous list of Avro binary objects.static <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> encodedObjects, int start, int count) Decodes a homogeneous portion of a list of Avro binary objects.static <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> encodedObjects, int start, int count, int threadCount, ExecutorService executor) Decodes a homogeneous portion of a list of Avro binary objects, optionally using multiple threads, with or without a supplied executor.static <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> encodedObjects, int threadCount, ExecutorService executor) Decodes a homogeneous list of Avro binary objects, optionally using multiple threads and/or a supplied executor.static <T extends org.apache.avro.generic.IndexedRecord>
Tdecode(T object, ByteBuffer encodedObject) Decodes an Avro binary object into a pre-created destination object.static <T> ByteBufferencode(TypeObjectMap<T> typeObjectMap, T object) Encodes a non-Avro-compatible object into Avro binary format using the specified type object map.static <T> ArrayList<ByteBuffer> Encodes a list of Avro-compatible objects into Avro binary format.static <T extends org.apache.avro.generic.IndexedRecord>
ByteBufferencode(T object) Encodes an Avro-compatible object into Avro binary format.
Method Details
decode
public static <T extends org.apache.avro.generic.IndexedRecord> T decode(T object, ByteBuffer encodedObject) throws GPUdbException Decodes an Avro binary object into a pre-created destination object.Type Parameters:T- the type of object being decodedParameters:object- the destination objectencodedObject- the Avro binary objectReturns:the destination object (same asobjectparameter)Throws:GPUdbException- if a decoding error occursdecode
Decodes an Avro binary object.Type Parameters:T- the type of object being decodedParameters:typeDescriptor- type descriptor for the type of object being decodedencodedObject- the Avro binary objectReturns:the decoded objectThrows:IllegalArgumentException- iftypeDescriptoris not aSchema,Type,TypeObjectMap, orClassthat implementsIndexedRecordGPUdbException- if a decoding error occursGPUdbRuntimeException- if unable to instantiate the class specified bytypeDescriptordecode
public static <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> encodedObjects, int start, int count) throws GPUdbException Decodes a homogeneous portion of a list of Avro binary objects.Type Parameters:T- the type of objects being decodedParameters:typeDescriptor- type descriptor for the type of objects being decodedencodedObjects- list of Avro binary objectsstart- index of first object withinencodedObjectsto decodecount- number of objects withinencodedObjectsto decodeReturns:list of decoded objectsThrows:IndexOutOfBoundsException- ifstartis less than zero,countis less than zero, orstartpluscountexceeds the length ofencodedObjectsIllegalArgumentException- iftypeDescriptoris not aSchema,Type,TypeObjectMap, orClassthat implementsIndexedRecordGPUdbException- if a decoding error occursGPUdbRuntimeException- if unable to instantiate the class specified bytypeDescriptordecode
public static <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> encodedObjects, int start, int count, int threadCount, ExecutorService executor) throws GPUdbException Decodes a homogeneous portion of a list of Avro binary objects, optionally using multiple threads, with or without a supplied executor.Type Parameters:T- the type of objects being decodedParameters:typeDescriptor- type descriptor for the type of objects being decodedencodedObjects- list of Avro binary objectsstart- index of first object withinencodedObjectsto decodecount- number of objects withinencodedObjectsto decodethreadCount- number of threads to use for decoding.executor- optional executor responsible for managing threads;nullto create threads on demandReturns:list of decoded objectsThrows:IndexOutOfBoundsException- ifstartis less than zero,countis less than zero, orstartpluscountexceeds the length ofencodedObjectsIllegalArgumentException- ifthreadCountis less than one ortypeDescriptoris not aSchema,Type,TypeObjectMap, orClassthat implementsIndexedRecordGPUdbException- if a decoding error occursGPUdbRuntimeException- if unable to instantiate the class specified bytypeDescriptordecode
public static <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> encodedObjects) throws GPUdbException Decodes a homogeneous list of Avro binary objects.Type Parameters:T- the type of objects being decodedParameters:typeDescriptor- type descriptor for the type of objects being decodedencodedObjects- list of Avro binary objectsReturns:list of decoded objectsThrows:IllegalArgumentException- iftypeDescriptoris not aType, aTypeObjectMap, aSchema, or aClassthat implementsIndexedRecordGPUdbException- if a decoding error occursGPUdbRuntimeException- if unable to instantiate the class specified bytypeDescriptordecode
public static <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> encodedObjects, int threadCount, ExecutorService executor) throws GPUdbException Decodes a homogeneous list of Avro binary objects, optionally using multiple threads and/or a supplied executor.Type Parameters:T- the type of objects being decodedParameters:typeDescriptor- type descriptor for the type of objects being decodedencodedObjects- list of Avro binary objectsthreadCount- number of threads to use for decoding.executor- optional executor responsible for managing threads;nullto create threads on demandReturns:list of decoded objectsThrows:IllegalArgumentException- ifthreadCountis less than one ortypeDescriptoris not aType, aTypeObjectMap, aSchema, or aClassthat implementsIndexedRecordGPUdbException- if a decoding error occursGPUdbRuntimeException- if unable to instantiate the class specified bytypeDescriptorencode
public static <T extends org.apache.avro.generic.IndexedRecord> ByteBuffer encode(T object) throws GPUdbException Encodes an Avro-compatible object into Avro binary format.Type Parameters:T- the type of object being encodedParameters:object- the object to encodeReturns:the encoded objectThrows:GPUdbException- if an encoding error occursencode
Encodes a non-Avro-compatible object into Avro binary format using the specified type object map.Type Parameters:T- the type of object being encodedParameters:typeObjectMap- the type object mapobject- the object to encodeReturns:the encoded objectThrows:GPUdbException- if an encoding error occursencode
Encodes a list of Avro-compatible objects into Avro binary format.Type Parameters:T- the type of objects being encodedParameters:objects- list of objects to encodeReturns:list of encoded objectsThrows:GPUdbException- if an encoding error occurs