提交 8f467f15 authored 作者: S.Vladykin's avatar S.Vladykin

JoinBatch.createViewIndexLookupBatch

上级 6762b765
...@@ -9,7 +9,6 @@ import java.util.ArrayList; ...@@ -9,7 +9,6 @@ import java.util.ArrayList;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.Prepared; import org.h2.command.Prepared;
import org.h2.command.dml.Query; import org.h2.command.dml.Query;
import org.h2.command.dml.Select;
import org.h2.command.dml.SelectUnion; import org.h2.command.dml.SelectUnion;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Session; import org.h2.engine.Session;
...@@ -101,19 +100,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex { ...@@ -101,19 +100,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
// we do not support batching for recursive queries // we do not support batching for recursive queries
return null; return null;
} }
// currently do not support unions return JoinBatch.createViewIndexLookupBatch(this);
return query.isUnion() ? null : createLookupBatchSimple((Select) query);
}
private IndexLookupBatch createLookupBatchSimple(Select select) {
// here we have already prepared plan for our sub-query,
// thus select already contains join batch for it (if it has to)
JoinBatch joinBatch = select.getJoinBatch();
if (joinBatch == null) {
// our sub-query itself is not batched, will run usual way
return null;
}
return joinBatch.asViewIndexLookupBatch(this);
} }
public Session getSession() { public Session getSession() {
......
...@@ -11,6 +11,9 @@ import java.util.Arrays; ...@@ -11,6 +11,9 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import org.h2.command.dml.Query;
import org.h2.command.dml.Select;
import org.h2.command.dml.SelectUnion;
import org.h2.index.Cursor; import org.h2.index.Cursor;
import org.h2.index.IndexCursor; import org.h2.index.IndexCursor;
import org.h2.index.IndexLookupBatch; import org.h2.index.IndexLookupBatch;
...@@ -368,11 +371,30 @@ public final class JoinBatch { ...@@ -368,11 +371,30 @@ public final class JoinBatch {
/** /**
* @return Adapter to allow joining to this batch in sub-queries and views. * @return Adapter to allow joining to this batch in sub-queries and views.
*/ */
public IndexLookupBatch asViewIndexLookupBatch(ViewIndex viewIndex) { private IndexLookupBatch viewIndexLookupBatch(ViewIndex viewIndex) {
assert viewIndexLookupBatch == null; assert viewIndexLookupBatch == null;
return viewIndexLookupBatch = new ViewIndexLookupBatch(viewIndex); return viewIndexLookupBatch = new ViewIndexLookupBatch(viewIndex);
} }
public static IndexLookupBatch createViewIndexLookupBatch(ViewIndex viewIndex) {
Query query = viewIndex.getQuery();
if (query.isUnion()) {
SelectUnion union = (SelectUnion) query;
// TODO
return null;
} else {
Select select = (Select) query;
// here we have already prepared plan for our sub-query,
// thus select already contains join batch for it (if it has to)
JoinBatch joinBatch = select.getJoinBatch();
if (joinBatch == null) {
// our sub-query itself is not batched, will run usual way
return null;
}
return joinBatch.viewIndexLookupBatch(viewIndex);
}
}
@Override @Override
public String toString() { public String toString() {
return "JoinBatch->\nprev->" + (current == null ? null : current.prev) + return "JoinBatch->\nprev->" + (current == null ? null : current.prev) +
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论