def _unify_str_type()

in python/graphscope/framework/utils.py [0:0]


def _unify_str_type(t):  # noqa: C901
    t = t.lower()
    if t in ("b", "bool"):
        return graph_def_pb2.DataTypePb.BOOL
    elif t in ("c", "char"):
        return graph_def_pb2.DataTypePb.CHAR
    elif t in ("s", "short"):
        return graph_def_pb2.DataTypePb.SHORT
    elif t in ("i", "int", "int32", "int32_t"):
        return graph_def_pb2.DataTypePb.INT
    elif t in ("l", "long", "int64_t", "int64"):
        return graph_def_pb2.DataTypePb.LONG
    elif t in ("uint32_t", "uint32"):
        return graph_def_pb2.DataTypePb.UINT
    elif t in ("uint64_t", "uint64"):
        return graph_def_pb2.DataTypePb.ULONG
    elif t in ("f", "float"):
        return graph_def_pb2.DataTypePb.FLOAT
    elif t in ("d", "double"):
        return graph_def_pb2.DataTypePb.DOUBLE
    elif t in ("str", "string", "std::string"):
        return graph_def_pb2.DataTypePb.STRING
    elif t == "bytes":
        return graph_def_pb2.DataTypePb.BYTES
    elif t == "date32[day]" or t == "date[32][day]" or t == "date32" or t == "date[32]":
        return graph_def_pb2.DataTypePb.DATE32
    elif t == "date64[ms]" or t == "date[64][ms]" or t == "date64" or t == "date[64]":
        return graph_def_pb2.DataTypePb.DATE64
    elif t == "time32[s]" or t == "time[32][s]":
        return graph_def_pb2.DataTypePb.TIME32_S
    elif t == "time32[ms]" or t == "time[32][ms]":
        return graph_def_pb2.DataTypePb.TIME32_MS
    elif t == "time32[us]" or t == "time[32][us]":
        return graph_def_pb2.DataTypePb.TIME32_US
    elif t == "time32[ns]" or t == "time[32][ns]":
        return graph_def_pb2.DataTypePb.TIME32_NS
    elif t == "time64[s]" or t == "time[64][s]":
        return graph_def_pb2.DataTypePb.TIME64_S
    elif t == "time64[ms]" or t == "time[64][ms]":
        return graph_def_pb2.DataTypePb.TIME64_MS
    elif t == "time64[us]" or t == "time[64][us]":
        return graph_def_pb2.DataTypePb.TIME64_US
    elif t == "time64[ns]" or t == "time[64][ns]":
        return graph_def_pb2.DataTypePb.TIME64_NS
    elif t.startswith("timestamp[s]"):
        return graph_def_pb2.DataTypePb.TIMESTAMP_S
    elif t.startswith("timestamp[ms]"):
        return graph_def_pb2.DataTypePb.TIMESTAMP_MS
    elif t.startswith("timestamp[us]"):
        return graph_def_pb2.DataTypePb.TIMESTAMP_US
    elif t.startswith("timestamp[ns]"):
        return graph_def_pb2.DataTypePb.TIMESTAMP_NS
    elif t == "int_list" or t.startswith("fixedlistint"):
        return graph_def_pb2.DataTypePb.INT_LIST
    elif t == "long_list" or t.startswith("fixedlistlong"):
        return graph_def_pb2.DataTypePb.LONG_LIST
    elif t == "float_list" or t.startswith("fixedlistfloat"):
        return graph_def_pb2.DataTypePb.FLOAT_LIST
    elif t == "double_list" or t.startswith("fixedlistdouble"):
        return graph_def_pb2.DataTypePb.DOUBLE_LIST
    elif t in ("empty", "grape::emptytype"):
        return graph_def_pb2.NULLVALUE
    raise TypeError("Not supported type {}".format(t))