Mask the given string except the last 'un_mask_char_count' chars. Ported from org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskShowLastN.
| 229 | /// Mask the given string except the last 'un_mask_char_count' chars. Ported from |
| 230 | /// org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskShowLastN. |
| 231 | IR_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. |
no test coverage detected