Resultcache fetch should deserialize aggregates when they are real results (#15654)

Fixes #15538
This commit is contained in:
Zoltan Haindrich 2024-01-10 12:42:33 +01:00 committed by GitHub
parent 99d4b7dca7
commit fefa763722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -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());
}
}
}