[style](java) format fe code with some check rules (#9460)
Issue Number: close #9403 set below rules' severity to error and format code according check info. a. Merge conflicts unresolved b. Avoid using corresponding octal or Unicode escape c. Avoid Escaped Unicode Characters d. No Line Wrap e. Package Name f. Type Name g. Annotation Location h. Interface Type Parameter i. CatchParameterName j. Pattern Variable Name k. Record Component Name l. Record Type Parameter Name m. Method Type Parameter Name n. Redundant Import o. Custom Import Order p. Unused Imports q. Avoid Star Import r. tab character in file s. Newline At End Of File t. Trailing whitespace found
This commit is contained in:
@ -42,7 +42,7 @@ public final class FeMetaVersion {
|
||||
public static final int VERSION_CURRENT = VERSION_109;
|
||||
|
||||
// all logs meta version should >= the minimum version, so that we could remove many if clause, for example
|
||||
// if (FE_METAVERSION < VERSION_94) ...
|
||||
// these clause will be useless and we could remove them
|
||||
// if (FE_METAVERSION < VERSION_94) ...
|
||||
// these clause will be useless and we could remove them
|
||||
public static final int MINIMUM_VERSION_REQUIRED = VERSION_100;
|
||||
}
|
||||
|
||||
@ -54,5 +54,3 @@ public class Codec {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ import java.io.DataInputStream;
|
||||
*
|
||||
* <p>
|
||||
* Typical usage is something like the following:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* DataInputBuffer buffer = new DataInputBuffer();
|
||||
@ -41,7 +41,7 @@ import java.io.DataInputStream;
|
||||
* ... read buffer using DataInput methods ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DataInputBuffer extends DataInputStream {
|
||||
private static class Buffer extends ByteArrayInputStream {
|
||||
|
||||
@ -34,7 +34,7 @@ import java.io.OutputStream;
|
||||
*
|
||||
* <p>
|
||||
* Typical usage is something like the following:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* DataOutputBuffer buffer = new DataOutputBuffer();
|
||||
@ -46,7 +46,7 @@ import java.io.OutputStream;
|
||||
* ... write data to its ultimate destination ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DataOutputBuffer extends DataOutputStream {
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
package org.apache.doris.common.io;
|
||||
|
||||
import org.apache.doris.meta.MetaContext;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -51,7 +52,7 @@ public class DeepCopy {
|
||||
out.close();
|
||||
|
||||
DataInputStream in = new DataInputStream(byteArrayOutputStream.getInputStream());
|
||||
|
||||
|
||||
Method readMethod = c.getDeclaredMethod(READ_FIELDS_METHOD_NAME, DataInput.class);
|
||||
readMethod.invoke(dest, in);
|
||||
in.close();
|
||||
|
||||
@ -59,7 +59,7 @@ public class IOUtils {
|
||||
|
||||
/**
|
||||
* Copies from one stream to another.
|
||||
*
|
||||
*
|
||||
* @param in
|
||||
* InputStream to read from
|
||||
* @param out
|
||||
@ -117,7 +117,7 @@ public class IOUtils {
|
||||
|
||||
/**
|
||||
* Copies from one stream to another.
|
||||
*
|
||||
*
|
||||
* @param in
|
||||
* InputStream to read from
|
||||
* @param out
|
||||
@ -155,7 +155,7 @@ public class IOUtils {
|
||||
|
||||
/**
|
||||
* Reads len bytes in a loop.
|
||||
*
|
||||
*
|
||||
* @param in
|
||||
* The InputStream to read from
|
||||
* @param buf
|
||||
@ -184,7 +184,7 @@ public class IOUtils {
|
||||
|
||||
/**
|
||||
* Similar to readFully(). Skips bytes in a loop.
|
||||
*
|
||||
*
|
||||
* @param in
|
||||
* The InputStream to skip bytes from
|
||||
* @param len
|
||||
@ -207,7 +207,7 @@ public class IOUtils {
|
||||
/**
|
||||
* Close the Closeable objects and <b>ignore</b> any {@link IOException} or
|
||||
* null pointers. Must only be used for cleanup in exception handlers.
|
||||
*
|
||||
*
|
||||
* @param log
|
||||
* the log to record problems to at debug level. Can be null.
|
||||
* @param closeables
|
||||
@ -230,7 +230,7 @@ public class IOUtils {
|
||||
/**
|
||||
* Closes the stream ignoring {@link IOException}. Must only be called in
|
||||
* cleaning up from exception handlers.
|
||||
*
|
||||
*
|
||||
* @param stream
|
||||
* the Stream to close
|
||||
*/
|
||||
@ -240,7 +240,7 @@ public class IOUtils {
|
||||
|
||||
/**
|
||||
* Closes the socket ignoring {@link IOException}
|
||||
*
|
||||
*
|
||||
* @param sock
|
||||
* the Socket to close
|
||||
*/
|
||||
|
||||
@ -30,7 +30,7 @@ import java.io.FilterInputStream;
|
||||
*
|
||||
* <p>
|
||||
* Typical usage is something like the following:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* InputBuffer buffer = new InputBuffer();
|
||||
@ -41,7 +41,7 @@ import java.io.FilterInputStream;
|
||||
* ... read buffer using InputStream methods ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @see DataInputBuffer
|
||||
* @see DataOutput
|
||||
*/
|
||||
|
||||
@ -40,7 +40,7 @@ public class LimitInputStream extends InputStream {
|
||||
|
||||
/**
|
||||
* An input stream that reads the limited bytes to the given stream.
|
||||
*
|
||||
*
|
||||
* @param in
|
||||
* The stream to be limited
|
||||
* @param limitspeed
|
||||
|
||||
@ -40,7 +40,7 @@ public class LimitOutputStream extends OutputStream {
|
||||
|
||||
/**
|
||||
* A output stream that writes the limited bytes to the given stream.
|
||||
*
|
||||
*
|
||||
* @param out
|
||||
* The stream to be limited
|
||||
* @param limitspeed
|
||||
|
||||
@ -19,8 +19,8 @@ package org.apache.doris.common.io;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FilterOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* A reusable {@link OutputStream} implementation that writes to an in-memory
|
||||
@ -32,7 +32,7 @@ import java.io.IOException;
|
||||
*
|
||||
* <p>
|
||||
* Typical usage is something like the following:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* OutputBuffer buffer = new OutputBuffer();
|
||||
@ -44,7 +44,7 @@ import java.io.IOException;
|
||||
* ... write data to its ultimate destination ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @see DataOutputBuffer
|
||||
* @see InputBuffer
|
||||
*/
|
||||
|
||||
@ -20,9 +20,9 @@ package org.apache.doris.common.io;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
@ -85,7 +85,7 @@ public class Text implements Writable {
|
||||
set(utf8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Returns the raw bytes; however, only data up to getLength() is valid.
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
@ -111,13 +111,13 @@ public class Text implements Writable {
|
||||
* Returns the Unicode Scalar Value (32-bit integer value) for the character
|
||||
* at <code>position</code>. Note that this method avoids using the
|
||||
* converter or doing String instantiation
|
||||
*
|
||||
*
|
||||
* @return the Unicode scalar value at position or -1 if the position is
|
||||
* invalid or points to a trailing byte
|
||||
*/
|
||||
public int charAt(int position) {
|
||||
if (position > this.length) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
if (position < 0) {
|
||||
return -1;
|
||||
@ -136,7 +136,7 @@ public class Text implements Writable {
|
||||
* as position <code>start</code>. The starting position is measured in
|
||||
* bytes and the return value is in terms of byte position in the buffer.
|
||||
* The backing buffer is not converted to a string for this operation.
|
||||
*
|
||||
*
|
||||
* @return byte position of the first occurence of the search string in the
|
||||
* UTF-8 buffer or -1 if not found
|
||||
*/
|
||||
@ -204,7 +204,7 @@ public class Text implements Writable {
|
||||
|
||||
/**
|
||||
* Set the Text to range of bytes
|
||||
*
|
||||
*
|
||||
* @param utf8
|
||||
* the data to copy from
|
||||
* @param start
|
||||
@ -220,7 +220,7 @@ public class Text implements Writable {
|
||||
|
||||
/**
|
||||
* Append a range of bytes to the end of the given text
|
||||
*
|
||||
*
|
||||
* @param utf8
|
||||
* the data to copy from
|
||||
* @param start
|
||||
@ -237,7 +237,7 @@ public class Text implements Writable {
|
||||
/**
|
||||
* Append a range of bytes to the end of the given text, and adjust
|
||||
* underlying buffer to reduce mem copy times
|
||||
*
|
||||
*
|
||||
* @param utf8
|
||||
* the data to copy from
|
||||
* @param start
|
||||
@ -265,9 +265,9 @@ public class Text implements Writable {
|
||||
* capacity and existing content of the buffer are unchanged. If
|
||||
* <code>len</code> is larger than the current capacity, the Text object's
|
||||
* capacity is increased to match.
|
||||
*
|
||||
*
|
||||
* @param len the number of bytes we need
|
||||
*
|
||||
*
|
||||
* @param keepData should the old data be kept
|
||||
*/
|
||||
public void setCapacity(int len, boolean keepData) {
|
||||
@ -282,7 +282,7 @@ public class Text implements Writable {
|
||||
|
||||
/**
|
||||
* Convert text back to string
|
||||
*
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
@ -336,7 +336,7 @@ public class Text implements Writable {
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
|
||||
public static String decode(byte[] utf8) throws CharacterCodingException {
|
||||
return decode(ByteBuffer.wrap(utf8), true);
|
||||
}
|
||||
@ -371,7 +371,7 @@ public class Text implements Writable {
|
||||
/**
|
||||
* Converts the provided String to bytes using the UTF-8 encoding. If the
|
||||
* input is malformed, invalid chars are replaced by a default value.
|
||||
*
|
||||
*
|
||||
* @return ByteBuffer: bytes stores at ByteBuffer.array() and length is
|
||||
* ByteBuffer.limit()
|
||||
*/
|
||||
@ -386,7 +386,7 @@ public class Text implements Writable {
|
||||
* <code>replace</code> is true, then malformed input is replaced with the
|
||||
* substitution character, which is U+FFFD. Otherwise the method throws a
|
||||
* MalformedInputException.
|
||||
*
|
||||
*
|
||||
* @return ByteBuffer: bytes stores at ByteBuffer.array() and length is
|
||||
* ByteBuffer.limit()
|
||||
*/
|
||||
@ -438,7 +438,7 @@ public class Text implements Writable {
|
||||
|
||||
/**
|
||||
* Check if a byte array contains valid utf-8
|
||||
*
|
||||
*
|
||||
* @param utf8
|
||||
* byte array
|
||||
* @throws MalformedInputException
|
||||
@ -450,7 +450,7 @@ public class Text implements Writable {
|
||||
|
||||
/**
|
||||
* Check to see if a byte array is valid utf-8
|
||||
*
|
||||
*
|
||||
* @param utf8
|
||||
* the array of bytes
|
||||
* @param start
|
||||
@ -604,7 +604,7 @@ public class Text implements Writable {
|
||||
/**
|
||||
* For the given string, returns the number of UTF-8 bytes required to
|
||||
* encode the string.
|
||||
*
|
||||
*
|
||||
* @param string
|
||||
* text to encode
|
||||
* @return number of UTF-8 bytes required to encode
|
||||
|
||||
@ -25,7 +25,7 @@ import java.io.IOException;
|
||||
* This interface requires only a uniform writable method "write()",
|
||||
* but does not require a uniform read method.
|
||||
* The usage of writable interface implementation class is as follows:
|
||||
*
|
||||
*
|
||||
* Class A implements Writable {
|
||||
* @Override
|
||||
* public void write(DataOutput out) throws IOException {
|
||||
@ -33,32 +33,32 @@ import java.io.IOException;
|
||||
* in.write(y);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* private void readFields(DataInput in) throws IOException {
|
||||
* x = in.read();
|
||||
* y = in.read();
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* public static A read(DataInput in) throws IOException {
|
||||
* A a = new A();
|
||||
* a.readFields();
|
||||
* return a;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* A a = new A();
|
||||
* a.write(out);
|
||||
* ...
|
||||
* A other = A.read(in);
|
||||
*
|
||||
*
|
||||
* The "readFields()" can be implemented as whatever you like, or even without it
|
||||
* by just implementing the static read method.
|
||||
*/
|
||||
public interface Writable {
|
||||
/**
|
||||
/**
|
||||
* Serialize the fields of this object to <code>out</code>.
|
||||
*
|
||||
*
|
||||
* @param out <code>DataOutput</code> to serialize this object into.
|
||||
* @throws IOException
|
||||
*/
|
||||
|
||||
@ -244,7 +244,7 @@ public final class FieldReflection {
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
modifiersField.setAccessible(true);
|
||||
int nonFinalModifiers = modifiersField.getInt(field) - 16;
|
||||
modifiersField.setInt(field, nonFinalModifiers);
|
||||
|
||||
@ -17,10 +17,11 @@
|
||||
|
||||
package org.apache.doris.common.property;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.doris.common.io.Text;
|
||||
import org.apache.doris.thrift.TPropertyVal;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
@ -396,4 +397,3 @@ public abstract class PropertySchema<T> {
|
||||
|
||||
public abstract void write(T val, DataOutput out) throws IOException;
|
||||
}
|
||||
|
||||
|
||||
@ -35,8 +35,8 @@ public class MetaContext {
|
||||
|
||||
public void setMetaVersion(int metaVersion) {
|
||||
if (metaVersion < FeMetaVersion.MINIMUM_VERSION_REQUIRED) {
|
||||
throw new IllegalArgumentException("Could not set meta version to "
|
||||
+ metaVersion + " since it is lower than minimum required version "
|
||||
throw new IllegalArgumentException("Could not set meta version to "
|
||||
+ metaVersion + " since it is lower than minimum required version "
|
||||
+ FeMetaVersion.MINIMUM_VERSION_REQUIRED);
|
||||
}
|
||||
this.metaVersion = metaVersion;
|
||||
@ -49,7 +49,7 @@ public class MetaContext {
|
||||
public void setThreadLocalInfo() {
|
||||
threadLocalInfo.set(this);
|
||||
}
|
||||
|
||||
|
||||
public static MetaContext get() {
|
||||
return threadLocalInfo.get();
|
||||
}
|
||||
|
||||
@ -27,8 +27,6 @@ import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class BitmapValueTest {
|
||||
|
||||
@Test
|
||||
@ -38,7 +36,7 @@ public class BitmapValueTest {
|
||||
ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
|
||||
DataOutput output = new DataOutputStream(byteArrayOutput);
|
||||
Codec.encodeVarint64(value, output);
|
||||
assertEquals(value, Codec.decodeVarint64(new DataInputStream(new ByteArrayInputStream(byteArrayOutput.toByteArray()))));
|
||||
Assert.assertEquals(value, Codec.decodeVarint64(new DataInputStream(new ByteArrayInputStream(byteArrayOutput.toByteArray()))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,9 +17,10 @@
|
||||
|
||||
package org.apache.doris.common.property;
|
||||
|
||||
import org.apache.doris.thrift.TPropertyVal;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.doris.thrift.TPropertyVal;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -33,8 +34,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class PropertiesSetTest {
|
||||
@Test
|
||||
public void testReadFromStr() {
|
||||
@ -116,7 +115,7 @@ public class PropertiesSetTest {
|
||||
public void testCheckRequiredOpts() {
|
||||
try {
|
||||
PropertiesSet.readFromStrMap(FileFormat.get(), Maps.newHashMap());
|
||||
fail("Expected an NoSuchElementException to be thrown");
|
||||
Assert.fail("Expected an NoSuchElementException to be thrown");
|
||||
} catch (NoSuchElementException e) {
|
||||
Assert.assertTrue(e.getMessage().contains("Missing"));
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
package org.apache.doris.common.property;
|
||||
|
||||
import org.apache.doris.thrift.TPropertyVal;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
|
||||
Reference in New Issue
Block a user