anthonylouisbsb commented on a change in pull request #10137: URL: https://github.com/apache/arrow/pull/10137#discussion_r756483095
########## File path: cpp/src/gandiva/interval_holder.cc ########## @@ -0,0 +1,277 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "gandiva/interval_holder.h" + +#include "gandiva/node.h" +#include "gandiva/regex_util.h" + +namespace gandiva { + +// pre-compiled pattern for matching period that only have numbers +static const RE2 period_only_contains_numbers(R"(\d+)"); + +// pre-compiled pattern for matching periods in 8601 formats that not contains weeks. +static const RE2 iso8601_complete_period( + R"(P([[:digit:]]+Y)?([[:digit:]]+M)?([[:digit:]]+D)?)" + R"(T([[:digit:]]+H)?([[:digit:]]+M)?([[:digit:]]+S|[[:digit:]]+\.[[:digit:]]+S)?)"); + +// pre-compiled pattern for matching periods in 8601 formats that not contain time +// (hours, minutes and seconds) information. +static const RE2 iso8601_period_without_time( + R"(P([[:digit:]]+Y)?([[:digit:]]+M)?([[:digit:]]+D)?)"); + +// pre-compiled pattern for matching periods in 8601 formats that not contain time +// (hours, minutes and seconds) information. +static const std::regex period_not_contains_time(R"(^((?!T).)*$)"); + +// pre-compiled pattern for matching periods in 8601 formats that contains weeks inside +// them. The ISO8601 specification defines that if the string contains a week, it can not +// have other time granularities information, like day, years and months. +static const RE2 iso8601_period_with_weeks(R"(P([[:digit:]]+W){1})"); + +int64_t IntervalDaysHolder::GetIntervalDayFromMillis(const std::string& number_as_string, + bool* out_valid) { + int64_t period_in_millis = std::stol(number_as_string); + + // It considers that a day has exactly 24 hours of duration + int64_t days_to_standard_millis = 86400000; Review comment: I put the value in a static const variable -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
