diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 97721b1a41b..db3795a4d52 100644 --- a/cpp/src/arrow/pretty_print.cc +++ b/cpp/src/arrow/pretty_print.cc @@ -158,9 +158,9 @@ class ArrayPrinter : public PrettyPrinter { template enable_if_date WriteDataValues(const T& array) { const auto data = array.raw_values(); - using unit = - typename std::conditional::value, util::date::days, - std::chrono::milliseconds>::type; + using unit = typename std::conditional::value, + arrow_vendored::date::days, + std::chrono::milliseconds>::type; WriteValues(array, [&](int64_t i) { FormatDateTime("%F", data[i], true); }); return Status::OK(); } @@ -367,9 +367,9 @@ class ArrayPrinter : public PrettyPrinter { template void FormatDateTime(const char* fmt, int64_t value, bool add_epoch) { if (add_epoch) { - (*sink_) << util::date::format(fmt, epoch_ + Unit{value}); + (*sink_) << arrow_vendored::date::format(fmt, epoch_ + Unit{value}); } else { - (*sink_) << util::date::format(fmt, Unit{value}); + (*sink_) << arrow_vendored::date::format(fmt, Unit{value}); } } @@ -391,12 +391,12 @@ class ArrayPrinter : public PrettyPrinter { } } - static util::date::sys_days epoch_; + static arrow_vendored::date::sys_days epoch_; std::string null_rep_; }; -util::date::sys_days ArrayPrinter::epoch_ = - util::date::sys_days{util::date::jan / 1 / 1970}; +arrow_vendored::date::sys_days ArrayPrinter::epoch_ = + arrow_vendored::date::sys_days{arrow_vendored::date::jan / 1 / 1970}; Status ArrayPrinter::WriteValidityBitmap(const Array& array) { Indent(); diff --git a/cpp/src/arrow/symbols.map b/cpp/src/arrow/symbols.map index a8825250d05..7262cc6a898 100644 --- a/cpp/src/arrow/symbols.map +++ b/cpp/src/arrow/symbols.map @@ -23,6 +23,7 @@ # Unfortunately this will also catch template specializations # (from e.g. STL or Flatbuffers) involving Arrow types. *arrow::*; + *arrow_vendored::*; }; # Also export C-level helpers arrow_*; diff --git a/cpp/src/arrow/util/parsing.h b/cpp/src/arrow/util/parsing.h index dd3c074733e..3d93ed29310 100644 --- a/cpp/src/arrow/util/parsing.h +++ b/cpp/src/arrow/util/parsing.h @@ -405,7 +405,7 @@ class StringConverter { // - "YYYY-MM-DD[ T]hh:mm:ss" // - "YYYY-MM-DD[ T]hh:mm:ssZ" // UTC is always assumed, and the DataType's timezone is ignored. - arrow::util::date::year_month_day ymd; + arrow_vendored::date::year_month_day ymd; if (ARROW_PREDICT_FALSE(length < 10)) { return false; } @@ -413,7 +413,7 @@ class StringConverter { if (ARROW_PREDICT_FALSE(!ParseYYYY_MM_DD(s, &ymd))) { return false; } - return ConvertTimePoint(arrow::util::date::sys_days(ymd), out); + return ConvertTimePoint(arrow_vendored::date::sys_days(ymd), out); } if (ARROW_PREDICT_FALSE(s[10] != ' ') && ARROW_PREDICT_FALSE(s[10] != 'T')) { return false; @@ -429,7 +429,7 @@ class StringConverter { if (ARROW_PREDICT_FALSE(!ParseHH_MM_SS(s + 11, &seconds))) { return false; } - return ConvertTimePoint(arrow::util::date::sys_days(ymd) + seconds, out); + return ConvertTimePoint(arrow_vendored::date::sys_days(ymd) + seconds, out); } return false; } @@ -458,7 +458,7 @@ class StringConverter { return true; } - bool ParseYYYY_MM_DD(const char* s, arrow::util::date::year_month_day* out) { + bool ParseYYYY_MM_DD(const char* s, arrow_vendored::date::year_month_day* out) { uint16_t year; uint8_t month, day; if (ARROW_PREDICT_FALSE(s[4] != '-') || ARROW_PREDICT_FALSE(s[7] != '-')) { @@ -473,8 +473,8 @@ class StringConverter { if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 8, 2, &day))) { return false; } - *out = {arrow::util::date::year{year}, arrow::util::date::month{month}, - arrow::util::date::day{day}}; + *out = {arrow_vendored::date::year{year}, arrow_vendored::date::month{month}, + arrow_vendored::date::day{day}}; return out->ok(); } diff --git a/cpp/src/arrow/vendored/datetime/date.h b/cpp/src/arrow/vendored/datetime/date.h index 3aef9f7443a..c8e14e53704 100644 --- a/cpp/src/arrow/vendored/datetime/date.h +++ b/cpp/src/arrow/vendored/datetime/date.h @@ -76,9 +76,7 @@ # endif #endif -namespace arrow -{ -namespace util +namespace arrow_vendored { namespace date { @@ -1109,7 +1107,7 @@ trunc(const std::chrono::duration& d) { using namespace std::chrono; using rep = typename std::common_type::type; - return To{detail::trunc(duration_cast(duration_cast>(d)).count())}; + return To{detail::trunc(duration_cast(duration_cast>(d)).count())}; } #ifndef HAS_CHRONO_ROUNDING @@ -1155,7 +1153,7 @@ floor(const std::chrono::duration& d) { using namespace std::chrono; using rep = typename std::common_type::type; - return floor(floor>(d)); + return floor(floor>(d)); } // round to nearest, to even on tie @@ -6127,7 +6125,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, { h = hours{H}; min = minutes{M}; - s = round(std::chrono::duration{S}); + s = round(duration{S}); } #endif command = nullptr; @@ -6508,7 +6506,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, long double S; read(is, rld{S, 1, width == -1 ? w : static_cast(width)}); if (!is.fail()) - s = round(std::chrono::duration{S}); + s = round(duration{S}); #if !ONLY_C_LOCALE } else if (modified == CharT{'O'}) @@ -6545,7 +6543,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, { h = hours{H}; min = minutes{M}; - s = round(std::chrono::duration{S}); + s = round(duration{S}); } } else @@ -8016,8 +8014,7 @@ operator<<(std::basic_ostream& os, } } // namespace date -} // namespace util -} // namespace arrow +} // namespace arrow_vendored #ifdef __GNUC__ diff --git a/cpp/src/arrow/vendored/datetime/ios.h b/cpp/src/arrow/vendored/datetime/ios.h index 23dc1671aa9..acad28d13b5 100644 --- a/cpp/src/arrow/vendored/datetime/ios.h +++ b/cpp/src/arrow/vendored/datetime/ios.h @@ -32,9 +32,7 @@ # if TARGET_OS_IPHONE # include - namespace arrow - { - namespace util + namespace arrow_vendored { namespace date { @@ -46,8 +44,7 @@ } // namespace iOSUtils } // namespace date - } // namespace util - } // namespace arrow + } // namespace arrow_vendored # endif // TARGET_OS_IPHONE #else // !__APPLE__ diff --git a/cpp/src/arrow/vendored/datetime/tz.cpp b/cpp/src/arrow/vendored/datetime/tz.cpp index e05423e13c6..1133b048f32 100644 --- a/cpp/src/arrow/vendored/datetime/tz.cpp +++ b/cpp/src/arrow/vendored/datetime/tz.cpp @@ -249,9 +249,7 @@ get_download_folder() #endif // !USE_OS_TZDB -namespace arrow -{ -namespace util +namespace arrow_vendored { namespace date { @@ -3789,8 +3787,7 @@ current_zone() } } // namespace date -} // namespace util -} // namespace arrow +} // namespace arrow_vendored #if defined(__GNUC__) && __GNUC__ < 5 # pragma GCC diagnostic pop diff --git a/cpp/src/arrow/vendored/datetime/tz.h b/cpp/src/arrow/vendored/datetime/tz.h index db78b2df971..249162b0149 100644 --- a/cpp/src/arrow/vendored/datetime/tz.h +++ b/cpp/src/arrow/vendored/datetime/tz.h @@ -155,9 +155,7 @@ static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true, # endif #endif -namespace arrow -{ -namespace util +namespace arrow_vendored { namespace date { @@ -2587,7 +2585,6 @@ to_gps_time(const tai_time& t) #endif // !MISSING_LEAP_SECONDS } // namespace date -} // namespace util } // namespace arrow #endif // TZ_H diff --git a/cpp/src/arrow/vendored/datetime/tz_private.h b/cpp/src/arrow/vendored/datetime/tz_private.h index cafa5ea2bf1..f98c3e79a44 100644 --- a/cpp/src/arrow/vendored/datetime/tz_private.h +++ b/cpp/src/arrow/vendored/datetime/tz_private.h @@ -34,9 +34,7 @@ #include #endif -namespace arrow -{ -namespace util +namespace arrow_vendored { namespace date { @@ -314,8 +312,7 @@ struct transition } // namespace detail } // namespace date -} // namespace util -} // namespace arrow +} // namespace arrow_vendored #if defined(_MSC_VER) && (_MSC_VER < 1900) #include "tz.h" diff --git a/cpp/src/gandiva/cast_time.cc b/cpp/src/gandiva/cast_time.cc index 1d4293b1996..843ce01f89d 100644 --- a/cpp/src/gandiva/cast_time.cc +++ b/cpp/src/gandiva/cast_time.cc @@ -52,12 +52,12 @@ extern "C" { // TODO : Do input validation or make sure the callers do that ? int gdv_fn_time_with_zone(int* time_fields, const char* zone, int zone_len, int64_t* ret_time) { - using arrow::util::date::day; - using arrow::util::date::local_days; - using arrow::util::date::locate_zone; - using arrow::util::date::month; - using arrow::util::date::time_zone; - using arrow::util::date::year; + using arrow_vendored::date::day; + using arrow_vendored::date::local_days; + using arrow_vendored::date::locate_zone; + using arrow_vendored::date::month; + using arrow_vendored::date::time_zone; + using arrow_vendored::date::year; using std::chrono::hours; using std::chrono::milliseconds; using std::chrono::minutes; diff --git a/cpp/src/gandiva/date_utils.h b/cpp/src/gandiva/date_utils.h index e87203bd017..f02aceb92b9 100644 --- a/cpp/src/gandiva/date_utils.h +++ b/cpp/src/gandiva/date_utils.h @@ -69,16 +69,16 @@ static inline bool ParseTimestamp(const char* buf, const char* format, // TODO: date::parse fails parsing when the hour value is 0. // eg.1886-12-01 00:00:00 - arrow::util::date::sys_seconds seconds; + arrow_vendored::date::sys_seconds seconds; if (ignoreTimeInDay) { - arrow::util::date::sys_days days; - stream >> arrow::util::date::parse(format, days); + arrow_vendored::date::sys_days days; + stream >> arrow_vendored::date::parse(format, days); if (stream.fail()) { return false; } seconds = days; } else { - stream >> arrow::util::date::parse(format, seconds); + stream >> arrow_vendored::date::parse(format, seconds); if (stream.fail()) { return false; } @@ -93,9 +93,9 @@ static inline bool ParseTimestamp(const char* buf, const char* format, return false; } // ignore the time part - arrow::util::date::sys_seconds secs = - arrow::util::date::sys_days(arrow::util::date::year(result.tm_year + 1900) / - (result.tm_mon + 1) / result.tm_mday); + arrow_vendored::date::sys_seconds secs = + arrow_vendored::date::sys_days(arrow_vendored::date::year(result.tm_year + 1900) / + (result.tm_mon + 1) / result.tm_mday); if (!ignoreTimeInDay) { secs += (std::chrono::hours(result.tm_hour) + std::chrono::minutes(result.tm_min) + std::chrono::seconds(result.tm_sec)); diff --git a/cpp/src/gandiva/precompiled/epoch_time_point.h b/cpp/src/gandiva/precompiled/epoch_time_point.h index 32d6cea7319..ec65d84854e 100644 --- a/cpp/src/gandiva/precompiled/epoch_time_point.h +++ b/cpp/src/gandiva/precompiled/epoch_time_point.h @@ -35,18 +35,19 @@ class EpochTimePoint { int TmMon() const { return static_cast(YearMonthDay().month()) - 1; } int TmYday() const { - auto to_days = arrow::util::date::floor(tp_); - auto first_day_in_year = - arrow::util::date::sys_days{YearMonthDay().year() / arrow::util::date::jan / 1}; + auto to_days = arrow_vendored::date::floor(tp_); + auto first_day_in_year = arrow_vendored::date::sys_days{ + YearMonthDay().year() / arrow_vendored::date::jan / 1}; return (to_days - first_day_in_year).count(); } int TmMday() const { return static_cast(YearMonthDay().day()); } int TmWday() const { - auto to_days = arrow::util::date::floor(tp_); - return (arrow::util::date::weekday{to_days} - arrow::util::date::Sunday) // NOLINT - .count(); // NOLINT + auto to_days = arrow_vendored::date::floor(tp_); + return (arrow_vendored::date::weekday{to_days} - // NOLINT + arrow_vendored::date::Sunday) + .count(); } int TmHour() const { return static_cast(TimeOfDay().hours().count()); } @@ -59,22 +60,22 @@ class EpochTimePoint { } EpochTimePoint AddYears(int num_years) const { - auto ymd = YearMonthDay() + arrow::util::date::years(num_years); - return EpochTimePoint((arrow::util::date::sys_days{ymd} + // NOLINT + auto ymd = YearMonthDay() + arrow_vendored::date::years(num_years); + return EpochTimePoint((arrow_vendored::date::sys_days{ymd} + // NOLINT TimeOfDay().to_duration()) .time_since_epoch()); } EpochTimePoint AddMonths(int num_months) const { - auto ymd = YearMonthDay() + arrow::util::date::months(num_months); - return EpochTimePoint((arrow::util::date::sys_days{ymd} + // NOLINT + auto ymd = YearMonthDay() + arrow_vendored::date::months(num_months); + return EpochTimePoint((arrow_vendored::date::sys_days{ymd} + // NOLINT TimeOfDay().to_duration()) .time_since_epoch()); } EpochTimePoint AddDays(int num_days) const { - auto days_since_epoch = arrow::util::date::sys_days{YearMonthDay()} // NOLINT - + arrow::util::date::days(num_days); + auto days_since_epoch = arrow_vendored::date::sys_days{YearMonthDay()} + // NOLINT + arrow_vendored::date::days(num_days); return EpochTimePoint( (days_since_epoch + TimeOfDay().to_duration()).time_since_epoch()); } @@ -88,15 +89,15 @@ class EpochTimePoint { int64_t MillisSinceEpoch() const { return tp_.time_since_epoch().count(); } private: - arrow::util::date::year_month_day YearMonthDay() const { - return arrow::util::date::year_month_day{ - arrow::util::date::floor(tp_)}; // NOLINT + arrow_vendored::date::year_month_day YearMonthDay() const { + return arrow_vendored::date::year_month_day{ + arrow_vendored::date::floor(tp_)}; // NOLINT } - arrow::util::date::time_of_day TimeOfDay() const { + arrow_vendored::date::time_of_day TimeOfDay() const { auto millis_since_midnight = - tp_ - arrow::util::date::floor(tp_); - return arrow::util::date::time_of_day( + tp_ - arrow_vendored::date::floor(tp_); + return arrow_vendored::date::time_of_day( millis_since_midnight); } diff --git a/cpp/src/gandiva/precompiled/time.cc b/cpp/src/gandiva/precompiled/time.cc index 77aca3f7be0..bb5327529d2 100644 --- a/cpp/src/gandiva/precompiled/time.cc +++ b/cpp/src/gandiva/precompiled/time.cc @@ -519,11 +519,11 @@ void set_error_for_date(int32 length, const char* input, const char* msg, } date64 castDATE_utf8(int64_t context, const char* input, int32 length) { - using arrow::util::date::day; - using arrow::util::date::month; - using arrow::util::date::sys_days; - using arrow::util::date::year; - using arrow::util::date::year_month_day; + using arrow_vendored::date::day; + using arrow_vendored::date::month; + using arrow_vendored::date::sys_days; + using arrow_vendored::date::year; + using arrow_vendored::date::year_month_day; using gandiva::TimeFields; // format : 0 is year, 1 is month and 2 is day. int dateFields[3]; @@ -583,11 +583,11 @@ date64 castDATE_utf8(int64_t context, const char* input, int32 length) { * Format is [ hours:minutes:seconds][.millis][ displacement|zone] */ timestamp castTIMESTAMP_utf8(int64_t context, const char* input, int32 length) { - using arrow::util::date::day; - using arrow::util::date::month; - using arrow::util::date::sys_days; - using arrow::util::date::year; - using arrow::util::date::year_month_day; + using arrow_vendored::date::day; + using arrow_vendored::date::month; + using arrow_vendored::date::sys_days; + using arrow_vendored::date::year; + using arrow_vendored::date::year_month_day; using gandiva::TimeFields; using std::chrono::hours; using std::chrono::milliseconds;