提交 448798ae authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix some warnings

上级 24108bee
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package org.h2.expression.function; package org.h2.expression.function;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
...@@ -233,7 +234,7 @@ public class ToChar { ...@@ -233,7 +234,7 @@ public class ToChar {
int separator = findDecimalSeparator(format); int separator = findDecimalSeparator(format);
int formatScale = calculateScale(format, separator); int formatScale = calculateScale(format, separator);
if (formatScale < number.scale()) { if (formatScale < number.scale()) {
number = number.setScale(formatScale, BigDecimal.ROUND_HALF_UP); number = number.setScale(formatScale, RoundingMode.HALF_UP);
} }
// any 9s to the left of the decimal separator but to the right of a // any 9s to the left of the decimal separator but to the right of a
...@@ -461,7 +462,7 @@ public class ToChar { ...@@ -461,7 +462,7 @@ public class ToChar {
} }
} }
int i = number.setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); int i = number.setScale(0, RoundingMode.HALF_UP).intValue();
String hex = Integer.toHexString(i); String hex = Integer.toHexString(i);
if (digits < hex.length()) { if (digits < hex.length()) {
hex = StringUtils.pad("", digits + 1, "#", true); hex = StringUtils.pad("", digits + 1, "#", true);
......
...@@ -1056,7 +1056,7 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -1056,7 +1056,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return getVersion(getRoot()); return getVersion(getRoot());
} }
private long getVersion(RootReference rootReference) { private static long getVersion(RootReference rootReference) {
RootReference previous = rootReference.previous; RootReference previous = rootReference.previous;
return previous == null || previous.root != rootReference.root || return previous == null || previous.root != rootReference.root ||
previous.appendCounter != rootReference.appendCounter ? previous.appendCounter != rootReference.appendCounter ?
......
...@@ -905,6 +905,7 @@ public class MVStore implements AutoCloseable { ...@@ -905,6 +905,7 @@ public class MVStore implements AutoCloseable {
/** /**
* Close the file and the store. Unsaved changes are written to disk first. * Close the file and the store. Unsaved changes are written to disk first.
*/ */
@Override
public void close() { public void close() {
if (closed) { if (closed) {
return; return;
......
...@@ -1236,10 +1236,12 @@ public abstract class Page implements Cloneable ...@@ -1236,10 +1236,12 @@ public abstract class Page implements Cloneable
} }
} }
@Override
public boolean isComplete() { public boolean isComplete() {
return complete; return complete;
} }
@Override
public void setComplete() { public void setComplete() {
recalculateTotalCount(); recalculateTotalCount();
complete = true; complete = true;
......
...@@ -11,6 +11,7 @@ import java.io.Reader; ...@@ -11,6 +11,7 @@ import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.sql.Date; import java.sql.Date;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
...@@ -1431,7 +1432,7 @@ public abstract class Value { ...@@ -1431,7 +1432,7 @@ public abstract class Value {
throw DbException.get( throw DbException.get(
ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_2, x.toString(), getColumnName(column)); ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_2, x.toString(), getColumnName(column));
} }
return x.setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); return x.setScale(0, RoundingMode.HALF_UP).longValue();
} }
private static String getColumnName(Object column) { private static String getColumnName(Object column) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package org.h2.value; package org.h2.value;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -95,7 +96,7 @@ public class ValueDecimal extends Value { ...@@ -95,7 +96,7 @@ public class ValueDecimal extends Value {
} }
BigDecimal bd = value.divide(dec.value, BigDecimal bd = value.divide(dec.value,
value.scale() + DIVIDE_SCALE_ADD, value.scale() + DIVIDE_SCALE_ADD,
BigDecimal.ROUND_HALF_DOWN); RoundingMode.HALF_DOWN);
if (bd.signum() == 0) { if (bd.signum() == 0) {
bd = BigDecimal.ZERO; bd = BigDecimal.ZERO;
} else if (bd.scale() > 0) { } else if (bd.scale() > 0) {
...@@ -265,7 +266,7 @@ public class ValueDecimal extends Value { ...@@ -265,7 +266,7 @@ public class ValueDecimal extends Value {
if (scale > BIG_DECIMAL_SCALE_MAX || scale < -BIG_DECIMAL_SCALE_MAX) { if (scale > BIG_DECIMAL_SCALE_MAX || scale < -BIG_DECIMAL_SCALE_MAX) {
throw DbException.getInvalidValueException("scale", scale); throw DbException.getInvalidValueException("scale", scale);
} }
return bd.setScale(scale, BigDecimal.ROUND_HALF_UP); return bd.setScale(scale, RoundingMode.HALF_UP);
} }
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package org.h2.test.bench; package org.h2.test.bench;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -214,7 +215,7 @@ public class BenchCThread { ...@@ -214,7 +215,7 @@ public class BenchCThread {
BigDecimal olAmount = new BigDecimal(olQuantity).multiply( BigDecimal olAmount = new BigDecimal(olQuantity).multiply(
price).multiply(ONE.add(wTax).add(tax)).multiply( price).multiply(ONE.add(wTax).add(tax)).multiply(
ONE.subtract(discount)); ONE.subtract(discount));
olAmount = olAmount.setScale(2, BigDecimal.ROUND_HALF_UP); olAmount = olAmount.setScale(2, RoundingMode.HALF_UP);
amt[number - 1] = olAmount; amt[number - 1] = olAmount;
total = total.add(olAmount); total = total.add(olAmount);
prep = prepare("INSERT INTO ORDER_LINE (OL_O_ID, OL_D_ID, OL_W_ID, OL_NUMBER, " prep = prepare("INSERT INTO ORDER_LINE (OL_O_ID, OL_D_ID, OL_W_ID, OL_NUMBER, "
......
...@@ -102,7 +102,7 @@ public class TestLIRSMemoryConsumption extends TestDb { ...@@ -102,7 +102,7 @@ public class TestLIRSMemoryConsumption extends TestDb {
return 2560; return 2560;
} }
private long getMemUsedKb() { private static long getMemUsedKb() {
Runtime rt = Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
long memory = Long.MAX_VALUE; long memory = Long.MAX_VALUE;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论