Skip to content

Conversation

ivancea
Copy link
Contributor

@ivancea ivancea commented Oct 3, 2025

2 implementers changed:

  • Aggregators: Change isNull() + getValueCount() to a single getValueCount(). getValueCount() delegates to isNull() internally for Array blocks, and they're supposed to be in sync.
  • Evaluators: Same change, also removing an impossible branch (getValueCount() == 0 after the isNull() == false)

These changes were made to:

  • Improve readability/branch sanity, specially in the evaluators case.
  • Slight performance improvement. itable accesses have been problematic in similar cases, and this change removes up to 25% of them. There are 2 cases:
    • The position is null: We change a isNull() to a getValueCount() delegating to isNull() in some cases
    • The position is not null: We change a isNull() + getValueCount() by removing the isNull(), which could access a BitSet

Aggs microbenchmarks show no differences.

@ivancea ivancea requested a review from nik9000 October 3, 2025 13:04
@ivancea ivancea added >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.3.0 labels Oct 3, 2025
@ivancea ivancea marked this pull request as draft October 3, 2025 13:04
Comment on lines 157 to 158
builder.addCode("case 1:\n");
builder.addStatement("break");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a bit weird, but I'm not sure if this is better than a variable + 2 ifs, like:

if (count == 0) { null + continue }
else if (count > 1) { warning + null + continue }

@ivancea ivancea marked this pull request as ready for review October 3, 2025 15:40
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@dnhatn dnhatn self-requested a review October 3, 2025 15:44
private void addRawBlock(LongBlock vBlock) {
for (int p = 0; p < vBlock.getPositionCount(); p++) {
if (vBlock.isNull(p)) {
int vValueValueCount = vBlock.getValueCount(p);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vValueValueCount -> vValueCount probably.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

if (valBlock.isNull(p)) {
switch (valBlock.getValueCount(p)) {
case 0:
result.appendNull();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you indent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I thought it was correct because spotless didn't change it. Only to remember now that spotless ignore these files :hehe:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants