Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::TimestampParser Class Reference

Used for parsing both default and custom formatted timestamp values. More...

#include <timestamp-parse-util.h>

Collaboration diagram for impala::TimestampParser:

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]
 

Detailed Description

Used for parsing both default and custom formatted timestamp values.

Definition at line 125 of file timestamp-parse-util.h.

Member Function Documentation

static int impala::TimestampParser::Format ( const DateTimeFormatContext dt_ctx,
const boost::gregorian::date &  d,
const boost::posix_time::time_duration &  t,
int  len,
char *  buff 
)
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().

void impala::TimestampParser::Init ( )
static
static bool impala::TimestampParser::Parse ( const char *  str,
int  len,
boost::gregorian::date *  d,
boost::posix_time::time_duration *  t 
)
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().

static bool impala::TimestampParser::Parse ( const char *  str,
int  len,
const DateTimeFormatContext dt_ctx,
boost::gregorian::date *  d,
boost::posix_time::time_duration *  t 
)
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.

Member Data Documentation

DateTimeFormatContext impala::TimestampParser::DEFAULT_DATE_CTX
staticprivate

Definition at line 487 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

const int impala::TimestampParser::DEFAULT_DATE_FMT_LEN = 10
staticprivate

Constants to hold default format lengths.

Definition at line 469 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

DateTimeFormatContext impala::TimestampParser::DEFAULT_DATE_TIME_CTX
staticprivate

Definition at line 489 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

const int impala::TimestampParser::DEFAULT_DATE_TIME_FMT_LEN = 29
staticprivate

Definition at line 473 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

DateTimeFormatContext impala::TimestampParser::DEFAULT_ISO_DATE_TIME_CTX
staticprivate

Definition at line 490 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

DateTimeFormatContext impala::TimestampParser::DEFAULT_SHORT_DATE_TIME_CTX
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.

Referenced by Init(), and Parse().

const int impala::TimestampParser::DEFAULT_SHORT_DATE_TIME_FMT_LEN = 19
staticprivate

Definition at line 472 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

DateTimeFormatContext impala::TimestampParser::DEFAULT_SHORT_ISO_DATE_TIME_CTX
staticprivate

Definition at line 486 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

DateTimeFormatContext impala::TimestampParser::DEFAULT_TIME_CTX
staticprivate

Definition at line 488 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

const int impala::TimestampParser::DEFAULT_TIME_FMT_LEN = 8
staticprivate

Definition at line 470 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

DateTimeFormatContext impala::TimestampParser::DEFAULT_TIME_FRAC_CTX
staticprivate

Definition at line 491 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

const int impala::TimestampParser::DEFAULT_TIME_FRAC_FMT_LEN = 18
staticprivate

Definition at line 471 of file timestamp-parse-util.h.

Referenced by Init(), and Parse().

bool impala::TimestampParser::initialized_ = false
staticprivate

Used to indicate if the parsing state has been initialized.

Definition at line 476 of file timestamp-parse-util.h.

Referenced by Format(), Init(), and Parse().

unordered_map< StringValue, int > impala::TimestampParser::REV_MONTH_INDEX
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().


The documentation for this class was generated from the following files: