Package com.gpudb
Class RecordObject
- java.lang.Object
-
- com.gpudb.RecordBase
-
- com.gpudb.RecordObject
-
- All Implemented Interfaces:
Record,org.apache.avro.generic.GenericContainer,org.apache.avro.generic.IndexedRecord
public abstract class RecordObject extends RecordBase
Abstract base class for objects that containRecorddata with a schema defined at compile time. Derived classes should correspond to a GPUdb type and contain public fields, annotated withRecordObject.Column, that correspond to columns in that type. TheRecordObject.Typeannotation may also be applied to derived classes to provide additional information about the type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceRecordObject.ColumnIndicates that a public field is a GPUdb type column.static interfaceRecordObject.TypeProvides additional information about a GPUdb type.
-
Constructor Summary
Constructors Modifier Constructor Description protectedRecordObject()Creates a new record object instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringcreateType(Class<? extends RecordObject> type, GPUdb gpudb)Creates a type in GPUdb based on the metadata in the specifiedRecordObjectclass and returns the type ID for reference.Objectget(int index)Returns the value of the specified field.static org.apache.avro.SchemagetSchema(Class<? extends RecordObject> type)Gets the Avro record schema corresponding to the metadata in the specifiedRecordObjectclass.TypegetType()Returns the GPUdbTypeof the record.static TypegetType(Class<? extends RecordObject> type)Gets theRecordObject.Typeobject corresponding to the metadata in the specifiedRecordObjectclass.voidput(int index, Object value)Sets the value of the specified field.-
Methods inherited from class com.gpudb.RecordBase
equals, get, getArray, getArray, getBytes, getBytes, getDataMap, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getJson, getJson, getLong, getLong, getSchema, getString, getString, getVector, getVector, hashCode, put, putArray, putArray, putBytes, putBytes, putDateTime, putDateTime, putDateTime, putDateTime, putDecimal, putJson, putJson, putVector, putVector, toString
-
-
-
-
Method Detail
-
getType
public static Type getType(Class<? extends RecordObject> type)
Gets theRecordObject.Typeobject corresponding to the metadata in the specifiedRecordObjectclass.- Parameters:
type- theRecordObjectclass from which to obtain metadata- Returns:
- the corresponding
RecordObject.Typeobject
-
getSchema
public static org.apache.avro.Schema getSchema(Class<? extends RecordObject> type)
Gets the Avro record schema corresponding to the metadata in the specifiedRecordObjectclass.- Parameters:
type- theRecordObjectclass from which to obtain metadata- Returns:
- the corresponding Avro record schema
-
createType
public static String createType(Class<? extends RecordObject> type, GPUdb gpudb) throws GPUdbException
Creates a type in GPUdb based on the metadata in the specifiedRecordObjectclass and returns the type ID for reference. If an identical type already exists in GPUdb, the type ID of the existing type will be returned and no new type will be created. The specified class will also automatically be added as aknown typein the specifiedGPUdbinstance.- Parameters:
type- theRecordObjectclass from which to obtain metadatagpudb- theGPUdbinstance in which to create the type- Returns:
- the type ID of the type in GPUdb
- Throws:
GPUdbException- if an error occurs while creating the type
-
getType
public Type getType()
Description copied from interface:RecordReturns the GPUdbTypeof the record.- Returns:
- the GPUdb type
-
get
public Object get(int index)
Description copied from interface:RecordReturns the value of the specified field.- Parameters:
index- the index of the field- Returns:
- the value of the field
-
-