16 #ifndef IMPALA_EXEC_TEXT_CONVERTER_INLINE_H
17 #define IMPALA_EXEC_TEXT_CONVERTER_INLINE_H
21 #include <boost/algorithm/string.hpp>
38 const char* data,
int len,
bool copy_string,
bool need_escape,
MemPool*
pool) {
61 bool reuse_data = type.
IsVarLen() && !(len != 0 && (copy_string || need_escape));
62 if (type.
type ==
TYPE_CHAR) reuse_data &= (buffer_len <= len);
65 str.
len = std::min(buffer_len, len);
67 str.
ptr =
const_cast<char*
>(data);
70 reinterpret_cast<char*>(slot);
74 memcpy(str.
ptr, data, str.
len);
90 *
reinterpret_cast<bool*
>(slot) =
94 *
reinterpret_cast<int8_t*
>(slot) =
95 StringParser::StringToInt<int8_t>(data, len, &parse_result);
98 *
reinterpret_cast<int16_t*
>(slot) =
99 StringParser::StringToInt<int16_t>(data, len, &parse_result);
102 *
reinterpret_cast<int32_t*
>(slot) =
103 StringParser::StringToInt<int32_t>(data, len, &parse_result);
106 *
reinterpret_cast<int64_t*
>(slot) =
107 StringParser::StringToInt<int64_t>(data, len, &parse_result);
110 *
reinterpret_cast<float*
>(slot) =
111 StringParser::StringToFloat<float>(data, len, &parse_result);
114 *
reinterpret_cast<double*
>(slot) =
115 StringParser::StringToFloat<double>(data, len, &parse_result);
129 StringParser::StringToDecimal<int32_t>(
130 data, len, slot_desc->
type(), &parse_result);
134 StringParser::StringToDecimal<int64_t>(
135 data, len, slot_desc->
type(), &parse_result);
138 DCHECK(
false) <<
"Planner should not generate this.";
142 StringParser::StringToDecimal<int128_t>(
143 data, len, slot_desc->
type(), &parse_result);
146 DCHECK(
false) <<
"Decimal slots can't be this size.";
155 DCHECK(
false) <<
"bad slot type: " << slot_desc->
type();
void SetNull(const NullIndicatorOffset &offset)
A tuple with 0 materialised slots is represented as NULL.
bool WriteSlot(const SlotDescriptor *slot_desc, Tuple *tuple, const char *data, int len, bool copy_string, bool need_escape, MemPool *pool)
void UnescapeString(const char *src, char *dest, int *len, int64_t maxlen=-1)
void * GetSlot(int offset)
bool HasDateOrTime() const
static void PadWithSpaces(char *cptr, int64_t cptr_len, int64_t num_chars)
const NullIndicatorOffset & null_indicator_offset() const
bool IsStringType() const
const ColumnType & type() const
bool check_null_
Indicates whether we should check for null_col_val_ and set slots to NULL.
int len
Only set if type == TYPE_CHAR or type == TYPE_VARCHAR.
static bool StringToBool(const char *s, int len, ParseResult *result)
Parses a string for 'true' or 'false', case insensitive.
std::string null_col_val_
Special string to indicate NULL column values.
static int StringCompare(const char *s1, int n1, const char *s2, int n2, int len)
uint8_t * Allocate(int size)