public final class Type extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Type.Column
Immutable collection of metadata about a column that is part of a GPUdb
type.
|
Constructor and Description |
---|
Type(List<Type.Column> columns)
Creates a
Type object with the specified column metadata and an
empty type label. |
Type(String typeSchema)
Creates a
Type object with column metadata from an Avro record
schema and an empty type label. |
Type(String label,
List<Type.Column> columns)
Creates a
Type object with the specified metadata. |
Type(String label,
String typeSchema,
Map<String,List<String>> properties)
Creates a
Type object with metadata in the format returned from
the GPUdb /show/table or /show/types endpoints. |
Type(String label,
Type.Column... columns)
Creates a
Type object with the specified metadata. |
Type(Type.Column... columns)
Creates a
Type object with the specified column metadata and an
empty type label. |
Modifier and Type | Method and Description |
---|---|
String |
create(GPUdb gpudb)
Creates a type in GPUdb based on the metadata in the
Type object
and returns the type ID for reference. |
boolean |
equals(Object obj) |
static Type |
fromDynamicSchema(String schemaString,
ByteBuffer encodedData)
Creates a
Type object with the specified dynamic schema metadata and
encoded dynamic table data. |
static Type |
fromTable(GPUdb gpudb,
String tableName)
Creates a
Type object containing metadata for the GPUdb type of
an existing table in GPUdb. |
static Type |
fromType(GPUdb gpudb,
String typeId)
Creates a
Type object containing metadata for an existing type
in GPUdb. |
Type.Column |
getColumn(int index)
Gets the column with the specified index.
|
Type.Column |
getColumn(String name)
Gets the column with the specified name.
|
int |
getColumnCount()
Gets the number of columns.
|
int |
getColumnIndex(String name)
Gets the index of the column with the specified name.
|
List<Type.Column> |
getColumns()
Gets the list of columns that the type comprises.
|
String |
getLabel()
Gets the user-defined description string which can be used to
differentiate between data with otherwise identical schemas.
|
org.apache.avro.Schema |
getSchema()
Gets the Avro record schema for the type.
|
int |
hashCode() |
Record |
newInstance()
Creates a new
Record based on the type. |
String |
toString() |
public Type(Type.Column... columns)
Type
object with the specified column metadata and an
empty type label.columns
- the list of columns that the type comprisesIllegalArgumentException
- if no columns are specifiedpublic Type(List<Type.Column> columns)
Type
object with the specified column metadata and an
empty type label.columns
- the list of columns that the type comprisesIllegalArgumentException
- if no columns are specifiedpublic Type(String label, Type.Column... columns)
Type
object with the specified metadata.label
- a user-defined description string which can be used to
differentiate between data with otherwise identical
schemascolumns
- the list of columns that the type comprisesIllegalArgumentException
- if no columns are specifiedpublic Type(String label, List<Type.Column> columns)
Type
object with the specified metadata.label
- a user-defined description string which can be used to
differentiate between data with otherwise identical
schemascolumns
- the list of columns that the type comprisesIllegalArgumentException
- if no columns are specifiedpublic Type(String typeSchema)
Type
object with column metadata from an Avro record
schema and an empty type label.typeSchema
- the Avro record schema for the typeIllegalArgumentException
- if typeSchema
is invalid or
contains unsupported field typespublic Type(String label, String typeSchema, Map<String,List<String>> properties)
Type
object with metadata in the format returned from
the GPUdb /show/table or /show/types endpoints.label
- a user-defined description string which can be used to
differentiate between data with otherwise identical
schemastypeSchema
- the Avro record schema for the typeproperties
- an optional map of column names to lists of properties
that apply to those columnsIllegalArgumentException
- if typeSchema
is invalid or
contains unsupported field types, or if any properties
are
invalidpublic static Type fromTable(GPUdb gpudb, String tableName) throws GPUdbException
Type
object containing metadata for the GPUdb type of
an existing table in GPUdb. Note that this method makes a request to
GPUdb to obtain the metadata.gpudb
- the GPUdb
instance from which to obtain the
metadatatableName
- the name of the table in GPUdbType
objectGPUdbException
- if the table does not exist or is not homogeneous,
or if an error occurs during the request for metadatapublic static Type fromType(GPUdb gpudb, String typeId) throws GPUdbException
Type
object containing metadata for an existing type
in GPUdb. Note that this method makes a request to GPUdb to obtain the
metadata.gpudb
- the GPUdb
instance from which to obtain the
metadatatypeId
- the type ID of the type in GPUdbType
objectGPUdbException
- if the type does not exist or if an error occurs
during the request for metadatapublic static Type fromDynamicSchema(String schemaString, ByteBuffer encodedData) throws GPUdbException
Type
object with the specified dynamic schema metadata and
encoded dynamic table data.schemaString
- a String object containing the dynamic schemaencodedData
- the binary encoded data that contains metadata on
the dynamic schemaType
objectGPUdbException
- if an error occurs during the processing of the metadatapublic String getLabel()
public List<Type.Column> getColumns()
public Type.Column getColumn(int index)
index
- the column indexIndexOutOfBoundsException
- if the specified index is out of rangepublic Type.Column getColumn(String name)
name
- the column namepublic int getColumnCount()
public int getColumnIndex(String name)
name
- the column namepublic org.apache.avro.Schema getSchema()
public Record newInstance()
Record
based on the type.Record
public String create(GPUdb gpudb) throws GPUdbException
Type
object
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.gpudb
- the GPUdb
instance in which to create the typeGPUdbException
- if an error occurs while creating the typeCopyright © 2020. All rights reserved.