MCPcopy Create free account
hub / github.com/apache/impala / GetSharedRepresentation

Method GetSharedRepresentation

be/src/util/tuple-row-compare.cc:410–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408
409template <typename U>
410U TupleRowZOrderComparator::GetSharedRepresentation(void* val, ColumnType type) const {
411 // The mask used for setting the sign bit correctly.
412 if (val == NULL) return 0;
413 constexpr U mask = (U)1 << (sizeof(U) * 8 - 1);
414 switch (type.type) {
415 case TYPE_NULL:
416 return 0;
417 case TYPE_BOOLEAN:
418 return static_cast<U>(*reinterpret_cast<const bool*>(val)) << (sizeof(U) * 8 - 1);
419 case TYPE_TINYINT:
420 return GetSharedIntRepresentation<U, int8_t>(
421 *reinterpret_cast<const int8_t*>(val), mask);
422 case TYPE_SMALLINT:
423 return GetSharedIntRepresentation<U, int16_t>(
424 *reinterpret_cast<const int16_t*>(val), mask);
425 case TYPE_INT:
426 return GetSharedIntRepresentation<U, int32_t>(
427 *reinterpret_cast<const int32_t*>(val), mask);
428 case TYPE_BIGINT:
429 return GetSharedIntRepresentation<U, int64_t>(
430 *reinterpret_cast<const int64_t*>(val), mask);
431 case TYPE_DATE:
432 return GetSharedIntRepresentation<U, int32_t>(
433 reinterpret_cast<const DateValue*>(val)->Value(), mask);
434 case TYPE_FLOAT:
435 return GetSharedFloatRepresentation<U, float>(val, mask);
436 case TYPE_DOUBLE:
437 return GetSharedFloatRepresentation<U, double>(val, mask);
438 case TYPE_STRING:
439 case TYPE_VARCHAR: {
440 const StringValue* string_value = reinterpret_cast<const StringValue*>(val);
441 return GetSharedStringRepresentation<U>(string_value->Ptr(), string_value->Len());
442 }
443 case TYPE_CHAR:
444 return GetSharedStringRepresentation<U>(
445 reinterpret_cast<const char*>(val), type.len);
446 case TYPE_TIMESTAMP: {
447 const TimestampValue* ts = reinterpret_cast<const TimestampValue*>(val);
448 const uint128_t nanosnds = static_cast<uint128_t>(ts->time().total_nanoseconds());
449 const uint128_t days = static_cast<uint128_t>(ts->date().day_number());
450 return (days << 64) | nanosnds;
451 }
452 case TYPE_DECIMAL:
453 switch (type.GetByteSize()) {
454 case 4:
455 return GetSharedIntRepresentation<U, int32_t>(
456 reinterpret_cast<const Decimal4Value*>(val)->value(), mask);
457 case 8:
458 return GetSharedIntRepresentation<U, int64_t>(
459 reinterpret_cast<const Decimal8Value*>(val)->value(), mask);
460 case 16: // value is of int128_t, big enough that no shifts are needed
461 return static_cast<U>(
462 reinterpret_cast<const Decimal16Value*>(val)->value()) ^ mask;
463 default:
464 DCHECK(false) << type;
465 return 0;
466 }
467 default:

Callers

nothing calls this directly

Calls 5

GetByteSizeMethod · 0.80
ValueMethod · 0.45
PtrMethod · 0.45
LenMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected