bool FieldConfig::StrToFieldType()

in aios/storage/indexlib/config/FieldConfig.cpp [241:311]


bool FieldConfig::StrToFieldType(const std::string& typeStr, FieldType& type)
{
    type = ft_unknown;
    if (!strcasecmp(typeStr.c_str(), "text")) {
        type = ft_text;
    } else if (!strcasecmp(typeStr.c_str(), "string")) {
        type = ft_string;
    } else if (!strcasecmp(typeStr.c_str(), "integer")) {
        type = ft_integer;
    } else if (!strcasecmp(typeStr.c_str(), "enum")) {
        type = ft_enum;
    } else if (!strcasecmp(typeStr.c_str(), "float")) {
        type = ft_float;
    } else if (!strcasecmp(typeStr.c_str(), "fp8")) {
        type = ft_fp8;
    } else if (!strcasecmp(typeStr.c_str(), "fp16")) {
        type = ft_fp16;
    } else if (!strcasecmp(typeStr.c_str(), "long")) {
        type = ft_long;
    } else if (!strcasecmp(typeStr.c_str(), "time")) {
        type = ft_time;
    } else if (!strcasecmp(typeStr.c_str(), "timestamp")) {
        type = ft_timestamp;
    } else if (!strcasecmp(typeStr.c_str(), "date")) {
        type = ft_date;
    } else if (!strcasecmp(typeStr.c_str(), "location")) {
        type = ft_location;
    } else if (!strcasecmp(typeStr.c_str(), "polygon")) {
        type = ft_polygon;
    } else if (!strcasecmp(typeStr.c_str(), "line")) {
        type = ft_line;
    } else if (!strcasecmp(typeStr.c_str(), "online")) {
        type = ft_online;
    } else if (!strcasecmp(typeStr.c_str(), "property")) {
        type = ft_property;
    } else if (!strcasecmp(typeStr.c_str(), "uint8")) {
        type = ft_uint8;
    } else if (!strcasecmp(typeStr.c_str(), "int8")) {
        type = ft_int8;
    } else if (!strcasecmp(typeStr.c_str(), "uint16")) {
        type = ft_uint16;
    } else if (!strcasecmp(typeStr.c_str(), "int16")) {
        type = ft_int16;
    } else if (!strcasecmp(typeStr.c_str(), "uint32")) {
        type = ft_uint32;
    } else if (!strcasecmp(typeStr.c_str(), "int32")) {
        type = ft_int32;
    } else if (!strcasecmp(typeStr.c_str(), "uint64")) {
        type = ft_uint64;
    } else if (!strcasecmp(typeStr.c_str(), "int64")) {
        type = ft_int64;
    } else if (!strcasecmp(typeStr.c_str(), "hash_64")) {
        type = ft_hash_64;
    } else if (!strcasecmp(typeStr.c_str(), "hash_128")) {
        type = ft_hash_128;
    } else if (!strcasecmp(typeStr.c_str(), "double")) {
        type = ft_double;
    } else if (!strcasecmp(typeStr.c_str(), "raw")) {
        type = ft_raw;
    }
    if (type == ft_unknown) {
        std::stringstream ss;
        ss << "Unknown field_type: " << typeStr << ", support field_type are: ";
        for (int ft = 0; ft < (int)ft_unknown; ++ft) {
            ss << FieldTypeToStr((FieldType)ft) << ",";
        }
        AUTIL_LOG(ERROR, "%s", ss.str().c_str());
        return false;
    }
    return true;
}