001/* 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019package org.apache.hadoop.hbase.regionserver; 020 021import java.io.IOException; 022 023import org.apache.commons.lang3.NotImplementedException; 024import org.apache.yetus.audience.InterfaceAudience; 025import org.apache.hadoop.fs.Path; 026import org.apache.hadoop.hbase.Cell; 027import org.apache.hadoop.hbase.client.Scan; 028 029/** 030 * A "non-lazy" scanner which always does a real seek operation. Most scanners 031 * are inherited from this class. 032 */ 033@InterfaceAudience.Private 034public abstract class NonLazyKeyValueScanner implements KeyValueScanner { 035 036 @Override 037 public boolean requestSeek(Cell kv, boolean forward, boolean useBloom) 038 throws IOException { 039 return doRealSeek(this, kv, forward); 040 } 041 042 @Override 043 public boolean realSeekDone() { 044 return true; 045 } 046 047 @Override 048 public void enforceSeek() throws IOException { 049 throw new NotImplementedException("enforceSeek must not be called on a " + 050 "non-lazy scanner"); 051 } 052 053 public static boolean doRealSeek(KeyValueScanner scanner, 054 Cell kv, boolean forward) throws IOException { 055 return forward ? scanner.reseek(kv) : scanner.seek(kv); 056 } 057 058 @Override 059 public boolean shouldUseScanner(Scan scan, HStore store, long oldestUnexpiredTS) { 060 // No optimizations implemented by default. 061 return true; 062 } 063 064 @Override 065 public boolean isFileScanner() { 066 // Not a file by default. 067 return false; 068 } 069 070 071 @Override 072 public Path getFilePath() { 073 // Not a file by default. 074 return null; 075 } 076 077 @Override 078 public Cell getNextIndexedKey() { 079 return null; 080 } 081 082 @Override 083 public void shipped() throws IOException { 084 // do nothing 085 } 086}