提交 b30f9e1a authored 作者: Noel Grandin's avatar Noel Grandin

cache lookups into exprToIndexInGroupByData

now the test is both faster and uses less memory than originally
上级 f6f3a3d8
...@@ -96,6 +96,11 @@ public class Select extends Query { ...@@ -96,6 +96,11 @@ public class Select extends Query {
* Key into groupByData that produces currentGroupByExprData. Not used in lazy mode. * Key into groupByData that produces currentGroupByExprData. Not used in lazy mode.
*/ */
private ValueArray currentGroupsKey; private ValueArray currentGroupsKey;
/**
* Cache the lookups into exprToIndexInGroupByData
*/
private Expression cachedLookup;
private Integer cachedLookupIndex;
private int havingIndex; private int havingIndex;
private boolean isGroupQuery, isGroupSortedQuery; private boolean isGroupQuery, isGroupSortedQuery;
...@@ -178,6 +183,8 @@ public class Select extends Query { ...@@ -178,6 +183,8 @@ public class Select extends Query {
if (index == null) { if (index == null) {
return null; return null;
} }
cachedLookup = expr;
cachedLookupIndex = index;
return currentGroupByExprData[index]; return currentGroupByExprData[index];
} }
...@@ -185,6 +192,10 @@ public class Select extends Query { ...@@ -185,6 +192,10 @@ public class Select extends Query {
* Set the group-by data for the current group and the passed in expression. * Set the group-by data for the current group and the passed in expression.
*/ */
public void setCurrentGroupExprData(Expression expr, Object obj) { public void setCurrentGroupExprData(Expression expr, Object obj) {
if (cachedLookup == expr) {
assert currentGroupByExprData[cachedLookupIndex] != null;
currentGroupByExprData[cachedLookupIndex] = obj;
}
Integer index = exprToIndexInGroupByData.get(expr); Integer index = exprToIndexInGroupByData.get(expr);
if (index != null) { if (index != null) {
assert currentGroupByExprData[index] != null; assert currentGroupByExprData[index] != null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论