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

Extract SelectGroups.createRow()

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