gjacoby126 commented on a change in pull request #973:
URL: https://github.com/apache/phoenix/pull/973#discussion_r545485500



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/iterate/OffsetResultIterator.java
##########
@@ -32,17 +36,27 @@
 public class OffsetResultIterator extends DelegateResultIterator {
     private int rowCount;
     private int offset;
+    private long pageSizeMs = Long.MAX_VALUE;
 
     public OffsetResultIterator(ResultIterator delegate, Integer offset) {
         super(delegate);
         this.offset = offset == null ? -1 : offset;
     }
 
+    public OffsetResultIterator(ResultIterator delegate, Integer offset, long 
pageSizeMs) {
+        this(delegate, offset);
+        this.pageSizeMs = pageSizeMs;
+    }
     @Override
     public Tuple next() throws SQLException {
+        long startTime = EnvironmentEdgeManager.currentTimeMillis();
         while (rowCount < offset) {
-            if (super.next() == null) { return null; }
+            Tuple tuple = super.next();
+            if (tuple == null) { return null; }
             rowCount++;
+            if (EnvironmentEdgeManager.currentTimeMillis() - startTime >= 
pageSizeMs) {

Review comment:
       I'm unclear why we're enforcing the time limits both in the 
FIlter/coprocs and also at the client level in the Iterators/Tuples. Do we need 
the latter in queries processed primarily on the client side? I'd expect the 
Iterator to be checking the Tuple returned to the client to see if it was the 
magic Dummy result, rather than checking the time itself. 

##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/iterate/OrderedResultIterator.java
##########
@@ -245,23 +256,33 @@ public int compare(ImmutableBytesWritable o1, 
ImmutableBytesWritable o2) {
     
     @Override
     public Tuple next() throws SQLException {
-        return getResultIterator().next();
+        getResultIterator();
+        if (!resultIteratorReady) {
+            return dummyTuple;
+        }
+        return resultIterator.next();
     }
     
     private PeekingResultIterator getResultIterator() throws SQLException {
-        if (resultIterator != null) {
+        if (resultIteratorReady) {

Review comment:
       what does Ready mean in this context?

##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PagedRegionScanner.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.phoenix.coprocessor;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.regionserver.Region;
+import org.apache.hadoop.hbase.regionserver.RegionScanner;
+import org.apache.phoenix.filter.PagedFilter;
+
+import static org.apache.phoenix.util.ScanUtil.getDummyResult;
+import static org.apache.phoenix.util.ScanUtil.getPhoenixPagedFilter;
+
+public class PagedRegionScanner extends BaseRegionScanner {
+    protected Region region;
+    protected Scan scan;
+    protected PagedFilter pageFilter;
+       public PagedRegionScanner(Region region, RegionScanner scanner, Scan 
scan) {
+           super(scanner);
+           this.region = region;
+           this.scan = scan;
+           pageFilter = getPhoenixPagedFilter(scan);
+           if (pageFilter != null) {
+               pageFilter.init();
+        }
+       }
+
+    private boolean next(List<Cell> results, boolean raw) throws IOException {
+        boolean hasMore = raw ? delegate.nextRaw(results) : 
delegate.next(results);

Review comment:
       if we throw an exception at either line 47 or line 56, do we clean up 
our state properly?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to