defs.h 1.7 KB

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #include <arrow/status.h>
  3. #include <arrow/result.h>
  4. #include <util/generic/yexception.h>
  5. #define ARROW_CHECK_STATUS(s, op, ...) \
  6. if (!s.ok()) { \
  7. ythrow yexception() << "Operation failed: [" << #op << "]\n" \
  8. << "" __VA_ARGS__ << ": [" << s.ToString() << "]"; \
  9. }
  10. #define ARROW_OK_S(op, ...) \
  11. do { \
  12. ::arrow::Status _s = (op); \
  13. ARROW_CHECK_STATUS(_s, op, __VA_ARGS__); \
  14. } while (false)
  15. #define ARROW_OK(op) ARROW_OK_S(op, "Bad status")
  16. #define ARROW_RESULT_S(op, ...) \
  17. [&]() { \
  18. auto result = (op); \
  19. ARROW_CHECK_STATUS(result.status(), op, __VA_ARGS__); \
  20. return std::move(result).ValueOrDie(); \
  21. }()
  22. #define ARROW_RESULT(op) ARROW_RESULT_S(op, "Bad status")
  23. #define ARROW_DEBUG_CHECK_DATUM_TYPES(expected, got) do { \
  24. Y_DEBUG_ABORT_UNLESS((expected) == (got), "Bad datum type: %s expected, %s got", \
  25. (expected).ToString().c_str(), (got).ToString().c_str()); \
  26. } while(false)