16 #include <boost/functional/hash.hpp>
29 stringstream* stream) {
30 if (value == NULL)
return;
32 const char* chars =
reinterpret_cast<const char*
>(value);
36 stream->write(chars,
sizeof(
bool));
39 stream->write(chars,
sizeof(int8_t));
42 stream->write(chars,
sizeof(int16_t));
45 stream->write(chars,
sizeof(int32_t));
48 stream->write(chars,
sizeof(int64_t));
51 stream->write(chars,
sizeof(
float));
54 stream->write(chars,
sizeof(
double));
58 string_val =
reinterpret_cast<const StringValue*
>(value);
59 stream->write(static_cast<char*>(string_val->
ptr), string_val->
len);
71 DCHECK(
false) <<
"bad RawValue::PrintValue() type: " << type.
DebugString();
84 const StringValue* string_val = NULL;
91 val = *
reinterpret_cast<const bool*
>(value);
92 *str = (val ?
"true" :
"false");
96 string_val =
reinterpret_cast<const StringValue*
>(value);
97 tmp.assign(static_cast<char*>(string_val->ptr), string_val->len);
122 return *
reinterpret_cast<const bool*
>(v1) - *reinterpret_cast<const bool*>(v2);
124 return *
reinterpret_cast<const int8_t*
>(v1) - *reinterpret_cast<const int8_t*>(v2);
126 return *
reinterpret_cast<const int16_t*
>(v1) -
127 *reinterpret_cast<const int16_t*>(v2);
129 i1 = *
reinterpret_cast<const int32_t*
>(v1);
130 i2 = *
reinterpret_cast<const int32_t*
>(v2);
131 return i1 > i2 ? 1 : (i1 < i2 ? -1 : 0);
133 b1 = *
reinterpret_cast<const int64_t*
>(v1);
134 b2 = *
reinterpret_cast<const int64_t*
>(v2);
135 return b1 > b2 ? 1 : (b1 < b2 ? -1 : 0);
138 f1 = *
reinterpret_cast<const float*
>(v1);
139 f2 = *
reinterpret_cast<const float*
>(v2);
140 if (isnan(f1) && isnan(f2))
return 0;
141 if (isnan(f1))
return -1;
142 if (isnan(f2))
return 1;
143 return f1 > f2 ? 1 : (f1 < f2 ? -1 : 0);
146 d1 = *
reinterpret_cast<const double*
>(v1);
147 d2 = *
reinterpret_cast<const double*
>(v2);
148 if (isnan(d1) && isnan(d2))
return 0;
149 if (isnan(d1))
return -1;
150 if (isnan(d2))
return 1;
151 return d1 > d2 ? 1 : (d1 < d2 ? -1 : 0);
154 string_value1 =
reinterpret_cast<const StringValue*
>(v1);
155 string_value2 =
reinterpret_cast<const StringValue*
>(v2);
156 return string_value1->
Compare(*string_value2);
160 return *ts_value1 > *ts_value2 ? 1 : (*ts_value1 < *ts_value2 ? -1 : 0);
166 return StringCompare(v1ptr, l1, v2ptr, l2, std::min(l1, l2));
172 *reinterpret_cast<const Decimal4Value*>(v2));
175 *reinterpret_cast<const Decimal8Value*>(v2));
178 *reinterpret_cast<const Decimal16Value*>(v2));
180 DCHECK(
false) << type;
184 DCHECK(
false) <<
"invalid type: " << type.
DebugString();
191 DCHECK(value != NULL);
196 *
reinterpret_cast<bool*
>(dst) = *reinterpret_cast<const bool*>(value);
199 *
reinterpret_cast<int8_t*
>(dst) = *reinterpret_cast<const int8_t*>(value);
202 *
reinterpret_cast<int16_t*
>(dst) = *reinterpret_cast<const int16_t*>(value);
205 *
reinterpret_cast<int32_t*
>(dst) = *reinterpret_cast<const int32_t*>(value);
208 *
reinterpret_cast<int64_t*
>(dst) = *reinterpret_cast<const int64_t*>(value);
211 *
reinterpret_cast<float*
>(dst) = *reinterpret_cast<const float*>(value);
214 *
reinterpret_cast<double*
>(dst) = *reinterpret_cast<const double*>(value);
218 *reinterpret_cast<const TimestampValue*>(value);
244 DCHECK(
false) <<
"RawValue::Write(): bad type: " << type.
DebugString();
250 void* dst, uint8_t** buf) {
251 DCHECK(value != NULL);
254 *
reinterpret_cast<bool*
>(dst) = *reinterpret_cast<const bool*>(value);
257 *
reinterpret_cast<int8_t*
>(dst) = *reinterpret_cast<const int8_t*>(value);
260 *
reinterpret_cast<int16_t*
>(dst) = *reinterpret_cast<const int16_t*>(value);
263 *
reinterpret_cast<int32_t*
>(dst) = *reinterpret_cast<const int32_t*>(value);
266 *
reinterpret_cast<int64_t*
>(dst) = *reinterpret_cast<const int64_t*>(value);
269 *
reinterpret_cast<float*
>(dst) = *reinterpret_cast<const float*>(value);
272 *
reinterpret_cast<double*
>(dst) = *reinterpret_cast<const double*>(value);
276 *reinterpret_cast<const TimestampValue*>(value);
284 memcpy(dst, value, type.
len);
290 dest->
ptr =
reinterpret_cast<char*
>(*buf);
299 DCHECK(
false) <<
"RawValue::Write(): bad type: " << type.
DebugString();
static void PrintValue(const void *value, const ColumnType &type, int scale, std::stringstream *stream)
void SetNull(const NullIndicatorOffset &offset)
static void PrintValueAsBytes(const void *value, const ColumnType &type, std::stringstream *stream)
Writes the byte representation of a value to a stringstream character-by-character.
A tuple with 0 materialised slots is represented as NULL.
static const int ASCII_PRECISION
Ascii output precision for double/float.
void * GetSlot(int offset)
const NullIndicatorOffset & null_indicator_offset() const
static int64_t UnpaddedCharLength(const char *cptr, int64_t len)
Returns number of characters in a char array (ignores trailing spaces)
std::string DebugString() const
const ColumnType & type() const
int Compare(const StringValue &other) const
int GetByteSize() const
Returns the byte size of this type. Returns 0 for variable length types.
int len
Only set if type == TYPE_CHAR or type == TYPE_VARCHAR.
static void Write(const void *value, Tuple *tuple, const SlotDescriptor *slot_desc, MemPool *pool)
static int Compare(const void *v1, const void *v2, const ColumnType &type)
static char * CharSlotToPtr(void *slot, const ColumnType &type)
static int StringCompare(const char *s1, int n1, const char *s2, int n2, int len)
uint8_t * Allocate(int size)