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

Function MaskLastNImpl

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

Mask the last 'mask_char_count' chars of the given string. Ported from org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskLastN.

Source from the content-addressed store, hash-verified

262/// Mask the last 'mask_char_count' chars of the given string. Ported from
263/// org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskLastN.
264IR_ALWAYS_INLINE static inline StringVal MaskLastNImpl(FunctionContext* ctx,
265 const StringVal& val, int mask_char_count, int masked_upper_char,
266 int masked_lower_char, int masked_digit_char, int masked_other_char) {
267 if (mask_char_count <= 0 || val.is_null || val.len == 0) return val;
268 if (mask_char_count > val.len) mask_char_count = val.len;
269 if (!ctx->impl()->GetConstFnAttr(FunctionContextImpl::UTF8_MODE)) {
270 return MaskSubStr(ctx, val, val.len - mask_char_count, val.len, masked_upper_char,
271 masked_lower_char, masked_digit_char, masked_other_char);
272 }
273 int start = GetUtf8CodePointCount(ctx, val) - mask_char_count;
274 if (start < 0) start = 0;
275 return MaskSubStrUtf8(ctx, val, start, val.len, masked_upper_char, masked_lower_char,
276 masked_digit_char, masked_other_char);
277}
278
279/// Mask the whole given string. Ported from
280/// org.apache.hadoop.hive.ql.udf.generic.GenericUDFMask.

Callers 1

MaskLastNMethod · 0.85

Calls 7

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

Tested by

no test coverage detected