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

Function MaskShowFirstNImpl

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

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

Source from the content-addressed store, hash-verified

213/// Mask the given string except the first 'un_mask_char_count' chars. Ported from
214/// org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskShowFirstN.
215IR_ALWAYS_INLINE static inline StringVal MaskShowFirstNImpl(FunctionContext* ctx,
216 const StringVal& val, int un_mask_char_count, int masked_upper_char,
217 int masked_lower_char, int masked_digit_char, int masked_other_char) {
218 // To be consistent with Hive, negative char_count is treated as 0.
219 if (un_mask_char_count < 0) un_mask_char_count = 0;
220 if (val.is_null || val.len == 0 || un_mask_char_count >= val.len) return val;
221 if (!ctx->impl()->GetConstFnAttr(FunctionContextImpl::UTF8_MODE)) {
222 return MaskSubStr(ctx, val, un_mask_char_count, val.len, masked_upper_char,
223 masked_lower_char, masked_digit_char, masked_other_char);
224 }
225 return MaskSubStrUtf8(ctx, val, un_mask_char_count, val.len, masked_upper_char,
226 masked_lower_char, masked_digit_char, masked_other_char);
227}
228
229/// Mask the given string except the last 'un_mask_char_count' chars. Ported from
230/// org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskShowLastN.

Callers 3

MaskLastNImplFunction · 0.85
MaskShowFirstNMethod · 0.85
MaskMethod · 0.85

Calls 5

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

Tested by

no test coverage detected