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

Function MaskShowLastNImpl

be/src/exprs/mask-functions-ir.cc:231–245  ·  view source on GitHub ↗

Mask the given string except the last 'un_mask_char_count' chars. Ported from org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskShowLastN.

Source from the content-addressed store, hash-verified

229/// Mask the given string except the last 'un_mask_char_count' chars. Ported from
230/// org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskShowLastN.
231IR_ALWAYS_INLINE static inline StringVal MaskShowLastNImpl(FunctionContext* ctx,
232 const StringVal& val, int un_mask_char_count, int masked_upper_char,
233 int masked_lower_char, int masked_digit_char, int masked_other_char) {
234 // To be consistent with Hive, negative char_count is treated as 0.
235 if (un_mask_char_count < 0) un_mask_char_count = 0;
236 if (val.is_null || val.len == 0 || un_mask_char_count >= val.len) return val;
237 if (!ctx->impl()->GetConstFnAttr(FunctionContextImpl::UTF8_MODE)) {
238 return MaskSubStr(ctx, val, 0, val.len - un_mask_char_count, masked_upper_char,
239 masked_lower_char, masked_digit_char, masked_other_char);
240 }
241 int end = GetUtf8CodePointCount(ctx, val) - un_mask_char_count;
242 if (end <= 0) return val;
243 return MaskSubStrUtf8(ctx, val, 0, end, masked_upper_char, masked_lower_char,
244 masked_digit_char, masked_other_char);
245}
246
247/// Mask the first 'mask_char_count' chars of the given string. Ported from
248/// org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskFirstN.

Callers 2

MaskFirstNImplFunction · 0.85
MaskShowLastNMethod · 0.85

Calls 6

MaskSubStrFunction · 0.85
GetUtf8CodePointCountFunction · 0.85
MaskSubStrUtf8Function · 0.85
GetNumDigitsFunction · 0.85
GetConstFnAttrMethod · 0.80
implMethod · 0.80

Tested by

no test coverage detected