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

wip

上级 459ed158
...@@ -19,6 +19,7 @@ import org.h2.message.DbException; ...@@ -19,6 +19,7 @@ import org.h2.message.DbException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow; import org.h2.result.SearchRow;
import org.h2.util.DoneFuture; import org.h2.util.DoneFuture;
import org.h2.util.IntArray;
import org.h2.util.New; import org.h2.util.New;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueLong; import org.h2.value.ValueLong;
...@@ -157,12 +158,10 @@ public final class JoinBatch { ...@@ -157,12 +158,10 @@ public final class JoinBatch {
// initialize current row // initialize current row
current = new JoinRow(new Object[filters.length]); current = new JoinRow(new Object[filters.length]);
if (viewIndexLookupBatch == null) { if (viewIndexLookupBatch == null) {
current.updateRow(top.id, top.filter.getIndexCursor(), JoinRow.S_NULL, JoinRow.S_CURSOR);
// initialize top cursor // initialize top cursor
top.filter.getIndexCursor().find(top.filter.getSession(), top.filter.getIndexConditions()); IndexCursor indexCursor = top.filter.getIndexCursor();
} else { current.updateRow(top.id, indexCursor, JoinRow.S_NULL, JoinRow.S_CURSOR);
// we are sub-query and joined to upper level query indexCursor.find(top.filter.getSession(), top.filter.getIndexConditions());
// TODO setup
} }
// we need fake first row because batchedNext always will move to the next row // we need fake first row because batchedNext always will move to the next row
JoinRow fake = new JoinRow(null); JoinRow fake = new JoinRow(null);
...@@ -683,9 +682,7 @@ public final class JoinBatch { ...@@ -683,9 +682,7 @@ public final class JoinBatch {
*/ */
private final class ViewIndexLookupBatch implements IndexLookupBatch { private final class ViewIndexLookupBatch implements IndexLookupBatch {
private final ViewIndex viewIndex; private final ViewIndex viewIndex;
private final ArrayList<Future<Cursor>> result = New.arrayList(); private final IntArray counts = new IntArray();
private boolean findCalled;
private boolean full;
private ViewIndexLookupBatch(ViewIndex viewIndex) { private ViewIndexLookupBatch(ViewIndex viewIndex) {
this.viewIndex = viewIndex; this.viewIndex = viewIndex;
...@@ -693,50 +690,46 @@ public final class JoinBatch { ...@@ -693,50 +690,46 @@ public final class JoinBatch {
@Override @Override
public void addSearchRows(SearchRow first, SearchRow last) { public void addSearchRows(SearchRow first, SearchRow last) {
if (findCalled) {
result.clear();
findCalled = false;
}
viewIndex.setupQueryParameters(viewIndex.getSession(), first, last, null); viewIndex.setupQueryParameters(viewIndex.getSession(), first, last, null);
if (top.collectSearchRows()) { if (top.collectSearchRows()) {
result.add(PLACEHOLDER);
if (top.isBatchFull()) { if (top.isBatchFull()) {
// TODO fetch();
} }
} else {
result.add(null);
} }
} }
private void fetch() { private void fetch() {
// TODO
}
private void onNextCursorStart() {
} }
@Override @Override
public boolean isBatchFull() { public boolean isBatchFull() {
assert !findCalled;
return top.isBatchFull();
} }
@Override @Override
public List<Future<Cursor>> find() { public List<Future<Cursor>> find() {
findCalled = true; state = State.FIND_CALLED;
return result; return result;
} }
@Override @Override
public void reset() { public void reset() {
findCalled = false; state = State.COLLECTING;
result.clear(); result.clear();
JoinBatch.this.reset(); JoinBatch.this.reset();
} }
} }
/** /**
* State of the * State of the ViewIndexLookupBatch
*/ */
enum State { enum State {
COLLECTING, FULL, FIND_CALLED
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论