提交 0186678a authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use ValueRow in SelectGroups

上级 214203c5
...@@ -51,8 +51,8 @@ import org.h2.util.StatementBuilder; ...@@ -51,8 +51,8 @@ import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueArray;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
import org.h2.value.ValueRow;
/** /**
* This class represents a simple SELECT statement. * This class represents a simple SELECT statement.
...@@ -499,7 +499,7 @@ public class Select extends Query { ...@@ -499,7 +499,7 @@ public class Select extends Query {
} }
private void processGroupResult(int columnCount, LocalResult result, long offset, boolean quickOffset) { private void processGroupResult(int columnCount, LocalResult result, long offset, boolean quickOffset) {
for (ValueArray currentGroupsKey; (currentGroupsKey = groupData.next()) != null;) { for (ValueRow currentGroupsKey; (currentGroupsKey = groupData.next()) != null;) {
Value[] keyValues = currentGroupsKey.getList(); Value[] keyValues = currentGroupsKey.getList();
Value[] row = new Value[columnCount]; Value[] row = new Value[columnCount];
for (int j = 0; groupIndex != null && j < groupIndex.length; j++) { for (int j = 0; groupIndex != null && j < groupIndex.length; j++) {
......
...@@ -18,7 +18,7 @@ import org.h2.expression.Expression; ...@@ -18,7 +18,7 @@ import org.h2.expression.Expression;
import org.h2.expression.analysis.DataAnalysisOperation; import org.h2.expression.analysis.DataAnalysisOperation;
import org.h2.expression.analysis.PartitionData; import org.h2.expression.analysis.PartitionData;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueArray; import org.h2.value.ValueRow;
/** /**
* Grouped data for aggregates. * Grouped data for aggregates.
...@@ -51,18 +51,18 @@ public abstract class SelectGroups { ...@@ -51,18 +51,18 @@ public abstract class SelectGroups {
/** /**
* Map of group-by key to group-by expression data e.g. AggregateData * Map of group-by key to group-by expression data e.g. AggregateData
*/ */
private TreeMap<ValueArray, Object[]> groupByData; private TreeMap<ValueRow, Object[]> groupByData;
/** /**
* Key into groupByData that produces currentGroupByExprData. Not used * Key into groupByData that produces currentGroupByExprData. Not used
* in lazy mode. * in lazy mode.
*/ */
private ValueArray currentGroupsKey; private ValueRow currentGroupsKey;
/** /**
* Cursor for {@link #next()} method. * Cursor for {@link #next()} method.
*/ */
private Iterator<Entry<ValueArray, Object[]>> cursor; private Iterator<Entry<ValueRow, Object[]>> cursor;
Grouped(Session session, ArrayList<Expression> expressions, int[] groupIndex) { Grouped(Session session, ArrayList<Expression> expressions, int[] groupIndex) {
super(session, expressions); super(session, expressions);
...@@ -80,7 +80,7 @@ public abstract class SelectGroups { ...@@ -80,7 +80,7 @@ public abstract class SelectGroups {
@Override @Override
public void nextSource() { public void nextSource() {
if (groupIndex == null) { if (groupIndex == null) {
currentGroupsKey = ValueArray.getEmpty(); currentGroupsKey = ValueRow.getEmpty();
} else { } else {
Value[] keyValues = new Value[groupIndex.length]; Value[] keyValues = new Value[groupIndex.length];
// update group // update group
...@@ -89,7 +89,7 @@ public abstract class SelectGroups { ...@@ -89,7 +89,7 @@ public abstract class SelectGroups {
Expression expr = expressions.get(idx); Expression expr = expressions.get(idx);
keyValues[i] = expr.getValue(session); keyValues[i] = expr.getValue(session);
} }
currentGroupsKey = ValueArray.get(keyValues); currentGroupsKey = ValueRow.get(keyValues);
} }
Object[] values = groupByData.get(currentGroupsKey); Object[] values = groupByData.get(currentGroupsKey);
if (values == null) { if (values == null) {
...@@ -114,15 +114,15 @@ public abstract class SelectGroups { ...@@ -114,15 +114,15 @@ 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(ValueArray.getEmpty(), createRow()); groupByData.put(ValueRow.getEmpty(), createRow());
} }
cursor = groupByData.entrySet().iterator(); cursor = groupByData.entrySet().iterator();
} }
@Override @Override
public ValueArray next() { public ValueRow next() {
if (cursor.hasNext()) { if (cursor.hasNext()) {
Map.Entry<ValueArray, Object[]> entry = cursor.next(); Map.Entry<ValueRow, Object[]> entry = cursor.next();
currentGroupByExprData = entry.getValue(); currentGroupByExprData = entry.getValue();
currentGroupRowId++; currentGroupRowId++;
return entry.getKey(); return entry.getKey();
...@@ -184,11 +184,11 @@ public abstract class SelectGroups { ...@@ -184,11 +184,11 @@ public abstract class SelectGroups {
} }
@Override @Override
public ValueArray next() { public ValueRow next() {
if (cursor.hasNext()) { if (cursor.hasNext()) {
currentGroupByExprData = cursor.next(); currentGroupByExprData = cursor.next();
currentGroupRowId++; currentGroupRowId++;
return ValueArray.getEmpty(); return ValueRow.getEmpty();
} }
return null; return null;
} }
...@@ -397,7 +397,7 @@ public abstract class SelectGroups { ...@@ -397,7 +397,7 @@ public abstract class SelectGroups {
* *
* @return the key of the next group, or null * @return the key of the next group, or null
*/ */
public abstract ValueArray next(); public abstract ValueRow next();
/** /**
* Removes the data for the current key. * Removes the data for the current key.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论