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

Split DataAnalysisOperation.getData()

上级 55cd7e22
...@@ -119,10 +119,14 @@ public abstract class AbstractAggregate extends DataAnalysisOperation { ...@@ -119,10 +119,14 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
protected void updateAggregate(Session session, SelectGroups groupData, int groupRowId) { protected void updateAggregate(Session session, SelectGroups groupData, int groupRowId) {
if (filterCondition == null || filterCondition.getBooleanValue(session)) { if (filterCondition == null || filterCondition.getBooleanValue(session)) {
ArrayList<SelectOrderBy> orderBy; ArrayList<SelectOrderBy> orderBy;
if (over != null && (orderBy = over.getOrderBy()) != null) { if (over != null) {
updateOrderedAggregate(session, groupData, groupRowId, orderBy); if ((orderBy = over.getOrderBy()) != null) {
updateOrderedAggregate(session, groupData, groupRowId, orderBy);
} else {
updateAggregate(session, getWindowData(session, groupData, false, false));
}
} else { } else {
updateAggregate(session, getData(session, groupData, false, false)); updateAggregate(session, getGroupData(groupData, false));
} }
} }
} }
......
...@@ -182,29 +182,31 @@ public abstract class DataAnalysisOperation extends Expression { ...@@ -182,29 +182,31 @@ public abstract class DataAnalysisOperation extends Expression {
*/ */
protected abstract void rememberExpressions(Session session, Value[] array); protected abstract void rememberExpressions(Session session, Value[] array);
protected Object getData(Session session, SelectGroups groupData, boolean ifExists, boolean forOrderBy) { protected Object getWindowData(Session session, SelectGroups groupData, boolean ifExists, boolean forOrderBy) {
Object data; Object data;
if (over != null) { ValueArray key = over.getCurrentKey(session);
ValueArray key = over.getCurrentKey(session); PartitionData partition = groupData.getWindowExprData(this, key);
PartitionData partition = groupData.getWindowExprData(this, key); if (partition == null) {
if (partition == null) { if (ifExists) {
if (ifExists) { return null;
return null;
}
data = forOrderBy ? new ArrayList<>() : createAggregateData();
groupData.setWindowExprData(this, key, new PartitionData(data));
} else {
data = partition.getData();
} }
data = forOrderBy ? new ArrayList<>() : createAggregateData();
groupData.setWindowExprData(this, key, new PartitionData(data));
} else { } else {
data = groupData.getCurrentGroupExprData(this); data = partition.getData();
if (data == null) { }
if (ifExists) { return data;
return null; }
}
data = createAggregateData(); protected Object getGroupData(SelectGroups groupData, boolean ifExists) {
groupData.setCurrentGroupExprData(this, data); Object data;
data = groupData.getCurrentGroupExprData(this);
if (data == null) {
if (ifExists) {
return null;
} }
data = createAggregateData();
groupData.setCurrentGroupExprData(this, data);
} }
return data; return data;
} }
...@@ -241,7 +243,7 @@ public abstract class DataAnalysisOperation extends Expression { ...@@ -241,7 +243,7 @@ public abstract class DataAnalysisOperation extends Expression {
if (groupData == null) { if (groupData == null) {
throw DbException.get(ErrorCode.INVALID_USE_OF_AGGREGATE_FUNCTION_1, getSQL()); throw DbException.get(ErrorCode.INVALID_USE_OF_AGGREGATE_FUNCTION_1, getSQL());
} }
return over == null ? getAggregatedValue(session, getData(session, groupData, true, false)) return over == null ? getAggregatedValue(session, getGroupData(groupData, true))
: getWindowResult(session, groupData); : getWindowResult(session, groupData);
} }
...@@ -293,7 +295,7 @@ public abstract class DataAnalysisOperation extends Expression { ...@@ -293,7 +295,7 @@ public abstract class DataAnalysisOperation extends Expression {
} }
array[ne] = ValueInt.get(groupRowId); array[ne] = ValueInt.get(groupRowId);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ArrayList<Value[]> data = (ArrayList<Value[]>) getData(session, groupData, false, true); ArrayList<Value[]> data = (ArrayList<Value[]>) getWindowData(session, groupData, false, true);
data.add(array); data.add(array);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论