gs::rpc::graph::DataTypePb PropertyTypeToPb()

in analytical_engine/core/object/fragment_wrapper.h [77:154]


gs::rpc::graph::DataTypePb PropertyTypeToPb(vineyard::PropertyType type) {
  if (arrow::boolean()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::BOOL;
  } else if (arrow::int16()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::SHORT;
  } else if (arrow::int32()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::INT;
  } else if (arrow::int64()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::LONG;
  } else if (arrow::uint32()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::UINT;
  } else if (arrow::uint64()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::ULONG;
  } else if (arrow::float32()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::FLOAT;
  } else if (arrow::float64()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::DOUBLE;
  } else if (arrow::utf8()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::STRING;
  } else if (arrow::large_utf8()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::STRING;
  } else if (arrow::date32()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::DATE32;
  } else if (arrow::date64()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::DATE64;
  } else if (type->id() == arrow::Type::TIME32) {
    auto time32_type = std::dynamic_pointer_cast<arrow::Time32Type>(type);
    switch (time32_type->unit()) {
    case arrow::TimeUnit::SECOND:
      return gs::rpc::graph::DataTypePb::TIME32_S;
    case arrow::TimeUnit::MILLI:
      return gs::rpc::graph::DataTypePb::TIME32_MS;
    case arrow::TimeUnit::MICRO:
      return gs::rpc::graph::DataTypePb::TIME32_US;
    case arrow::TimeUnit::NANO:
      return gs::rpc::graph::DataTypePb::TIME32_NS;
    }
  } else if (type->id() == arrow::Type::TIME64) {
    auto time64_type = std::dynamic_pointer_cast<arrow::Time64Type>(type);
    switch (time64_type->unit()) {
    case arrow::TimeUnit::SECOND:
      return gs::rpc::graph::DataTypePb::TIME64_S;
    case arrow::TimeUnit::MILLI:
      return gs::rpc::graph::DataTypePb::TIME64_MS;
    case arrow::TimeUnit::MICRO:
      return gs::rpc::graph::DataTypePb::TIME64_US;
    case arrow::TimeUnit::NANO:
      return gs::rpc::graph::DataTypePb::TIME64_NS;
    }
  } else if (type->id() == arrow::Type::TIMESTAMP) {
    auto timestamp_type = std::dynamic_pointer_cast<arrow::TimestampType>(type);
    switch (timestamp_type->unit()) {
    case arrow::TimeUnit::SECOND:
      return gs::rpc::graph::DataTypePb::TIMESTAMP_S;
    case arrow::TimeUnit::MILLI:
      return gs::rpc::graph::DataTypePb::TIMESTAMP_MS;
    case arrow::TimeUnit::MICRO:
      return gs::rpc::graph::DataTypePb::TIMESTAMP_US;
    case arrow::TimeUnit::NANO:
      return gs::rpc::graph::DataTypePb::TIMESTAMP_NS;
    }
  } else if (arrow::large_list(arrow::int32())->Equals(type)) {
    return gs::rpc::graph::DataTypePb::INT_LIST;
  } else if (arrow::large_list(arrow::int64())->Equals(type)) {
    return gs::rpc::graph::DataTypePb::LONG_LIST;
  } else if (arrow::large_list(arrow::float32())->Equals(type)) {
    return gs::rpc::graph::DataTypePb::FLOAT_LIST;
  } else if (arrow::large_list(arrow::float64())->Equals(type)) {
    return gs::rpc::graph::DataTypePb::DOUBLE_LIST;
  } else if (arrow::large_list(arrow::large_utf8())->Equals(type)) {
    return gs::rpc::graph::DataTypePb::STRING_LIST;
  } else if (arrow::null()->Equals(type)) {
    return gs::rpc::graph::DataTypePb::NULLVALUE;
  }

  LOG(ERROR) << "Unsupported arrow type " << type->ToString();
  return gs::rpc::graph::DataTypePb::UNKNOWN;
}