Skip to content

Commit 2656547

Browse files
committed
Spotless
1 parent 5d790ef commit 2656547

File tree

8 files changed

+48
-87
lines changed

8 files changed

+48
-87
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/KnnFunctionIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ public void testKnnWithLookupJoin() {
191191
);
192192
}
193193

194-
195194
public void testKnnIncorrectCasting() {
196195
var query = String.format(Locale.ROOT, """
197196
FROM test

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ private static Expression processVectorFunction(org.elasticsearch.xpack.esql.cor
16701670
List<Expression> args = vectorFunction.arguments();
16711671
List<Expression> newArgs = new ArrayList<>();
16721672
// Only the first vector arguments are vectors and considered for casting
1673-
int vectorArgsCount = ((VectorFunction)vectorFunction).vectorArgumentsCount();
1673+
int vectorArgsCount = ((VectorFunction) vectorFunction).vectorArgumentsCount();
16741674
for (int i = 0; i < args.size(); i++) {
16751675
Expression arg = args.get(i);
16761676
if (i < vectorArgsCount && arg.resolved()) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDenseVector.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import org.elasticsearch.common.io.stream.StreamInput;
1313
import org.elasticsearch.compute.ann.ConvertEvaluator;
1414
import org.elasticsearch.xpack.esql.capabilities.PostAnalysisPlanVerificationAware;
15-
import org.elasticsearch.xpack.esql.capabilities.PostAnalysisVerificationAware;
16-
import org.elasticsearch.xpack.esql.capabilities.PostOptimizationVerificationAware;
1715
import org.elasticsearch.xpack.esql.common.Failure;
1816
import org.elasticsearch.xpack.esql.common.Failures;
1917
import org.elasticsearch.xpack.esql.core.expression.Expression;
@@ -76,28 +74,19 @@ public BiConsumer<LogicalPlan, Failures> postAnalysisPlanVerification() {
7674
Object fold = arg.fold(FoldContext.small());
7775
if ((fold instanceof List<?> list) && arg.dataType().isNumeric()) {
7876
if (list.size() <= 1) {
79-
failures.add(Failure.fail(
80-
this,
81-
"[" + sourceText() + "] requires at least two values to convert to a dense_vector"
82-
));
77+
failures.add(
78+
Failure.fail(this, "[" + sourceText() + "] requires at least two values to convert to a dense_vector")
79+
);
8380
}
8481
return;
8582
}
8683
if ((arg.dataType() == KEYWORD) && fold instanceof BytesRef bytesRef) {
8784
if (bytesRef.length == 0) {
88-
failures.add(Failure.fail(
89-
this,
90-
"["
91-
+ sourceText()
92-
+ "] must be a non-empty hexadecimal string"));
85+
failures.add(Failure.fail(this, "[" + sourceText() + "] must be a non-empty hexadecimal string"));
9386
}
9487
return;
9588
}
96-
failures.add(Failure.fail(
97-
this,
98-
"["
99-
+ sourceText()
100-
+ "] must be a multi-valued input of numbers or an hexadecimal string"));
89+
failures.add(Failure.fail(this, "[" + sourceText() + "] must be a multi-valued input of numbers or an hexadecimal string"));
10190
}
10291
};
10392
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDenseVectorFromStringEvaluator.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616
import org.elasticsearch.compute.operator.DriverContext;
1717
import org.elasticsearch.compute.operator.EvalOperator;
1818
import org.elasticsearch.core.Releasables;
19-
import org.elasticsearch.xpack.esql.core.InvalidArgumentException;
2019
import org.elasticsearch.xpack.esql.core.tree.Source;
2120

2221
import java.util.HexFormat;
2322

2423
public class ToDenseVectorFromStringEvaluator extends AbstractConvertFunction.AbstractEvaluator {
25-
private static final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(
26-
ToDenseVectorFromStringEvaluator.class
27-
);
24+
private static final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(ToDenseVectorFromStringEvaluator.class);
2825

2926
private final EvalOperator.ExpressionEvaluator field;
3027

@@ -65,16 +62,20 @@ public Block evalBlock(Block b) {
6562
dimensions = bytes.length;
6663
} else {
6764
if (bytes.length != dimensions) {
68-
throw new IllegalArgumentException("All dense_vector must have the same number of dimensions. Expected: "
69-
+ dimensions + ", found: " + bytes.length);
65+
throw new IllegalArgumentException(
66+
"All dense_vector must have the same number of dimensions. Expected: "
67+
+ dimensions
68+
+ ", found: "
69+
+ bytes.length
70+
);
7071
}
7172
}
7273
builder.beginPositionEntry();
7374
for (byte value : bytes) {
7475
builder.appendFloat(value);
7576
}
7677
builder.endPositionEntry();
77-
} catch (IllegalArgumentException e) {
78+
} catch (IllegalArgumentException e) {
7879
registerException(e);
7980
builder.appendNull();
8081
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ public int vectorArgumentsCount() {
8282
return 2;
8383
}
8484

85-
// @Override
86-
// public BiConsumer<LogicalPlan, Failures> postAnalysisPlanVerification() {
87-
// return (lp, failures) -> {
88-
// for (Expression child : children()) {
89-
// if (child instanceof PostAnalysisVerificationAware pa) {
90-
// pa.postAnalysisVerification(failures);
91-
// }
92-
// }
93-
// };
94-
// }
85+
// @Override
86+
// public BiConsumer<LogicalPlan, Failures> postAnalysisPlanVerification() {
87+
// return (lp, failures) -> {
88+
// for (Expression child : children()) {
89+
// if (child instanceof PostAnalysisVerificationAware pa) {
90+
// pa.postAnalysisVerification(failures);
91+
// }
92+
// }
93+
// };
94+
// }
9595

9696
@Override
9797
public final EvalOperator.ExpressionEvaluator.Factory toEvaluator(EvaluatorMapper.ToEvaluator toEvaluator) {

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,10 +2541,7 @@ public void testVectorFunctionHexImplicitCastingError() {
25412541
private void checkVectorFunctionHexImplicitCastingError(String clause) {
25422542
var query = "from test | " + clause;
25432543
VerificationException error = expectThrows(VerificationException.class, () -> analyze(query, "mapping-dense_vector.json"));
2544-
assertThat(
2545-
error.getMessage(),
2546-
containsString("for argument [\"notcorrect\"]; dense_vectors must be a hex-encoded string")
2547-
);
2544+
assertThat(error.getMessage(), containsString("for argument [\"notcorrect\"]; dense_vectors must be a hex-encoded string"));
25482545
}
25492546

25502547
public void testMagnitudePlanWithDenseVectorImplicitCasting() {

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDenseVectorTests.java

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -57,54 +57,30 @@ public static Iterable<Object[]> parameters() {
5757
);
5858
}));
5959

60-
suppliers.add(
61-
new TestCaseSupplier(
62-
"double",
63-
List.of(DataType.DOUBLE),
64-
() -> {
65-
List<Double> data = Arrays.asList(randomArray(1, 10, Double[]::new, ESTestCase::randomDouble));
66-
return new TestCaseSupplier.TestCase(
67-
List.of(
68-
new TestCaseSupplier.TypedData(
69-
data,
70-
DataType.DOUBLE,
71-
"double"
72-
)
73-
),
74-
evaluatorName("Double", "d"),
75-
DataType.DENSE_VECTOR,
76-
equalTo(data.stream().map(Number::floatValue).toList())
77-
);
78-
}
79-
)
80-
);
60+
suppliers.add(new TestCaseSupplier("double", List.of(DataType.DOUBLE), () -> {
61+
List<Double> data = Arrays.asList(randomArray(1, 10, Double[]::new, ESTestCase::randomDouble));
62+
return new TestCaseSupplier.TestCase(
63+
List.of(new TestCaseSupplier.TypedData(data, DataType.DOUBLE, "double")),
64+
evaluatorName("Double", "d"),
65+
DataType.DENSE_VECTOR,
66+
equalTo(data.stream().map(Number::floatValue).toList())
67+
);
68+
}));
8169

82-
suppliers.add(
83-
new TestCaseSupplier(
84-
"keyword",
85-
List.of(DataType.KEYWORD),
86-
() -> {
87-
byte[] bytes = randomByteArrayOfLength(randomIntBetween(1, 20));
88-
String data = HexFormat.of().formatHex(bytes);
89-
List<Float> expected = new ArrayList<>(bytes.length);
90-
for (int i = 0; i < bytes.length; i++) {
91-
expected.add((float) bytes[i]);
92-
}
93-
return new TestCaseSupplier.TestCase(
94-
List.of(
95-
new TestCaseSupplier.TypedData(
96-
new BytesRef(data),
97-
DataType.KEYWORD,
98-
"keyword"
99-
)
100-
),
101-
evaluatorName("String", "s"),
102-
DataType.DENSE_VECTOR,
103-
is(expected)
104-
);
105-
}
106-
)
107-
);
70+
suppliers.add(new TestCaseSupplier("keyword", List.of(DataType.KEYWORD), () -> {
71+
byte[] bytes = randomByteArrayOfLength(randomIntBetween(1, 20));
72+
String data = HexFormat.of().formatHex(bytes);
73+
List<Float> expected = new ArrayList<>(bytes.length);
74+
for (int i = 0; i < bytes.length; i++) {
75+
expected.add((float) bytes[i]);
76+
}
77+
return new TestCaseSupplier.TestCase(
78+
List.of(new TestCaseSupplier.TypedData(new BytesRef(data), DataType.KEYWORD, "keyword")),
79+
evaluatorName("String", "s"),
80+
DataType.DENSE_VECTOR,
81+
is(expected)
82+
);
83+
}));
10884

10985
return parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(true, suppliers);
11086
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8625,7 +8625,6 @@ public void testMorePushDownConjunctionsAndNotDisjunctionsToKnnPrefilter() {
86258625
assertThat(leftAnd.right(), equalTo(rightAndPrefilter));
86268626
}
86278627

8628-
86298628
public void testTest() {
86308629
assumeTrue("knn must be enabled", EsqlCapabilities.Cap.KNN_FUNCTION_V3.isEnabled());
86318630

0 commit comments

Comments
 (0)