mirror of https://github.com/apache/druid.git
Window Functions : Improve performance by comparing Strings in frame bytes without converting them (#17091)
This commit is contained in:
parent
8d1e596740
commit
b9a4c73e52
|
@ -159,6 +159,12 @@ public class SqlWindowFunctionsBenchmark
|
|||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intermediateComputeSizeBytes()
|
||||
{
|
||||
return 200_000_000;
|
||||
}
|
||||
};
|
||||
|
||||
@Setup(Level.Trial)
|
||||
|
@ -336,7 +342,8 @@ public class SqlWindowFunctionsBenchmark
|
|||
{
|
||||
final Map<String, Object> context = ImmutableMap.of(
|
||||
PlannerContext.CTX_ENABLE_WINDOW_FNS, true,
|
||||
QueryContexts.MAX_SUBQUERY_BYTES_KEY, "auto"
|
||||
QueryContexts.MAX_SUBQUERY_BYTES_KEY, "disabled",
|
||||
QueryContexts.MAX_SUBQUERY_ROWS_KEY, -1
|
||||
);
|
||||
try (final DruidPlanner planner = plannerFactory.createPlannerForTesting(engine, sql, context)) {
|
||||
final PlannerResult plannerResult = planner.plan();
|
||||
|
@ -420,4 +427,15 @@ public class SqlWindowFunctionsBenchmark
|
|||
+ "GROUP BY dimUniform, dimSequential";
|
||||
querySql(sql, blackhole);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void windowWithGroupbyTime(Blackhole blackhole)
|
||||
{
|
||||
String sql = "SELECT "
|
||||
+ "SUM(dimSequentialHalfNull) + SUM(dimHyperUnique), "
|
||||
+ "LAG(SUM(dimSequentialHalfNull + dimHyperUnique)) OVER (PARTITION BY dimUniform ORDER BY dimSequential) "
|
||||
+ "FROM foo "
|
||||
+ "GROUP BY __time, dimUniform, dimSequential";
|
||||
querySql(sql, blackhole);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.apache.druid.frame.read.columnar;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.apache.datasketches.memory.Memory;
|
||||
import org.apache.druid.common.config.NullHandling;
|
||||
import org.apache.druid.error.DruidException;
|
||||
|
@ -507,6 +508,12 @@ public class StringFrameColumnReader implements FrameColumnReader
|
|||
return Comparator.nullsFirst(Comparator.comparing(o -> ((String) o)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareRows(int rowNum1, int rowNum2)
|
||||
{
|
||||
return ObjectUtils.compare(getStringUtf8(rowNum1), getStringUtf8(rowNum2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ByteBuffer containing UTF-8 encoded string number {@code index}. The ByteBuffer is always newly
|
||||
* created, so it is OK to change its position, limit, etc. However, it may point to shared memory, so it is
|
||||
|
|
Loading…
Reference in New Issue