You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "clintropolis (via GitHub)" <gi...@apache.org> on 2025/09/09 07:09:02 UTC
Re: [PR] Vectorized implementation of timestamp_ceil, timestamp_extract. (druid)
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org