Package com.gpudb

Class Type

    • Constructor Detail

      • Type

        public Type​(Type.Column... columns)
        Creates a Type object with the specified column metadata and an empty type label.
        Parameters:
        columns - the list of columns that the type comprises
        Throws:
        IllegalArgumentException - if no columns are specified
      • Type

        public Type​(List<Type.Column> columns)
        Creates a Type object with the specified column metadata and an empty type label.
        Parameters:
        columns - the list of columns that the type comprises
        Throws:
        IllegalArgumentException - if no columns are specified
      • Type

        public Type​(String label,
                    Type.Column... columns)
        Creates a Type object with the specified metadata.
        Parameters:
        label - a user-defined description string which can be used to differentiate between data with otherwise identical schemas
        columns - the list of columns that the type comprises
        Throws:
        IllegalArgumentException - if no columns are specified
      • Type

        public Type​(String label,
                    List<Type.Column> columns)
        Creates a Type object with the specified metadata.
        Parameters:
        label - a user-defined description string which can be used to differentiate between data with otherwise identical schemas
        columns - the list of columns that the type comprises
        Throws:
        IllegalArgumentException - if no columns are specified
      • Type

        public Type​(String typeSchema)
        Creates a Type object with column metadata from an Avro record schema and an empty type label.
        Parameters:
        typeSchema - the Avro record schema for the type
        Throws:
        IllegalArgumentException - if typeSchema is invalid or contains unsupported field types
      • Type

        public 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.
        Parameters:
        label - a user-defined description string which can be used to differentiate between data with otherwise identical schemas
        typeSchema - the Avro record schema for the type
        properties - an optional map of column names to lists of properties that apply to those columns
        Throws:
        IllegalArgumentException - if typeSchema is invalid or contains unsupported field types, or if any properties are invalid
    • Method Detail

      • fromTable

        public static Type fromTable​(GPUdb gpudb,
                                     String tableName)
                              throws GPUdbException
        Creates a 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.
        Parameters:
        gpudb - the GPUdb instance from which to obtain the metadata
        tableName - the name of the table in GPUdb
        Returns:
        the created Type object
        Throws:
        GPUdbException - if the table does not exist or is not homogeneous, or if an error occurs during the request for metadata
      • fromType

        public static Type fromType​(GPUdb gpudb,
                                    String typeId)
                             throws GPUdbException
        Creates a Type object containing metadata for an existing type in GPUdb. Note that this method makes a request to GPUdb to obtain the metadata.
        Parameters:
        gpudb - the GPUdb instance from which to obtain the metadata
        typeId - the type ID of the type in GPUdb
        Returns:
        the created Type object
        Throws:
        GPUdbException - if the type does not exist or if an error occurs during the request for metadata
      • fromDynamicSchema

        public static Type fromDynamicSchema​(String schemaString,
                                             ByteBuffer encodedData)
                                      throws GPUdbException
        Creates a Type object with the specified dynamic schema metadata and encoded dynamic table data.
        Parameters:
        schemaString - a String object containing the dynamic schema
        encodedData - the binary encoded data that contains metadata on the dynamic schema
        Returns:
        the created Type object
        Throws:
        GPUdbException - if an error occurs during the processing of the metadata
      • getLabel

        public String getLabel()
        Gets the user-defined description string which can be used to differentiate between data with otherwise identical schemas.
        Returns:
        the label string
      • getColumns

        public List<Type.Column> getColumns()
        Gets the list of columns that the type comprises.
        Returns:
        the list of columns that the type comprises
      • getColumn

        public Type.Column getColumn​(int index)
        Gets the column with the specified index.
        Parameters:
        index - the column index
        Returns:
        the column with the specified index
        Throws:
        IndexOutOfBoundsException - if the specified index is out of range
      • getColumn

        public Type.Column getColumn​(String name)
        Gets the column with the specified name.
        Parameters:
        name - the column name
        Returns:
        the column with the specified name, or null if no such column exists
      • getColumnCount

        public int getColumnCount()
        Gets the number of columns.
        Returns:
        the number of columns
      • getColumnIndex

        public int getColumnIndex​(String name)
        Gets the index of the column with the specified name.
        Parameters:
        name - the column name
        Returns:
        the index of the column with the specified name, or -1 if no such column exists
      • getSchema

        public org.apache.avro.Schema getSchema()
        Gets the Avro record schema for the type.
        Returns:
        the Avro record schema for the type
      • newInstance

        public Record newInstance()
        Creates a new Record based on the type.
        Returns:
        a new Record
      • create

        public String create​(GPUdb gpudb)
                      throws GPUdbException
        Creates a type in GPUdb based on the metadata in the 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.
        Parameters:
        gpudb - the GPUdb instance 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object