RYA-377 Create the GetQueryResultStream interactor.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/3ccfbadc Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/3ccfbadc Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/3ccfbadc Branch: refs/heads/master Commit: 3ccfbadc3e4b50726fb19213c43f58d3445bfc75 Parents: a95fe5a Author: kchilton2 <kevin.e.chil...@gmail.com> Authored: Thu Oct 26 15:35:42 2017 -0400 Committer: caleb <caleb.me...@parsons.com> Committed: Tue Jan 9 15:12:59 2018 -0500 ---------------------------------------------------------------------- .../streams/api/entity/QueryResultStream.java | 50 +++++++++++++++++++ .../api/interactor/GetQueryResultStream.java | 52 ++++++++++++++++++++ 2 files changed, 102 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3ccfbadc/extras/rya.streams/api/src/main/java/org/apache/rya/streams/api/entity/QueryResultStream.java ---------------------------------------------------------------------- diff --git a/extras/rya.streams/api/src/main/java/org/apache/rya/streams/api/entity/QueryResultStream.java b/extras/rya.streams/api/src/main/java/org/apache/rya/streams/api/entity/QueryResultStream.java new file mode 100644 index 0000000..fdd62df --- /dev/null +++ b/extras/rya.streams/api/src/main/java/org/apache/rya/streams/api/entity/QueryResultStream.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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. + */ +package org.apache.rya.streams.api.entity; + +import java.util.Collection; +import java.util.UUID; + +import org.apache.rya.api.model.VisibilityBindingSet; +import org.apache.rya.streams.api.exception.RyaStreamsException; + +import edu.umd.cs.findbugs.annotations.DefaultAnnotation; +import edu.umd.cs.findbugs.annotations.NonNull; + +/** + * An infinite stream of {@link VisibilityBindingSet}s that are the results of a query within Rya Streams. + */ +@DefaultAnnotation(NonNull.class) +public interface QueryResultStream extends AutoCloseable { + + /** + * @return Identifies which query in Rya Streams this result stream is over. + */ + public UUID getQueryId(); + + /** + * Wait at most {@code timeoutMs} milliseconds for the next collection of results. + * + * @param timeoutMs - The number of milliseconds to at most wait for the next collection of results. (not null) + * @return The next collection of {@link VisibilityBindingSet}s that are the result of the query. Empty if + * there where no new results within the timout period. + * @throws RyaStreamsException Could not fetch the next set of results. + */ + public Collection<VisibilityBindingSet> poll(long timeoutMs) throws RyaStreamsException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3ccfbadc/extras/rya.streams/api/src/main/java/org/apache/rya/streams/api/interactor/GetQueryResultStream.java ---------------------------------------------------------------------- diff --git a/extras/rya.streams/api/src/main/java/org/apache/rya/streams/api/interactor/GetQueryResultStream.java b/extras/rya.streams/api/src/main/java/org/apache/rya/streams/api/interactor/GetQueryResultStream.java new file mode 100644 index 0000000..9ca577c --- /dev/null +++ b/extras/rya.streams/api/src/main/java/org/apache/rya/streams/api/interactor/GetQueryResultStream.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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. + */ +package org.apache.rya.streams.api.interactor; + +import java.util.UUID; + +import org.apache.rya.streams.api.entity.QueryResultStream; +import org.apache.rya.streams.api.exception.RyaStreamsException; + +import edu.umd.cs.findbugs.annotations.DefaultAnnotation; +import edu.umd.cs.findbugs.annotations.NonNull; + +/** + * Get a {@link QueryResultStream} over the results of a query that is being managed by Rya Streams. + */ +@DefaultAnnotation(NonNull.class) +public interface GetQueryResultStream { + + /** + * Stream all of the results that have been produced by a query. + * + * @param queryId - Indicates which query results to stream. (not null) + * @return A {@link QueryResultStream} that starts with the first result that was ever produced. + * @throws RyaStreamsException Could not create the result stream. + */ + public QueryResultStream fromStart(UUID queryId) throws RyaStreamsException; + + /** + * Stream results that have been produced by a query after this method was invoked. + * + * @param queryId - Indicates which query results to stream. (not null) + * @return A {@link QueryResultStream} that only returns results that were produced after this method is invoked. + * @throws RyaStreamsException Could not create the result stream. + */ + public QueryResultStream fromNow(UUID queryId) throws RyaStreamsException; +} \ No newline at end of file