Skip to content

Commit 15f4c04

Browse files
authored
[hotfix] Fix some typo and format some code (alibaba#108)
1 parent c0fb32e commit 15f4c04

File tree

27 files changed

+46
-71
lines changed

27 files changed

+46
-71
lines changed

fluss-client/src/main/java/com/alibaba/fluss/client/lakehouse/paimon/PaimonBucketAssigner.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public PaimonBucketAssigner(RowType rowType, List<String> bucketKey, int bucketN
4848
this.flussRowWrapper = new FlussRowWrapper();
4949
}
5050

51-
private static int[] getBucketKeyIndex(RowType rowType, List<String> bucketKey) {
51+
private int[] getBucketKeyIndex(RowType rowType, List<String> bucketKey) {
5252
int[] bucketKeyIndex = new int[bucketKey.size()];
5353
for (int i = 0; i < bucketKey.size(); i++) {
5454
bucketKeyIndex[i] = rowType.getFieldIndex(bucketKey.get(i));

fluss-client/src/main/java/com/alibaba/fluss/client/metrics/ScannerMetricGroup.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
/** The metric group for scanner, including {@link LogScanner} and {@link SnapshotScanner}. */
3838
@Internal
3939
public class ScannerMetricGroup extends AbstractMetricGroup {
40-
private static final String name = "scanner";
40+
41+
private static final String NAME = "scanner";
4142
private static final int WINDOW_SIZE = 1024;
4243

4344
private final TablePath tablePath;
@@ -57,7 +58,7 @@ public class ScannerMetricGroup extends AbstractMetricGroup {
5758
private volatile long pollStartMs;
5859

5960
public ScannerMetricGroup(ClientMetricGroup parent, TablePath tablePath) {
60-
super(parent.getMetricRegistry(), makeScope(parent, name), parent);
61+
super(parent.getMetricRegistry(), makeScope(parent, NAME), parent);
6162
this.tablePath = tablePath;
6263

6364
fetchRequestCount = new ThreadSafeSimpleCounter();
@@ -122,7 +123,7 @@ private long lastPollSecondsAgo() {
122123

123124
@Override
124125
protected String getGroupName(CharacterFilter filter) {
125-
return name;
126+
return NAME;
126127
}
127128

128129
@Override

fluss-client/src/main/java/com/alibaba/fluss/client/scanner/log/LogFetcher.java

-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public class LogFetcher implements Closeable {
8787
private final LogRecordReadContext remoteReadContext;
8888
@Nullable private final Projection projection;
8989
private final RpcClient rpcClient;
90-
private final Configuration conf;
9190
private final int maxFetchBytes;
9291
private final int maxBucketFetchBytes;
9392
private final boolean isCheckCrcs;
@@ -121,7 +120,6 @@ public LogFetcher(
121120
this.projection = projection;
122121
this.rpcClient = rpcClient;
123122
this.logScannerStatus = logScannerStatus;
124-
this.conf = conf;
125123
this.maxFetchBytes = (int) conf.get(ConfigOptions.LOG_FETCH_MAX_BYTES).getBytes();
126124
this.maxBucketFetchBytes =
127125
(int) conf.get(ConfigOptions.LOG_FETCH_MAX_BYTES_FOR_BUCKET).getBytes();

fluss-common/src/main/java/com/alibaba/fluss/fs/FsPath.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public FsPath(String pathString) {
189189
}
190190

191191
// uri path is the rest of the string -- query & fragment not supported
192-
final String path = pathString.substring(start, pathString.length());
192+
final String path = pathString.substring(start);
193193

194194
initialize(scheme, authority, path);
195195
}

fluss-common/src/main/java/com/alibaba/fluss/fs/local/LocalFileSystem.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,9 @@ public boolean delete(final FsPath f, final boolean recursive) throws IOExceptio
134134
File[] containedFiles = file.listFiles();
135135
if (containedFiles == null) {
136136
throw new IOException(
137-
"Directory "
138-
+ file.toString()
139-
+ " does not exist or an I/O error occurred");
137+
"Directory " + file + " does not exist or an I/O error occurred");
140138
} else if (containedFiles.length != 0) {
141-
throw new IOException("Directory " + file.toString() + " is not empty");
139+
throw new IOException("Directory " + file + " is not empty");
142140
}
143141
}
144142

fluss-common/src/main/java/com/alibaba/fluss/row/BinaryString.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import javax.annotation.Nonnull;
2323
import javax.annotation.Nullable;
2424

25-
import java.io.UnsupportedEncodingException;
2625
import java.nio.charset.StandardCharsets;
2726
import java.util.Arrays;
2827

@@ -525,7 +524,7 @@ public BinaryString toUpperCase() {
525524
// fallback
526525
return javaToUpperCase();
527526
}
528-
int upper = Character.toUpperCase((int) b);
527+
int upper = Character.toUpperCase(b);
529528
if (upper > 127) {
530529
// fallback
531530
return javaToUpperCase();
@@ -559,7 +558,7 @@ public BinaryString toLowerCase() {
559558
// fallback
560559
return javaToLowerCase();
561560
}
562-
int lower = Character.toLowerCase((int) b);
561+
int lower = Character.toLowerCase(b);
563562
if (lower > 127) {
564563
// fallback
565564
return javaToLowerCase();
@@ -808,13 +807,9 @@ public static int encodeUTF8(String str, byte[] bytes) {
808807
}
809808

810809
public static int defaultEncodeUTF8(String str, byte[] bytes) {
811-
try {
812-
byte[] buffer = str.getBytes("UTF-8");
813-
System.arraycopy(buffer, 0, bytes, 0, buffer.length);
814-
return buffer.length;
815-
} catch (UnsupportedEncodingException e) {
816-
throw new RuntimeException("encodeUTF8 error", e);
817-
}
810+
byte[] buffer = str.getBytes(StandardCharsets.UTF_8);
811+
System.arraycopy(buffer, 0, bytes, 0, buffer.length);
812+
return buffer.length;
818813
}
819814

820815
public static String decodeUTF8(byte[] input, int offset, int byteLen) {

fluss-common/src/main/java/com/alibaba/fluss/utils/NetUtils.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public static Iterator<Integer> getPortRangeFromString(String rangeDefinition)
184184
int dashIdx = range.indexOf('-');
185185
if (dashIdx == -1) {
186186
// only one port in range:
187-
final int port = Integer.valueOf(range);
187+
final int port = Integer.parseInt(range);
188188
if (!isValidHostPort(port)) {
189189
throw new IllegalConfigurationException(
190190
"Invalid port configuration. Port must be between 0"
@@ -195,15 +195,15 @@ public static Iterator<Integer> getPortRangeFromString(String rangeDefinition)
195195
rangeIterator = Collections.singleton(Integer.valueOf(range)).iterator();
196196
} else {
197197
// evaluate range
198-
final int start = Integer.valueOf(range.substring(0, dashIdx));
198+
final int start = Integer.parseInt(range.substring(0, dashIdx));
199199
if (!isValidHostPort(start)) {
200200
throw new IllegalConfigurationException(
201201
"Invalid port configuration. Port must be between 0"
202202
+ "and 65535, but was "
203203
+ start
204204
+ ".");
205205
}
206-
final int end = Integer.valueOf(range.substring(dashIdx + 1, range.length()));
206+
final int end = Integer.parseInt(range.substring(dashIdx + 1));
207207
if (!isValidHostPort(end)) {
208208
throw new IllegalConfigurationException(
209209
"Invalid port configuration. Port must be between 0"

fluss-common/src/main/java/com/alibaba/fluss/utils/UnionIterator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class UnionIterator<T> implements Iterator<T>, Iterable<T> {
3535

3636
private Iterator<T> currentIterator;
3737

38-
private ArrayList<Iterator<T>> furtherIterators = new ArrayList<>();
38+
private final ArrayList<Iterator<T>> furtherIterators = new ArrayList<>();
3939

4040
private int nextIterator;
4141

fluss-common/src/test/java/com/alibaba/fluss/fs/SafetyNetCloseableRegistryTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void testReaperThreadStartFailed() throws Exception {
254254

255255
try {
256256
new SafetyNetCloseableRegistry(OutOfMemoryReaperThread::new);
257-
} catch (OutOfMemoryError error) {
257+
} catch (OutOfMemoryError ignored) {
258258
}
259259
assertThat(SafetyNetCloseableRegistry.isReaperThreadRunning()).isFalse();
260260

fluss-common/src/test/java/com/alibaba/fluss/record/LogTestBase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected void assertIndexedLogRecordBatchAndRowEquals(
8080
LogRecordReadContext readContext =
8181
LogRecordReadContext.createIndexedReadContext(rowType, TestData.DEFAULT_SCHEMA_ID);
8282
try (CloseableIterator<LogRecord> actualIter = actual.records(readContext);
83-
CloseableIterator<LogRecord> expectIter = expected.records(readContext); ) {
83+
CloseableIterator<LogRecord> expectIter = expected.records(readContext)) {
8484
int i = 0;
8585
while (actualIter.hasNext() && expectIter.hasNext()) {
8686
DefaultLogRecord actualRecord = (DefaultLogRecord) actualIter.next();

fluss-common/src/test/java/com/alibaba/fluss/row/TestInternalRowGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static CompactedRow genCompactedRowForAllType() {
126126
for (int i = 0; i < dataTypes.length; i++) {
127127
rowEncoder.encodeField(i, fieldGetters[i].getFieldOrNull(indexedRow));
128128
}
129-
return (CompactedRow) rowEncoder.finishRow();
129+
return rowEncoder.finishRow();
130130
}
131131

132132
private static void setRandomNull(

fluss-common/src/test/java/com/alibaba/fluss/row/indexed/IndexedRowTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void testProjectRow() {
160160
assertThat(row.getInt(0)).isEqualTo(1000);
161161
assertThat(row.getString(2)).isEqualTo(BinaryString.fromString("hello"));
162162

163-
IndexedRow projectRow = (IndexedRow) row.projectRow(new int[] {0, 2});
163+
IndexedRow projectRow = row.projectRow(new int[] {0, 2});
164164
assertThat(projectRow.getInt(0)).isEqualTo(1000);
165165
assertThat(projectRow.getString(1)).isEqualTo(BinaryString.fromString("hello"));
166166

fluss-common/src/test/java/com/alibaba/fluss/testutils/LogRecordBatchAssert.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public LogRecordBatchAssert isEqualTo(LogRecordBatch expected) {
8282
.isEqualTo(expected.getRecordCount());
8383
try (LogRecordReadContext readContext = createReadContext(expected.schemaId());
8484
CloseableIterator<LogRecord> actualIter = actual.records(readContext);
85-
CloseableIterator<LogRecord> expectIter = expected.records(readContext); ) {
85+
CloseableIterator<LogRecord> expectIter = expected.records(readContext)) {
8686
while (expectIter.hasNext()) {
8787
assertThat(actualIter.hasNext()).isTrue();
8888
assertThatLogRecord(actualIter.next())

fluss-common/src/test/java/com/alibaba/fluss/utils/UnionIteratorTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void testUnion() {
5050

5151
iter.clear();
5252
iter.addList(Arrays.asList(1, 2, 3, 4, 5, 6, 7));
53-
iter.addList(Collections.<Integer>emptyList());
53+
iter.addList(Collections.emptyList());
5454
iter.addList(Arrays.asList(8, 9, 10, 11));
5555

5656
int val = 1;

fluss-connectors/fluss-connector-flink/src/main/java/com/alibaba/fluss/connector/flink/source/enumerator/initializer/BucketOffsetsRetrieverImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public Map<Integer, Long> latestOffsets(
5252
@Override
5353
public Map<Integer, Long> earliestOffsets(
5454
@Nullable String partitionName, Collection<Integer> buckets) {
55-
Map<Integer, Long> bucketWithOffset = new HashMap<>();
55+
Map<Integer, Long> bucketWithOffset = new HashMap<>(buckets.size());
5656
for (Integer bucket : buckets) {
5757
bucketWithOffset.put(bucket, EARLIEST_OFFSET);
5858
}

fluss-connectors/fluss-connector-flink/src/main/java/com/alibaba/fluss/connector/flink/utils/FlinkConversions.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,7 @@ public static org.apache.flink.configuration.ConfigOption<?> toFlinkOption(
290290
option = builder.stringType().defaultValue(defaultValue);
291291
} else if (clazz.equals(MemorySize.class)) {
292292
// use string type in Flink option instead to make convert back easier
293-
option =
294-
builder.stringType()
295-
.defaultValue(((MemorySize) flussOption.defaultValue()).toString());
293+
option = builder.stringType().defaultValue(flussOption.defaultValue().toString());
296294
} else if (clazz.isEnum()) {
297295
//noinspection unchecked
298296
option =

fluss-filesystems/fluss-fs-hadoop/src/test/java/com/alibaba/fluss/fs/hdfs/HadoopDataInputStreamTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private static final class SeekableByteArrayInputStream extends InputStream
9393
implements Seekable, PositionedReadable {
9494
private final byte[] buffer;
9595
private int position;
96-
private int count;
96+
private final int count;
9797

9898
public SeekableByteArrayInputStream(byte[] buffer) {
9999
this.buffer = buffer;

fluss-lakehouse/fluss-lakehouse-paimon/src/main/java/com/alibaba/fluss/lakehouse/paimon/sink/committer/PaimonStoreMultiCommitter.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ private void putSnapshotIdAndLogStartOffset(
309309
}
310310
}
311311

312-
Long getLogStartOffset(
312+
private Long getLogStartOffset(
313313
Identifier identifier,
314314
FileStoreTable fileStoreTable,
315315
TableBucket tableBucket,
@@ -343,7 +343,7 @@ Long getLogStartOffset(
343343
return null;
344344
}
345345

346-
List<Split> getSplits(
346+
private List<Split> getSplits(
347347
Identifier identifier,
348348
long snapshotId,
349349
FileStoreTable fileStoreTable,
@@ -377,9 +377,7 @@ List<Split> getSplits(
377377
private PaimonAndFlussCommittable toCommittable(
378378
List<PaimonWrapperManifestCommittable> committables) {
379379
Map<Identifier, List<ManifestCommittable>> paimonManifestCommittable = new HashMap<>();
380-
381380
Map<Long, Map<TableBucket, Long>> flussLogEndOffsetByTableId = new HashMap<>();
382-
383381
Map<Identifier, Long> tableIdByPaimonIdentifier = new HashMap<>();
384382
Map<Long, String> partitionNameById = new HashMap<>();
385383

fluss-metrics/fluss-metrics-jmx/src/test/java/com/alibaba/fluss/metrics/jmx/JMXServerTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ public interface TestObjectMBean {
8585

8686
/** Test MBean Object. */
8787
public static class TestObject implements TestObjectMBean {
88-
private final int foo = 1;
8988

9089
@Override
9190
public int getFoo() {
92-
return foo;
91+
return 1;
9392
}
9493
}
9594
}

fluss-rpc/src/main/java/com/alibaba/fluss/rpc/metrics/ClientMetricGroup.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@
2424

2525
/** The metric group for clients. */
2626
public class ClientMetricGroup extends AbstractMetricGroup {
27-
private static final String name = "client";
27+
28+
private static final String NAME = "client";
2829

2930
private final String clientId;
3031

3132
public ClientMetricGroup(MetricRegistry registry, String clientId) {
32-
super(registry, new String[] {name}, null);
33+
super(registry, new String[] {NAME}, null);
3334
this.clientId = clientId;
3435
}
3536

3637
@Override
3738
protected String getGroupName(CharacterFilter filter) {
38-
return name;
39+
return NAME;
3940
}
4041

4142
@Override

fluss-rpc/src/main/java/com/alibaba/fluss/rpc/protocol/Errors.java

-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ public enum Errors {
175175
INVALID_CONFIG_EXCEPTION(39, "The config is invalid.", InvalidConfigException::new),
176176
LAKE_STORAGE_NOT_CONFIGURED_EXCEPTION(
177177
40, "The lake storage is not configured.", LakeStorageNotConfiguredException::new);
178-
;
179178

180179
private static final Logger LOG = LoggerFactory.getLogger(Errors.class);
181180

fluss-server/src/main/java/com/alibaba/fluss/server/kv/snapshot/RocksIncrementalSnapshot.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@ private void takeDBNativeSnapshot(@Nonnull File outputDirectory) throws Exceptio
164164
Checkpoint snapshot = Checkpoint.create(db)) {
165165
snapshot.createCheckpoint(outputDirectory.toString());
166166
} catch (Exception ex) {
167+
Exception exception = ex;
167168
try {
168169
FileUtils.deleteDirectory(outputDirectory);
169170
} catch (IOException cleanupEx) {
170-
ex = ExceptionUtils.firstOrSuppressed(cleanupEx, ex);
171+
exception = ExceptionUtils.firstOrSuppressed(cleanupEx, exception);
171172
}
172-
throw ex;
173+
throw exception;
173174
}
174175
}
175176

fluss-server/src/main/java/com/alibaba/fluss/server/kv/wal/ArrowWalBuilder.java

-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828
public class ArrowWalBuilder implements WalBuilder {
2929

3030
private final MemoryLogRecordsArrowBuilder recordsBuilder;
31-
private final AbstractPagedOutputView outputView;
3231

3332
public ArrowWalBuilder(int schemaId, ArrowWriter writer, AbstractPagedOutputView outputView) {
3433
this.recordsBuilder = MemoryLogRecordsArrowBuilder.builder(schemaId, writer, outputView);
35-
this.outputView = outputView;
3634
}
3735

3836
@Override

fluss-server/src/main/java/com/alibaba/fluss/server/metrics/group/CoordinatorMetricGroup.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@
2525
/** The metric group for coordinator server. */
2626
public class CoordinatorMetricGroup extends AbstractMetricGroup {
2727

28-
private static final String name = "coordinator";
28+
private static final String NAME = "coordinator";
2929

3030
protected final String clusterId;
3131
protected final String hostname;
3232
protected final String serverId;
3333

3434
public CoordinatorMetricGroup(
3535
MetricRegistry registry, String clusterId, String hostname, String serverId) {
36-
super(registry, new String[] {clusterId, hostname, name}, null);
36+
super(registry, new String[] {clusterId, hostname, NAME}, null);
3737
this.clusterId = clusterId;
3838
this.hostname = hostname;
3939
this.serverId = serverId;
4040
}
4141

4242
@Override
4343
protected String getGroupName(CharacterFilter filter) {
44-
return name;
44+
return NAME;
4545
}
4646

4747
@Override

fluss-server/src/main/java/com/alibaba/fluss/server/metrics/group/TabletServerMetricGroup.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/** The metric group for tablet server. */
3232
public class TabletServerMetricGroup extends AbstractMetricGroup {
3333

34-
private static final String name = "tabletserver";
34+
private static final String NAME = "tabletserver";
3535

3636
private final Map<PhysicalTablePath, PhysicalTableMetricGroup> metricGroupByPhysicalTable =
3737
new ConcurrentHashMap<>();
@@ -46,7 +46,7 @@ public class TabletServerMetricGroup extends AbstractMetricGroup {
4646

4747
public TabletServerMetricGroup(
4848
MetricRegistry registry, String clusterId, String hostname, int serverId) {
49-
super(registry, new String[] {clusterId, hostname, name}, null);
49+
super(registry, new String[] {clusterId, hostname, NAME}, null);
5050
this.clusterId = clusterId;
5151
this.hostname = hostname;
5252
this.serverId = serverId;
@@ -66,7 +66,7 @@ protected final void putVariables(Map<String, String> variables) {
6666

6767
@Override
6868
protected String getGroupName(CharacterFilter filter) {
69-
return name;
69+
return NAME;
7070
}
7171

7272
public Counter replicationBytesIn() {

0 commit comments

Comments
 (0)