From 8d96730bf6922b39c9eadadc57bcebc20ef12205 Mon Sep 17 00:00:00 2001 From: Micah Kornfield Date: Wed, 15 May 2019 19:49:53 -0700 Subject: [PATCH 1/5] ARROW-5346: change namespace of datetime to arrow_vendored revert changes to library. --- cpp/src/arrow/pretty_print.cc | 12 +++---- cpp/src/arrow/symbols.map | 1 + cpp/src/arrow/util/parsing.h | 12 +++---- cpp/src/arrow/vendored/datetime/date.h | 14 ++++---- cpp/src/arrow/vendored/datetime/ios.h | 4 +-- cpp/src/arrow/vendored/datetime/tz.cpp | 4 +-- cpp/src/arrow/vendored/datetime/tz.h | 2 +- cpp/src/arrow/vendored/datetime/tz_private.h | 4 +-- cpp/src/gandiva/cast_time.cc | 12 +++---- cpp/src/gandiva/date_utils.h | 12 +++---- .../gandiva/precompiled/epoch_time_point.h | 32 +++++++++---------- 11 files changed, 55 insertions(+), 54 deletions(-) diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 97721b1a41b..40bd2bab493 100644 --- a/cpp/src/arrow/pretty_print.cc +++ b/cpp/src/arrow/pretty_print.cc @@ -159,7 +159,7 @@ class ArrayPrinter : public PrettyPrinter { enable_if_date WriteDataValues(const T& array) { const auto data = array.raw_values(); using unit = - typename std::conditional::value, util::date::days, + typename std::conditional::value, arrow_vendored::util::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::util::date::format(fmt, epoch_ + Unit{value}); } else { - (*sink_) << util::date::format(fmt, Unit{value}); + (*sink_) << arrow_vendored::util::date::format(fmt, Unit{value}); } } @@ -391,12 +391,12 @@ class ArrayPrinter : public PrettyPrinter { } } - static util::date::sys_days epoch_; + static arrow_vendored::util::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::util::date::sys_days ArrayPrinter::epoch_ = + arrow_vendored::util::date::sys_days{arrow_vendored::util::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..27087adec14 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::util::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::util::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::util::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::util::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::util::date::year{year}, arrow_vendored::util::date::month{month}, + arrow_vendored::util::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..752217d9200 100644 --- a/cpp/src/arrow/vendored/datetime/date.h +++ b/cpp/src/arrow/vendored/datetime/date.h @@ -76,7 +76,7 @@ # endif #endif -namespace arrow +namespace arrow_vendored { namespace util { @@ -1109,7 +1109,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 +1155,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 +6127,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 +6508,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 +6545,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 @@ -8017,7 +8017,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..b7f4cbbb7a9 100644 --- a/cpp/src/arrow/vendored/datetime/ios.h +++ b/cpp/src/arrow/vendored/datetime/ios.h @@ -32,7 +32,7 @@ # if TARGET_OS_IPHONE # include - namespace arrow + namespace arrow_vendored { namespace util { @@ -47,7 +47,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..a63eaf15e2f 100644 --- a/cpp/src/arrow/vendored/datetime/tz.cpp +++ b/cpp/src/arrow/vendored/datetime/tz.cpp @@ -249,7 +249,7 @@ get_download_folder() #endif // !USE_OS_TZDB -namespace arrow +namespace arrow_vendored { namespace util { @@ -3790,7 +3790,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..aea617e22b3 100644 --- a/cpp/src/arrow/vendored/datetime/tz.h +++ b/cpp/src/arrow/vendored/datetime/tz.h @@ -155,7 +155,7 @@ static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true, # endif #endif -namespace arrow +namespace arrow_vendored { namespace util { diff --git a/cpp/src/arrow/vendored/datetime/tz_private.h b/cpp/src/arrow/vendored/datetime/tz_private.h index cafa5ea2bf1..8e35fdfdde6 100644 --- a/cpp/src/arrow/vendored/datetime/tz_private.h +++ b/cpp/src/arrow/vendored/datetime/tz_private.h @@ -34,7 +34,7 @@ #include #endif -namespace arrow +namespace arrow_vendored { namespace util { @@ -315,7 +315,7 @@ struct transition } // 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..38b191a4e62 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::util::date::day; + using arrow_vendored::util::date::local_days; + using arrow_vendored::util::date::locate_zone; + using arrow_vendored::util::date::month; + using arrow_vendored::util::date::time_zone; + using arrow_vendored::util::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..34512a545e5 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::util::date::sys_seconds seconds; if (ignoreTimeInDay) { - arrow::util::date::sys_days days; - stream >> arrow::util::date::parse(format, days); + arrow_vendored::util::date::sys_days days; + stream >> arrow_vendored::util::date::parse(format, days); if (stream.fail()) { return false; } seconds = days; } else { - stream >> arrow::util::date::parse(format, seconds); + stream >> arrow_vendored::util::date::parse(format, seconds); if (stream.fail()) { return false; } @@ -93,8 +93,8 @@ 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) / + arrow_vendored::util::date::sys_seconds secs = + arrow_vendored::util::date::sys_days(arrow_vendored::util::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) + diff --git a/cpp/src/gandiva/precompiled/epoch_time_point.h b/cpp/src/gandiva/precompiled/epoch_time_point.h index 32d6cea7319..c6ee8dabc8a 100644 --- a/cpp/src/gandiva/precompiled/epoch_time_point.h +++ b/cpp/src/gandiva/precompiled/epoch_time_point.h @@ -35,17 +35,17 @@ class EpochTimePoint { int TmMon() const { return static_cast(YearMonthDay().month()) - 1; } int TmYday() const { - auto to_days = arrow::util::date::floor(tp_); + auto to_days = arrow_vendored::util::date::floor(tp_); auto first_day_in_year = - arrow::util::date::sys_days{YearMonthDay().year() / arrow::util::date::jan / 1}; + arrow_vendored::util::date::sys_days{YearMonthDay().year() / arrow_vendored::util::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 + auto to_days = arrow_vendored::util::date::floor(tp_); + return (arrow_vendored::util::date::weekday{to_days} - arrow_vendored::util::date::Sunday) // NOLINT .count(); // NOLINT } @@ -59,22 +59,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::util::date::years(num_years); + return EpochTimePoint((arrow_vendored::util::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::util::date::months(num_months); + return EpochTimePoint((arrow_vendored::util::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::util::date::sys_days{YearMonthDay()} // NOLINT + + arrow_vendored::util::date::days(num_days); return EpochTimePoint( (days_since_epoch + TimeOfDay().to_duration()).time_since_epoch()); } @@ -88,15 +88,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::util::date::year_month_day YearMonthDay() const { + return arrow_vendored::util::date::year_month_day{ + arrow_vendored::util::date::floor(tp_)}; // NOLINT } - arrow::util::date::time_of_day TimeOfDay() const { + arrow_vendored::util::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::util::date::floor(tp_); + return arrow_vendored::util::date::time_of_day( millis_since_midnight); } From 2b851397c2a8afea85b80e0ab81a0c9fb74f0eb2 Mon Sep 17 00:00:00 2001 From: Micah Kornfield Date: Wed, 15 May 2019 20:25:21 -0700 Subject: [PATCH 2/5] lint and format --- cpp/src/arrow/pretty_print.cc | 6 ++--- cpp/src/arrow/util/parsing.h | 3 ++- cpp/src/gandiva/date_utils.h | 6 ++--- .../gandiva/precompiled/epoch_time_point.h | 23 +++++++++++-------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 40bd2bab493..652b36e05d8 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, arrow_vendored::util::date::days, - std::chrono::milliseconds>::type; + using unit = typename std::conditional::value, + arrow_vendored::util::date::days, + std::chrono::milliseconds>::type; WriteValues(array, [&](int64_t i) { FormatDateTime("%F", data[i], true); }); return Status::OK(); } diff --git a/cpp/src/arrow/util/parsing.h b/cpp/src/arrow/util/parsing.h index 27087adec14..552e6e1ee01 100644 --- a/cpp/src/arrow/util/parsing.h +++ b/cpp/src/arrow/util/parsing.h @@ -473,7 +473,8 @@ class StringConverter { if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 8, 2, &day))) { return false; } - *out = {arrow_vendored::util::date::year{year}, arrow_vendored::util::date::month{month}, + *out = {arrow_vendored::util::date::year{year}, + arrow_vendored::util::date::month{month}, arrow_vendored::util::date::day{day}}; return out->ok(); } diff --git a/cpp/src/gandiva/date_utils.h b/cpp/src/gandiva/date_utils.h index 34512a545e5..793f6bea19b 100644 --- a/cpp/src/gandiva/date_utils.h +++ b/cpp/src/gandiva/date_utils.h @@ -93,9 +93,9 @@ static inline bool ParseTimestamp(const char* buf, const char* format, return false; } // ignore the time part - arrow_vendored::util::date::sys_seconds secs = - arrow_vendored::util::date::sys_days(arrow_vendored::util::date::year(result.tm_year + 1900) / - (result.tm_mon + 1) / result.tm_mday); + arrow_vendored::util::date::sys_seconds secs = arrow_vendored::util::date::sys_days( + arrow_vendored::util::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 c6ee8dabc8a..89f30f81b2c 100644 --- a/cpp/src/gandiva/precompiled/epoch_time_point.h +++ b/cpp/src/gandiva/precompiled/epoch_time_point.h @@ -35,18 +35,21 @@ class EpochTimePoint { int TmMon() const { return static_cast(YearMonthDay().month()) - 1; } int TmYday() const { - auto to_days = arrow_vendored::util::date::floor(tp_); - auto first_day_in_year = - arrow_vendored::util::date::sys_days{YearMonthDay().year() / arrow_vendored::util::date::jan / 1}; + auto to_days = + arrow_vendored::util::date::floor(tp_); + auto first_day_in_year = arrow_vendored::util::date::sys_days{ + YearMonthDay().year() / arrow_vendored::util::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_vendored::util::date::floor(tp_); - return (arrow_vendored::util::date::weekday{to_days} - arrow_vendored::util::date::Sunday) // NOLINT - .count(); // NOLINT + auto to_days = + arrow_vendored::util::date::floor(tp_); + return (arrow_vendored::util::date::weekday{to_days} - // NOLINT + arrow_vendored::util::date::Sunday) + .count(); } int TmHour() const { return static_cast(TimeOfDay().hours().count()); } @@ -73,8 +76,9 @@ class EpochTimePoint { } EpochTimePoint AddDays(int num_days) const { - auto days_since_epoch = arrow_vendored::util::date::sys_days{YearMonthDay()} // NOLINT - + arrow_vendored::util::date::days(num_days); + auto days_since_epoch = + arrow_vendored::util::date::sys_days{YearMonthDay()} + // NOLINT + arrow_vendored::util::date::days(num_days); return EpochTimePoint( (days_since_epoch + TimeOfDay().to_duration()).time_since_epoch()); } @@ -90,7 +94,8 @@ class EpochTimePoint { private: arrow_vendored::util::date::year_month_day YearMonthDay() const { return arrow_vendored::util::date::year_month_day{ - arrow_vendored::util::date::floor(tp_)}; // NOLINT + arrow_vendored::util::date::floor( + tp_)}; // NOLINT } arrow_vendored::util::date::time_of_day TimeOfDay() const { From 67489e43af2e1de648ed7147939fa2a5288abf6c Mon Sep 17 00:00:00 2001 From: Micah Kornfield Date: Thu, 16 May 2019 06:08:49 -0700 Subject: [PATCH 3/5] fix time.cc --- cpp/src/gandiva/precompiled/time.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cpp/src/gandiva/precompiled/time.cc b/cpp/src/gandiva/precompiled/time.cc index 77aca3f7be0..ade5f6ad519 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::util::date::day; + using arrow_vendored::util::date::month; + using arrow_vendored::util::date::sys_days; + using arrow_vendored::util::date::year; + using arrow_vendored::util::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::util::date::day; + using arrow_vendored::util::date::month; + using arrow_vendored::util::date::sys_days; + using arrow_vendored::util::date::year; + using arrow_vendored::util::date::year_month_day; using gandiva::TimeFields; using std::chrono::hours; using std::chrono::milliseconds; From 9408e192b9d0140fcf2aec2a8baa322c2c18c108 Mon Sep 17 00:00:00 2001 From: Micah Kornfield Date: Thu, 16 May 2019 11:49:00 -0700 Subject: [PATCH 4/5] remove util namespace --- cpp/src/arrow/pretty_print.cc | 12 +++---- cpp/src/arrow/util/parsing.h | 14 ++++---- cpp/src/arrow/vendored/datetime/date.h | 3 -- cpp/src/arrow/vendored/datetime/ios.h | 3 -- cpp/src/arrow/vendored/datetime/tz.cpp | 3 -- cpp/src/arrow/vendored/datetime/tz.h | 3 -- cpp/src/arrow/vendored/datetime/tz_private.h | 3 -- cpp/src/gandiva/cast_time.cc | 12 +++---- cpp/src/gandiva/date_utils.h | 12 +++---- .../gandiva/precompiled/epoch_time_point.h | 36 +++++++++---------- cpp/src/gandiva/precompiled/time.cc | 20 +++++------ 11 files changed, 53 insertions(+), 68 deletions(-) diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 652b36e05d8..db3795a4d52 100644 --- a/cpp/src/arrow/pretty_print.cc +++ b/cpp/src/arrow/pretty_print.cc @@ -159,7 +159,7 @@ class ArrayPrinter : public PrettyPrinter { enable_if_date WriteDataValues(const T& array) { const auto data = array.raw_values(); using unit = typename std::conditional::value, - arrow_vendored::util::date::days, + 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_) << arrow_vendored::util::date::format(fmt, epoch_ + Unit{value}); + (*sink_) << arrow_vendored::date::format(fmt, epoch_ + Unit{value}); } else { - (*sink_) << arrow_vendored::util::date::format(fmt, Unit{value}); + (*sink_) << arrow_vendored::date::format(fmt, Unit{value}); } } @@ -391,12 +391,12 @@ class ArrayPrinter : public PrettyPrinter { } } - static arrow_vendored::util::date::sys_days epoch_; + static arrow_vendored::date::sys_days epoch_; std::string null_rep_; }; -arrow_vendored::util::date::sys_days ArrayPrinter::epoch_ = - arrow_vendored::util::date::sys_days{arrow_vendored::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/util/parsing.h b/cpp/src/arrow/util/parsing.h index 552e6e1ee01..6193741d525 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_vendored::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_vendored::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_vendored::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_vendored::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,9 +473,9 @@ class StringConverter { if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 8, 2, &day))) { return false; } - *out = {arrow_vendored::util::date::year{year}, - arrow_vendored::util::date::month{month}, - arrow_vendored::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 752217d9200..c8e14e53704 100644 --- a/cpp/src/arrow/vendored/datetime/date.h +++ b/cpp/src/arrow/vendored/datetime/date.h @@ -78,8 +78,6 @@ namespace arrow_vendored { -namespace util -{ namespace date { @@ -8016,7 +8014,6 @@ operator<<(std::basic_ostream& os, } } // namespace date -} // namespace util } // namespace arrow_vendored diff --git a/cpp/src/arrow/vendored/datetime/ios.h b/cpp/src/arrow/vendored/datetime/ios.h index b7f4cbbb7a9..acad28d13b5 100644 --- a/cpp/src/arrow/vendored/datetime/ios.h +++ b/cpp/src/arrow/vendored/datetime/ios.h @@ -34,8 +34,6 @@ namespace arrow_vendored { - namespace util - { namespace date { namespace iOSUtils @@ -46,7 +44,6 @@ } // namespace iOSUtils } // namespace date - } // namespace util } // namespace arrow_vendored # endif // TARGET_OS_IPHONE diff --git a/cpp/src/arrow/vendored/datetime/tz.cpp b/cpp/src/arrow/vendored/datetime/tz.cpp index a63eaf15e2f..1133b048f32 100644 --- a/cpp/src/arrow/vendored/datetime/tz.cpp +++ b/cpp/src/arrow/vendored/datetime/tz.cpp @@ -251,8 +251,6 @@ get_download_folder() namespace arrow_vendored { -namespace util -{ namespace date { // +---------------------+ @@ -3789,7 +3787,6 @@ current_zone() } } // namespace date -} // namespace util } // namespace arrow_vendored #if defined(__GNUC__) && __GNUC__ < 5 diff --git a/cpp/src/arrow/vendored/datetime/tz.h b/cpp/src/arrow/vendored/datetime/tz.h index aea617e22b3..249162b0149 100644 --- a/cpp/src/arrow/vendored/datetime/tz.h +++ b/cpp/src/arrow/vendored/datetime/tz.h @@ -157,8 +157,6 @@ static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true, namespace arrow_vendored { -namespace util -{ 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 8e35fdfdde6..f98c3e79a44 100644 --- a/cpp/src/arrow/vendored/datetime/tz_private.h +++ b/cpp/src/arrow/vendored/datetime/tz_private.h @@ -36,8 +36,6 @@ namespace arrow_vendored { -namespace util -{ namespace date { @@ -314,7 +312,6 @@ struct transition } // namespace detail } // namespace date -} // namespace util } // namespace arrow_vendored #if defined(_MSC_VER) && (_MSC_VER < 1900) diff --git a/cpp/src/gandiva/cast_time.cc b/cpp/src/gandiva/cast_time.cc index 38b191a4e62..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_vendored::util::date::day; - using arrow_vendored::util::date::local_days; - using arrow_vendored::util::date::locate_zone; - using arrow_vendored::util::date::month; - using arrow_vendored::util::date::time_zone; - using arrow_vendored::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 793f6bea19b..08abbec2937 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_vendored::util::date::sys_seconds seconds; + arrow_vendored::date::sys_seconds seconds; if (ignoreTimeInDay) { - arrow_vendored::util::date::sys_days days; - stream >> arrow_vendored::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_vendored::util::date::parse(format, seconds); + stream >> arrow_vendored::date::parse(format, seconds); if (stream.fail()) { return false; } @@ -93,8 +93,8 @@ static inline bool ParseTimestamp(const char* buf, const char* format, return false; } // ignore the time part - arrow_vendored::util::date::sys_seconds secs = arrow_vendored::util::date::sys_days( - arrow_vendored::util::date::year(result.tm_year + 1900) / (result.tm_mon + 1) / + 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) + diff --git a/cpp/src/gandiva/precompiled/epoch_time_point.h b/cpp/src/gandiva/precompiled/epoch_time_point.h index 89f30f81b2c..dcd62c4065b 100644 --- a/cpp/src/gandiva/precompiled/epoch_time_point.h +++ b/cpp/src/gandiva/precompiled/epoch_time_point.h @@ -36,9 +36,9 @@ class EpochTimePoint { int TmYday() const { auto to_days = - arrow_vendored::util::date::floor(tp_); - auto first_day_in_year = arrow_vendored::util::date::sys_days{ - YearMonthDay().year() / arrow_vendored::util::date::jan / 1}; + 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(); } @@ -46,9 +46,9 @@ class EpochTimePoint { int TmWday() const { auto to_days = - arrow_vendored::util::date::floor(tp_); - return (arrow_vendored::util::date::weekday{to_days} - // NOLINT - arrow_vendored::util::date::Sunday) + arrow_vendored::date::floor(tp_); + return (arrow_vendored::date::weekday{to_days} - // NOLINT + arrow_vendored::date::Sunday) .count(); } @@ -62,23 +62,23 @@ class EpochTimePoint { } EpochTimePoint AddYears(int num_years) const { - auto ymd = YearMonthDay() + arrow_vendored::util::date::years(num_years); - return EpochTimePoint((arrow_vendored::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_vendored::util::date::months(num_months); - return EpochTimePoint((arrow_vendored::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_vendored::util::date::sys_days{YearMonthDay()} + // NOLINT - arrow_vendored::util::date::days(num_days); + arrow_vendored::date::sys_days{YearMonthDay()} + // NOLINT + arrow_vendored::date::days(num_days); return EpochTimePoint( (days_since_epoch + TimeOfDay().to_duration()).time_since_epoch()); } @@ -92,16 +92,16 @@ class EpochTimePoint { int64_t MillisSinceEpoch() const { return tp_.time_since_epoch().count(); } private: - arrow_vendored::util::date::year_month_day YearMonthDay() const { - return arrow_vendored::util::date::year_month_day{ - arrow_vendored::util::date::floor( + arrow_vendored::date::year_month_day YearMonthDay() const { + return arrow_vendored::date::year_month_day{ + arrow_vendored::date::floor( tp_)}; // NOLINT } - arrow_vendored::util::date::time_of_day TimeOfDay() const { + arrow_vendored::date::time_of_day TimeOfDay() const { auto millis_since_midnight = - tp_ - arrow_vendored::util::date::floor(tp_); - return arrow_vendored::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 ade5f6ad519..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_vendored::util::date::day; - using arrow_vendored::util::date::month; - using arrow_vendored::util::date::sys_days; - using arrow_vendored::util::date::year; - using arrow_vendored::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_vendored::util::date::day; - using arrow_vendored::util::date::month; - using arrow_vendored::util::date::sys_days; - using arrow_vendored::util::date::year; - using arrow_vendored::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; From 3d2581efd6db40d2d8c326df6363cb7b4633230b Mon Sep 17 00:00:00 2001 From: Micah Kornfield Date: Thu, 16 May 2019 11:50:12 -0700 Subject: [PATCH 5/5] make format --- cpp/src/arrow/util/parsing.h | 3 +-- cpp/src/gandiva/date_utils.h | 6 +++--- cpp/src/gandiva/precompiled/epoch_time_point.h | 14 +++++--------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cpp/src/arrow/util/parsing.h b/cpp/src/arrow/util/parsing.h index 6193741d525..3d93ed29310 100644 --- a/cpp/src/arrow/util/parsing.h +++ b/cpp/src/arrow/util/parsing.h @@ -473,8 +473,7 @@ class StringConverter { if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 8, 2, &day))) { return false; } - *out = {arrow_vendored::date::year{year}, - arrow_vendored::date::month{month}, + *out = {arrow_vendored::date::year{year}, arrow_vendored::date::month{month}, arrow_vendored::date::day{day}}; return out->ok(); } diff --git a/cpp/src/gandiva/date_utils.h b/cpp/src/gandiva/date_utils.h index 08abbec2937..f02aceb92b9 100644 --- a/cpp/src/gandiva/date_utils.h +++ b/cpp/src/gandiva/date_utils.h @@ -93,9 +93,9 @@ static inline bool ParseTimestamp(const char* buf, const char* format, return false; } // ignore the time part - 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); + 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 dcd62c4065b..ec65d84854e 100644 --- a/cpp/src/gandiva/precompiled/epoch_time_point.h +++ b/cpp/src/gandiva/precompiled/epoch_time_point.h @@ -35,8 +35,7 @@ class EpochTimePoint { int TmMon() const { return static_cast(YearMonthDay().month()) - 1; } int TmYday() const { - auto to_days = - arrow_vendored::date::floor(tp_); + 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(); @@ -45,8 +44,7 @@ class EpochTimePoint { int TmMday() const { return static_cast(YearMonthDay().day()); } int TmWday() const { - auto to_days = - arrow_vendored::date::floor(tp_); + auto to_days = arrow_vendored::date::floor(tp_); return (arrow_vendored::date::weekday{to_days} - // NOLINT arrow_vendored::date::Sunday) .count(); @@ -76,9 +74,8 @@ class EpochTimePoint { } EpochTimePoint AddDays(int num_days) const { - auto days_since_epoch = - arrow_vendored::date::sys_days{YearMonthDay()} + // NOLINT - arrow_vendored::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()); } @@ -94,8 +91,7 @@ class EpochTimePoint { private: arrow_vendored::date::year_month_day YearMonthDay() const { return arrow_vendored::date::year_month_day{ - arrow_vendored::date::floor( - tp_)}; // NOLINT + arrow_vendored::date::floor(tp_)}; // NOLINT } arrow_vendored::date::time_of_day TimeOfDay() const {