iHBASE-16792 Reuse KeyValue.KeyOnlyKeyValue in

BufferedDataBlockEncoder.SeekerState (Binlijin)
This commit is contained in:
Ramkrishna 2016-10-14 17:52:24 +05:30
parent 9a94dc90b4
commit 4127fd2a7c
3 changed files with 19 additions and 4 deletions

View File

@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.ClassSize; import org.apache.hadoop.hbase.util.ClassSize;
import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.io.RawComparator; import org.apache.hadoop.io.RawComparator;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
/** /**
@ -2641,6 +2642,20 @@ public class KeyValue implements ExtendedCell {
this.rowLen = Bytes.toShort(this.bytes, this.offset); this.rowLen = Bytes.toShort(this.bytes, this.offset);
} }
public void set(KeyOnlyKeyValue keyOnlyKeyValue) {
this.bytes = keyOnlyKeyValue.bytes;
this.length = keyOnlyKeyValue.length;
this.offset = keyOnlyKeyValue.offset;
this.rowLen = keyOnlyKeyValue.rowLen;
}
public void clear() {
rowLen = -1;
bytes = null;
offset = 0;
length = 0;
}
@Override @Override
public int getKeyOffset() { public int getKeyOffset() {
return this.offset; return this.offset;

View File

@ -139,7 +139,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
protected void invalidate() { protected void invalidate() {
valueOffset = -1; valueOffset = -1;
tagsCompressedLength = 0; tagsCompressedLength = 0;
currentKey = new KeyValue.KeyOnlyKeyValue(); currentKey.clear();
uncompressTags = true; uncompressTags = true;
currentBuffer = null; currentBuffer = null;
} }
@ -188,7 +188,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
keyBuffer, nextState.lastCommonPrefix, nextState.keyLength keyBuffer, nextState.lastCommonPrefix, nextState.keyLength
- nextState.lastCommonPrefix); - nextState.lastCommonPrefix);
} }
currentKey = nextState.currentKey; currentKey.set(nextState.currentKey);
valueOffset = nextState.valueOffset; valueOffset = nextState.valueOffset;
keyLength = nextState.keyLength; keyLength = nextState.keyLength;

View File

@ -361,9 +361,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
// We need to ensure that while we are calculating the smallestReadPoint // We need to ensure that while we are calculating the smallestReadPoint
// no new RegionScanners can grab a readPoint that we are unaware of. // no new RegionScanners can grab a readPoint that we are unaware of.
// We achieve this by synchronizing on the scannerReadPoints object. // We achieve this by synchronizing on the scannerReadPoints object.
synchronized(scannerReadPoints) { synchronized (scannerReadPoints) {
minimumReadPoint = mvcc.getReadPoint(); minimumReadPoint = mvcc.getReadPoint();
for (Long readPoint: this.scannerReadPoints.values()) { for (Long readPoint : this.scannerReadPoints.values()) {
if (readPoint < minimumReadPoint) { if (readPoint < minimumReadPoint) {
minimumReadPoint = readPoint; minimumReadPoint = readPoint;
} }