int MakeArray()

in c/validation/adbc_validation_util.h [237:282]


int MakeArray(struct ArrowArray* parent, struct ArrowArray* array,
              const std::vector<std::optional<T>>& values) {
  for (const auto& v : values) {
    if (v.has_value()) {
      if constexpr (std::is_same<T, int8_t>::value || std::is_same<T, int16_t>::value ||
                    std::is_same<T, int32_t>::value || std::is_same<T, int64_t>::value) {
        if (int errno_res = ArrowArrayAppendInt(array, *v); errno_res != 0) {
          return errno_res;
        }
        // XXX: cpplint gets weird here and thinks this is an unbraced if
      } else if constexpr (std::is_same<T,  // NOLINT(readability/braces)
                                        uint8_t>::value ||
                           std::is_same<T, uint16_t>::value ||
                           std::is_same<T, uint32_t>::value ||
                           std::is_same<T, uint64_t>::value) {
        if (int errno_res = ArrowArrayAppendUInt(array, *v); errno_res != 0) {
          return errno_res;
        }
      } else if constexpr (std::is_same<T, float>::value ||  // NOLINT(readability/braces)
                           std::is_same<T, double>::value) {
        if (int errno_res = ArrowArrayAppendDouble(array, *v); errno_res != 0) {
          return errno_res;
        }
      } else if constexpr (std::is_same<T, std::string>::value) {
        struct ArrowBufferView view;
        view.data.as_char = v->c_str();
        view.size_bytes = v->size();
        if (int errno_res = ArrowArrayAppendBytes(array, view); errno_res != 0) {
          return errno_res;
        }
      } else if constexpr (std::is_same<T, ArrowInterval*>::value) {
        if (int errno_res = ArrowArrayAppendInterval(array, *v); errno_res != 0) {
          return errno_res;
        }
      } else {
        static_assert(!sizeof(T), "Not yet implemented");
        return ENOTSUP;
      }
    } else {
      if (int errno_res = ArrowArrayAppendNull(array, 1); errno_res != 0) {
        return errno_res;
      }
    }
  }
  return 0;
}