HBASE-24194 : Refactor anonymous inner classes of BufferedEncodedSeeker to named inner classes (#1522)
Signed-off-by: Peter Somogyi <psomogyi@apache.org> Signed-off-by: binlijin <binlijin@gmail.com>
This commit is contained in:
parent
589d075de8
commit
d4b64c2545
|
@ -84,7 +84,29 @@ public class CopyKeyDataBlockEncoder extends BufferedDataBlockEncoder {
|
|||
@Override
|
||||
public EncodedSeeker createSeeker(KVComparator comparator,
|
||||
final HFileBlockDecodingContext decodingCtx) {
|
||||
return new BufferedEncodedSeeker<SeekerState>(comparator, decodingCtx) {
|
||||
return new SeekerStateBufferedEncodedSeeker(comparator, decodingCtx);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuffer internalDecodeKeyValues(DataInputStream source, int allocateHeaderLength,
|
||||
int skipLastBytes, HFileBlockDefaultDecodingContext decodingCtx) throws IOException {
|
||||
int decompressedSize = source.readInt();
|
||||
ByteBuffer buffer = ByteBuffer.allocate(decompressedSize +
|
||||
allocateHeaderLength);
|
||||
buffer.position(allocateHeaderLength);
|
||||
ByteBufferUtils.copyFromStreamToBuffer(buffer, source, decompressedSize);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static class SeekerStateBufferedEncodedSeeker
|
||||
extends BufferedEncodedSeeker<SeekerState> {
|
||||
|
||||
public SeekerStateBufferedEncodedSeeker(KVComparator comparator,
|
||||
HFileBlockDecodingContext decodingCtx) {
|
||||
super(comparator, decodingCtx);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decodeNext() {
|
||||
current.keyLength = currentBuffer.getInt();
|
||||
|
@ -112,18 +134,5 @@ public class CopyKeyDataBlockEncoder extends BufferedDataBlockEncoder {
|
|||
current.lastCommonPrefix = 0;
|
||||
decodeNext();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuffer internalDecodeKeyValues(DataInputStream source, int allocateHeaderLength,
|
||||
int skipLastBytes, HFileBlockDefaultDecodingContext decodingCtx) throws IOException {
|
||||
int decompressedSize = source.readInt();
|
||||
ByteBuffer buffer = ByteBuffer.allocate(decompressedSize +
|
||||
allocateHeaderLength);
|
||||
buffer.position(allocateHeaderLength);
|
||||
ByteBufferUtils.copyFromStreamToBuffer(buffer, source, decompressedSize);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -378,11 +378,41 @@ public class DiffKeyDeltaEncoder extends BufferedDataBlockEncoder {
|
|||
@Override
|
||||
public EncodedSeeker createSeeker(KVComparator comparator,
|
||||
HFileBlockDecodingContext decodingCtx) {
|
||||
return new BufferedEncodedSeeker<DiffSeekerState>(comparator, decodingCtx) {
|
||||
return new DiffSeekerStateBufferedEncodedSeeker(comparator, decodingCtx);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuffer internalDecodeKeyValues(DataInputStream source, int allocateHeaderLength,
|
||||
int skipLastBytes, HFileBlockDefaultDecodingContext decodingCtx) throws IOException {
|
||||
int decompressedSize = source.readInt();
|
||||
ByteBuffer buffer = ByteBuffer.allocate(decompressedSize +
|
||||
allocateHeaderLength);
|
||||
buffer.position(allocateHeaderLength);
|
||||
DiffCompressionState state = new DiffCompressionState();
|
||||
while (source.available() > skipLastBytes) {
|
||||
uncompressSingleKeyValue(source, buffer, state);
|
||||
afterDecodingKeyValue(source, buffer, decodingCtx);
|
||||
}
|
||||
|
||||
if (source.available() != skipLastBytes) {
|
||||
throw new IllegalStateException("Read too much bytes.");
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static class DiffSeekerStateBufferedEncodedSeeker
|
||||
extends BufferedEncodedSeeker<DiffSeekerState> {
|
||||
|
||||
private byte[] familyNameWithSize;
|
||||
private static final int TIMESTAMP_WITH_TYPE_LENGTH =
|
||||
Bytes.SIZEOF_LONG + Bytes.SIZEOF_BYTE;
|
||||
|
||||
private DiffSeekerStateBufferedEncodedSeeker(KVComparator comparator,
|
||||
HFileBlockDecodingContext decodingCtx) {
|
||||
super(comparator, decodingCtx);
|
||||
}
|
||||
|
||||
private void decode(boolean isFirst) {
|
||||
byte flag = currentBuffer.get();
|
||||
byte type = 0;
|
||||
|
@ -503,26 +533,5 @@ public class DiffKeyDeltaEncoder extends BufferedDataBlockEncoder {
|
|||
protected DiffSeekerState createSeekerState() {
|
||||
return new DiffSeekerState();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuffer internalDecodeKeyValues(DataInputStream source, int allocateHeaderLength,
|
||||
int skipLastBytes, HFileBlockDefaultDecodingContext decodingCtx) throws IOException {
|
||||
int decompressedSize = source.readInt();
|
||||
ByteBuffer buffer = ByteBuffer.allocate(decompressedSize +
|
||||
allocateHeaderLength);
|
||||
buffer.position(allocateHeaderLength);
|
||||
DiffCompressionState state = new DiffCompressionState();
|
||||
while (source.available() > skipLastBytes) {
|
||||
uncompressSingleKeyValue(source, buffer, state);
|
||||
afterDecodingKeyValue(source, buffer, decodingCtx);
|
||||
}
|
||||
|
||||
if (source.available() != skipLastBytes) {
|
||||
throw new IllegalStateException("Read too much bytes.");
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -398,7 +398,17 @@ public class FastDiffDeltaEncoder extends BufferedDataBlockEncoder {
|
|||
@Override
|
||||
public EncodedSeeker createSeeker(KVComparator comparator,
|
||||
final HFileBlockDecodingContext decodingCtx) {
|
||||
return new BufferedEncodedSeeker<FastDiffSeekerState>(comparator, decodingCtx) {
|
||||
return new FastDiffSeekerStateBufferedEncodedSeeker(comparator, decodingCtx);
|
||||
}
|
||||
|
||||
private class FastDiffSeekerStateBufferedEncodedSeeker
|
||||
extends BufferedEncodedSeeker<FastDiffSeekerState> {
|
||||
|
||||
private FastDiffSeekerStateBufferedEncodedSeeker(KVComparator comparator,
|
||||
HFileBlockDecodingContext decodingCtx) {
|
||||
super(comparator, decodingCtx);
|
||||
}
|
||||
|
||||
private void decode(boolean isFirst) {
|
||||
byte flag = currentBuffer.get();
|
||||
if ((flag & FLAG_SAME_KEY_LENGTH) == 0) {
|
||||
|
@ -524,6 +534,5 @@ public class FastDiffDeltaEncoder extends BufferedDataBlockEncoder {
|
|||
protected FastDiffSeekerState createSeekerState() {
|
||||
return new FastDiffSeekerState();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,17 @@ public class PrefixKeyDeltaEncoder extends BufferedDataBlockEncoder {
|
|||
@Override
|
||||
public EncodedSeeker createSeeker(KVComparator comparator,
|
||||
final HFileBlockDecodingContext decodingCtx) {
|
||||
return new BufferedEncodedSeeker<SeekerState>(comparator, decodingCtx) {
|
||||
return new SeekerStateBufferedEncodedSeeker(comparator, decodingCtx);
|
||||
}
|
||||
|
||||
private static class SeekerStateBufferedEncodedSeeker
|
||||
extends BufferedEncodedSeeker<SeekerState> {
|
||||
|
||||
private SeekerStateBufferedEncodedSeeker(KVComparator comparator,
|
||||
HFileBlockDecodingContext decodingCtx) {
|
||||
super(comparator, decodingCtx);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decodeNext() {
|
||||
current.keyLength = ByteBufferUtils.readCompressedInt(currentBuffer);
|
||||
|
@ -227,6 +237,5 @@ public class PrefixKeyDeltaEncoder extends BufferedDataBlockEncoder {
|
|||
ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT);
|
||||
decodeNext();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue