HBASE-14657 Remove unneeded API from EncodedSeeker (Heng Chen)
This commit is contained in:
parent
34fe1f5fd7
commit
9e3c381bee
@ -594,40 +594,6 @@ abstract class BufferedDataBlockEncoder implements DataBlockEncoder {
|
|||||||
return dup.slice();
|
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);
|
|
||||||
ByteBufferUtils.copyFromBufferToBuffer(kvBuffer, currentBuffer, 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.
|
|
||||||
ByteBufferUtils.copyFromBufferToBuffer(kvBuffer, currentBuffer, 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
|
@Override
|
||||||
public Cell getKeyValue() {
|
public Cell getKeyValue() {
|
||||||
return current.shallowCopy();
|
return current.shallowCopy();
|
||||||
|
@ -154,9 +154,6 @@ public interface DataBlockEncoder {
|
|||||||
*/
|
*/
|
||||||
ByteBuffer getValueShallowCopy();
|
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 KeyValue object at the current position. Includes memstore
|
* @return the KeyValue object at the current position. Includes memstore
|
||||||
|
@ -85,14 +85,6 @@ public class PrefixTreeSeeker implements EncodedSeeker {
|
|||||||
return CellUtil.getValueBufferShallowCopy(ptSearcher.current());
|
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
|
* currently must do deep copy into new array
|
||||||
*/
|
*/
|
||||||
|
@ -273,17 +273,17 @@ public class TestDataBlockEncoders {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
do {
|
do {
|
||||||
KeyValue expectedKeyValue = sampleKv.get(i);
|
KeyValue expectedKeyValue = sampleKv.get(i);
|
||||||
ByteBuffer keyValue = seeker.getKeyValueBuffer();
|
KeyValue keyValue = KeyValueUtil.copyToNewKeyValue(seeker.getKeyValue());
|
||||||
if (0 != Bytes.compareTo(keyValue.array(), keyValue.arrayOffset(), keyValue.limit(),
|
if (0 != Bytes.compareTo(keyValue.getBuffer(), keyValue.getOffset(), keyValue.getLength(),
|
||||||
expectedKeyValue.getBuffer(), expectedKeyValue.getOffset(),
|
expectedKeyValue.getBuffer(), expectedKeyValue.getOffset(),
|
||||||
expectedKeyValue.getLength())) {
|
expectedKeyValue.getLength())) {
|
||||||
|
|
||||||
int commonPrefix = 0;
|
int commonPrefix = 0;
|
||||||
byte[] left = keyValue.array();
|
byte[] left = keyValue.getBuffer();
|
||||||
byte[] right = expectedKeyValue.getBuffer();
|
byte[] right = expectedKeyValue.getBuffer();
|
||||||
int leftOff = keyValue.arrayOffset();
|
int leftOff = keyValue.getOffset();
|
||||||
int rightOff = expectedKeyValue.getOffset();
|
int rightOff = expectedKeyValue.getOffset();
|
||||||
int length = Math.min(keyValue.limit(), expectedKeyValue.getLength());
|
int length = Math.min(keyValue.getLength(), expectedKeyValue.getLength());
|
||||||
while (commonPrefix < length
|
while (commonPrefix < length
|
||||||
&& left[commonPrefix + leftOff] == right[commonPrefix + rightOff]) {
|
&& left[commonPrefix + leftOff] == right[commonPrefix + rightOff]) {
|
||||||
commonPrefix++;
|
commonPrefix++;
|
||||||
@ -293,7 +293,7 @@ public class TestDataBlockEncoders {
|
|||||||
+ "encoder: %s i: %d commonPrefix: %d" + "\n expected %s\n actual %s", encoder
|
+ "encoder: %s i: %d commonPrefix: %d" + "\n expected %s\n actual %s", encoder
|
||||||
.toString(), i, commonPrefix, Bytes.toStringBinary(expectedKeyValue.getBuffer(),
|
.toString(), i, commonPrefix, Bytes.toStringBinary(expectedKeyValue.getBuffer(),
|
||||||
expectedKeyValue.getOffset(), expectedKeyValue.getLength()), Bytes
|
expectedKeyValue.getOffset(), expectedKeyValue.getLength()), Bytes
|
||||||
.toStringBinary(keyValue)));
|
.toStringBinary(keyValue.getBuffer())));
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
} while (seeker.next());
|
} while (seeker.next());
|
||||||
@ -341,7 +341,7 @@ public class TestDataBlockEncoders {
|
|||||||
seeker.seekToKeyInBlock(keyValue, seekBefore);
|
seeker.seekToKeyInBlock(keyValue, seekBefore);
|
||||||
seeker.rewind();
|
seeker.rewind();
|
||||||
|
|
||||||
ByteBuffer actualKeyValue = seeker.getKeyValueBuffer();
|
ByteBuffer actualKeyValue = KeyValueUtil.copyKeyToNewByteBuffer(seeker.getKeyValue());
|
||||||
ByteBuffer actualKey = seeker.getKeyDeepCopy();
|
ByteBuffer actualKey = seeker.getKeyDeepCopy();
|
||||||
ByteBuffer actualValue = seeker.getValueShallowCopy();
|
ByteBuffer actualValue = seeker.getValueShallowCopy();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user