提交 728d18f2 authored 作者: S.Vladykin's avatar S.Vladykin

JoinBatch.reset called after query as well as before to cleanup resources immediately

上级 6b374192
......@@ -639,18 +639,25 @@ public class Select extends Query {
topTableFilter.lock(session, exclusive, exclusive);
ResultTarget to = result != null ? result : target;
if (limitRows != 0) {
if (isQuickAggregateQuery) {
queryQuick(columnCount, to);
} else if (isGroupQuery) {
if (isGroupSortedQuery) {
queryGroupSorted(columnCount, to);
try {
if (isQuickAggregateQuery) {
queryQuick(columnCount, to);
} else if (isGroupQuery) {
if (isGroupSortedQuery) {
queryGroupSorted(columnCount, to);
} else {
queryGroup(columnCount, result);
}
} else if (isDistinctQuery) {
queryDistinct(to, limitRows);
} else {
queryGroup(columnCount, result);
queryFlat(columnCount, to, limitRows);
}
} finally {
JoinBatch jb = getJoinBatch();
if (jb != null) {
jb.reset(false);
}
} else if (isDistinctQuery) {
queryDistinct(to, limitRows);
} else {
queryFlat(columnCount, to, limitRows);
}
}
if (offsetExpr != null) {
......
......@@ -59,7 +59,9 @@ public interface IndexLookupBatch {
String getPlanSQL();
/**
* Reset this batch to clear state. This method will be called before each query execution.
* Reset this batch to clear state. This method will be called before and after each query execution.
*
* @param beforeQuery if it is being called before query execution
*/
void reset();
void reset(boolean beforeQuery);
}
......@@ -107,15 +107,17 @@ public final class JoinBatch {
/**
* Reset state of this batch.
*
* @param beforeQuery {@code true} if reset was called before the query run, {@code false} if after
*/
public void reset() {
public void reset(boolean beforeQuery) {
current = null;
started = false;
found = false;
for (JoinFilter jf : filters) {
jf.reset();
jf.reset(beforeQuery);
}
if (additionalFilter != null) {
if (beforeQuery && additionalFilter != null) {
additionalFilter.reset();
}
}
......@@ -423,9 +425,9 @@ public final class JoinBatch {
assert lookupBatch != null || id == 0;
}
private void reset() {
private void reset(boolean beforeQuery) {
if (lookupBatch != null) {
lookupBatch.reset();
lookupBatch.reset(beforeQuery);
}
}
......@@ -659,7 +661,7 @@ public final class JoinBatch {
}
@Override
public void reset() {
public void reset(boolean beforeQuery) {
full = false;
first = last = null;
result.set(0, null);
......@@ -783,11 +785,11 @@ public final class JoinBatch {
}
@Override
public void reset() {
public void reset(boolean beforeQuery) {
if (resultSize != 0 && !resetAfterFind()) {
// find was not called, need to just clear runners
for (int i = 0; i < resultSize; i++) {
((QueryRunnerBase) result.get(i)).clear();
queryRunner(i).clear();
}
resultSize = 0;
}
......
......@@ -328,7 +328,7 @@ public class TableFilter implements ColumnResolver {
public void reset() {
if (joinBatch != null && joinFilterId == 0) {
// reset join batch only on top table filter
joinBatch.reset();
joinBatch.reset(true);
return;
}
if (nestedJoin != null) {
......
......@@ -1344,7 +1344,7 @@ public class TestTableEngines extends TestBase {
}
@Override
public void reset() {
public void reset(boolean beforeQuery) {
searchRows.clear();
}
};
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论