提交 d185228a authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Extract SelectGroups.createRow()

上级 c3780d9d
...@@ -99,7 +99,7 @@ public abstract class SelectGroups { ...@@ -99,7 +99,7 @@ public abstract class SelectGroups {
} }
Object[] values = groupByData.get(currentGroupsKey); Object[] values = groupByData.get(currentGroupsKey);
if (values == null) { if (values == null) {
values = new Object[Math.max(exprToIndexInGroupByData.size(), expressions.size())]; values = createRow();
groupByData.put(currentGroupsKey, values); groupByData.put(currentGroupsKey, values);
} }
currentGroupByExprData = values; currentGroupByExprData = values;
...@@ -120,8 +120,7 @@ public abstract class SelectGroups { ...@@ -120,8 +120,7 @@ public abstract class SelectGroups {
public void done() { public void done() {
super.done(); super.done();
if (groupIndex == null && groupByData.size() == 0) { if (groupIndex == null && groupByData.size() == 0) {
groupByData.put(defaultGroup, groupByData.put(defaultGroup, createRow());
new Object[Math.max(exprToIndexInGroupByData.size(), expressions.size())]);
} }
cursor = groupByData.entrySet().iterator(); cursor = groupByData.entrySet().iterator();
} }
...@@ -166,7 +165,7 @@ public abstract class SelectGroups { ...@@ -166,7 +165,7 @@ public abstract class SelectGroups {
@Override @Override
public void nextSource() { public void nextSource() {
Object[] values = new Object[Math.max(exprToIndexInGroupByData.size(), expressions.size())]; Object[] values = createRow();
rows.add(values); rows.add(values);
currentGroupByExprData = values; currentGroupByExprData = values;
currentGroupRowId++; currentGroupRowId++;
...@@ -208,7 +207,7 @@ public abstract class SelectGroups { ...@@ -208,7 +207,7 @@ public abstract class SelectGroups {
* Maps an expression object to an index, to use in accessing the Object[] * Maps an expression object to an index, to use in accessing the Object[]
* pointed to by groupByData. * pointed to by groupByData.
*/ */
final HashMap<Expression, Integer> exprToIndexInGroupByData = new HashMap<>(); private final HashMap<Expression, Integer> exprToIndexInGroupByData = new HashMap<>();
/** /**
* Maps an window expression object to its data. * Maps an window expression object to its data.
...@@ -293,6 +292,10 @@ public abstract class SelectGroups { ...@@ -293,6 +292,10 @@ public abstract class SelectGroups {
currentGroupByExprData[index] = obj; currentGroupByExprData[index] = obj;
} }
final Object[] createRow() {
return new Object[Math.max(exprToIndexInGroupByData.size(), expressions.size())];
}
/** /**
* Get the window data for the specified expression. * Get the window data for the specified expression.
* *
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论