Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
Used for parsing both default and custom formatted timestamp values. More...
#include <timestamp-parse-util.h>
Static Public Member Functions | |
static void | Init () |
static bool | ParseFormatTokens (DateTimeFormatContext *dt_ctx) |
static bool | Parse (const char *str, int len, boost::gregorian::date *d, boost::posix_time::time_duration *t) |
static bool | Parse (const char *str, int len, const DateTimeFormatContext &dt_ctx, boost::gregorian::date *d, boost::posix_time::time_duration *t) |
static int | Format (const DateTimeFormatContext &dt_ctx, const boost::gregorian::date &d, const boost::posix_time::time_duration &t, int len, char *buff) |
Static Private Member Functions | |
static bool | ParseDateTime (const char *str, int str_len, const DateTimeFormatContext &dt_ctx, DateTimeParseResult *dt_result) |
Static Private Attributes | |
static const int | DEFAULT_DATE_FMT_LEN = 10 |
Constants to hold default format lengths. More... | |
static const int | DEFAULT_TIME_FMT_LEN = 8 |
static const int | DEFAULT_TIME_FRAC_FMT_LEN = 18 |
static const int | DEFAULT_SHORT_DATE_TIME_FMT_LEN = 19 |
static const int | DEFAULT_DATE_TIME_FMT_LEN = 29 |
static bool | initialized_ = false |
Used to indicate if the parsing state has been initialized. More... | |
static boost::unordered_map < StringValue, int > | REV_MONTH_INDEX |
Lazily initialized pseudo-constant hashmap for mapping month names to an index. More... | |
static DateTimeFormatContext | DEFAULT_SHORT_DATE_TIME_CTX |
static DateTimeFormatContext | DEFAULT_SHORT_ISO_DATE_TIME_CTX |
static DateTimeFormatContext | DEFAULT_DATE_CTX |
static DateTimeFormatContext | DEFAULT_TIME_CTX |
static DateTimeFormatContext | DEFAULT_DATE_TIME_CTX [10] |
static DateTimeFormatContext | DEFAULT_ISO_DATE_TIME_CTX [10] |
static DateTimeFormatContext | DEFAULT_TIME_FRAC_CTX [10] |
Used for parsing both default and custom formatted timestamp values.
Definition at line 125 of file timestamp-parse-util.h.
|
inlinestatic |
Format the date/time values using the given format context. Note that a string terminator will be appended to the string. dt_ctx – date/time format context d – the date value t – the time value len – the output buffer length (should be at least dt_ctx.fmt_exp_len + 1) buff – the output string buffer (must be large enough to hold value) Return the number of characters copied in to the buffer (excluding terminator).
Terminate the string
Definition at line 335 of file timestamp-parse-util.h.
References impala::DAY_IN_MONTH, impala::DateTimeFormatContext::fmt_out_len, impala::FRACTION, impala::DateTimeFormatContext::has_date_toks, impala::DateTimeFormatContext::has_time_toks, impala::HOUR_IN_DAY, initialized_, impala::DateTimeFormatToken::len, impala::MINUTE_IN_HOUR, impala::MONTH_IN_YEAR, impala::MONTH_IN_YEAR_SLT, impala::SECOND_IN_MINUTE, impala::SEPARATOR, impala::DateTimeFormatContext::toks, impala::DateTimeFormatToken::type, impala::DateTimeFormatToken::val, and impala::YEAR.
Referenced by impala::TimestampValue::Format().
|
static |
Initializes the static parser context which includes default date/time formats and lookup tables. This must be called before any of the Parse* related functions can be used.
Definition at line 33 of file timestamp-parse-util.cc.
References DEFAULT_DATE_CTX, DEFAULT_DATE_FMT_LEN, DEFAULT_DATE_TIME_CTX, DEFAULT_DATE_TIME_FMT_LEN, DEFAULT_ISO_DATE_TIME_CTX, DEFAULT_SHORT_DATE_TIME_CTX, DEFAULT_SHORT_DATE_TIME_FMT_LEN, DEFAULT_SHORT_ISO_DATE_TIME_CTX, DEFAULT_TIME_CTX, DEFAULT_TIME_FMT_LEN, DEFAULT_TIME_FRAC_CTX, DEFAULT_TIME_FRAC_FMT_LEN, initialized_, ParseFormatTokens(), impala::DateTimeFormatContext::Reset(), and REV_MONTH_INDEX.
Referenced by impala::InitCommonRuntime().
|
inlinestatic |
Parse a default date/time string. The default timestamp format is: yyyy-MM-dd HH:mm:ss.SSSSSSSSS or yyyy-MM-ddTHH:mm:ss.SSSSSSSSS. Either just the date or just the time may be specified. All components are required in either the date or time except for the fractional seconds following the period. In the case of just a date, the time will be set to 00:00:00. In the case of just a time, the date will be set to invalid. str – valid pointer to the string to parse len – length of the string to parse (must be > 0) dt_ctx – date/time format context (must contain valid tokens) d – the date value where the results of the parsing will be placed t – the time value where the results of the parsing will be placed Returns true if the date/time was successfully parsed.
Definition at line 202 of file timestamp-parse-util.h.
References DEFAULT_DATE_CTX, DEFAULT_DATE_FMT_LEN, DEFAULT_DATE_TIME_CTX, DEFAULT_DATE_TIME_FMT_LEN, DEFAULT_ISO_DATE_TIME_CTX, DEFAULT_SHORT_DATE_TIME_CTX, DEFAULT_SHORT_DATE_TIME_FMT_LEN, DEFAULT_SHORT_ISO_DATE_TIME_CTX, DEFAULT_TIME_CTX, DEFAULT_TIME_FMT_LEN, DEFAULT_TIME_FRAC_CTX, DEFAULT_TIME_FRAC_FMT_LEN, initialized_, LIKELY, and UNLIKELY.
Referenced by impala::TimestampValue::TimestampValue().
|
inlinestatic |
Parse a date/time string. The data must adhere to the format, otherwise it will be rejected i.e. no missing tokens. In the case of just a date, the time will be set to 00:00:00. In the case of just a time, the date will be set to invalid. str – valid pointer to the string to parse len – length of the string to parse (must be > 0) d – the date value where the results of the parsing will be placed t – the time value where the results of the parsing will be placed Returns true if the date/time was successfully parsed.
Definition at line 292 of file timestamp-parse-util.h.
References impala::DateTimeParseResult::day, impala::DateTimeParseResult::fraction, impala::DateTimeFormatContext::has_date_toks, impala::DateTimeFormatContext::has_time_toks, impala::DateTimeParseResult::hour, initialized_, impala::DateTimeParseResult::minute, impala::DateTimeParseResult::month, ParseDateTime(), impala::DateTimeParseResult::second, impala::DateTimeFormatContext::toks, UNLIKELY, VLOG_ROW, and impala::DateTimeParseResult::year.
|
inlinestaticprivate |
Definition at line 390 of file timestamp-parse-util.h.
References impala::DateTimeParseResult::day, impala::DAY_IN_MONTH, impala::DateTimeFormatContext::fmt_len, impala::FRACTION, impala::DateTimeParseResult::fraction, impala::DateTimeParseResult::hour, impala::HOUR_IN_DAY, impala::DateTimeFormatToken::len, impala::DateTimeParseResult::minute, impala::MINUTE_IN_HOUR, impala::DateTimeParseResult::month, impala::MONTH_IN_YEAR, impala::MONTH_IN_YEAR_SLT, impala::StringParser::PARSE_SUCCESS, impala::DateTimeFormatToken::pos, REV_MONTH_INDEX, impala::DateTimeParseResult::second, impala::SECOND_IN_MINUTE, impala::SEPARATOR, impala::DateTimeFormatContext::toks, impala::DateTimeFormatToken::type, UNLIKELY, impala::DateTimeFormatToken::val, impala::YEAR, and impala::DateTimeParseResult::year.
Referenced by Parse().
|
inlinestatic |
Parse the date/time format into tokens and place them in the context. dt_ctx – date/time format context Return true if the parse was successful.
Definition at line 135 of file timestamp-parse-util.h.
References impala::DAY_IN_MONTH, impala::DateTimeFormatContext::fmt, impala::DateTimeFormatContext::fmt_len, impala::DateTimeFormatContext::fmt_out_len, impala::FRACTION, impala::DateTimeFormatContext::has_date_toks, impala::DateTimeFormatContext::has_time_toks, impala::HOUR_IN_DAY, impala::DateTimeFormatToken::len, impala::MINUTE_IN_HOUR, impala::MONTH_IN_YEAR, impala::MONTH_IN_YEAR_SLT, impala::SECOND_IN_MINUTE, impala::SEPARATOR, impala::DateTimeFormatContext::toks, impala::UNKNOWN, UNLIKELY, and impala::YEAR.
Referenced by Init(), impala::TEST(), and impala::TestTimestampTokens().
|
staticprivate |
Definition at line 487 of file timestamp-parse-util.h.
|
staticprivate |
Constants to hold default format lengths.
Definition at line 469 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 489 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 473 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 490 of file timestamp-parse-util.h.
|
staticprivate |
Pseudo-constant default date/time contexts. Backwards compatibility is provided on variable length fractional components by defining a format context for each expected length (0 - 9). This logic will be refactored when the parser supports lazy token groups.
Definition at line 485 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 472 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 486 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 488 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 470 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 491 of file timestamp-parse-util.h.
|
staticprivate |
Definition at line 471 of file timestamp-parse-util.h.
|
staticprivate |
Used to indicate if the parsing state has been initialized.
Definition at line 476 of file timestamp-parse-util.h.
|
staticprivate |
Lazily initialized pseudo-constant hashmap for mapping month names to an index.
Definition at line 479 of file timestamp-parse-util.h.
Referenced by Init(), and ParseDateTime().