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

Method PrimitiveValueToJSON

be/src/runtime/complex-value-writer.inline.h:48–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46// If 'map_key' is false, 'stringify_map_keys_' has no effect.
47template <class JsonStream>
48void ComplexValueWriter<JsonStream>::PrimitiveValueToJSON(void* value,
49 const ColumnType& type, bool map_key) {
50 if (type.IsBooleanType() && !map_key) {
51 writer_->Bool( *(reinterpret_cast<bool*>(value)) );
52 return;
53 }
54
55 string tmp;
56 // Passing -1 as 'scale' means we do not modify the precision setting of the stream
57 // (used when printing floating point values).
58 constexpr int scale = -1;
59 RawValue::PrintValue(value, type, scale, &tmp);
60 const bool should_convert_to_string = map_key && stringify_map_keys_;
61 if (IsPrimitiveTypePrintedAsString(type) || should_convert_to_string) {
62 if (type.IsBinaryType()) {
63 int64_t base64_max_len;
64 bool succ = Base64EncodeBufLen(tmp.size(), &base64_max_len);
65 DCHECK(succ);
66
67 // 'base64_max_len' includes the null terminator.
68 string buf(base64_max_len - 1, '\0');
69 unsigned base64_len = 0;
70 succ = Base64Encode(tmp.c_str(), tmp.size(), base64_max_len, buf.data(),
71 &base64_len);
72 DCHECK(succ);
73
74 tmp = std::move(buf);
75 }
76 writer_->String(tmp.c_str());
77 } else {
78 writer_->RawValue(tmp.c_str(), tmp.size(),
79 map_key ? rapidjson::kStringType : rapidjson::kNumberType);
80 }
81}
82
83template <class JsonStream>
84void ComplexValueWriter<JsonStream>::WriteNull(bool map_key) {

Callers

nothing calls this directly

Calls 11

PrintValueFunction · 0.85
Base64EncodeBufLenFunction · 0.85
moveFunction · 0.85
IsBooleanTypeMethod · 0.80
IsBinaryTypeMethod · 0.80
Base64EncodeFunction · 0.50
BoolMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected