Skip to content

Comments

Vectorize the numeric part of Earliest Aggregator#12483

Closed
somu-imply wants to merge 9 commits intoapache:masterfrom
somu-imply:numeric_vectorize_earliest
Closed

Vectorize the numeric part of Earliest Aggregator#12483
somu-imply wants to merge 9 commits intoapache:masterfrom
somu-imply:numeric_vectorize_earliest

Conversation

@somu-imply
Copy link
Contributor

@somu-imply somu-imply commented Apr 25, 2022

Vectorizing the earliest aggregator

SqlExpressionBenchmark.querySql       42           5000000        false  avgt    5   86.661 ± 10.316  ms/op
SqlExpressionBenchmark.querySql       42           5000000        force  avgt    5   58.923 ±  9.156  ms/op
SqlExpressionBenchmark.querySql       43           5000000        false  avgt    5   76.705 ± 13.739  ms/op
SqlExpressionBenchmark.querySql       43           5000000        force  avgt    5   43.493 ±  7.034  ms/op
SqlExpressionBenchmark.querySql       44           5000000        false  avgt    5   75.060 ±  5.100  ms/op
SqlExpressionBenchmark.querySql       44           5000000        force  avgt    5   38.841 ±  1.883  ms/op
SqlExpressionBenchmark.querySql       45           5000000        false  avgt    5  189.588 ±  6.205  ms/op
SqlExpressionBenchmark.querySql       45           5000000        force  avgt    5   62.001 ±  9.902  ms/op

where

42 --> long
43 --> float
44 --> double
45 --> all three

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@somu-imply somu-imply changed the title Numeric vectorize earliest Vectorize the numeric part of Earliest Aggregator Apr 25, 2022
*/
public class LongFirstVectorAggregator extends NumericFirstVectorAggregator
{
long firstValue;
Copy link
Contributor

Choose a reason for hiding this comment

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

private?

final boolean[] nullValueVector = valueSelector.getNullVector();
boolean nullAbsent = false;
firstTime = buf.getLong(position);
//check if nullVector is found or not
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: spacing on comments are inconsistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adjusted

}

/**
*
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to have an overall description of the method be in the javadocs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

/**
*
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to have an overall description of the method be in the javadocs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


/**
* Vectorized version of on heap 'last' aggregator for column selectors with type LONG..
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

stale javadocs. Similar comment for other VectorAggregator classes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

}

@Test
public void testPrimitiveEarliestInSubqueryGroupBy() throws Exception
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look like a subquery that is being tested

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Copy link
Contributor

@suneet-s suneet-s left a comment

Choose a reason for hiding this comment

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

|   0% (0/7)     |   0% (0/4)     |  73% (11/15)   | org/apache/druid/query/aggregation/first/FloatFirstAggregatorFactory.java

Overall LGTM. This is the only thing that slightly concerns me. Can you look into why there's no coverage for changes to this class, while there is coverage for the other aggregator factories.

@somu-imply
Copy link
Contributor Author

somu-imply commented Apr 30, 2022

@suneet-s I have added additional tests that would cover the factory classes for all the three new additions. The coverage would improve now.

Element | class | method | body | branch
---------------------------------------------------------------------------------------
DoubleFirstAggregatorFactory | 100% (6/6) | 59% (22/37) | 71% (74/103) | 45% (20/44)
DoubleFirstVectorAggregator | 100% (1/1) | 100% (4/4) | 100% (10/10) | 50% (1/2)
FloatFirstAggregatorFactory | 100% (6/6) | 59% (22/37) | 71% (71/100) | 50% (20/40)
FloatFirstVectorAggregator | 100% (1/1) | 100% (4/4) | 100% (10/10) | 50% (1/2)
LongFirstAggregatorFactory | 100% (6/6) | 59% (22/37) | 69% (71/102) | 50% (20/40)
LongFirstVectorAggregator | 100% (1/1) | 100% (4/4) | 100% (10/10) | 50% (1/2)
NumericFirstVectorAggregator | 100% (1/1) | 75% (6/8) | 87% (43/49) | 63% (23/36)

@TSFenwick I have updated as per your review comments.

@suneet-s
Copy link
Contributor

suneet-s commented May 2, 2022

@somu-imply It looks like there are still some failing tests, can you fix them up please.

TimeseriesQueryRunnerTest.testTimeseriesWithFirstLastAggregator is one example

@somu-imply
Copy link
Contributor Author

somu-imply commented Jun 12, 2023

Instead of conflict resolution that's gonna make things difficult, I'll make a fresh PR will close this once the new one's up and linked to this.

And that is #14408

@somu-imply somu-imply closed this Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants