Utility to put val into an AnyVal struct
| 262 | |
| 263 | /// Utility to put val into an AnyVal struct |
| 264 | static void SetAnyVal(const void* slot, const ColumnType& type, AnyVal* dst) { |
| 265 | if (slot == NULL) { |
| 266 | dst->is_null = true; |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | dst->is_null = false; |
| 271 | switch (type.type) { |
| 272 | case TYPE_NULL: return; |
| 273 | case TYPE_BOOLEAN: |
| 274 | reinterpret_cast<BooleanVal*>(dst)->val = *reinterpret_cast<const bool*>(slot); |
| 275 | return; |
| 276 | case TYPE_TINYINT: |
| 277 | reinterpret_cast<TinyIntVal*>(dst)->val = *reinterpret_cast<const int8_t*>(slot); |
| 278 | return; |
| 279 | case TYPE_SMALLINT: |
| 280 | reinterpret_cast<SmallIntVal*>(dst)->val = *reinterpret_cast<const int16_t*>(slot); |
| 281 | return; |
| 282 | case TYPE_INT: |
| 283 | reinterpret_cast<IntVal*>(dst)->val = *reinterpret_cast<const int32_t*>(slot); |
| 284 | return; |
| 285 | case TYPE_BIGINT: |
| 286 | reinterpret_cast<BigIntVal*>(dst)->val = *reinterpret_cast<const int64_t*>(slot); |
| 287 | return; |
| 288 | case TYPE_FLOAT: |
| 289 | reinterpret_cast<FloatVal*>(dst)->val = *reinterpret_cast<const float*>(slot); |
| 290 | return; |
| 291 | case TYPE_DOUBLE: |
| 292 | reinterpret_cast<DoubleVal*>(dst)->val = *reinterpret_cast<const double*>(slot); |
| 293 | return; |
| 294 | case TYPE_STRING: |
| 295 | case TYPE_VARCHAR: |
| 296 | reinterpret_cast<const StringValue*>(slot)->ToStringVal( |
| 297 | reinterpret_cast<StringVal*>(dst)); |
| 298 | if (type.type == TYPE_VARCHAR) { |
| 299 | StringVal* sv = reinterpret_cast<StringVal*>(dst); |
| 300 | DCHECK_GE(type.len, 0); |
| 301 | DCHECK_LE(sv->len, type.len); |
| 302 | } |
| 303 | return; |
| 304 | case TYPE_CHAR: |
| 305 | case TYPE_FIXED_UDA_INTERMEDIATE: { |
| 306 | StringVal* sv = reinterpret_cast<StringVal*>(dst); |
| 307 | sv->ptr = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(slot)); |
| 308 | sv->len = type.len; |
| 309 | return; |
| 310 | } |
| 311 | case TYPE_TIMESTAMP: |
| 312 | reinterpret_cast<const TimestampValue*>(slot)->ToTimestampVal( |
| 313 | reinterpret_cast<TimestampVal*>(dst)); |
| 314 | return; |
| 315 | case TYPE_DECIMAL: |
| 316 | switch (type.GetByteSize()) { |
| 317 | case 4: |
| 318 | reinterpret_cast<DecimalVal*>(dst)->val4 = |
| 319 | *reinterpret_cast<const int32_t*>(slot); |
| 320 | return; |
| 321 | case 8: |
nothing calls this directly
no test coverage detected