Skip to content

Commit 6087bad

Browse files
authored
cleanups (#117997)
1 parent 0d4c0f2 commit 6087bad

File tree

3 files changed

+18
-51
lines changed

3 files changed

+18
-51
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/planner/ExpressionTranslators.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ protected Query asQuery(Not not, TranslatorHandler handler) {
107107
}
108108

109109
public static Query doTranslate(Not not, TranslatorHandler handler) {
110-
Query wrappedQuery = handler.asQuery(not.field());
111-
Query q = wrappedQuery.negate(not.source());
112-
return q;
110+
return handler.asQuery(not.field()).negate(not.source());
113111
}
114112
}
115113

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/util/CollectionUtils.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ public static <T> List<T> combine(List<? extends T> left, List<? extends T> righ
3030
}
3131

3232
List<T> list = new ArrayList<>(left.size() + right.size());
33-
if (left.isEmpty() == false) {
34-
list.addAll(left);
35-
}
36-
if (right.isEmpty() == false) {
37-
list.addAll(right);
38-
}
33+
list.addAll(left);
34+
list.addAll(right);
3935
return list;
4036
}
4137

@@ -73,13 +69,6 @@ public static <T> List<T> combine(Collection<? extends T> left, T... entries) {
7369
return list;
7470
}
7571

76-
public static int mapSize(int size) {
77-
if (size < 2) {
78-
return size + 1;
79-
}
80-
return (int) (size / 0.75f + 1f);
81-
}
82-
8372
@SafeVarargs
8473
@SuppressWarnings("varargs")
8574
public static <T> List<T> nullSafeList(T... entries) {

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/type/DataTypes.java

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -112,41 +112,21 @@ public static DataType fromEs(String name) {
112112
}
113113

114114
public static DataType fromJava(Object value) {
115-
if (value == null) {
116-
return NULL;
117-
}
118-
if (value instanceof Integer) {
119-
return INTEGER;
120-
}
121-
if (value instanceof Long) {
122-
return LONG;
123-
}
124-
if (value instanceof BigInteger) {
125-
return UNSIGNED_LONG;
126-
}
127-
if (value instanceof Boolean) {
128-
return BOOLEAN;
129-
}
130-
if (value instanceof Double) {
131-
return DOUBLE;
132-
}
133-
if (value instanceof Float) {
134-
return FLOAT;
135-
}
136-
if (value instanceof Byte) {
137-
return BYTE;
138-
}
139-
if (value instanceof Short) {
140-
return SHORT;
141-
}
142-
if (value instanceof ZonedDateTime) {
143-
return DATETIME;
144-
}
145-
if (value instanceof String || value instanceof Character) {
146-
return KEYWORD;
147-
}
148-
149-
return null;
115+
return switch (value) {
116+
case null -> NULL;
117+
case Integer i -> INTEGER;
118+
case Long l -> LONG;
119+
case BigInteger bigInteger -> UNSIGNED_LONG;
120+
case Boolean b -> BOOLEAN;
121+
case Double v -> DOUBLE;
122+
case Float v -> FLOAT;
123+
case Byte b -> BYTE;
124+
case Short s -> SHORT;
125+
case ZonedDateTime zonedDateTime -> DATETIME;
126+
case String s -> KEYWORD;
127+
case Character c -> KEYWORD;
128+
default -> null;
129+
};
150130
}
151131

152132
public static boolean isUnsupported(DataType from) {

0 commit comments

Comments
 (0)