@@ -118,9 +118,8 @@ case class Like(left: Expression, right: Expression) extends StringRegexExpressi
118
118
if (rVal != null ) {
119
119
val regexStr =
120
120
StringEscapeUtils .escapeJava(escape(rVal.asInstanceOf [UTF8String ].toString()))
121
- // inline mutable state since not many Like operations in a task
122
121
val pattern = ctx.addMutableState(patternClass, " patternLike" ,
123
- v => s """ $v = ${ patternClass} .compile(" $regexStr"); """ , forceInline = true )
122
+ v => s """ $v = $patternClass.compile(" $regexStr"); """ )
124
123
125
124
// We don't use nullSafeCodeGen here because we don't want to re-evaluate right again.
126
125
val eval = left.genCode(ctx)
@@ -143,9 +142,9 @@ case class Like(left: Expression, right: Expression) extends StringRegexExpressi
143
142
val rightStr = ctx.freshName(" rightStr" )
144
143
nullSafeCodeGen(ctx, ev, (eval1, eval2) => {
145
144
s """
146
- String $rightStr = ${ eval2} .toString();
147
- ${ patternClass} $pattern = ${ patternClass} .compile( $escapeFunc( $rightStr));
148
- ${ev.value} = $pattern.matcher( ${ eval1} .toString()).matches();
145
+ String $rightStr = $eval2.toString();
146
+ $patternClass $pattern = $patternClass.compile( $escapeFunc( $rightStr));
147
+ ${ev.value} = $pattern.matcher( $eval1.toString()).matches();
149
148
"""
150
149
})
151
150
}
@@ -194,9 +193,8 @@ case class RLike(left: Expression, right: Expression) extends StringRegexExpress
194
193
if (rVal != null ) {
195
194
val regexStr =
196
195
StringEscapeUtils .escapeJava(rVal.asInstanceOf [UTF8String ].toString())
197
- // inline mutable state since not many RLike operations in a task
198
196
val pattern = ctx.addMutableState(patternClass, " patternRLike" ,
199
- v => s """ $v = ${ patternClass} .compile(" $regexStr"); """ , forceInline = true )
197
+ v => s """ $v = $patternClass.compile(" $regexStr"); """ )
200
198
201
199
// We don't use nullSafeCodeGen here because we don't want to re-evaluate right again.
202
200
val eval = left.genCode(ctx)
@@ -219,9 +217,9 @@ case class RLike(left: Expression, right: Expression) extends StringRegexExpress
219
217
val pattern = ctx.freshName(" pattern" )
220
218
nullSafeCodeGen(ctx, ev, (eval1, eval2) => {
221
219
s """
222
- String $rightStr = ${ eval2} .toString();
223
- ${ patternClass} $pattern = ${ patternClass} .compile( $rightStr);
224
- ${ev.value} = $pattern.matcher( ${ eval1} .toString()).find(0);
220
+ String $rightStr = $eval2.toString();
221
+ $patternClass $pattern = $patternClass.compile( $rightStr);
222
+ ${ev.value} = $pattern.matcher( $eval1.toString()).find(0);
225
223
"""
226
224
})
227
225
}
@@ -338,25 +336,25 @@ case class RegExpReplace(subject: Expression, regexp: Expression, rep: Expressio
338
336
339
337
nullSafeCodeGen(ctx, ev, (subject, regexp, rep) => {
340
338
s """
341
- if (! $regexp.equals( ${ termLastRegex} )) {
339
+ if (! $regexp.equals( $termLastRegex)) {
342
340
// regex value changed
343
- ${ termLastRegex} = $regexp.clone();
344
- ${ termPattern} = ${ classNamePattern} .compile( ${ termLastRegex} .toString());
341
+ $termLastRegex = $regexp.clone();
342
+ $termPattern = $classNamePattern.compile( $termLastRegex.toString());
345
343
}
346
- if (! $rep.equals( ${ termLastReplacementInUTF8} )) {
344
+ if (! $rep.equals( $termLastReplacementInUTF8)) {
347
345
// replacement string changed
348
- ${ termLastReplacementInUTF8} = $rep.clone();
349
- ${ termLastReplacement} = ${ termLastReplacementInUTF8} .toString();
346
+ $termLastReplacementInUTF8 = $rep.clone();
347
+ $termLastReplacement = $termLastReplacementInUTF8.toString();
350
348
}
351
- $classNameStringBuffer ${ termResult} = new $classNameStringBuffer();
352
- java.util.regex.Matcher ${ matcher} = ${ termPattern} .matcher( $subject.toString());
349
+ $classNameStringBuffer $termResult = new $classNameStringBuffer();
350
+ java.util.regex.Matcher $matcher = $termPattern.matcher( $subject.toString());
353
351
354
- while ( ${ matcher} .find()) {
355
- ${ matcher} .appendReplacement( ${ termResult} , ${ termLastReplacement} );
352
+ while ( $matcher.find()) {
353
+ $matcher.appendReplacement( $termResult, $termLastReplacement);
356
354
}
357
- ${ matcher} .appendTail( ${ termResult} );
358
- ${ev.value} = UTF8String.fromString( ${ termResult} .toString());
359
- ${ termResult} = null;
355
+ $matcher.appendTail( $termResult);
356
+ ${ev.value} = UTF8String.fromString( $termResult.toString());
357
+ $termResult = null;
360
358
$setEvNotNull
361
359
"""
362
360
})
@@ -425,19 +423,19 @@ case class RegExpExtract(subject: Expression, regexp: Expression, idx: Expressio
425
423
426
424
nullSafeCodeGen(ctx, ev, (subject, regexp, idx) => {
427
425
s """
428
- if (! $regexp.equals( ${ termLastRegex} )) {
426
+ if (! $regexp.equals( $termLastRegex)) {
429
427
// regex value changed
430
- ${ termLastRegex} = $regexp.clone();
431
- ${ termPattern} = ${ classNamePattern} .compile( ${ termLastRegex} .toString());
428
+ $termLastRegex = $regexp.clone();
429
+ $termPattern = $classNamePattern.compile( $termLastRegex.toString());
432
430
}
433
- java.util.regex.Matcher ${ matcher} =
434
- ${ termPattern} .matcher( $subject.toString());
435
- if ( ${ matcher} .find()) {
436
- java.util.regex.MatchResult ${ matchResult} = ${ matcher} .toMatchResult();
437
- if ( ${ matchResult} .group( $idx) == null) {
431
+ java.util.regex.Matcher $matcher =
432
+ $termPattern.matcher( $subject.toString());
433
+ if ( $matcher.find()) {
434
+ java.util.regex.MatchResult $matchResult = $matcher.toMatchResult();
435
+ if ( $matchResult.group( $idx) == null) {
438
436
${ev.value} = UTF8String.EMPTY_UTF8;
439
437
} else {
440
- ${ev.value} = UTF8String.fromString( ${ matchResult} .group( $idx));
438
+ ${ev.value} = UTF8String.fromString( $matchResult.group( $idx));
441
439
}
442
440
$setEvNotNull
443
441
} else {
0 commit comments