Java Code Examples for org.apache.kudu.Type#DOUBLE

The following examples show how to use org.apache.kudu.Type#DOUBLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KuduTemplate.java    From canal with Apache License 2.0 6 votes vote down vote up
/**
 * kudu数据类型映射
 *
 * @param
 */
private Type toKuduType(String mysqlType) throws IllegalArgumentException {

    switch (mysqlType) {
        case "varchar":
            return Type.STRING;
        case "int":
            return Type.INT8;
        case "decimal":
            return Type.DOUBLE;
        case "double":
            return Type.DOUBLE;
        case "datetime":
            return Type.STRING;
        case "timestamp":
            return Type.STRING;
        default:
            throw new IllegalArgumentException("The provided data type doesn't map to know any known one.");
    }
}
 
Example 2
Source File: KuduUtils.java    From DataLink with Apache License 2.0 5 votes vote down vote up
public static Type getKuduType(String typeName) {
    if (typeName == null || typeName.trim() == "") {
        return null;
    }

    String lowercaseTypeNmae = typeName.toLowerCase();

    if (lowercaseTypeNmae.startsWith("char") || lowercaseTypeNmae.startsWith("varchar") || lowercaseTypeNmae.contains("text") || lowercaseTypeNmae.contains("blob")) {
        return Type.STRING;
    } else if (lowercaseTypeNmae.equals("tinyint")) {
        return Type.INT8;
    } else if (lowercaseTypeNmae.equals("smallint")) {
        return Type.INT16;
    } else if (lowercaseTypeNmae.equals("mediumint") || lowercaseTypeNmae.equals("int")) {
        return Type.INT32;
    } else if (lowercaseTypeNmae.equals("bigint")) {
        return Type.INT64;
    } else if (lowercaseTypeNmae.equals("bigint")) {
        return Type.INT64;
    } else if (lowercaseTypeNmae.contains("float")) {
        return Type.FLOAT;
    } else if (lowercaseTypeNmae.contains("double")) {
        return Type.DOUBLE;
    } else if (lowercaseTypeNmae.contains("double")) {
        return Type.DOUBLE;
    } else if (lowercaseTypeNmae.contains("date") || lowercaseTypeNmae.contains("time") || lowercaseTypeNmae.contains("datetime") || lowercaseTypeNmae.contains("timestamp")) {
        return Type.STRING;
    } else {
        return null;
    }
}
 
Example 3
Source File: AbstractKuduProcessor.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a NiFi DataType to it's equivalent Kudu Type.
 */
private Type toKuduType(DataType nifiType) {
    switch (nifiType.getFieldType()) {
        case BOOLEAN:
            return Type.BOOL;
        case BYTE:
            return Type.INT8;
        case SHORT:
            return Type.INT16;
        case INT:
            return Type.INT32;
        case LONG:
            return Type.INT64;
        case FLOAT:
            return Type.FLOAT;
        case DOUBLE:
            return Type.DOUBLE;
        case DECIMAL:
            return Type.DECIMAL;
        case TIMESTAMP:
            return Type.UNIXTIME_MICROS;
        case CHAR:
        case STRING:
            return Type.STRING;
        default:
            throw new IllegalArgumentException(String.format("unsupported type %s", nifiType));
    }
}
 
Example 4
Source File: KuduTypeUtils.java    From bahir-flink with Apache License 2.0 4 votes vote down vote up
@Override
public Type visit(DoubleType doubleType) {
    return Type.DOUBLE;
}