提交 1fdbd2a9 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Improve readability of ResultTempTable.createIndex()

上级 1fccc783
...@@ -90,36 +90,33 @@ public class ResultTempTable implements ResultExternal { ...@@ -90,36 +90,33 @@ public class ResultTempTable implements ResultExternal {
} }
private void createIndex() { private void createIndex() {
IndexColumn[] indexCols = null; IndexColumn[] indexCols;
if (sort != null) { if (sort != null) {
int[] colIndex = sort.getQueryColumnIndexes(); int[] colIndex = sort.getQueryColumnIndexes();
int len = colIndex.length; int len = colIndex.length;
int totalLen;
BitSet used;
if (distinct) { if (distinct) {
totalLen = columnCount; BitSet used = new BitSet();
used = new BitSet(); indexCols = new IndexColumn[columnCount];
} else {
totalLen = len;
used = null;
}
indexCols = new IndexColumn[totalLen];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
int idx = colIndex[i]; int idx = colIndex[i];
if (used != null) {
used.set(idx); used.set(idx);
}
IndexColumn indexColumn = createIndexColumn(idx); IndexColumn indexColumn = createIndexColumn(idx);
indexColumn.sortType = sort.getSortTypes()[i]; indexColumn.sortType = sort.getSortTypes()[i];
indexCols[i] = indexColumn; indexCols[i] = indexColumn;
} }
if (used != null) {
int idx = 0; int idx = 0;
for (int i = len; i < totalLen; i++) { for (int i = len; i < columnCount; i++) {
idx = used.nextClearBit(idx); idx = used.nextClearBit(idx);
indexCols[i] = createIndexColumn(idx); indexCols[i] = createIndexColumn(idx);
idx++; idx++;
} }
} else {
indexCols = new IndexColumn[len];
for (int i = 0; i < len; i++) {
IndexColumn indexColumn = createIndexColumn(colIndex[i]);
indexColumn.sortType = sort.getSortTypes()[i];
indexCols[i] = indexColumn;
}
} }
} else { } else {
indexCols = new IndexColumn[columnCount]; indexCols = new IndexColumn[columnCount];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论