Serializes expression value 'value' to thrift structure TColumnValue 'col_val'. 'type' indicates the type of the expression value.
| 90 | // Serializes expression value 'value' to thrift structure TColumnValue 'col_val'. |
| 91 | // 'type' indicates the type of the expression value. |
| 92 | static void SetTColumnValue( |
| 93 | const void* value, const ColumnType& type, TColumnValue* col_val) { |
| 94 | if (value == nullptr) return; |
| 95 | DCHECK(col_val != nullptr); |
| 96 | |
| 97 | string tmp; |
| 98 | switch (type.type) { |
| 99 | case TYPE_BOOLEAN: |
| 100 | col_val->__set_bool_val(*reinterpret_cast<const bool*>(value)); |
| 101 | break; |
| 102 | case TYPE_TINYINT: |
| 103 | col_val->__set_byte_val(*reinterpret_cast<const int8_t*>(value)); |
| 104 | break; |
| 105 | case TYPE_SMALLINT: |
| 106 | col_val->__set_short_val(*reinterpret_cast<const int16_t*>(value)); |
| 107 | break; |
| 108 | case TYPE_INT: |
| 109 | col_val->__set_int_val(*reinterpret_cast<const int32_t*>(value)); |
| 110 | break; |
| 111 | case TYPE_BIGINT: |
| 112 | col_val->__set_long_val(*reinterpret_cast<const int64_t*>(value)); |
| 113 | break; |
| 114 | case TYPE_FLOAT: |
| 115 | col_val->__set_double_val(*reinterpret_cast<const float*>(value)); |
| 116 | break; |
| 117 | case TYPE_DOUBLE: |
| 118 | col_val->__set_double_val(*reinterpret_cast<const double*>(value)); |
| 119 | break; |
| 120 | case TYPE_DECIMAL: |
| 121 | switch (type.GetByteSize()) { |
| 122 | case 4: |
| 123 | col_val->string_val = |
| 124 | reinterpret_cast<const Decimal4Value*>(value)->ToString(type); |
| 125 | break; |
| 126 | case 8: |
| 127 | col_val->string_val = |
| 128 | reinterpret_cast<const Decimal8Value*>(value)->ToString(type); |
| 129 | break; |
| 130 | case 16: |
| 131 | col_val->string_val = |
| 132 | reinterpret_cast<const Decimal16Value*>(value)->ToString(type); |
| 133 | break; |
| 134 | default: |
| 135 | DCHECK(false) << "Bad Type: " << type; |
| 136 | } |
| 137 | col_val->__isset.string_val = true; |
| 138 | break; |
| 139 | case TYPE_STRING: |
| 140 | case TYPE_VARCHAR: { |
| 141 | const StringValue* string_val = reinterpret_cast<const StringValue*>(value); |
| 142 | tmp.assign(string_val->Ptr(), string_val->Len()); |
| 143 | col_val->binary_val.swap(tmp); |
| 144 | col_val->__isset.binary_val = true; |
| 145 | break; |
| 146 | } |
| 147 | case TYPE_CHAR: |
| 148 | tmp.assign(reinterpret_cast<const char*>(value), type.len); |
| 149 | col_val->binary_val.swap(tmp); |
no test coverage detected