Search in sources :

Example 1 with CHTypeUInt64

use of com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt64 in project tispark by pingcap.

the class CHTypeMapping method parseType.

public static CHType parseType(String typeName) {
    if (typeName == null || typeName.isEmpty()) {
        throw new UnsupportedOperationException("Empty CH type!");
    }
    typeName = typeName.trim();
    switch(typeName) {
        case "UInt8":
            return new CHTypeUInt8();
        case "UInt16":
            return new CHTypeUInt16();
        case "UInt32":
            return new CHTypeUInt32();
        case "UInt64":
            return new CHTypeUInt64();
        case "Int8":
            return new CHTypeInt8();
        case "Int16":
            return new CHTypeInt16();
        case "Int32":
            return new CHTypeInt32();
        case "Int64":
            return new CHTypeInt64();
        case "Float32":
            return new CHTypeFloat32();
        case "Float64":
            return new CHTypeFloat64();
        case "Date":
            return new CHTypeDate();
        case "DateTime":
            return new CHTypeDateTime();
        case "MyDateTime":
            return new CHTypeMyDateTime();
        case "MyDate":
            return new CHTypeMyDate();
        case "String":
            return new CHTypeString();
    }
    if (typeName.startsWith("FixedString")) {
        String remain = StringUtils.removeStart(typeName, "FixedString");
        remain = StringUtils.removeEnd(StringUtils.removeStart(remain, "("), ")");
        try {
            int length = Integer.parseInt(remain);
            return new CHTypeFixedString(length);
        } catch (NumberFormatException e) {
            throw new UnsupportedOperationException("Illegal CH type: " + typeName);
        }
    }
    if (typeName.startsWith("MyDateTime")) {
        return new CHTypeMyDateTime();
    }
    if (typeName.startsWith("Decimal")) {
        String remain = StringUtils.removeStart(typeName, "Decimal");
        remain = StringUtils.removeEnd(StringUtils.removeStart(remain, "("), ")");
        try {
            String[] args = remain.split(",");
            int precision = Integer.parseInt(args[0]);
            int scale = Integer.parseInt(args[1]);
            return new CHTypeDecimal(precision, scale);
        } catch (Exception e) {
            throw new UnsupportedOperationException("Illegal CH type: " + typeName);
        }
    }
    if (typeName.startsWith("Nullable")) {
        String remain = StringUtils.removeStart(typeName, "Nullable");
        remain = StringUtils.removeEnd(StringUtils.removeStart(remain, "("), ")");
        CHType type = parseType(remain);
        type.setNullable(true);
        return type;
    }
    throw new UnsupportedOperationException("Unsupported CH type: " + typeName);
}
Also used : CHTypeUInt16(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt16) CHTypeInt16(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeInt16) CHTypeDateTime(com.pingcap.tikv.columnar.datatypes.CHTypeDateTime) CHTypeString(com.pingcap.tikv.columnar.datatypes.CHTypeString) CHTypeUInt32(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt32) CHTypeUInt64(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt64) CHTypeFloat64(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeFloat64) CHTypeMyDateTime(com.pingcap.tikv.columnar.datatypes.CHTypeMyDateTime) CHTypeString(com.pingcap.tikv.columnar.datatypes.CHTypeString) CHTypeFixedString(com.pingcap.tikv.columnar.datatypes.CHTypeFixedString) CHType(com.pingcap.tikv.columnar.datatypes.CHType) CHTypeFloat32(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeFloat32) CHTypeMyDate(com.pingcap.tikv.columnar.datatypes.CHTypeMyDate) CHTypeFixedString(com.pingcap.tikv.columnar.datatypes.CHTypeFixedString) CHTypeInt8(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeInt8) CHTypeUInt8(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt8) CHTypeDate(com.pingcap.tikv.columnar.datatypes.CHTypeDate) CHTypeDecimal(com.pingcap.tikv.columnar.datatypes.CHTypeDecimal) CHTypeInt32(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeInt32) CHTypeInt64(com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeInt64)

Aggregations

CHType (com.pingcap.tikv.columnar.datatypes.CHType)1 CHTypeDate (com.pingcap.tikv.columnar.datatypes.CHTypeDate)1 CHTypeDateTime (com.pingcap.tikv.columnar.datatypes.CHTypeDateTime)1 CHTypeDecimal (com.pingcap.tikv.columnar.datatypes.CHTypeDecimal)1 CHTypeFixedString (com.pingcap.tikv.columnar.datatypes.CHTypeFixedString)1 CHTypeMyDate (com.pingcap.tikv.columnar.datatypes.CHTypeMyDate)1 CHTypeMyDateTime (com.pingcap.tikv.columnar.datatypes.CHTypeMyDateTime)1 CHTypeFloat32 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeFloat32)1 CHTypeFloat64 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeFloat64)1 CHTypeInt16 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeInt16)1 CHTypeInt32 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeInt32)1 CHTypeInt64 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeInt64)1 CHTypeInt8 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeInt8)1 CHTypeUInt16 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt16)1 CHTypeUInt32 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt32)1 CHTypeUInt64 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt64)1 CHTypeUInt8 (com.pingcap.tikv.columnar.datatypes.CHTypeNumber.CHTypeUInt8)1 CHTypeString (com.pingcap.tikv.columnar.datatypes.CHTypeString)1