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

Method Base64Decode

be/src/exprs/string-functions-ir.cc:1553–1580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1551}
1552
1553StringVal StringFunctions::Base64Decode(FunctionContext* ctx, const StringVal& str) {
1554 if (str.is_null) return StringVal::null();
1555 if (0 == str.len) return StringVal(ctx, 0);
1556 int64_t out_max = 0;
1557 if (UNLIKELY(!Base64DecodeBufLen(
1558 reinterpret_cast<const char*>(str.ptr), static_cast<int64_t>(str.len),
1559 &out_max))) {
1560 stringstream ss;
1561 ss << "Invalid base64 string; input length is " << str.len
1562 << ", which is not a multiple of 4.";
1563 ctx->AddWarning(ss.str().c_str());
1564 return StringVal::null();
1565 }
1566 StringVal result(ctx, out_max);
1567 if (UNLIKELY(result.is_null)) return result;
1568 unsigned out_len = 0;
1569 if (UNLIKELY(!impala::Base64Decode(
1570 reinterpret_cast<const char*>(str.ptr), static_cast<int64_t>(str.len),
1571 out_max, reinterpret_cast<char*>(result.ptr), &out_len))) {
1572 stringstream ss;
1573 ss << "Could not base64 decode input in space " << out_max
1574 << "; actual output length " << out_len;
1575 ctx->AddWarning(ss.str().c_str());
1576 return StringVal::null();
1577 }
1578 result.len = out_len;
1579 return result;
1580}
1581
1582StringVal StringFunctions::GetJsonObject(FunctionContext *ctx, const StringVal &json_str,
1583 const StringVal &path_str) {

Callers

nothing calls this directly

Calls 5

StringValClass · 0.85
Base64DecodeBufLenFunction · 0.85
AddWarningMethod · 0.80
Base64DecodeFunction · 0.50
strMethod · 0.45

Tested by

no test coverage detected