virajjasani commented on code in PR #1736:
URL: https://github.com/apache/phoenix/pull/1736#discussion_r1456430105
##########
phoenix-core-client/src/main/java/org/apache/phoenix/iterate/OffsetResultIterator.java:
##########
@@ -32,32 +34,49 @@
*/
public class OffsetResultIterator extends DelegateResultIterator {
private int rowCount;
- private int offset;
+ private final int offset;
+ private Tuple lastScannedTuple;
private long pageSizeMs = Long.MAX_VALUE;
+ private boolean isIncompatibleClient = false;
public OffsetResultIterator(ResultIterator delegate, Integer offset) {
super(delegate);
this.offset = offset == null ? -1 : offset;
+ this.lastScannedTuple = null;
}
- public OffsetResultIterator(ResultIterator delegate, Integer offset, long
pageSizeMs) {
+ public OffsetResultIterator(ResultIterator delegate, Integer offset, long
pageSizeMs,
+ boolean isIncompatibleClient) {
this(delegate, offset);
this.pageSizeMs = pageSizeMs;
+ this.isIncompatibleClient = isIncompatibleClient;
}
+
@Override
public Tuple next() throws SQLException {
+ long startTime = EnvironmentEdgeManager.currentTimeMillis();
while (rowCount < offset) {
Tuple tuple = super.next();
- if (tuple == null) { return null; }
+ if (tuple == null) {
+ return null;
+ }
if (tuple.size() == 0 || isDummy(tuple)) {
// while rowCount < offset absorb the dummy and call next on
the underlying scanner
continue;
}
rowCount++;
- // no page timeout check at this level because we cannot correctly
resume
- // scans for OFFSET queries until the offset is reached
+ lastScannedTuple = tuple;
+ if (!isIncompatibleClient) {
+ if (EnvironmentEdgeManager.currentTimeMillis() - startTime >=
pageSizeMs) {
Review Comment:
yes, the scan attributes remain unaffected because hbase client keeps the
same scan object and it just updates start rowkey:
```
// Else, its signal from depths of ScannerCallable that we need to reset
the scanner.
if (this.lastResult != null) {
// The region has moved. We need to open a brand new scanner at the
new location.
// Reset the startRow to the row we've seen last so that the new
scanner starts at
// the correct row. Otherwise we may see previously returned rows
again.
// If the lastRow is not partial, then we should start from the next
row. As now we can
// exclude the start row, the logic here is the same for both normal
scan and reversed scan.
// If lastResult is partial then include it, otherwise exclude it.
scan.withStartRow(lastResult.getRow(),
lastResult.mayHaveMoreCellsInRow());
}
```
So, we are good from scan attributes viewpoint. I will address the remaining
comments, including offset queries today.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]