Skip to content

Commit 038d35d

Browse files
committed
Changed logic to avoid autoboxing by adding hasValue methods for type-specific blocks.
1 parent a2b2b26 commit 038d35d

File tree

13 files changed

+323
-187
lines changed

13 files changed

+323
-187
lines changed

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanBlock.java

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlock.java

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/DoubleBlock.java

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FloatBlock.java

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/IntBlock.java

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/LongBlock.java

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-Block.java.st

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,35 @@ $else$
5454
$type$ get$Type$(int valueIndex);
5555
$endif$
5656

57+
/**
58+
* Checks if this block has the given value at valueIndex. If at this index we have a
59+
* multivalue, then it returns true if any values match.
60+
*
61+
* @param valueIndex the index at which we should check the value(s)
62+
* @param value the value to check against
63+
*/
64+
default boolean hasValue(int valueIndex, $type$ value) {
65+
final var count = getValueCount(valueIndex);
66+
final var startIndex = getFirstValueIndex(valueIndex);
67+
for (int index = startIndex; index < startIndex + count; index++) {
68+
$if(BytesRef)$
69+
var ref = new BytesRef();
70+
ref = getBytesRef(index, ref);
71+
if (ref.length == 0) {
72+
continue;
73+
}
74+
if(value.equals(ref)) {
75+
return true;
76+
}
77+
$else$
78+
if(value == get$Type$(index)) {
79+
return true;
80+
}
81+
$endif$
82+
}
83+
return false;
84+
}
85+
5786
@Override
5887
$Type$Vector asVector();
5988

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsBooleanEvaluator.java

Lines changed: 24 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)