java.lang.Object
com.gpudb.TypeObjectMap<T>
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAn accessor that returns a value from an object.static final classA factory that uses reflection to create new instances of the specified class.static final classA combinedTypeObjectMap.AccessorandTypeObjectMap.Mutatorthat provides access to a specified field using reflection, converting the value to and from the data type of a specified GPUdbcolumn.static final classA combinedTypeObjectMap.AccessorandTypeObjectMap.Mutatorthat provides access to a field via specified get and set methods using reflection, converting the value to and from the data type of a specified GPUdbcolumn.static interfaceA factory that creates new instances of the specified class.static final classA combinedTypeObjectMap.AccessorandTypeObjectMap.Mutatorthat provides access to a specified field using reflection.static final classA combinedTypeObjectMap.AccessorandTypeObjectMap.Mutatorthat provides access to a field via specified get and set methods using reflection.static interfaceA mutator that sets a value in an object.Constructor Summary
ConstructorsConstructorDescriptionTypeObjectMap(Type type, Class<T> objectClass, TypeObjectMap.Factory<T> factory, List<TypeObjectMap.Accessor> accessors, List<TypeObjectMap.Mutator> mutators) Creates aTypeObjectMapfor the specifiedTypeand class.Method Summary
Modifier and TypeMethodDescriptioncreateType(GPUdb gpudb) Creates a type in GPUdb based on the metadata in the specifiedTypeObjectMapobject and returns the type ID for reference.static <T> TypeObjectMap<T> Creates aTypeObjectMapbased on the specified class.static <T> TypeObjectMap<T> Creates aTypeObjectMapbased on the specified class with the specified type label and overrides.static <T> TypeObjectMap<T> Creates aTypeObjectMapbased on the specifiedTypeand class.static <T> TypeObjectMap<T> Creates aTypeObjectMapbased on the specifiedTypeand class with the specified overrides.Returns the value of the column at the specified index from the specified object.Class<?> Returns the class of the type object map.org.apache.avro.SchemaReturns the Avro record schema of the type object map.getType()Returns the GPUdbTypeof the type object map.Creates a new instance of the class specified when the type object map was created.voidSets the value of the column at the specified index in the specified object.
Constructor Details
TypeObjectMap
public TypeObjectMap(Type type, Class<T> objectClass, TypeObjectMap.Factory<T> factory, List<TypeObjectMap.Accessor> accessors, List<TypeObjectMap.Mutator> mutators) Creates aTypeObjectMapfor the specifiedTypeand class. The specifiedfactorymust create new instances of the class, and the specifiedaccessorsandmutatorsmust get and set the values in instances of the class corresponding to the columns in the type (the lists must be in column order and use the data types of the columns rather than any underlying fields in the class).Parameters:type- the typeobjectClass- the classfactory- factory that creates instances of the classaccessors- accessors that get column values from the classmutators- mutators that set column values in the class
Method Details
fromClass
Creates aTypeObjectMapbased on the specified class. All public fields and get/set method pairs with supported data types will be used as columns and ordered by name.Type Parameters:T- the classParameters:objectClass- the classReturns:the type object mapThrows:IllegalArgumentException- if the specified class is not publicfromClass
public static <T> TypeObjectMap<T> fromClass(Class<T> objectClass, String label, Map<String, Type.Column> columnOverrides) Creates aTypeObjectMapbased on the specified class with the specified type label and overrides. By default, all public fields and get/set method pairs with supported data types will be used as columns and ordered by name, but column names, data types and properties can be overridden with entries in thecolumnOverridesmap. Each entry in the map must consist of the name of a field in the specified class (or for method pairs, the name following “get” and “set”) as a key, and aType.Columnobject providing the name, data type, and properties to use for the corresponding column as a value. To prevent a column from being created for a field or method pair, use a value ofnull.Type Parameters:T- the classParameters:objectClass- the classlabel- the type label (nullto use class name)columnOverrides- the map of overrides (nullfor none)Returns:the type object mapThrows:IllegalArgumentException- if the specified class is not publicfromType
Creates aTypeObjectMapbased on the specifiedTypeand class. Each column in the type is mapped to a public field of the same name, or in the absence of such a field, a get/set method pair where the name following “get” and “set” is the same.Type Parameters:T- the classParameters:type- the typeobjectClass- the classReturns:the type object mapThrows:IllegalArgumentException- if the specified class is not public, a column exists in the specified type that has no matching field or method pair in the class, or a column has a type that is incompatible with the matching field or method pairfromType
public static <T> TypeObjectMap<T> fromType(Type type, Class<T> objectClass, Map<String, String> columnOverrides) Creates aTypeObjectMapbased on the specifiedTypeand class with the specified overrides. By default, each column is mapped to a public field of the same name, or in the absence of such a field, a get/set method pair where the name following “get” and “set” is the same, but field and method pair names can be overridden with entries in thecolumnOverridesmap. Each entry in the map must consist of the name of a column in the specified type as a key, and the name of the corresponding field (or for method pairs, the name following “get” and “set”) as a value.Type Parameters:T- the classParameters:type- the typeobjectClass- the classcolumnOverrides-Returns:the type object mapThrows:IllegalArgumentException- if the specified class is not public, a column exists in the specified type that has no matching field or method pair in the class, or a column has a type that is incompatible with the matching field or method pairgetSchema
public org.apache.avro.Schema getSchema()Returns the Avro record schema of the type object map.Returns:the Avro record schema of the type object mapcreateType
Creates a type in GPUdb based on the metadata in the specifiedTypeObjectMapobject 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 type object map will also automatically be added as aknown type and known type object mapin the specifiedGPUdbinstance.Parameters:gpudb- theGPUdbinstance in which to create the typeReturns:the type ID of the type in GPUdbThrows:GPUdbException- if an error occurs while creating the type