Skip to content

Commit ee50d48

Browse files
authored
HBASE-23625 Reduced number of Checkstyle violations in hbase-common
Signed-off-by: Viraj Jasani <[email protected]>
1 parent 8bf4985 commit ee50d48

9 files changed

Lines changed: 107 additions & 176 deletions

File tree

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
@@ -15,14 +15,12 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
1918
package org.apache.hadoop.hbase;
2019

2120
import java.io.IOException;
2221

2322
import org.apache.hadoop.hbase.classification.InterfaceAudience;
2423
import org.apache.hadoop.hbase.classification.InterfaceStability;
25-
import org.apache.hadoop.hbase.Cell;
2624

2725
/**
2826
* An interface for iterating through a sequence of cells. Similar to Java's Iterator, but without
@@ -59,7 +57,7 @@ public interface CellScanner {
5957
/**
6058
* Advance the scanner 1 cell.
6159
* @return true if the next cell is found and {@link #current()} will return a valid Cell
62-
* @throws IOException
60+
* @throws IOException if advancing the scanner fails
6361
*/
6462
boolean advance() throws IOException;
6563
}

hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractByteRange.java

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
@InterfaceAudience.Private
6060
@InterfaceStability.Evolving
6161
public abstract class AbstractByteRange implements ByteRange {
62-
6362
public static final int UNSET_HASH_VALUE = -1;
6463

6564
// Note to maintainers: Do not make these final, as the intention is to
@@ -95,18 +94,17 @@ public byte[] getBytes() {
9594
return bytes;
9695
}
9796

98-
@Override
99-
public abstract ByteRange unset();
100-
10197
@Override
10298
public ByteRange set(int capacity) {
10399
return set(new byte[capacity]);
104100
}
105101

106102
@Override
107103
public ByteRange set(byte[] bytes) {
108-
if (null == bytes)
104+
if (null == bytes) {
109105
return unset();
106+
}
107+
110108
clearHashCache();
111109
this.bytes = bytes;
112110
this.offset = 0;
@@ -116,8 +114,10 @@ public ByteRange set(byte[] bytes) {
116114

117115
@Override
118116
public ByteRange set(byte[] bytes, int offset, int length) {
119-
if (null == bytes)
117+
if (null == bytes) {
120118
return unset();
119+
}
120+
121121
clearHashCache();
122122
this.bytes = bytes;
123123
this.offset = offset;
@@ -172,15 +172,19 @@ public byte get(int index) {
172172

173173
@Override
174174
public ByteRange get(int index, byte[] dst) {
175-
if (0 == dst.length)
175+
if (0 == dst.length) {
176176
return this;
177+
}
178+
177179
return get(index, dst, 0, dst.length);
178180
}
179181

180182
@Override
181183
public ByteRange get(int index, byte[] dst, int offset, int length) {
182-
if (0 == length)
184+
if (0 == length) {
183185
return this;
186+
}
187+
184188
System.arraycopy(this.bytes, this.offset + index, dst, offset, length);
185189
return this;
186190
}
@@ -243,27 +247,6 @@ public static int getVLongSize(long val) {
243247
return rPos + 1;
244248
}
245249

246-
@Override
247-
public abstract ByteRange put(int index, byte val);
248-
249-
@Override
250-
public abstract ByteRange put(int index, byte[] val);
251-
252-
@Override
253-
public abstract ByteRange put(int index, byte[] val, int offset, int length);
254-
255-
@Override
256-
public abstract ByteRange putInt(int index, int val);
257-
258-
@Override
259-
public abstract ByteRange putLong(int index, long val);
260-
261-
@Override
262-
public abstract ByteRange putShort(int index, short val);
263-
264-
@Override
265-
public abstract int putVLong(int index, long val);
266-
267250
//
268251
// methods for duplicating the current instance
269252
//

hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractPositionedByteRange.java

Lines changed: 7 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
*/
1818
package org.apache.hadoop.hbase.util;
1919

20-
2120
import org.apache.hadoop.hbase.classification.InterfaceAudience;
2221
import org.apache.hadoop.hbase.classification.InterfaceStability;
2322

24-
import com.google.common.annotations.VisibleForTesting;
25-
2623
/**
2724
* Extends the basic {@link SimpleByteRange} implementation with position
2825
* support. {@code position} is considered transient, not fundamental to the
@@ -48,9 +45,6 @@ public abstract class AbstractPositionedByteRange extends AbstractByteRange impl
4845

4946
protected int limit = 0;
5047

51-
@Override
52-
public abstract PositionedByteRange unset();
53-
5448
@Override
5549
public PositionedByteRange set(int capacity) {
5650
this.position = 0;
@@ -134,77 +128,24 @@ public byte get() {
134128

135129
@Override
136130
public PositionedByteRange get(byte[] dst) {
137-
if (0 == dst.length)
131+
if (0 == dst.length) {
138132
return this;
139-
return this.get(dst, 0, dst.length); // be clear we're calling self, not
140-
// super
133+
}
134+
135+
return this.get(dst, 0, dst.length); // be clear we're calling self, not super
141136
}
142137

143138
@Override
144139
public PositionedByteRange get(byte[] dst, int offset, int length) {
145-
if (0 == length)
140+
if (0 == length) {
146141
return this;
142+
}
143+
147144
super.get(this.position, dst, offset, length);
148145
this.position += length;
149146
return this;
150147
}
151148

152-
@Override
153-
public abstract PositionedByteRange put(byte val);
154-
155-
@Override
156-
public abstract PositionedByteRange put(byte[] val);
157-
158-
@Override
159-
public abstract PositionedByteRange put(byte[] val, int offset, int length);
160-
161-
@Override
162-
public abstract PositionedByteRange putInt(int index, int val);
163-
164-
@Override
165-
public abstract PositionedByteRange putLong(int index, long val);
166-
167-
@Override
168-
public abstract PositionedByteRange putShort(int index, short val);
169-
170-
@Override
171-
public abstract PositionedByteRange putInt(int val);
172-
173-
@Override
174-
public abstract PositionedByteRange putLong(long val);
175-
176-
@Override
177-
public abstract PositionedByteRange putShort(short val);
178-
179-
@Override
180-
public abstract int putVLong(int index, long val);
181-
182-
@Override
183-
public abstract int putVLong(long val);
184-
/**
185-
* Similar to {@link java.nio.ByteBuffer#flip()}. Sets length to position, position to
186-
* offset.
187-
*/
188-
@VisibleForTesting
189-
PositionedByteRange flip() {
190-
clearHashCache();
191-
length = position;
192-
position = offset;
193-
return this;
194-
}
195-
196-
/**
197-
* Similar to {@link java.nio.ByteBuffer#clear()}. Sets position to 0, length to
198-
* capacity.
199-
*/
200-
@VisibleForTesting
201-
PositionedByteRange clear() {
202-
clearHashCache();
203-
position = 0;
204-
length = bytes.length - offset;
205-
return this;
206-
}
207-
208149
// java boilerplate
209150

210151
@Override
@@ -247,24 +188,6 @@ public long getVLong() {
247188
return p;
248189
}
249190

250-
@Override
251-
public abstract PositionedByteRange put(int index, byte val);
252-
253-
@Override
254-
public abstract PositionedByteRange put(int index, byte[] val);
255-
256-
@Override
257-
public abstract PositionedByteRange put(int index, byte[] val, int offset, int length);
258-
259-
@Override
260-
public abstract PositionedByteRange deepCopy();
261-
262-
@Override
263-
public abstract PositionedByteRange shallowCopy();
264-
265-
@Override
266-
public abstract PositionedByteRange shallowCopySubRange(int innerOffset, int copyLength);
267-
268191
@Override
269192
public PositionedByteRange setLimit(int limit) {
270193
this.limit = limit;

hbase-common/src/main/java/org/apache/hadoop/hbase/util/AtomicUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
* Utilities related to atomic operations.
2626
*/
2727
@InterfaceAudience.Private
28-
public class AtomicUtils {
28+
public final class AtomicUtils {
29+
private AtomicUtils() {
30+
}
31+
2932
/**
3033
* Updates a AtomicLong which is supposed to maintain the minimum values. This method is not
3134
* synchronized but is thread-safe.
@@ -59,5 +62,4 @@ public static void updateMax(AtomicLong max, long value) {
5962
}
6063
}
6164
}
62-
6365
}

0 commit comments

Comments
 (0)