diff --git a/core/trino-spi/src/main/java/io/trino/spi/type/Decimals.java b/core/trino-spi/src/main/java/io/trino/spi/type/Decimals.java index c8f31874f3ba..4383a7467727 100644 --- a/core/trino-spi/src/main/java/io/trino/spi/type/Decimals.java +++ b/core/trino-spi/src/main/java/io/trino/spi/type/Decimals.java @@ -27,8 +27,8 @@ import static io.trino.spi.StandardErrorCode.NUMERIC_VALUE_OUT_OF_RANGE; import static io.trino.spi.type.DecimalType.createDecimalType; -import static io.trino.spi.type.Int128Math.POWERS_OF_TEN; import static io.trino.spi.type.Int128Math.absExact; +import static io.trino.spi.type.Int128Math.powerOfTen; import static java.lang.Math.abs; import static java.lang.Math.pow; import static java.lang.Math.round; @@ -339,6 +339,6 @@ public static boolean overflows(Int128 value, int precision) return overflows(value.getHigh(), value.getLow()); } - return absExact(value).compareTo(POWERS_OF_TEN[precision]) >= 0; + return absExact(value).compareTo(powerOfTen(precision)) >= 0; } } diff --git a/core/trino-spi/src/main/java/io/trino/spi/type/Int128Math.java b/core/trino-spi/src/main/java/io/trino/spi/type/Int128Math.java index 3f5fabf87721..dfd950489e55 100644 --- a/core/trino-spi/src/main/java/io/trino/spi/type/Int128Math.java +++ b/core/trino-spi/src/main/java/io/trino/spi/type/Int128Math.java @@ -31,7 +31,7 @@ public final class Int128Math private static final int NUMBER_OF_LONGS = 2; private static final int NUMBER_OF_INTS = 2 * NUMBER_OF_LONGS; - public static final Int128[] POWERS_OF_TEN = new Int128[38]; // 10^38 is the largest value < Int128.MAX_VALUE + private static final Int128[] POWERS_OF_TEN = new Int128[38]; // 10^38 is the largest value < Int128.MAX_VALUE private static final Int128[] POWERS_OF_FIVE = new Int128[54]; // 5^54 is the largest value < Int128.MAX_VALUE private static final long ALL_BITS_SET_64 = 0xFFFFFFFFFFFFFFFFL; @@ -98,6 +98,11 @@ public final class Int128Math } } + public static Int128 powerOfTen(int exponent) + { + return POWERS_OF_TEN[exponent]; + } + public static void rescale(long high, long low, int factor, long[] result, int offset) { if (factor == 0) { diff --git a/lib/trino-rcfile/src/main/java/io/trino/rcfile/text/TextRcFileEncoding.java b/lib/trino-rcfile/src/main/java/io/trino/rcfile/text/TextRcFileEncoding.java index c6639e62cc3e..8186ee23d366 100644 --- a/lib/trino-rcfile/src/main/java/io/trino/rcfile/text/TextRcFileEncoding.java +++ b/lib/trino-rcfile/src/main/java/io/trino/rcfile/text/TextRcFileEncoding.java @@ -20,13 +20,14 @@ import io.trino.spi.type.TimestampType; import io.trino.spi.type.Type; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class TextRcFileEncoding implements RcFileEncoding { - public static final byte[] DEFAULT_SEPARATORS = new byte[] { + private static final byte[] DEFAULT_SEPARATORS = new byte[] { 1, // Start of Heading 2, // Start of text 3, // End of Text @@ -70,7 +71,7 @@ public TextRcFileEncoding() { this( DEFAULT_NULL_SEQUENCE, - DEFAULT_SEPARATORS, + DEFAULT_SEPARATORS.clone(), null, false); } @@ -83,6 +84,11 @@ public TextRcFileEncoding(Slice nullSequence, byte[] separators, Byte escapeByte this.lastColumnTakesRest = lastColumnTakesRest; } + public static byte[] getDefaultSeparators(int nestingLevels) + { + return Arrays.copyOf(DEFAULT_SEPARATORS, nestingLevels); + } + @Override public ColumnEncoding booleanEncoding(Type type) { diff --git a/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/serializers/BooleanLexicoder.java b/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/serializers/BooleanLexicoder.java index cb9017aaf4a4..47b9d666c84a 100644 --- a/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/serializers/BooleanLexicoder.java +++ b/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/serializers/BooleanLexicoder.java @@ -21,13 +21,10 @@ public class BooleanLexicoder implements Lexicoder { - public static final byte[] TRUE = new byte[] {1}; - public static final byte[] FALSE = new byte[] {0}; - @Override public byte[] encode(Boolean v) { - return v ? TRUE : FALSE; + return new byte[] {v ? (byte) 1 : 0}; } @Override diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/rcfile/RcFilePageSourceFactory.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/rcfile/RcFilePageSourceFactory.java index 869d8855a9eb..11a933295b71 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/rcfile/RcFilePageSourceFactory.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/rcfile/RcFilePageSourceFactory.java @@ -59,7 +59,6 @@ import java.io.FileNotFoundException; import java.io.IOException; -import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.OptionalInt; @@ -76,7 +75,7 @@ import static io.trino.plugin.hive.ReaderPageSource.noProjectionAdaptation; import static io.trino.plugin.hive.util.HiveUtil.getDeserializerClassName; import static io.trino.rcfile.text.TextRcFileEncoding.DEFAULT_NULL_SEQUENCE; -import static io.trino.rcfile.text.TextRcFileEncoding.DEFAULT_SEPARATORS; +import static io.trino.rcfile.text.TextRcFileEncoding.getDefaultSeparators; import static java.lang.Math.min; import static java.lang.Math.toIntExact; import static java.lang.String.format; @@ -238,14 +237,14 @@ public static TextRcFileEncoding createTextVectorEncoding(Properties schema) else { nestingLevels = TEXT_EXTENDED_NESTING_LEVELS; } - byte[] separators = Arrays.copyOf(DEFAULT_SEPARATORS, nestingLevels); + byte[] separators = getDefaultSeparators(nestingLevels); // the first three separators are set by old-old properties - separators[0] = getByte(schema.getProperty(FIELD_DELIM, schema.getProperty(SERIALIZATION_FORMAT)), DEFAULT_SEPARATORS[0]); + separators[0] = getByte(schema.getProperty(FIELD_DELIM, schema.getProperty(SERIALIZATION_FORMAT)), separators[0]); // for map field collection delimiter, Hive 1.x uses "colelction.delim" but Hive 3.x uses "collection.delim" // https://issues.apache.org/jira/browse/HIVE-16922 - separators[1] = getByte(schema.getProperty(COLLECTION_DELIM, schema.getProperty("colelction.delim")), DEFAULT_SEPARATORS[1]); - separators[2] = getByte(schema.getProperty(MAPKEY_DELIM), DEFAULT_SEPARATORS[2]); + separators[1] = getByte(schema.getProperty(COLLECTION_DELIM, schema.getProperty("colelction.delim")), separators[1]); + separators[2] = getByte(schema.getProperty(MAPKEY_DELIM), separators[2]); // null sequence Slice nullSequence; diff --git a/pom.xml b/pom.xml index 7db03f566d99..70d432ee8eec 100644 --- a/pom.xml +++ b/pom.xml @@ -1817,14 +1817,18 @@ -Xep:BoxedPrimitiveConstructor:ERROR \ -Xep:ClassCanBeStatic:ERROR \ -Xep:CompareToZero:ERROR \ + -Xep:EqualsGetClass:OFF \ -Xep:EqualsIncompatibleType:ERROR \ -Xep:FallThrough:ERROR \ -Xep:GuardedBy:OFF \ + -Xep:ImmutableEnumChecker:OFF \ -Xep:ImmutableSetForContains:ERROR \ -Xep:InconsistentHashCode:ERROR \ -Xep:InjectOnConstructorOfAbstractClass:ERROR \ -Xep:MissingCasesInEnumSwitch:ERROR \ -Xep:MissingOverride:ERROR \ + -Xep:MutableConstantField:OFF \ + -Xep:MutablePublicArray:ERROR \ -Xep:NullOptional:ERROR \ -Xep:ObjectToString:ERROR \ -Xep:UnnecessaryMethodReference:ERROR \ diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/cli/SuiteRun.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/cli/SuiteRun.java index 05cb62341a26..3ebb80e78087 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/cli/SuiteRun.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/cli/SuiteRun.java @@ -241,7 +241,7 @@ private String formatSuiteTestRuns(List suiteTestRuns) private void printTestRunsSummary(List results) { ConsoleTable table = new ConsoleTable(); - table.addHeader(HEADER); + table.addHeader(HEADER.toArray()); results.forEach(result -> table.addRow(result.toRow())); table.addSeparator(); log.info("Suite tests results:\n%s", table.render()); @@ -350,9 +350,7 @@ private static String suiteRunId(String runId, String suiteName, SuiteTestRun su static class TestRunResult { - public static final Object[] HEADER = { - "id", "suite", "environment", "config", "options", "status", "elapsed", "error" - }; + public static final List HEADER = List.of("id", "suite", "environment", "config", "options", "status", "elapsed", "error"); private final String runId; private final SuiteTestRun suiteRun; diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentListener.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentListener.java index 5203ec0ab3e3..e79bda9f945e 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentListener.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentListener.java @@ -260,7 +260,7 @@ private StatisticsFetcher fetcher(DockerContainer container) private void printContainerStats() { ConsoleTable statistics = new ConsoleTable(); - statistics.addHeader(HEADER); + statistics.addHeader(HEADER.toArray()); fetchers.entrySet().forEach(entry -> statistics.addRow(entry.getValue().get().toRow(entry.getKey()))); statistics.addSeparator(); diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/StatisticsFetcher.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/StatisticsFetcher.java index 29f320dd94e9..6d4adc37bf04 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/StatisticsFetcher.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/StatisticsFetcher.java @@ -183,7 +183,7 @@ public void close() public static class Stats { - public static final String[] HEADER = { + public static final List HEADER = List.of( "container", "cpu", "mem", @@ -191,8 +191,7 @@ public static class Stats "mem %", "pids", "net in", - "net out" - }; + "net out"); private long systemCpuUsage = -1; private long totalCpuUsage = -1;