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

Move stage constants to DataAnalysisOperation

上级 2e263d53
......@@ -25,7 +25,7 @@ import org.h2.expression.ExpressionColumn;
import org.h2.expression.ExpressionVisitor;
import org.h2.expression.Parameter;
import org.h2.expression.Wildcard;
import org.h2.expression.aggregate.Aggregate;
import org.h2.expression.analysis.DataAnalysisOperation;
import org.h2.expression.analysis.Window;
import org.h2.index.Cursor;
import org.h2.index.Index;
......@@ -389,7 +389,7 @@ public class Select extends Query {
private void queryWindow(int columnCount, LocalResult result, long offset, boolean quickOffset) {
initGroupData(columnCount);
try {
gatherGroup(columnCount, Aggregate.STAGE_WINDOW);
gatherGroup(columnCount, DataAnalysisOperation.STAGE_WINDOW);
processGroupResult(columnCount, result, offset, quickOffset);
} finally {
groupData.reset();
......@@ -399,12 +399,12 @@ public class Select extends Query {
private void queryGroupWindow(int columnCount, LocalResult result, long offset, boolean quickOffset) {
initGroupData(columnCount);
try {
gatherGroup(columnCount, Aggregate.STAGE_GROUP);
gatherGroup(columnCount, DataAnalysisOperation.STAGE_GROUP);
try {
isGroupWindowStage2 = true;
while (groupData.next() != null) {
if (havingIndex < 0 || expressions.get(havingIndex).getBooleanValue(session)) {
updateAgg(columnCount, Aggregate.STAGE_WINDOW);
updateAgg(columnCount, DataAnalysisOperation.STAGE_WINDOW);
} else {
groupData.remove();
}
......@@ -422,7 +422,7 @@ public class Select extends Query {
private void queryGroup(int columnCount, LocalResult result, long offset, boolean quickOffset) {
initGroupData(columnCount);
try {
gatherGroup(columnCount, Aggregate.STAGE_GROUP);
gatherGroup(columnCount, DataAnalysisOperation.STAGE_GROUP);
processGroupResult(columnCount, result, offset, quickOffset);
} finally {
groupData.reset();
......@@ -433,7 +433,7 @@ public class Select extends Query {
if (groupData == null) {
groupData = SelectGroups.getInstance(session, expressions, isGroupQuery, groupIndex);
} else {
updateAgg(columnCount, Aggregate.STAGE_RESET);
updateAgg(columnCount, DataAnalysisOperation.STAGE_RESET);
}
groupData.reset();
}
......@@ -1742,7 +1742,7 @@ public class Select extends Query {
groupData = SelectGroups.getInstance(getSession(), Select.this.expressions, isGroupQuery, groupIndex);
} else {
// TODO is this branch possible?
updateAgg(columnCount, Aggregate.STAGE_RESET);
updateAgg(columnCount, DataAnalysisOperation.STAGE_RESET);
groupData.resetLazy();
}
}
......@@ -1778,7 +1778,7 @@ public class Select extends Query {
groupData.nextLazyGroup();
}
groupData.nextLazyRow();
updateAgg(columnCount, Aggregate.STAGE_GROUP);
updateAgg(columnCount, DataAnalysisOperation.STAGE_GROUP);
if (row != null) {
return row;
}
......
......@@ -155,21 +155,6 @@ public class Aggregate extends AbstractAggregate {
ENVELOPE,
}
/**
* Reset stage. Used to reset internal data to its initial state.
*/
public static final int STAGE_RESET = 0;
/**
* Group stage, used for explicit or implicit GROUP BY operation.
*/
public static final int STAGE_GROUP = 1;
/**
* Window processing stage.
*/
public static final int STAGE_WINDOW = 2;
private static final HashMap<String, AggregateType> AGGREGATES = new HashMap<>(64);
private final AggregateType type;
......
......@@ -16,7 +16,6 @@ import org.h2.command.dml.SelectOrderBy;
import org.h2.engine.Session;
import org.h2.expression.Expression;
import org.h2.expression.ExpressionVisitor;
import org.h2.expression.aggregate.Aggregate;
import org.h2.message.DbException;
import org.h2.result.SortOrder;
import org.h2.table.ColumnResolver;
......@@ -30,6 +29,21 @@ import org.h2.value.ValueInt;
*/
public abstract class DataAnalysisOperation extends Expression {
/**
* Reset stage. Used to reset internal data to its initial state.
*/
public static final int STAGE_RESET = 0;
/**
* Group stage, used for explicit or implicit GROUP BY operation.
*/
public static final int STAGE_GROUP = 1;
/**
* Window processing stage.
*/
public static final int STAGE_WINDOW = 2;
protected final Select select;
protected Window over;
......@@ -126,12 +140,12 @@ public abstract class DataAnalysisOperation extends Expression {
@Override
public final void updateAggregate(Session session, int stage) {
if (stage == Aggregate.STAGE_RESET) {
updateGroupAggregates(session, Aggregate.STAGE_RESET);
if (stage == STAGE_RESET) {
updateGroupAggregates(session, STAGE_RESET);
lastGroupRowId = 0;
return;
}
boolean window = stage == Aggregate.STAGE_WINDOW;
boolean window = stage == STAGE_WINDOW;
if (window != (over != null)) {
if (!window && select.isWindowQuery()) {
updateGroupAggregates(session, stage);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论