Skip to content

Commit 89769e9

Browse files
author
elasticsearchmachine
committed
[CI] Auto commit changes from spotless
1 parent bd0bfb0 commit 89769e9

File tree

5 files changed

+29
-40
lines changed

5 files changed

+29
-40
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/regex/WildcardPattern.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public WildcardPattern(String pattern) {
3737
// early initialization to force string validation
3838
this.regex = StringUtils.wildcardToJavaPattern(pattern, '\\');
3939
}
40-
public WildcardPattern(StreamInput in) throws IOException{
40+
41+
public WildcardPattern(StreamInput in) throws IOException {
4142
this(in.readString());
4243
}
4344

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/regex/WildcardPatternList.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
*
2828
*/
2929
public class WildcardPatternList extends AbstractStringPattern implements NamedWriteable {
30-
public static final Entry ENTRY = new Entry(
31-
WildcardPatternList.class,
32-
"WildcardPatternList",
33-
WildcardPatternList::new
34-
);
30+
public static final Entry ENTRY = new Entry(WildcardPatternList.class, "WildcardPatternList", WildcardPatternList::new);
3531
public static final String NAME = "WildcardPatternList";
3632
private final List<WildcardPattern> patternList;
3733

@@ -56,20 +52,21 @@ public void writeTo(StreamOutput out) throws IOException {
5652
public String getWriteableName() {
5753
return NAME;
5854
}
59-
public static WildcardPatternList readFrom(StreamInput in) throws IOException{
55+
56+
public static WildcardPatternList readFrom(StreamInput in) throws IOException {
6057
return new WildcardPatternList(in.readCollectionAsList(WildcardPattern::readFrom));
6158
}
6259

6360
public List<WildcardPattern> patternList() {
6461
return patternList;
6562
}
66-
//public String pattern() {
67-
// return wildcard;
68-
//}
63+
// public String pattern() {
64+
// return wildcard;
65+
// }
6966

7067
@Override
7168
public Automaton createAutomaton(boolean ignoreCase) {
72-
List<Automaton> automatonList = patternList.stream().map(x->x.createAutomaton(ignoreCase)).toList();
69+
List<Automaton> automatonList = patternList.stream().map(x -> x.createAutomaton(ignoreCase)).toList();
7370
return Operations.union(automatonList);
7471
}
7572

@@ -80,7 +77,7 @@ public String asJavaRegex() {
8077

8178
@Override
8279
public String pattern() {
83-
return "(\"" + patternList.stream().map(WildcardPattern::pattern).collect(Collectors.joining("\", \"")) + "\")";
80+
return "(\"" + patternList.stream().map(WildcardPattern::pattern).collect(Collectors.joining("\", \"")) + "\")";
8481
}
8582

8683
/**
@@ -90,13 +87,12 @@ public String asLuceneWildcard() {
9087
throw new RuntimeException("LIKELIST does not have a Lucine Wildcard");
9188
}
9289

93-
9490
/**
9591
* Returns the pattern in (IndexNameExpressionResolver) wildcard format.
9692
*/
97-
//public String asIndexNameWildcard() {
98-
// return wildcard;
99-
//}
93+
// public String asIndexNameWildcard() {
94+
// return wildcard;
95+
// }
10096

10197
@Override
10298
public int hashCode() {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
import org.elasticsearch.xpack.esql.expression.function.scalar.string.ToLower;
179179
import org.elasticsearch.xpack.esql.expression.function.scalar.string.ToUpper;
180180
import org.elasticsearch.xpack.esql.expression.function.scalar.string.Trim;
181-
import org.elasticsearch.xpack.esql.expression.function.scalar.string.regex.WildcardLikeList;
182181
import org.elasticsearch.xpack.esql.expression.function.scalar.util.Delay;
183182
import org.elasticsearch.xpack.esql.parser.ParsingException;
184183
import org.elasticsearch.xpack.esql.session.Configuration;
@@ -418,8 +417,8 @@ private static FunctionDefinition[][] functions() {
418417
// IP
419418
new FunctionDefinition[] { def(CIDRMatch.class, CIDRMatch::new, "cidr_match") },
420419
new FunctionDefinition[] { def(IpPrefix.class, IpPrefix::new, "ip_prefix") },
421-
//likelist
422-
//new FunctionDefinition[] { def(WildcardLikeList.class, WildcardLikeList::new, "like_list") },
420+
// likelist
421+
// new FunctionDefinition[] { def(WildcardLikeList.class, WildcardLikeList::new, "like_list") },
423422

424423
// conversion functions
425424
new FunctionDefinition[] {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/regex/WildcardLikeList.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public WildcardLikeList(StreamInput in) throws IOException {
7575
);
7676
}
7777

78-
7978
@Override
8079
public void writeTo(StreamOutput out) throws IOException {
8180
source().writeTo(out);
@@ -106,8 +105,8 @@ protected WildcardLikeList replaceChild(Expression newLeft) {
106105

107106
@Override
108107
public Translatable translatable(LucenePushdownPredicates pushdownPredicates) {
109-
if(pattern().patternList().size() != 1){
110-
//we only support a single pattern in the list for pushdown for now
108+
if (pattern().patternList().size() != 1) {
109+
// we only support a single pattern in the list for pushdown for now
111110
return Translatable.NO;
112111
}
113112
return pushdownPredicates.isPushableAttribute(field()) ? Translatable.YES : Translatable.NO;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -731,24 +731,22 @@ public Expression visitLogicalIn(EsqlBaseParser.LogicalInContext ctx) {
731731
return ctx.NOT() == null ? e : new Not(source, e);
732732
}
733733

734-
private Expression buildWildcardLike(Source source, Expression left, Expression pattern){
735-
return new WildcardLike(
736-
source,
737-
left,
738-
new WildcardPattern(pattern.fold(FoldContext.small() /* TODO remove me */).toString()));
734+
private Expression buildWildcardLike(Source source, Expression left, Expression pattern) {
735+
return new WildcardLike(source, left, new WildcardPattern(pattern.fold(FoldContext.small() /* TODO remove me */).toString()));
739736
}
740737

741738
@Override
742739
public Expression visitLogicalInLike(EsqlBaseParser.LogicalInLikeContext ctx) {
743740

744741
List<Expression> expressions = ctx.valueExpression().stream().map(this::expression).toList();
745742
Source source = source(ctx);
746-
List <WildcardPattern> wildcardPatterns = expressions.subList(1, expressions.size()).stream()
747-
.map(x->new WildcardPattern(x.fold(FoldContext.small()).toString()))
743+
List<WildcardPattern> wildcardPatterns = expressions.subList(1, expressions.size())
744+
.stream()
745+
.map(x -> new WildcardPattern(x.fold(FoldContext.small()).toString()))
748746
.toList();
749-
//Expression e = wildcardPatterns.size() == 1
750-
// ? new WildcardLike( source, expressions.getFirst(),wildcardPatterns.getFirst())
751-
// : new WildcardLikeList(source, expressions.getFirst(), new WildcardPatternList(wildcardPatterns));
747+
// Expression e = wildcardPatterns.size() == 1
748+
// ? new WildcardLike( source, expressions.getFirst(),wildcardPatterns.getFirst())
749+
// : new WildcardLikeList(source, expressions.getFirst(), new WildcardPatternList(wildcardPatterns));
752750
Expression e = new WildcardLikeList(source, expressions.getFirst(), new WildcardPatternList(wildcardPatterns));
753751
return ctx.NOT() == null ? e : new Not(source, e);
754752
}
@@ -761,27 +759,23 @@ public Object visitIsNull(EsqlBaseParser.IsNullContext ctx) {
761759
}
762760

763761
@Override
764-
public Expression visitLikeExpression(EsqlBaseParser.LikeExpressionContext ctx){
762+
public Expression visitLikeExpression(EsqlBaseParser.LikeExpressionContext ctx) {
765763
Source source = source(ctx);
766764
List<Expression> expressions = ctx.valueExpression().stream().map(this::expression).toList();
767765
/*WildcardLike result = new WildcardLike(
768766
source,
769767
expressions.get(0),
770768
new WildcardPattern(expressions.get(1).fold(FoldContext.small() ).toString()));*/
771-
WildcardPattern pattern = new WildcardPattern(expressions.get(1).fold(FoldContext.small() ).toString());
769+
WildcardPattern pattern = new WildcardPattern(expressions.get(1).fold(FoldContext.small()).toString());
772770
WildcardLikeList result = new WildcardLikeList(source, expressions.getFirst(), new WildcardPatternList(List.of(pattern)));
773771
return ctx.NOT() == null ? result : new Not(source, result);
774772
}
775773

776774
@Override
777-
public Expression visitRlikeExpression(EsqlBaseParser.RlikeExpressionContext ctx){
775+
public Expression visitRlikeExpression(EsqlBaseParser.RlikeExpressionContext ctx) {
778776
Source source = source(ctx);
779777
List<Expression> expressions = ctx.valueExpression().stream().map(this::expression).toList();
780-
RLike rLike = new RLike(
781-
source,
782-
expressions.get(0),
783-
new RLikePattern(expressions.get(1).fold(FoldContext.small() ).toString())
784-
);
778+
RLike rLike = new RLike(source, expressions.get(0), new RLikePattern(expressions.get(1).fold(FoldContext.small()).toString()));
785779
return ctx.NOT() == null ? rLike : new Not(source, rLike);
786780
}
787781

0 commit comments

Comments
 (0)