This is an automated email from the ASF dual-hosted git repository.

rohangarg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new fefa7637220 Resultcache fetch should deserialize aggregates when they 
are real results (#15654)
fefa7637220 is described below

commit fefa76372203bb83c934a5a8a7cbe3b4ca3828fa
Author: Zoltan Haindrich <[email protected]>
AuthorDate: Wed Jan 10 12:42:33 2024 +0100

    Resultcache fetch should deserialize aggregates when they are real results 
(#15654)
    
    Fixes #15538
---
 .../src/main/java/org/apache/druid/query/CacheStrategy.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/processing/src/main/java/org/apache/druid/query/CacheStrategy.java 
b/processing/src/main/java/org/apache/druid/query/CacheStrategy.java
index d883e7555e9..ce4f742e6d1 100644
--- a/processing/src/main/java/org/apache/druid/query/CacheStrategy.java
+++ b/processing/src/main/java/org/apache/druid/query/CacheStrategy.java
@@ -24,6 +24,7 @@ import com.google.common.base.Function;
 import org.apache.druid.guice.annotations.ExtensionPoint;
 import org.apache.druid.java.util.common.ISE;
 import org.apache.druid.query.aggregation.AggregatorFactory;
+import org.apache.druid.segment.column.ColumnType;
 
 import java.util.Iterator;
 import java.util.List;
@@ -36,6 +37,7 @@ import java.util.List;
 @ExtensionPoint
 public interface CacheStrategy<T, CacheType, QueryType extends Query<T>>
 {
+
   /**
    * This method is deprecated and retained for backward incompatibility.
    * Returns whether the given query is cacheable or not.
@@ -155,10 +157,15 @@ public interface CacheStrategy<T, CacheType, QueryType 
extends Query<T>>
         throw new ISE("Ran out of objects while reading aggregators from 
cache!");
       }
 
-      if (isResultLevelCache) {
-        addToResultFunction.apply(aggregator.getName(), i, resultIter.next());
-      } else {
+      ColumnType resultType = aggregator.getResultType();
+      ColumnType intermediateType = aggregator.getIntermediateType();
+
+      boolean needsDeserialize = !isResultLevelCache || 
resultType.equals(intermediateType);
+
+      if (needsDeserialize) {
         addToResultFunction.apply(aggregator.getName(), i, 
aggregator.deserialize(resultIter.next()));
+      } else {
+        addToResultFunction.apply(aggregator.getName(), i, resultIter.next());
       }
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to