Search in sources :

Example 1 with ColumnType

use of org.apache.ignite.schema.definition.ColumnType in project ignite-3 by apache.

the class SchemaConfigurationConverter method convert.

/**
 * Convert ColumnTypeView to ColumnType.
 *
 * @param colTypeView ColumnTypeView.
 * @return ColumnType.
 */
public static ColumnType convert(ColumnTypeView colTypeView) {
    String typeName = colTypeView.type().toUpperCase();
    ColumnType res = types.get(typeName);
    if (res != null) {
        return res;
    } else {
        switch(typeName) {
            case "BITMASK":
                int bitmaskLen = colTypeView.length();
                return ColumnType.bitmaskOf(bitmaskLen);
            case "STRING":
                int strLen = colTypeView.length();
                return ColumnType.stringOf(strLen);
            case "BLOB":
                int blobLen = colTypeView.length();
                return ColumnType.blobOf(blobLen);
            case "DECIMAL":
                int prec = colTypeView.precision();
                int scale = colTypeView.scale();
                return ColumnType.decimalOf(prec, scale);
            case "NUMBER":
                return colTypeView.precision() == 0 ? ColumnType.numberOf() : ColumnType.numberOf(colTypeView.precision());
            case "TIME":
                return ColumnType.time(colTypeView.precision());
            case "DATETIME":
                return ColumnType.datetime(colTypeView.precision());
            case "TIMESTAMP":
                return ColumnType.timestamp(colTypeView.precision());
            default:
                throw new IllegalArgumentException("Unknown type " + typeName);
        }
    }
}
Also used : ColumnType(org.apache.ignite.schema.definition.ColumnType)

Aggregations

ColumnType (org.apache.ignite.schema.definition.ColumnType)1