Skip to content

Commit

Permalink
fixup! extend PageableTask interface and provide a generic PageabaleT…
Browse files Browse the repository at this point in the history
…askResult
  • Loading branch information
mfussenegger committed Feb 18, 2015
1 parent 691abd8 commit 7a6d6bd
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 33 deletions.
6 changes: 0 additions & 6 deletions sql/src/main/java/io/crate/executor/BigArrayPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.Iterators;
import org.elasticsearch.common.util.ObjectArray;

import java.util.Iterator;
Expand Down Expand Up @@ -86,11 +85,6 @@ public boolean isLastPage() {
return isLastPage;
}

@Override
public Page concat(Page otherPage) {
return new IteratorPage(Iterators.concat(iterator(), otherPage.iterator()), size + otherPage.size(), otherPage.isLastPage());
}

@Override
public Iterator<Object[]> iterator() {
return new ObjectArrayIterator<>(page, start, size);
Expand Down
8 changes: 0 additions & 8 deletions sql/src/main/java/io/crate/executor/IteratorPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

package io.crate.executor;

import com.google.common.collect.Iterators;

import java.util.Iterator;

public class IteratorPage implements Page {
Expand All @@ -47,12 +45,6 @@ public boolean isLastPage() {
return isLastPage;
}

@Override
public Page concat(Page otherPage) {
return new IteratorPage(Iterators.concat(iterator, otherPage.iterator()),
size + otherPage.size(), otherPage.isLastPage());
}

@Override
public Iterator<Object[]> iterator() {
return iterator;
Expand Down
7 changes: 0 additions & 7 deletions sql/src/main/java/io/crate/executor/ObjectArrayPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package io.crate.executor;

import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
import io.crate.core.collections.ArrayIterator;

import java.util.Iterator;
Expand Down Expand Up @@ -60,10 +59,4 @@ public long size() {
public boolean isLastPage() {
return isLastPage;
}

@Override
public Page concat(Page otherPage) {
return new IteratorPage(Iterators.concat(iterator(), otherPage.iterator()),
size + otherPage.size(), otherPage.isLastPage());
}
}
7 changes: 0 additions & 7 deletions sql/src/main/java/io/crate/executor/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public interface Page extends Iterable<Object[]> {

public boolean isLastPage();

public Page concat(Page otherPage);

public static final Page EMPTY = new Page() {
@Override
public long size() {
Expand All @@ -50,11 +48,6 @@ public boolean isLastPage() {
return true;
}

@Override
public Page concat(Page otherPage) {
return otherPage;
}

@Override
public Iterator<Object[]> iterator() {
return Collections.emptyIterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private ListenableFuture<TaskResult> pageWithOverlap(final PageInfo newPageInfo)
task.fetchMore(remainingPageInfo, context, new FutureCallback<TaskResult>() {
@Override
public void onSuccess(TaskResult result) {
future.set(new PageableTaskResult<>(task, newPageInfo, page.concat(result.page()), context));
future.set(new PageableTaskResult<>(task, newPageInfo, Pages.concat(page, result.page()), context));
}

@Override
Expand Down
14 changes: 14 additions & 0 deletions sql/src/main/java/io/crate/executor/Pages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.crate.executor;

import com.google.common.collect.Iterators;

public class Pages {

public static Page concat(Page firstPage, Page secondPage) {
return new IteratorPage(
Iterators.concat(firstPage.iterator(), secondPage.iterator()),
firstPage.size() + secondPage.size(),
secondPage.isLastPage()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ public void execute(FutureCallback<QueryThenFetchContext> callback,
AtomicInteger totalOps = new AtomicInteger(0);

int requestIdx = -1;
Iterator<Tuple<String, QueryShardRequest>> iterator = ctx.requests.iterator();
//noinspection WhileLoopReplaceableByForEach
while (iterator.hasNext()) {
Tuple<String, QueryShardRequest> requestTuple = iterator.next();
for (Tuple<String, QueryShardRequest> requestTuple : ctx.requests) {
requestIdx++;
state.blocks().indexBlockedRaiseException(ClusterBlockLevel.READ, requestTuple.v2().index());
transportQueryShardAction.executeQuery(
Expand Down

0 comments on commit 7a6d6bd

Please sign in to comment.