HBASE-14657 Remove unneeded API from EncodedSeeker (Heng Chen)
This commit is contained in:
parent
467bc098a9
commit
c21e8ed1d8
|
@ -759,38 +759,6 @@ abstract class BufferedDataBlockEncoder implements DataBlockEncoder {
|
|||
return dup.slice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer getKeyValueBuffer() {
|
||||
ByteBuffer kvBuffer = createKVBuffer();
|
||||
kvBuffer.putInt(current.keyLength);
|
||||
kvBuffer.putInt(current.valueLength);
|
||||
kvBuffer.put(current.keyBuffer, 0, current.keyLength);
|
||||
currentBuffer.get(kvBuffer, current.valueOffset, current.valueLength);
|
||||
if (current.tagsLength > 0) {
|
||||
// Put short as unsigned
|
||||
kvBuffer.put((byte) (current.tagsLength >> 8 & 0xff));
|
||||
kvBuffer.put((byte) (current.tagsLength & 0xff));
|
||||
if (current.tagsOffset != -1) {
|
||||
// the offset of the tags bytes in the underlying buffer is marked. So the temp
|
||||
// buffer,tagsBuffer was not been used.
|
||||
currentBuffer.get(kvBuffer, current.tagsOffset, current.tagsLength);
|
||||
} else {
|
||||
// When tagsOffset is marked as -1, tag compression was present and so the tags were
|
||||
// uncompressed into temp buffer, tagsBuffer. Let us copy it from there
|
||||
kvBuffer.put(current.tagsBuffer, 0, current.tagsLength);
|
||||
}
|
||||
}
|
||||
kvBuffer.rewind();
|
||||
return kvBuffer;
|
||||
}
|
||||
|
||||
protected ByteBuffer createKVBuffer() {
|
||||
int kvBufSize = (int) KeyValue.getKeyValueDataStructureSize(current.keyLength,
|
||||
current.valueLength, current.tagsLength);
|
||||
ByteBuffer kvBuffer = ByteBuffer.allocate(kvBufSize);
|
||||
return kvBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cell getCell() {
|
||||
return current.toCell();
|
||||
|
|
|
@ -154,10 +154,6 @@ public interface DataBlockEncoder {
|
|||
* @return value at current position
|
||||
*/
|
||||
ByteBuffer getValueShallowCopy();
|
||||
|
||||
//TODO : to be removed - currently used in testcases only
|
||||
/** @return a key value buffer with the position set at the beginning of the buffer */
|
||||
ByteBuffer getKeyValueBuffer();
|
||||
|
||||
/**
|
||||
* @return the Cell at the current position. Includes memstore timestamp.
|
||||
|
|
|
@ -86,14 +86,6 @@ public class PrefixTreeSeeker implements EncodedSeeker {
|
|||
return CellUtil.getValueBufferShallowCopy(ptSearcher.current());
|
||||
}
|
||||
|
||||
/**
|
||||
* currently must do deep copy into new array
|
||||
*/
|
||||
@Override
|
||||
public ByteBuffer getKeyValueBuffer() {
|
||||
return KeyValueUtil.copyToNewByteBuffer(ptSearcher.current());
|
||||
}
|
||||
|
||||
/**
|
||||
* currently must do deep copy into new array
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.hadoop.hbase.io.encoding;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -333,14 +334,14 @@ public class TestDataBlockEncoders {
|
|||
|
||||
private void checkSeekingConsistency(List<DataBlockEncoder.EncodedSeeker> encodedSeekers,
|
||||
boolean seekBefore, Cell keyValue) {
|
||||
ByteBuffer expectedKeyValue = null;
|
||||
Cell expectedKeyValue = null;
|
||||
ByteBuffer expectedKey = null;
|
||||
ByteBuffer expectedValue = null;
|
||||
for (DataBlockEncoder.EncodedSeeker seeker : encodedSeekers) {
|
||||
seeker.seekToKeyInBlock(keyValue, seekBefore);
|
||||
seeker.rewind();
|
||||
|
||||
ByteBuffer actualKeyValue = seeker.getKeyValueBuffer();
|
||||
Cell actualKeyValue = seeker.getCell();
|
||||
ByteBuffer actualKey = null;
|
||||
if (seeker instanceof PrefixTreeSeeker) {
|
||||
byte[] serializedKey = CellUtil.getCellKeySerializedAsKeyValueKey(seeker.getKey());
|
||||
|
@ -351,7 +352,7 @@ public class TestDataBlockEncoders {
|
|||
ByteBuffer actualValue = seeker.getValueShallowCopy();
|
||||
|
||||
if (expectedKeyValue != null) {
|
||||
assertEquals(expectedKeyValue, actualKeyValue);
|
||||
assertTrue(CellUtil.equals(expectedKeyValue, actualKeyValue));
|
||||
} else {
|
||||
expectedKeyValue = actualKeyValue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue