Skip to content

Commit f74f152

Browse files
committed
HBASE-27206 Clean up error-prone findings in hbase-common
1 parent 02f2636 commit f74f152

File tree

108 files changed

+652
-1024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+652
-1024
lines changed

hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferExtendedCell.java

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -60,53 +60,33 @@
6060
*/
6161
@InterfaceAudience.Private
6262
public abstract class ByteBufferExtendedCell implements ExtendedCell {
63-
/**
64-
* @return The {@link ByteBuffer} containing the row bytes.
65-
*/
63+
/** Return the {@link ByteBuffer} containing the row bytes. */
6664
public abstract ByteBuffer getRowByteBuffer();
6765

68-
/**
69-
* @return Position in the {@link ByteBuffer} where row bytes start
70-
*/
66+
/** Return the position in the {@link ByteBuffer} where row bytes start */
7167
public abstract int getRowPosition();
7268

73-
/**
74-
* @return The {@link ByteBuffer} containing the column family bytes.
75-
*/
69+
/** Return the {@link ByteBuffer} containing the column family bytes. */
7670
public abstract ByteBuffer getFamilyByteBuffer();
7771

78-
/**
79-
* @return Position in the {@link ByteBuffer} where column family bytes start
80-
*/
72+
/** Return the position in the {@link ByteBuffer} where column family bytes start */
8173
public abstract int getFamilyPosition();
8274

83-
/**
84-
* @return The {@link ByteBuffer} containing the column qualifier bytes.
85-
*/
75+
/** Return the {@link ByteBuffer} containing the column qualifier bytes. */
8676
public abstract ByteBuffer getQualifierByteBuffer();
8777

88-
/**
89-
* @return Position in the {@link ByteBuffer} where column qualifier bytes start
90-
*/
78+
/** Return the position in the {@link ByteBuffer} where column qualifier bytes start */
9179
public abstract int getQualifierPosition();
9280

93-
/**
94-
* @return The {@link ByteBuffer} containing the value bytes.
95-
*/
81+
/** Return the {@link ByteBuffer} containing the value bytes. */
9682
public abstract ByteBuffer getValueByteBuffer();
9783

98-
/**
99-
* @return Position in the {@link ByteBuffer} where value bytes start
100-
*/
84+
/** Return the position in the {@link ByteBuffer} where value bytes start */
10185
public abstract int getValuePosition();
10286

103-
/**
104-
* @return The {@link ByteBuffer} containing the tag bytes.
105-
*/
87+
/** Return the {@link ByteBuffer} containing the tag bytes. */
10688
public abstract ByteBuffer getTagsByteBuffer();
10789

108-
/**
109-
* @return Position in the {@link ByteBuffer} where tag bytes start
110-
*/
90+
/** Return the position in the {@link ByteBuffer} where tag bytes start */
11191
public abstract int getTagsPosition();
11292
}

hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public long heapSize() {
264264
if (this.buf.hasArray()) {
265265
return ClassSize.align(FIXED_OVERHEAD + length);
266266
}
267-
return ClassSize.align(FIXED_OVERHEAD) + this.getSerializedSize();
267+
return (long) ClassSize.align(FIXED_OVERHEAD) + this.getSerializedSize();
268268
}
269269

270270
@Override

hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ public interface Cell extends HeapSize {
6868
*/
6969
byte[] getRowArray();
7070

71-
/**
72-
* @return Array index of first row byte
73-
*/
71+
/** Return the array index of first row byte */
7472
int getRowOffset();
7573

76-
/**
77-
* @return Number of row bytes. Must be < rowArray.length - offset.
78-
*/
74+
/** Return the number of row bytes. Must be < rowArray.length - offset. */
7975
short getRowLength();
8076

8177
// 2) Family
@@ -87,14 +83,10 @@ public interface Cell extends HeapSize {
8783
*/
8884
byte[] getFamilyArray();
8985

90-
/**
91-
* @return Array index of first family byte
92-
*/
86+
/** Return the array index of first family byte */
9387
int getFamilyOffset();
9488

95-
/**
96-
* @return Number of family bytes. Must be < familyArray.length - offset.
97-
*/
89+
/** Return the number of family bytes. Must be < familyArray.length - offset. */
9890
byte getFamilyLength();
9991

10092
// 3) Qualifier
@@ -105,28 +97,24 @@ public interface Cell extends HeapSize {
10597
*/
10698
byte[] getQualifierArray();
10799

108-
/**
109-
* @return Array index of first qualifier byte
110-
*/
100+
/** Return the array index of first qualifier byte */
111101
int getQualifierOffset();
112102

113-
/**
114-
* @return Number of qualifier bytes. Must be < qualifierArray.length - offset.
115-
*/
103+
/** Return the number of qualifier bytes. Must be < qualifierArray.length - offset. */
116104
int getQualifierLength();
117105

118106
// 4) Timestamp
119107

120108
/**
121-
* @return Long value representing time at which this cell was "Put" into the row. Typically
122-
* represents the time of insertion, but can be any value from 0 to Long.MAX_VALUE.
109+
* Return a long value representing time at which this cell was "Put" into the row. Typically
110+
* represents the time of insertion, but can be any value from 0 to Long.MAX_VALUE.
123111
*/
124112
long getTimestamp();
125113

126114
// 5) Type
127115

128116
/**
129-
* @return The byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc
117+
* Return the byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc
130118
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0. Use {@link #getType()}.
131119
*/
132120
@Deprecated
@@ -154,19 +142,13 @@ public interface Cell extends HeapSize {
154142
*/
155143
byte[] getValueArray();
156144

157-
/**
158-
* @return Array index of first value byte
159-
*/
145+
/** Return the array index of first value byte */
160146
int getValueOffset();
161147

162-
/**
163-
* @return Number of value bytes. Must be < valueArray.length - offset.
164-
*/
148+
/** Return the number of value bytes. Must be < valueArray.length - offset. */
165149
int getValueLength();
166150

167-
/**
168-
* @return Serialized size (defaults to include tag length if has some tags).
169-
*/
151+
/** Return the serialized size (defaults to include tag length if has some tags). */
170152
int getSerializedSize();
171153

172154
/**
@@ -178,7 +160,7 @@ public interface Cell extends HeapSize {
178160
byte[] getTagsArray();
179161

180162
/**
181-
* @return the first offset where the tags start in the Cell
163+
* Return the first offset where the tags start in the Cell
182164
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0. Tags are are now internal.
183165
*/
184166
@Deprecated

hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ default int compareRows(byte[] leftRow, byte[] rightRow) {
9595
}
9696

9797
/**
98+
* Lexicographically compare two rows
9899
* @param row ByteBuffer that wraps a row; will read from current position and will reading all
99100
* remaining; will not disturb the ByteBuffer internal state.
100101
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
@@ -111,7 +112,7 @@ default int compareRows(ByteBuffer row, Cell cell) {
111112
}
112113

113114
/**
114-
* Lexographically compares the two cells excluding the row part. It compares family, qualifier,
115+
* Lexicographically compares the two cells excluding the row part. It compares family, qualifier,
115116
* timestamp and the type
116117
* @param leftCell the left hand side cell
117118
* @param rightCell the right hand side cell
@@ -121,7 +122,7 @@ default int compareRows(ByteBuffer row, Cell cell) {
121122
int compareWithoutRow(Cell leftCell, Cell rightCell);
122123

123124
/**
124-
* Lexographically compares the families of the two cells
125+
* Lexicographically compares the families of the two cells
125126
* @param leftCell the left hand side cell
126127
* @param rightCell the right hand side cell
127128
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
@@ -130,7 +131,7 @@ default int compareRows(ByteBuffer row, Cell cell) {
130131
int compareFamilies(Cell leftCell, Cell rightCell);
131132

132133
/**
133-
* Lexographically compares the qualifiers of the two cells
134+
* Lexicographically compares the qualifiers of the two cells
134135
* @param leftCell the left hand side cell
135136
* @param rightCell the right hand side cell
136137
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
@@ -163,10 +164,9 @@ default int compareRows(ByteBuffer row, Cell cell) {
163164
int compareTimestamps(long leftCellts, long rightCellts);
164165

165166
/**
166-
* @return A dumbed-down, fast comparator for hbase2 base-type, the {@link ByteBufferKeyValue}.
167-
* Create an instance when you make a new memstore, when you know only BBKVs will be
168-
* passed. Do not pollute with types other than BBKV if can be helped; the Comparator will
169-
* slow.
167+
* Return a dumbed-down, fast comparator for hbase2 base-type, the {@link ByteBufferKeyValue}.
168+
* Create an instance when you make a new memstore, when you know only BBKVs will be passed. Do
169+
* not pollute with types other than BBKV if can be helped; the Comparator will slow.
170170
*/
171-
Comparator getSimpleComparator();
171+
Comparator<Cell> getSimpleComparator();
172172
}

hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.hadoop.hbase;
1919

2020
import java.util.Comparator;
21-
import org.apache.hadoop.hbase.KeyValue.Type;
2221
import org.apache.hadoop.hbase.util.ByteBufferUtils;
2322
import org.apache.hadoop.hbase.util.Bytes;
2423
import org.apache.yetus.audience.InterfaceAudience;
@@ -691,11 +690,11 @@ public final int compareWithoutRow(final Cell left, final Cell right) {
691690
int rFamLength = right.getFamilyLength();
692691
int lQualLength = left.getQualifierLength();
693692
int rQualLength = right.getQualifierLength();
694-
if (lFamLength + lQualLength == 0 && left.getTypeByte() == Type.Minimum.getCode()) {
693+
if (lFamLength + lQualLength == 0 && left.getTypeByte() == KeyValue.Type.Minimum.getCode()) {
695694
// left is "bigger", i.e. it appears later in the sorted order
696695
return 1;
697696
}
698-
if (rFamLength + rQualLength == 0 && right.getTypeByte() == Type.Minimum.getCode()) {
697+
if (rFamLength + rQualLength == 0 && right.getTypeByte() == KeyValue.Type.Minimum.getCode()) {
699698
return -1;
700699
}
701700
if (lFamLength != rFamLength) {

hbase-common/src/main/java/org/apache/hadoop/hbase/CellScannable.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
*/
2727
@InterfaceAudience.Public
2828
public interface CellScannable {
29-
/**
30-
* @return A CellScanner over the contained {@link Cell}s
31-
*/
29+
/** Return a CellScanner over the contained {@link Cell}s */
3230
CellScanner cellScanner();
3331
}

hbase-common/src/main/java/org/apache/hadoop/hbase/CellScanner.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@
4747
*/
4848
@InterfaceAudience.Public
4949
public interface CellScanner {
50-
/**
51-
* @return the current Cell which may be mutable
52-
*/
50+
/** Return the current Cell, which may be mutable */
5351
Cell current();
5452

5553
/**

0 commit comments

Comments
 (0)