mirror of
https://github.com/apache/impala.git
synced 2026-01-14 21:00:37 -05:00
This patch removes all occurrences of "using namespace std" and "using namespace boost(.*)" from the codebase. However, there are still cases where namespace directives are used (e.g. for rapidjson, thrift, gutil). These have to be tackled in subsequent patches. To reduce the patch size, this patch introduces a new header file called "names.h" that will include many of our most frequently used symbols iff the corresponding include was already added. This means, that this header file will pull in for example map / string / vector etc, only iff vector was already included. This requires "common/names.h" to be the last include. After including `names.h` a new block contains a sorted list of using definitions (this patch does not fix namespace directive declarations for other than std / boost namespaces.) Change-Id: Iebe4c054670d655bc355347e381dae90999cfddf Reviewed-on: http://gerrit.cloudera.org:8080/338 Reviewed-by: Martin Grund <mgrund@cloudera.com> Tested-by: Internal Jenkins
89 lines
3.7 KiB
C++
89 lines
3.7 KiB
C++
// Copyright 2013 Cloudera Inc.
|
|
//
|
|
// Licensed 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 "runtime/timestamp-parse-util.h"
|
|
#include <boost/assign/list_of.hpp>
|
|
|
|
namespace assign = boost::assign;
|
|
using boost::unordered_map;
|
|
|
|
namespace impala {
|
|
|
|
bool TimestampParser::initialized_ = false;
|
|
unordered_map<StringValue, int> TimestampParser::REV_MONTH_INDEX;
|
|
DateTimeFormatContext TimestampParser::DEFAULT_SHORT_DATE_TIME_CTX;
|
|
DateTimeFormatContext TimestampParser::DEFAULT_SHORT_ISO_DATE_TIME_CTX;
|
|
DateTimeFormatContext TimestampParser::DEFAULT_DATE_CTX;
|
|
DateTimeFormatContext TimestampParser::DEFAULT_TIME_CTX;
|
|
DateTimeFormatContext TimestampParser::DEFAULT_DATE_TIME_CTX[10];
|
|
DateTimeFormatContext TimestampParser::DEFAULT_ISO_DATE_TIME_CTX[10];
|
|
DateTimeFormatContext TimestampParser::DEFAULT_TIME_FRAC_CTX[10];
|
|
|
|
void TimestampParser::Init() {
|
|
if (TimestampParser::initialized_) return;
|
|
// This needs to be lazily init'd because a StringValues hash function will be invoked
|
|
// for each entry that's placed in the map. The hash function expects that
|
|
// CpuInfo::Init() has already been called.
|
|
REV_MONTH_INDEX = assign::map_list_of
|
|
(StringValue("jan"), 1)(StringValue("feb"), 2)(StringValue("mar"), 3)
|
|
(StringValue("apr"), 4)(StringValue("may"), 5)(StringValue("jun"), 6)
|
|
(StringValue("jul"), 7)(StringValue("aug"), 8)(StringValue("sep"), 9)
|
|
(StringValue("oct"), 10)(StringValue("nov"), 11)(StringValue("dec"), 12);
|
|
|
|
// Setup the default date/time context yyyy-MM-dd HH:mm:ss.SSSSSSSSS
|
|
const char* DATE_TIME_CTX_FMT = "yyyy-MM-dd HH:mm:ss.SSSSSSSSS";
|
|
const int FRACTIONAL_MAX_LEN = 9;
|
|
for (int i = FRACTIONAL_MAX_LEN; i >= 0; --i) {
|
|
DEFAULT_DATE_TIME_CTX[i].Reset(DATE_TIME_CTX_FMT,
|
|
DEFAULT_DATE_TIME_FMT_LEN - (FRACTIONAL_MAX_LEN - i));
|
|
ParseFormatTokens(&DEFAULT_DATE_TIME_CTX[i]);
|
|
}
|
|
|
|
// Setup the default ISO date/time context yyyy-MM-ddTHH:mm:ss.SSSSSSSSS
|
|
for (int i = FRACTIONAL_MAX_LEN; i >= 0; --i) {
|
|
DEFAULT_ISO_DATE_TIME_CTX[i].Reset("yyyy-MM-ddTHH:mm:ss.SSSSSSSSS",
|
|
DEFAULT_DATE_TIME_FMT_LEN - (FRACTIONAL_MAX_LEN - i));
|
|
ParseFormatTokens(&DEFAULT_ISO_DATE_TIME_CTX[i]);
|
|
}
|
|
|
|
// Setup the short default date/time context yyyy-MM-dd HH:mm:ss
|
|
DEFAULT_SHORT_DATE_TIME_CTX.Reset("yyyy-MM-dd HH:mm:ss",
|
|
DEFAULT_SHORT_DATE_TIME_FMT_LEN);
|
|
ParseFormatTokens(&DEFAULT_SHORT_DATE_TIME_CTX);
|
|
|
|
// Setup the short default ISO date/time context yyyy-MM-ddTHH:mm:ss
|
|
DEFAULT_SHORT_ISO_DATE_TIME_CTX.Reset("yyyy-MM-ddTHH:mm:ss",
|
|
DEFAULT_SHORT_DATE_TIME_FMT_LEN);
|
|
ParseFormatTokens(&DEFAULT_SHORT_ISO_DATE_TIME_CTX);
|
|
|
|
// Setup the default short date context yyyy-MM-dd
|
|
DEFAULT_DATE_CTX.Reset("yyyy-MM-dd", DEFAULT_DATE_FMT_LEN);
|
|
ParseFormatTokens(&DEFAULT_DATE_CTX);
|
|
|
|
// Setup the default short time context HH:mm:ss
|
|
DEFAULT_TIME_CTX.Reset("HH:mm:ss", DEFAULT_TIME_FMT_LEN);
|
|
ParseFormatTokens(&DEFAULT_TIME_CTX);
|
|
|
|
// Setup the default short time context with fractional seconds HH:mm:ss.SSSSSSSSS
|
|
for (int i = FRACTIONAL_MAX_LEN; i >= 0; --i) {
|
|
DEFAULT_TIME_FRAC_CTX[i].Reset(DATE_TIME_CTX_FMT + 11,
|
|
DEFAULT_TIME_FRAC_FMT_LEN - (FRACTIONAL_MAX_LEN - i));
|
|
ParseFormatTokens(&DEFAULT_TIME_FRAC_CTX[i]);
|
|
}
|
|
// Flag that the parser is ready.
|
|
TimestampParser::initialized_ = true;
|
|
}
|
|
|
|
}
|