diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java index be8c192..5b049fd 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java @@ -677,11 +677,6 @@ abstract class BufferedDataBlockEncoder implements DataBlockEncoder { } @Override - public int seekToKeyInBlock(byte[] key, int offset, int length, boolean seekBefore) { - return seekToKeyInBlock(new KeyValue.KeyOnlyKeyValue(key, offset, length), seekBefore); - } - - @Override public int seekToKeyInBlock(Cell seekCell, boolean seekBefore) { int rowCommonPrefix = 0; int familyCommonPrefix = 0; diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java index 872c22c..8073e54 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java @@ -182,27 +182,6 @@ public interface DataBlockEncoder { * previous block if the requested key turns out to be the first key of the * current block. * - * @param key byte array containing the key - * @param offset key position the array - * @param length key length in bytes - * @param seekBefore find the key strictly less than the given key in case - * of an exact match. Does not matter in case of an inexact match. - * @return 0 on exact match, 1 on inexact match. - */ - @Deprecated - int seekToKeyInBlock( - byte[] key, int offset, int length, boolean seekBefore - ); - /** - * Moves the seeker position within the current block to: - * * @param key - Cell to which the seek should happen * @param seekBefore find the key strictly less than the given key in case * of an exact match. Does not matter in case of an inexact match. diff --git a/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java b/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java index b95055c..d9852be 100644 --- a/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java +++ b/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java @@ -140,35 +140,6 @@ public class PrefixTreeSeeker implements EncodedSeeker { private static final boolean USE_POSITION_BEFORE = false; - /** - * Seek forward only (should be called reseekToKeyInBlock?). - *

- * If the exact key is found look at the seekBefore variable and:
- * - if true: go to the previous key if it's true
- * - if false: stay on the exact key - *

- * If the exact key is not found, then go to the previous key *if possible*, but remember to - * leave the scanner in a valid state if possible. - *

- * @param keyOnlyBytes KeyValue format of a Cell's key at which to position the seeker - * @param offset offset into the keyOnlyBytes array - * @param length number of bytes of the keyOnlyBytes array to use - * @param forceBeforeOnExactMatch if an exact match is found and seekBefore=true, back up 1 Cell - * @return 0 if the seeker is on the exact key
- * 1 if the seeker is not on the key for any reason, including seekBefore being true - */ - @Override - public int seekToKeyInBlock(byte[] keyOnlyBytes, int offset, int length, - boolean forceBeforeOnExactMatch) { - if (USE_POSITION_BEFORE) { - return seekToOrBeforeUsingPositionAtOrBefore(keyOnlyBytes, offset, length, - forceBeforeOnExactMatch); - } else { - return seekToOrBeforeUsingPositionAtOrAfter(keyOnlyBytes, offset, length, - forceBeforeOnExactMatch); - } - } - /* * Support both of these options since the underlying PrefixTree supports both. Possibly * expand the EncodedSeeker to utilize them both. diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java index 43bbab5..58502bb 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java @@ -174,17 +174,6 @@ public class HalfStoreFileReader extends StoreFile.Reader { } @Override - public boolean seekBefore(byte[] key) throws IOException { - return seekBefore(key, 0, key.length); - } - - @Override - public boolean seekBefore(byte [] key, int offset, int length) - throws IOException { - return seekBefore(new KeyValue.KeyOnlyKeyValue(key, offset, length)); - } - - @Override public boolean seekTo() throws IOException { if (top) { int r = this.delegate.seekTo(new KeyValue.KeyOnlyKeyValue(splitkey, 0, splitkey.length)); @@ -212,29 +201,6 @@ public class HalfStoreFileReader extends StoreFile.Reader { splitkey, 0, splitkey.length) < 0; } - @Override - public int seekTo(byte[] key) throws IOException { - return seekTo(key, 0, key.length); - } - - @Override - public int seekTo(byte[] key, int offset, int length) throws IOException { - return seekTo(new KeyValue.KeyOnlyKeyValue(key, offset, length)); - } - - @Override - public int reseekTo(byte[] key) throws IOException { - return reseekTo(key, 0, key.length); - } - - @Override - public int reseekTo(byte[] key, int offset, int length) - throws IOException { - //This function is identical to the corresponding seekTo function except - //that we call reseekTo (and not seekTo) on the delegate. - return reseekTo(new KeyValue.KeyOnlyKeyValue(key, offset, length)); - } - public org.apache.hadoop.hbase.io.hfile.HFile.Reader getReader() { return this.delegate.getReader(); } @@ -338,7 +304,7 @@ public class HalfStoreFileReader extends StoreFile.Reader { // Get a scanner that caches the block and that uses pread. HFileScanner scanner = getScanner(true, true); try { - if (scanner.seekBefore(this.splitkey)) { + if (scanner.seekBefore(this.splitCell)) { return Bytes.toBytes(scanner.getKey()); } } catch (IOException e) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java index 7b92df9..41779a7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java @@ -264,7 +264,7 @@ public class HFilePrettyPrinter extends Configured implements Tool { if (this.isSeekToRow) { // seek to the first kv on this row shouldScanKeysValues = - (scanner.seekTo(KeyValueUtil.createFirstOnRow(this.row).getKey()) != -1); + (scanner.seekTo(KeyValueUtil.createFirstOnRow(this.row)) != -1); } else { shouldScanKeysValues = scanner.seekTo(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java index 933ad22..1e84e6a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java @@ -478,21 +478,6 @@ public class HFileReaderImpl implements HFile.Reader, Configurable { } @Override - public int seekTo(byte[] key) throws IOException { - return seekTo(key, 0, key.length); - } - - @Override - public boolean seekBefore(byte[] key) throws IOException { - return seekBefore(key, 0, key.length); - } - - @Override - public int reseekTo(byte[] key) throws IOException { - return reseekTo(key, 0, key.length); - } - - @Override public HFile.Reader getReader() { return reader; } @@ -652,18 +637,6 @@ public class HFileReaderImpl implements HFile.Reader, Configurable { } @Override - public int seekTo(byte[] key, int offset, int length) throws IOException { - // Always rewind to the first key of the block, because the given key - // might be before or after the current key. - return seekTo(new KeyValue.KeyOnlyKeyValue(key, offset, length)); - } - - @Override - public int reseekTo(byte[] key, int offset, int length) throws IOException { - return reseekTo(new KeyValue.KeyOnlyKeyValue(key, offset, length)); - } - - @Override public int seekTo(Cell key) throws IOException { return seekTo(key, true); } @@ -724,11 +697,6 @@ public class HFileReaderImpl implements HFile.Reader, Configurable { } @Override - public boolean seekBefore(byte[] key, int offset, int length) throws IOException { - return seekBefore(new KeyValue.KeyOnlyKeyValue(key, offset, length)); - } - - @Override public boolean seekBefore(Cell key) throws IOException { HFileBlock seekToBlock = reader.getDataBlockIndexReader().seekToDataBlock(key, block, cacheBlocks, pread, isCompaction, reader.getEffectiveEncodingInCache(isCompaction)); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileScanner.java index deaa2c0..7466b21 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileScanner.java @@ -39,69 +39,57 @@ import org.apache.hadoop.hbase.Cell; @InterfaceAudience.Private public interface HFileScanner { /** - * SeekTo or just before the passed key. Examine the return - * code to figure whether we found the key or not. - * Consider the key stream of all the keys in the file, - * k[0] .. k[n], where there are n keys in the file. - * @param key Key to find. - * @return -1, if key < k[0], no position; - * 0, such that k[i] = key and scanner is left in position i; and - * 1, such that k[i] < key, and scanner is left in position i. - * The scanner will position itself between k[i] and k[i+1] where - * k[i] < key <= k[i+1]. - * If there is no key k[i+1] greater than or equal to the input key, then the + * SeekTo or just before the passed cell. Examine the return + * code to figure whether we found the cell or not. + * Consider the cell stream of all the cells in the file, + * c[0] .. c[n], where there are n cells in the file. + * @param cell + * @return -1, if cell < c[0], no position; + * 0, such that c[i] = cell and scanner is left in position i; and + * 1, such that c[i] < cell, and scanner is left in position i. + * The scanner will position itself between c[i] and c[i+1] where + * c[i] < cell <= c[i+1]. + * If there is no cell c[i+1] greater than or equal to the input cell, then the * scanner will position itself at the end of the file and next() will return * 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 cell) throws IOException; - int seekTo(Cell c) throws IOException; /** - * Reseek to or just before the passed key. Similar to seekTo + * Reseek to or just before the passed cell. Similar to seekTo * except that this can be called even if the scanner is not at the beginning * of a file. - * This can be used to seek only to keys which come after the current position + * This can be used to seek only to cells which come after the current position * of the scanner. - * Consider the key stream of all the keys in the file, - * k[0] .. k[n], where there are n keys in the file after + * Consider the cell stream of all the cells in the file, + * c[0] .. c[n], where there are n cellc in the file after * current position of HFileScanner. - * The scanner will position itself between k[i] and k[i+1] where - * k[i] < key <= k[i+1]. - * If there is no key k[i+1] greater than or equal to the input key, then the + * The scanner will position itself between c[i] and c[i+1] where + * c[i] < cell <= c[i+1]. + * If there is no cell c[i+1] greater than or equal to the input cell, then the * scanner will position itself at the end of the file and next() will return * false when it is called. - * @param key Key to find (should be non-null) - * @return -1, if key < k[0], no position; - * 0, such that k[i] = key and scanner is left in position i; and - * 1, such that k[i] < key, and scanner is left in position i. + * @param cell Cell to find (should be non-null) + * @return -1, if cell < c[0], no position; + * 0, such that c[i] = cell and scanner is left in position i; and + * 1, such that c[i] < cell, 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 cell) throws IOException; - int reseekTo(Cell c) 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. - * @param key Key to find - * @return false if key <= k[0] or true with scanner in position 'i' such - * that: k[i] < key. Furthermore: there may be a k[i+1], such that - * k[i] < key <= k[i+1] but there may also NOT be a k[i+1], and next() will + * Consider the cell stream of all the cells in the file, + * c[0] .. c[n], where there are n cells in the file. + * @param cell Cell to find + * @return false if cell <= c[0] or true with scanner in position 'i' such + * that: c[i] < cell. Furthermore: there may be a c[i+1], such that + * c[i] < cell <= c[i+1] but there may also NOT be a c[i+1], and next() will * 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 diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java index 686df49..042deed 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -1870,8 +1870,7 @@ public class HStore implements Store { // Unlikely that there'll be an instance of actual first row in table. if (walkForwardInSingleRow(scanner, firstOnRow, state)) return true; // If here, need to start backing up. - while (scanner.seekBefore(firstOnRow.getBuffer(), firstOnRow.getKeyOffset(), - firstOnRow.getKeyLength())) { + while (scanner.seekBefore(firstOnRow)) { Cell kv = scanner.getKeyValue(); if (!state.isTargetTable(kv)) break; if (!state.isBetterCandidate(kv)) break; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java index a8ee091..22fd46e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java @@ -422,8 +422,7 @@ public class StoreFileScanner implements KeyValueScanner { KeyValue seekKey = KeyValueUtil.createFirstOnRow(key.getRowArray(), key.getRowOffset(), key.getRowLength()); if (seekCount != null) seekCount.incrementAndGet(); - if (!hfs.seekBefore(seekKey.getBuffer(), seekKey.getKeyOffset(), - seekKey.getKeyLength())) { + if (!hfs.seekBefore(seekKey)) { close(); return false; }