in phoenix5-hive4/src/it/java/org/apache/hadoop/hive/ql/QOutProcessor.java [212:311]
LineProcessingResult processLine(String line) {
LineProcessingResult result = new LineProcessingResult(line);
Matcher matcher = null;
result.line = replaceHandler.processLine(result.line);
if (fsType == FsType.ENCRYPTED_HDFS) {
for (Pattern pattern : partialReservedPlanMask) {
matcher = pattern.matcher(result.line);
if (matcher.find()) {
result.line = PARTIAL_MASK_PATTERN + " " + matcher.group(0);
result.partialMaskWasMatched = true;
break;
}
}
}
else {
for (PatternReplacementPair prp : partialPlanMask) {
matcher = prp.pattern.matcher(result.line);
if (matcher.find()) {
result.line = result.line.replaceAll(prp.pattern.pattern(), prp.replacement);
result.partialMaskWasMatched = true;
}
}
}
if (!result.partialMaskWasMatched) {
for (Pair<Pattern, String> pair : patternsWithMaskComments) {
Pattern pattern = pair.getLeft();
String maskComment = pair.getRight();
matcher = pattern.matcher(result.line);
if (matcher.find()) {
result.line = matcher.replaceAll(maskComment);
result.partialMaskWasMatched = true;
break;
}
}
if (!result.partialMaskWasMatched && queryMasks.contains(Mask.STATS)) {
matcher = MASK_STATS.pattern.matcher(result.line);
if (matcher.find()) {
result.line = result.line.replaceAll(MASK_STATS.pattern.pattern(), MASK_STATS.replacement);
result.partialMaskWasMatched = true;
}
}
if (!result.partialMaskWasMatched && queryMasks.contains(Mask.DATASIZE)) {
matcher = MASK_DATA_SIZE.pattern.matcher(result.line);
if (matcher.find()) {
result.line = result.line.replaceAll(MASK_DATA_SIZE.pattern.pattern(), MASK_DATA_SIZE.replacement);
result.partialMaskWasMatched = true;
}
}
if (!result.partialMaskWasMatched && queryMasks.contains(Mask.LINEAGE)) {
matcher = MASK_LINEAGE.pattern.matcher(result.line);
if (matcher.find()) {
result.line = result.line.replaceAll(MASK_LINEAGE.pattern.pattern(), MASK_LINEAGE.replacement);
result.partialMaskWasMatched = true;
}
}
for (String prefix : maskIfStartsWith) {
if (result.line.startsWith(prefix)) {
result.line = MASK_PATTERN;
}
}
for (String word : maskIfContains) {
if (result.line.contains(word)) {
result.line = MASK_PATTERN;
}
}
for (String[] words : maskIfContainsMultiple) {
int pos = 0;
boolean containsAllInOrder = true;
for (String word : words) {
int wordPos = result.line.substring(pos).indexOf(word);
if (wordPos == -1) {
containsAllInOrder = false;
break;
} else {
pos += wordPos + word.length();
}
}
if (containsAllInOrder) {
result.line = MASK_PATTERN;
}
}
for (Pattern pattern : planMask) {
result.line = pattern.matcher(result.line).replaceAll(MASK_PATTERN);
}
}
return result;
}