clintropolis commented on code in PR #18500:
URL: https://github.com/apache/druid/pull/18500#discussion_r2332216685
##########
processing/src/main/java/org/apache/druid/query/expression/TimestampExtractExprMacro.java:
##########
@@ -183,6 +188,38 @@ public ExpressionType getOutputType(InputBindingInspector
inspector)
{
return getOutputExpressionType(unit);
}
+
+ @Override
+ public boolean canVectorize(InputBindingInspector inspector)
+ {
+ return args.get(0).canVectorize(inspector);
+ }
+
+ @Override
+ public <T> ExprVectorProcessor<T>
asVectorProcessor(VectorInputBindingInspector inspector)
+ {
+ final ExprVectorProcessor<?> processor;
+
+ if (getOutputExpressionType(unit).is(ExprType.DOUBLE)) {
+ processor = new DoubleUnivariateLongFunctionVectorProcessor(
+
CastToTypeVectorProcessor.cast(args.get(0).asVectorProcessor(inspector),
ExpressionType.LONG),
+ input -> {
+ final DateTime dateTime = new DateTime(input, chronology);
+ return getExprEval(dateTime, unit).asDouble();
Review Comment:
kind of sad we have to make an `ExprEval` to throw away, one of the benefits
of vector expr processing is much less garbage objects to deal with. maybe we
should change this method to return a `Number` and make another helper method
for things that need to wrap it in `ExprEval`?
##########
processing/src/main/java/org/apache/druid/query/expression/TimestampExtractExprMacro.java:
##########
@@ -183,6 +188,38 @@ public ExpressionType getOutputType(InputBindingInspector
inspector)
{
return getOutputExpressionType(unit);
}
+
+ @Override
+ public boolean canVectorize(InputBindingInspector inspector)
+ {
+ return args.get(0).canVectorize(inspector);
+ }
+
+ @Override
+ public <T> ExprVectorProcessor<T>
asVectorProcessor(VectorInputBindingInspector inspector)
+ {
+ final ExprVectorProcessor<?> processor;
+
+ if (getOutputExpressionType(unit).is(ExprType.DOUBLE)) {
+ processor = new DoubleUnivariateLongFunctionVectorProcessor(
+
CastToTypeVectorProcessor.cast(args.get(0).asVectorProcessor(inspector),
ExpressionType.LONG),
Review Comment:
I missed cleaning this up, but the explicit `cast` call is no longer needed
here, it is handled by the vector processor,
https://github.com/apache/druid/blob/master/processing/src/main/java/org/apache/druid/math/expr/vector/DoubleUnivariateLongFunctionVectorProcessor.java#L38
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]