-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and inherit from PageDownstream and RowUpstream to officially bridge between Pages and Rows, Projectors
- Loading branch information
Showing
11 changed files
with
808 additions
and
230 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
core/src/main/java/io/crate/core/collections/BucketPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to CRATE Technology GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate licenses | ||
* this file to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.core.collections; | ||
|
||
import com.google.common.util.concurrent.ListenableFuture; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* Abstraction on a set of buckets that belong together | ||
* e.g. sent from different nodes but belonging to the same relation | ||
* | ||
* TODO: rename to Page once we are rid of io.crate.executor.Page | ||
*/ | ||
public class BucketPage { | ||
|
||
private final List<ListenableFuture<Bucket>> buckets; | ||
|
||
public BucketPage(List<ListenableFuture<Bucket>> buckets) { | ||
this.buckets = buckets; | ||
} | ||
|
||
public List<ListenableFuture<Bucket>> buckets() { | ||
return buckets; | ||
} | ||
|
||
@SafeVarargs | ||
public static BucketPage from(ListenableFuture<Bucket> ... futures) { | ||
return new BucketPage(Arrays.asList(futures)); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
sql/src/main/java/io/crate/operation/PageConsumeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to CRATE Technology GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate licenses | ||
* this file to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.operation; | ||
|
||
/** | ||
* Listener that is called when a Page is consumed to signal how to carry on | ||
* e.g. getting another page or shutting down. | ||
* | ||
*/ | ||
public interface PageConsumeListener { | ||
|
||
/** | ||
* called by the consumer of a {@link io.crate.core.collections.BucketPage} | ||
* to signal that he needs another page. | ||
*/ | ||
public void needMore(); | ||
|
||
/** | ||
* called by the consumer of a {@link io.crate.core.collections.BucketPage} | ||
* to signal that he does not need any more pages. | ||
*/ | ||
public void finished(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Licensed to CRATE Technology GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate licenses | ||
* this file to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.operation; | ||
|
||
import io.crate.core.collections.BucketPage; | ||
|
||
/** | ||
* Receiving and consuming {@linkplain io.crate.core.collections.BucketPage}s. | ||
* | ||
* The contract is that {@link #nextPage(io.crate.core.collections.BucketPage, PageConsumeListener)} is | ||
* called as long as this downstream does not call {@link PageConsumeListener#finished()} and the page source | ||
* is not exceeded. | ||
* <p> | ||
* One of {@link #fail(Throwable)} and {@link #finish()} must be called exactly | ||
* once at last. | ||
* | ||
*/ | ||
public interface PageDownstream { | ||
|
||
/** | ||
* Feed a page to this downstream. | ||
* This method may not be called when this downstream has already called | ||
* {@link PageConsumeListener#finished()}. | ||
* @param page the page with the buckets to consume | ||
* @param listener to be called when the page is consumed signalling if more pages are needed. | ||
*/ | ||
public void nextPage(BucketPage page, PageConsumeListener listener); | ||
|
||
/** | ||
* Must be called by the ones feeding pages | ||
* when producing and feeding pages to this downstream | ||
* has finished due to calling {@link PageConsumeListener#finished()} or due to | ||
* the page source being exceeded. | ||
* <p> | ||
* Must be called exactly once. | ||
*/ | ||
public void finish(); | ||
|
||
/** | ||
* Must be called when the one feeding pages to this downstream somehow failed. | ||
* <p> | ||
* Must be called exactly once. | ||
*/ | ||
public void fail(Throwable e); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.