diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java index 736f330..86d2673 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java @@ -27,8 +27,10 @@ import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.KeyValueUtil; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.io.hfile.CacheConfig; import org.apache.hadoop.hbase.io.hfile.HFileScanner; @@ -286,6 +288,24 @@ public class HalfStoreFileReader extends StoreFile.Reader { public boolean isSeeked() { return this.delegate.isSeeked(); } + + @Override + public int seekTo(Cell kv) throws IOException { + KeyValue keyValue = KeyValueUtil.ensureKeyValue(kv); + return seekTo(keyValue.getBuffer(), keyValue.getOffset(), keyValue.getLength()); + } + + @Override + public int reseekTo(Cell kv) throws IOException { + KeyValue keyValue = KeyValueUtil.ensureKeyValue(kv); + return reseekTo(keyValue.getBuffer(), keyValue.getOffset(), keyValue.getLength()); + } + + @Override + public boolean seekBefore(Cell kv) throws IOException { + KeyValue keyValue = KeyValueUtil.ensureKeyValue(kv); + return seekBefore(keyValue.getBuffer(), keyValue.getOffset(), keyValue.getLength()); + } }; } diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java index acbeed2..f6e759a 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java @@ -28,9 +28,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.KVComparator; +import org.apache.hadoop.hbase.KeyValueUtil; import org.apache.hadoop.hbase.fs.HFileSystem; import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper; import org.apache.hadoop.hbase.io.encoding.DataBlockEncoder; @@ -541,8 +543,20 @@ public class HFileReaderV2 extends AbstractHFileReader { // always going forward in the file. return seekTo(key, offset, length, false); } + + @Override + public int seekTo(Cell kv) throws IOException { + KeyValue keyValue = KeyValueUtil.ensureKeyValue(kv); + return seekTo(keyValue.getBuffer(), keyValue.getKeyOffset(), keyValue.getKeyLength()); + } @Override + public int reseekTo(Cell kv) throws IOException { + KeyValue keyValue = KeyValueUtil.ensureKeyValue(kv); + return reseekTo(keyValue.getBuffer(), keyValue.getKeyOffset(), keyValue.getKeyLength()); + } + + @Override public boolean seekBefore(byte[] key, int offset, int length) throws IOException { HFileBlock seekToBlock = @@ -576,6 +590,12 @@ public class HFileReaderV2 extends AbstractHFileReader { loadBlockAndSeekToKey(seekToBlock, firstKeyInCurrentBlock, true, key, offset, length, true); return true; } + + @Override + public boolean seekBefore(Cell kv) throws IOException { + KeyValue keyValue = KeyValueUtil.ensureKeyValue(kv); + return seekBefore(keyValue.getBuffer(), keyValue.getKeyOffset(), keyValue.getKeyLength()); + } /** diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileScanner.java hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileScanner.java index 0e353ef..840a78c 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileScanner.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileScanner.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.KeyValue; /** @@ -54,8 +55,12 @@ public interface HFileScanner { * false when it is called. * @throws IOException */ + @Deprecated int seekTo(byte[] key) throws IOException; + @Deprecated int seekTo(byte[] key, int offset, int length) throws IOException; + + int seekTo(Cell kv) throws IOException; /** * Reseek to or just before the passed key. Similar to seekTo * except that this can be called even if the scanner is not at the beginning @@ -76,8 +81,12 @@ public interface HFileScanner { * 1, such that k[i] < key, and scanner is left in position i. * @throws IOException */ + @Deprecated int reseekTo(byte[] key) throws IOException; + @Deprecated int reseekTo(byte[] key, int offset, int length) throws IOException; + + int reseekTo(Cell kv) throws IOException; /** * Consider the key stream of all the keys in the file, * k[0] .. k[n], where there are n keys in the file. @@ -88,8 +97,12 @@ public interface HFileScanner { * return false (EOF). * @throws IOException */ + @Deprecated boolean seekBefore(byte[] key) throws IOException; + @Deprecated boolean seekBefore(byte[] key, int offset, int length) throws IOException; + + boolean seekBefore(Cell kv) throws IOException; /** * Positions this scanner at the start of the file. * @return False if empty file; i.e. a call to next would return false and