Skip to content

Commit

Permalink
HBASE-26922 Fix LineLength warnings as much as possible if it can not…
Browse files Browse the repository at this point in the history
… be fixed by spotless (#4324)

Signed-off-by: Yulin Niu <[email protected]
  • Loading branch information
Apache9 authored Apr 9, 2022
1 parent eb4c2ae commit 3ae0d90
Show file tree
Hide file tree
Showing 54 changed files with 446 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public class StreamSlowMonitor implements ConfigurationObserver {
*/
private static final String DATANODE_PACKET_FLUSH_CHECK_SPEED_MIN_DATA_LENGTH_KEY =
"hbase.regionserver.async.wal.datanode.slow.check.speed.packet.data.length.min";
private static final long DEFAULT_DATANODE_PACKET_FLUSH_CHECK_SPEED_MIN_DATA_LENGTH =
64 * 1024; //64KB
// 64KB
private static final long DEFAULT_DATANODE_PACKET_FLUSH_CHECK_SPEED_MIN_DATA_LENGTH = 64 * 1024;

/**
* Configure for the slow packet process time, a duration from send to ACK.
Expand All @@ -79,7 +79,8 @@ public class StreamSlowMonitor implements ConfigurationObserver {
*/
public static final String DATANODE_SLOW_PACKET_PROCESS_TIME_KEY =
"hbase.regionserver.async.wal.datanode.slow.packet.process.time.millis";
private static final long DEFAULT_DATANODE_SLOW_PACKET_PROCESS_TIME = 6000; // 6s in ms
// 6s in ms
private static final long DEFAULT_DATANODE_SLOW_PACKET_PROCESS_TIME = 6000;

/**
* Configure for the check of large packet(which is configured by
Expand All @@ -89,7 +90,8 @@ public class StreamSlowMonitor implements ConfigurationObserver {
*/
private static final String DATANODE_SLOW_PACKET_FLUSH_MIN_SPEED_KEY =
"hbase.regionserver.async.wal.datanode.slow.packet.speed.min.kbs";
private static final double DEFAULT_DATANODE_SLOW_PACKET_FLUSH_MIN_SPEED = 20; // 20KB/s
// 20KB/s
private static final double DEFAULT_DATANODE_SLOW_PACKET_FLUSH_MIN_SPEED = 20;

private final String name;
// this is a map of datanodeInfo->queued slow PacketAckData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ public void testSecondaryAndTertiaryPlacementWithSingleServer() {
// the primary can be assigned but the secondary/tertiary would be null
Map<String,Integer> rackToServerCount = new HashMap<>();
rackToServerCount.put("rack1", 1);
Triple<Map<RegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<RegionInfo>>
primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(1, rackToServerCount);
Triple<Map<RegionInfo, ServerName>, FavoredNodeAssignmentHelper,
List<RegionInfo>> primaryRSMapAndHelper =
secondaryAndTertiaryRSPlacementHelper(1, rackToServerCount);
FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
Map<RegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
List<RegionInfo> regions = primaryRSMapAndHelper.getThird();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public String toString() {
}
}

private final ConcurrentMap<TableName, ConcurrentNavigableMap<byte[], StaleLocationCacheEntry>>
staleCache = new ConcurrentHashMap<>();
private final ConcurrentMap<TableName,
ConcurrentNavigableMap<byte[], StaleLocationCacheEntry>> staleCache = new ConcurrentHashMap<>();
private volatile int numOfReplicas;
private final AsyncConnectionImpl conn;
private final TableName tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public static Filter createFilterFromArguments(ArrayList<byte []> filterArgument
/**
* @param pbBytes A pb serialized {@link ColumnCountGetFilter} instance
* @return An instance of {@link ColumnCountGetFilter} made from <code>bytes</code>
* @throws org.apache.hadoop.hbase.exceptions.DeserializationException
* @see #toByteArray
*/
public static ColumnCountGetFilter parseFrom(final byte [] pbBytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ public int compare(Pair<byte[], Pair<byte[], byte[]>> o1,

byte[] nextRow() {
if (nextRows.isEmpty()) {
throw new IllegalStateException(
"NextRows should not be empty, make sure to call nextRow() after updateTracker() return true");
throw new IllegalStateException("NextRows should not be empty, "
+ "make sure to call nextRow() after updateTracker() return true");
} else {
return nextRows.peek().getFirst();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ FilterProtos.SingleColumnValueFilter convert() {
/**
* @param pbBytes A pb serialized {@link SingleColumnValueFilter} instance
* @return An instance of {@link SingleColumnValueFilter} made from <code>bytes</code>
* @throws org.apache.hadoop.hbase.exceptions.DeserializationException
* @see #toByteArray
*/
public static SingleColumnValueFilter parseFrom(final byte [] pbBytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3004,9 +3004,7 @@ public static TableDescriptor toTableDescriptor(final TableSchema ts) {
}

/**
* Creates {@link CompactionState} from
* {@link org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState}
* state
* Creates {@link CompactionState} from {@link GetRegionInfoResponse.CompactionState} state
* @param state the protobuf CompactionState
* @return CompactionState
*/
Expand All @@ -3019,9 +3017,7 @@ public static GetRegionInfoResponse.CompactionState createCompactionState(Compac
}

/**
* Creates {@link CompactionState} from
* {@link org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos
* .RegionLoad.CompactionState} state
* Creates {@link CompactionState} from {@link RegionLoad.CompactionState} state
* @param state the protobuf CompactionState
* @return CompactionState
*/
Expand All @@ -3041,9 +3037,7 @@ public static Optional<Long> toOptionalTimestamp(MajorCompactionTimestampRespons
}

/**
* Creates
* {@link org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription.Type}
* from {@link SnapshotType}
* Creates {@link SnapshotProtos.SnapshotDescription.Type} from {@link SnapshotType}
* @param type the SnapshotDescription type
* @return the protobuf SnapshotDescription type
*/
Expand All @@ -3053,9 +3047,8 @@ public static Optional<Long> toOptionalTimestamp(MajorCompactionTimestampRespons
}

/**
* Creates
* {@link org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription.Type}
* from the type of SnapshotDescription string
* Creates {@link SnapshotProtos.SnapshotDescription.Type} from the type of SnapshotDescription
* string
* @param snapshotDesc string representing the snapshot description type
* @return the protobuf SnapshotDescription type
*/
Expand All @@ -3065,18 +3058,16 @@ public static Optional<Long> toOptionalTimestamp(MajorCompactionTimestampRespons
}

/**
* Creates {@link SnapshotType} from the
* {@link org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription.Type}
* @param type the snapshot description type
* @return the protobuf SnapshotDescription type
* Creates {@link SnapshotType} from the {@link SnapshotProtos.SnapshotDescription.Type}
* @param type the snapshot description type
* @return the protobuf SnapshotDescription type
*/
public static SnapshotType createSnapshotType(SnapshotProtos.SnapshotDescription.Type type) {
return SnapshotType.valueOf(type.toString());
}

/**
* Convert from {@link SnapshotDescription} to
* {@link org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription}
* Convert from {@link SnapshotDescription} to {@link SnapshotProtos.SnapshotDescription}
* @param snapshotDesc the POJO SnapshotDescription
* @return the protobuf SnapshotDescription
*/
Expand Down Expand Up @@ -3110,9 +3101,7 @@ public static SnapshotType createSnapshotType(SnapshotProtos.SnapshotDescription
}

/**
* Convert from
* {@link org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription} to
* {@link SnapshotDescription}
* Convert from {@link SnapshotProtos.SnapshotDescription} to {@link SnapshotDescription}
* @param snapshotDesc the protobuf SnapshotDescription
* @return the POJO SnapshotDescription
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
* faster will likely manifest at the macro level.
* </p>
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
value="UNKNOWN",
justification="Findbugs doesn't like the way we are negating the result of a compare in below")
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "UNKNOWN",
justification = "Findbugs doesn't like the way we are negating the result of"
+ " a compare in below")
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class CellComparatorImpl implements CellComparator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ default int write(OutputStream out, boolean withTags) throws IOException {
}

/**
* @param withTags Whether to write tags.
* @return Bytes count required to serialize this Cell in a {@link KeyValue} format.
* <br> KeyValue format <br>
* KeyValue format
* <p/>
* <code>&lt;4 bytes keylength&gt; &lt;4 bytes valuelength&gt; &lt;2 bytes rowlength&gt;
* &lt;row&gt; &lt;1 byte columnfamilylength&gt; &lt;columnfamily&gt; &lt;columnqualifier&gt;
* &lt;8 bytes timestamp&gt; &lt;1 byte keytype&gt; &lt;value&gt; &lt;2 bytes tagslength&gt;
* &lt;tags&gt;</code>
* @param withTags Whether to write tags.
* @return Bytes count required to serialize this Cell in a {@link KeyValue} format.
*/
// TODO remove the boolean param once HBASE-16706 is done.
default int getSerializedSize(boolean withTags) {
Expand Down
22 changes: 12 additions & 10 deletions hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -2369,21 +2369,23 @@ int compareIgnoringPrefix(int commonPrefix, byte[] left, int loffset, int llengt

/**
* HeapSize implementation
*
* <p/>
* We do not count the bytes in the rowCache because it should be empty for a KeyValue in the
* MemStore.
*/
@Override
public long heapSize() {
/*
* Deep object overhead for this KV consists of two parts. The first part is the KV object
* itself, while the second part is the backing byte[]. We will only count the array overhead
* from the byte[] only if this is the first KV in there.
*/
return ClassSize.align(FIXED_OVERHEAD) +
(offset == 0
? ClassSize.sizeOfByteArray(length) // count both length and object overhead
: length); // only count the number of bytes
// Deep object overhead for this KV consists of two parts. The first part is the KV object
// itself, while the second part is the backing byte[]. We will only count the array overhead
// from the byte[] only if this is the first KV in there.
int fixed = ClassSize.align(FIXED_OVERHEAD);
if (offset == 0) {
// count both length and object overhead
return fixed + ClassSize.sizeOfByteArray(length);
} else {
// only count the number of bytes
return fixed + length;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1616,11 +1616,13 @@ public int getValuePosition() {
}

private static class FirstOnRowCell extends EmptyCell {
// @formatter:off
private static final int FIXED_HEAPSIZE =
ClassSize.OBJECT // object
+ ClassSize.REFERENCE // row array
+ Bytes.SIZEOF_INT // row offset
+ Bytes.SIZEOF_SHORT; // row length
// @formatter:on
private final byte[] rowArray;
private final int roffset;
private final short rlength;
Expand Down Expand Up @@ -1670,11 +1672,13 @@ public Type getType() {
}

private static class FirstOnRowByteBufferExtendedCell extends EmptyByteBufferExtendedCell {
// @formatter:off
private static final int FIXED_OVERHEAD =
ClassSize.OBJECT // object
+ ClassSize.REFERENCE // row buffer
+ Bytes.SIZEOF_INT // row offset
+ Bytes.SIZEOF_SHORT; // row length
// @formatter:on
private final ByteBuffer rowBuff;
private final int roffset;
private final short rlength;
Expand Down Expand Up @@ -1725,11 +1729,12 @@ public Type getType() {
}

private static class LastOnRowByteBufferExtendedCell extends EmptyByteBufferExtendedCell {
private static final int FIXED_OVERHEAD =
ClassSize.OBJECT // object
// @formatter:off
private static final int FIXED_OVERHEAD = ClassSize.OBJECT // object
+ ClassSize.REFERENCE // rowBuff
+ Bytes.SIZEOF_INT // roffset
+ Bytes.SIZEOF_SHORT; // rlength
// @formatter:on
private final ByteBuffer rowBuff;
private final int roffset;
private final short rlength;
Expand Down Expand Up @@ -1781,11 +1786,12 @@ public Type getType() {

private static class FirstOnRowColByteBufferExtendedCell
extends FirstOnRowByteBufferExtendedCell {
private static final int FIXED_OVERHEAD =
FirstOnRowByteBufferExtendedCell.FIXED_OVERHEAD
+ ClassSize.REFERENCE * 2 // family buffer and column buffer
+ Bytes.SIZEOF_INT * 3 // famOffset, colOffset, colLength
+ Bytes.SIZEOF_BYTE; // famLength
// @formatter:off
private static final int FIXED_OVERHEAD = FirstOnRowByteBufferExtendedCell.FIXED_OVERHEAD
+ ClassSize.REFERENCE * 2 // family buffer and column buffer
+ Bytes.SIZEOF_INT * 3 // famOffset, colOffset, colLength
+ Bytes.SIZEOF_BYTE; // famLength
// @formatter:on
private final ByteBuffer famBuff;
private final int famOffset;
private final byte famLength;
Expand Down Expand Up @@ -1850,11 +1856,12 @@ public int getQualifierLength() {
}

private static class FirstOnRowColCell extends FirstOnRowCell {
private static final long FIXED_HEAPSIZE =
FirstOnRowCell.FIXED_HEAPSIZE
// @formatter:off
private static final long FIXED_HEAPSIZE = FirstOnRowCell.FIXED_HEAPSIZE
+ Bytes.SIZEOF_BYTE // flength
+ Bytes.SIZEOF_INT * 3 // foffset, qoffset, qlength
+ ClassSize.REFERENCE * 2; // fArray, qArray
// @formatter:on
private final byte[] fArray;
private final int foffset;
private final byte flength;
Expand Down Expand Up @@ -1913,10 +1920,11 @@ public int getQualifierLength() {
}

private static class FirstOnRowColTSCell extends FirstOnRowColCell {
private static final long FIXED_HEAPSIZE =
FirstOnRowColCell.FIXED_HEAPSIZE
+ Bytes.SIZEOF_LONG; // ts
// @formatter:off
private static final long FIXED_HEAPSIZE = FirstOnRowColCell.FIXED_HEAPSIZE
+ Bytes.SIZEOF_LONG; // ts
private long ts;
// @formatter:on

public FirstOnRowColTSCell(byte[] rArray, int roffset, short rlength, byte[] fArray,
int foffset, byte flength, byte[] qArray, int qoffset, int qlength, long ts) {
Expand All @@ -1937,10 +1945,11 @@ public long heapSize() {

private static class FirstOnRowColTSByteBufferExtendedCell
extends FirstOnRowColByteBufferExtendedCell {
private static final int FIXED_OVERHEAD =
FirstOnRowColByteBufferExtendedCell.FIXED_OVERHEAD
+ Bytes.SIZEOF_LONG; // ts
// @formatter:off
private static final int FIXED_OVERHEAD = FirstOnRowColByteBufferExtendedCell.FIXED_OVERHEAD
+ Bytes.SIZEOF_LONG; // ts
private long ts;
// @formatter:on

public FirstOnRowColTSByteBufferExtendedCell(ByteBuffer rBuffer, int roffset, short rlength,
ByteBuffer fBuffer, int foffset, byte flength, ByteBuffer qBuffer, int qoffset, int qlength,
Expand All @@ -1961,11 +1970,12 @@ public long heapSize() {
}

private static class LastOnRowCell extends EmptyCell {
private static final int FIXED_OVERHEAD =
ClassSize.OBJECT // object
// @formatter:off
private static final int FIXED_OVERHEAD = ClassSize.OBJECT // object
+ ClassSize.REFERENCE // row array
+ Bytes.SIZEOF_INT // row offset
+ Bytes.SIZEOF_SHORT; // row length
// @formatter:on
private final byte[] rowArray;
private final int roffset;
private final short rlength;
Expand Down Expand Up @@ -2015,10 +2025,12 @@ public Type getType() {
}

private static class LastOnRowColCell extends LastOnRowCell {
// @formatter:off
private static final long FIXED_OVERHEAD = LastOnRowCell.FIXED_OVERHEAD
+ ClassSize.REFERENCE * 2 // fArray and qArray
+ Bytes.SIZEOF_INT * 3 // foffset, qoffset, qlength
+ Bytes.SIZEOF_BYTE; // flength
+ ClassSize.REFERENCE * 2 // fArray and qArray
+ Bytes.SIZEOF_INT * 3 // foffset, qoffset, qlength
+ Bytes.SIZEOF_BYTE; // flength
// @formatter:on
private final byte[] fArray;
private final int foffset;
private final byte flength;
Expand Down Expand Up @@ -2077,11 +2089,12 @@ public int getQualifierLength() {
}

private static class LastOnRowColByteBufferExtendedCell extends LastOnRowByteBufferExtendedCell {
private static final int FIXED_OVERHEAD =
LastOnRowByteBufferExtendedCell.FIXED_OVERHEAD
+ ClassSize.REFERENCE * 2 // fBuffer and qBuffer
+ Bytes.SIZEOF_INT * 3 // foffset, qoffset, qlength
+ Bytes.SIZEOF_BYTE; // flength
// @formatter:off
private static final int FIXED_OVERHEAD = LastOnRowByteBufferExtendedCell.FIXED_OVERHEAD
+ ClassSize.REFERENCE * 2 // fBuffer and qBuffer
+ Bytes.SIZEOF_INT * 3 // foffset, qoffset, qlength
+ Bytes.SIZEOF_BYTE; // flength
// @formatter:on
private final ByteBuffer fBuffer;
private final int foffset;
private final byte flength;
Expand Down Expand Up @@ -2146,11 +2159,12 @@ public int getQualifierLength() {
}

private static class FirstOnRowDeleteFamilyCell extends EmptyCell {
private static final int FIXED_OVERHEAD =
ClassSize.OBJECT // object
// @formatter:off
private static final int FIXED_OVERHEAD = ClassSize.OBJECT // object
+ ClassSize.REFERENCE * 2 // fBuffer and qBuffer
+ Bytes.SIZEOF_INT * 3 // foffset, qoffset, qlength
+ Bytes.SIZEOF_BYTE; // flength
// @formatter:on
private final byte[] row;
private final byte[] fam;

Expand Down
Loading

0 comments on commit 3ae0d90

Please sign in to comment.