diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java index 2cb0b616c37..26fc338f641 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java @@ -676,16 +676,13 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner * (see HBASE-13109) */ private ScanQueryMatcher.MatchCode optimize(ScanQueryMatcher.MatchCode qcode, Cell cell) { - Cell nextIndexedKey = getNextIndexedKey(); - if (nextIndexedKey == null || nextIndexedKey == HConstants.NO_NEXT_INDEXED_KEY || - store == null) { - return qcode; - } switch(qcode) { case INCLUDE_AND_SEEK_NEXT_COL: case SEEK_NEXT_COL: { - if (matcher.compareKeyForNextColumn(nextIndexedKey, cell) >= 0) { + Cell nextIndexedKey = getNextIndexedKey(); + if (nextIndexedKey != null && nextIndexedKey != HConstants.NO_NEXT_INDEXED_KEY + && matcher.compareKeyForNextColumn(nextIndexedKey, cell) >= 0) { return qcode == MatchCode.SEEK_NEXT_COL ? MatchCode.SKIP : MatchCode.INCLUDE; } break; @@ -693,7 +690,9 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner case INCLUDE_AND_SEEK_NEXT_ROW: case SEEK_NEXT_ROW: { - if (matcher.compareKeyForNextRow(nextIndexedKey, cell) >= 0) { + Cell nextIndexedKey = getNextIndexedKey(); + if (nextIndexedKey != null && nextIndexedKey != HConstants.NO_NEXT_INDEXED_KEY + && matcher.compareKeyForNextRow(nextIndexedKey, cell) >= 0) { return qcode == MatchCode.SEEK_NEXT_ROW ? MatchCode.SKIP : MatchCode.INCLUDE; } break;