Unverified 提交 a51ece58 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #968 from katzyn/misc

Assorted changes
...@@ -8,6 +8,7 @@ package org.h2.util; ...@@ -8,6 +8,7 @@ package org.h2.util;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle; import java.lang.invoke.VarHandle;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
/** /**
...@@ -28,6 +29,46 @@ public final class Bits { ...@@ -28,6 +29,46 @@ public final class Bits {
*/ */
private static final VarHandle LONG_VH = MethodHandles.byteArrayViewVarHandle(long[].class, ByteOrder.BIG_ENDIAN); private static final VarHandle LONG_VH = MethodHandles.byteArrayViewVarHandle(long[].class, ByteOrder.BIG_ENDIAN);
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as signed.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public static int compareNotNullSigned(byte[] data1, byte[] data2) {
return Integer.signum(Arrays.compare(data1, data2));
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as unsigned.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public static int compareNotNullUnsigned(byte[] data1, byte[] data2) {
return Integer.signum(Arrays.compareUnsigned(data1, data2));
}
/** /**
* Reads a int value from the byte array at the given position in big-endian * Reads a int value from the byte array at the given position in big-endian
* order. * order.
......
...@@ -311,7 +311,7 @@ public abstract class Command implements CommandInterface { ...@@ -311,7 +311,7 @@ public abstract class Command implements CommandInterface {
errorCode != ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1) { errorCode != ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1) {
throw e; throw e;
} }
long now = System.nanoTime() / 1000000; long now = System.nanoTime() / 1_000_000;
if (start != 0 && now - start > session.getLockTimeout()) { if (start != 0 && now - start > session.getLockTimeout()) {
throw DbException.get(ErrorCode.LOCK_TIMEOUT_1, e.getCause(), ""); throw DbException.get(ErrorCode.LOCK_TIMEOUT_1, e.getCause(), "");
} }
...@@ -327,7 +327,7 @@ public abstract class Command implements CommandInterface { ...@@ -327,7 +327,7 @@ public abstract class Command implements CommandInterface {
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
// ignore // ignore
} }
long slept = System.nanoTime() / 1000000 - now; long slept = System.nanoTime() / 1_000_000 - now;
if (slept >= sleep) { if (slept >= sleep) {
break; break;
} }
......
...@@ -149,7 +149,7 @@ public abstract class Query extends Prepared { ...@@ -149,7 +149,7 @@ public abstract class Query extends Prepared {
public int getCostAsExpression() { public int getCostAsExpression() {
// ensure the cost is not larger than 1 million, // ensure the cost is not larger than 1 million,
// so that adding other values can't overflow // so that adding other values can't overflow
return (int) Math.min(1000000.0, 10.0 + 10.0 * getCost()); return (int) Math.min(1_000_000d, 10d + 10d * getCost());
} }
/** /**
......
...@@ -445,9 +445,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -445,9 +445,7 @@ public class ConnectionInfo implements Cloneable {
* @return the property keys * @return the property keys
*/ */
String[] getKeys() { String[] getKeys() {
String[] keys = new String[prop.size()]; return prop.keySet().toArray(new String[prop.size()]);
prop.keySet().toArray(keys);
return keys;
} }
/** /**
......
...@@ -246,12 +246,12 @@ public class Constants { ...@@ -246,12 +246,12 @@ public class Constants {
/** /**
* The default value for the MAX_MEMORY_UNDO setting. * The default value for the MAX_MEMORY_UNDO setting.
*/ */
public static final int DEFAULT_MAX_MEMORY_UNDO = 50000; public static final int DEFAULT_MAX_MEMORY_UNDO = 50_000;
/** /**
* The default for the setting MAX_OPERATION_MEMORY. * The default for the setting MAX_OPERATION_MEMORY.
*/ */
public static final int DEFAULT_MAX_OPERATION_MEMORY = 100000; public static final int DEFAULT_MAX_OPERATION_MEMORY = 100_000;
/** /**
* The default page size to use for new databases. * The default page size to use for new databases.
...@@ -312,7 +312,7 @@ public class Constants { ...@@ -312,7 +312,7 @@ public class Constants {
/** /**
* The highest possible parameter index. * The highest possible parameter index.
*/ */
public static final int MAX_PARAMETER_INDEX = 100000; public static final int MAX_PARAMETER_INDEX = 100_000;
/** /**
* The memory needed by a object of class Data * The memory needed by a object of class Data
...@@ -404,7 +404,7 @@ public class Constants { ...@@ -404,7 +404,7 @@ public class Constants {
/** /**
* The number of distinct values to keep in memory when running ANALYZE. * The number of distinct values to keep in memory when running ANALYZE.
*/ */
public static final int SELECTIVITY_DISTINCT_COUNT = 10000; public static final int SELECTIVITY_DISTINCT_COUNT = 10_000;
/** /**
* The default directory name of the server properties file for the H2 * The default directory name of the server properties file for the H2
...@@ -512,7 +512,7 @@ public class Constants { ...@@ -512,7 +512,7 @@ public class Constants {
* The maximum time in milliseconds to keep the cost of a view. * The maximum time in milliseconds to keep the cost of a view.
* 10000 means 10 seconds. * 10000 means 10 seconds.
*/ */
public static final int VIEW_COST_CACHE_MAX_AGE = 10000; public static final int VIEW_COST_CACHE_MAX_AGE = 10_000;
/** /**
* The name of the index cache that is used for temporary view (subqueries * The name of the index cache that is used for temporary view (subqueries
......
...@@ -1234,8 +1234,7 @@ public class Database implements DataHandler { ...@@ -1234,8 +1234,7 @@ public class Database implements DataHandler {
} }
private synchronized void closeAllSessionsException(Session except) { private synchronized void closeAllSessionsException(Session except) {
Session[] all = new Session[userSessions.size()]; Session[] all = userSessions.toArray(new Session[userSessions.size()]);
userSessions.toArray(all);
for (Session s : all) { for (Session s : all) {
if (s != except) { if (s != except) {
try { try {
......
...@@ -54,7 +54,7 @@ public class DbSettings extends SettingsBase { ...@@ -54,7 +54,7 @@ public class DbSettings extends SettingsBase {
* Database setting <code>ANALYZE_SAMPLE</code> (default: 10000).<br /> * Database setting <code>ANALYZE_SAMPLE</code> (default: 10000).<br />
* The default sample size when analyzing a table. * The default sample size when analyzing a table.
*/ */
public final int analyzeSample = get("ANALYZE_SAMPLE", 10000); public final int analyzeSample = get("ANALYZE_SAMPLE", 10_000);
/** /**
* Database setting <code>DATABASE_TO_UPPER</code> (default: true).<br /> * Database setting <code>DATABASE_TO_UPPER</code> (default: true).<br />
...@@ -144,7 +144,7 @@ public class DbSettings extends SettingsBase { ...@@ -144,7 +144,7 @@ public class DbSettings extends SettingsBase {
* times out. After the timeout, the LOB is no longer accessible using this * times out. After the timeout, the LOB is no longer accessible using this
* reference. * reference.
*/ */
public final int lobTimeout = get("LOB_TIMEOUT", 300000); public final int lobTimeout = get("LOB_TIMEOUT", 300_000);
/** /**
* Database setting <code>MAX_COMPACT_COUNT</code> * Database setting <code>MAX_COMPACT_COUNT</code>
......
...@@ -352,9 +352,7 @@ public class Session extends SessionWithState { ...@@ -352,9 +352,7 @@ public class Session extends SessionWithState {
if (variables == null) { if (variables == null) {
return new String[0]; return new String[0];
} }
String[] list = new String[variables.size()]; return variables.keySet().toArray(new String[variables.size()]);
variables.keySet().toArray(list);
return list;
} }
/** /**
...@@ -835,8 +833,7 @@ public class Session extends SessionWithState { ...@@ -835,8 +833,7 @@ public class Session extends SessionWithState {
} }
} }
if (savepoints != null) { if (savepoints != null) {
String[] names = new String[savepoints.size()]; String[] names = savepoints.keySet().toArray(new String[savepoints.size()]);
savepoints.keySet().toArray(names);
for (String name : names) { for (String name : names) {
Savepoint sp = savepoints.get(name); Savepoint sp = savepoints.get(name);
int savepointIndex = sp.logIndex; int savepointIndex = sp.logIndex;
......
...@@ -129,7 +129,7 @@ public class SysProperties { ...@@ -129,7 +129,7 @@ public class SysProperties {
* been set for the database. * been set for the database.
*/ */
public static final int COLLATOR_CACHE_SIZE = public static final int COLLATOR_CACHE_SIZE =
Utils.getProperty("h2.collatorCacheSize", 32000); Utils.getProperty("h2.collatorCacheSize", 32_000);
/** /**
* System property <code>h2.consoleTableIndexes</code> * System property <code>h2.consoleTableIndexes</code>
...@@ -260,7 +260,7 @@ public class SysProperties { ...@@ -260,7 +260,7 @@ public class SysProperties {
* The default maximum number of rows to be kept in memory in a result set. * The default maximum number of rows to be kept in memory in a result set.
*/ */
public static final int MAX_MEMORY_ROWS = public static final int MAX_MEMORY_ROWS =
getAutoScaledForMemoryProperty("h2.maxMemoryRows", 40000); getAutoScaledForMemoryProperty("h2.maxMemoryRows", 40_000);
/** /**
* System property <code>h2.maxTraceDataLength</code> * System property <code>h2.maxTraceDataLength</code>
......
...@@ -259,7 +259,7 @@ class AggregateDataMedian extends AggregateData { ...@@ -259,7 +259,7 @@ class AggregateDataMedian extends AggregateData {
nanos += DateTimeUtils.NANOS_PER_DAY / 2; nanos += DateTimeUtils.NANOS_PER_DAY / 2;
} }
if ((offset & 1) != 0) { if ((offset & 1) != 0) {
nanos += 30L * 1000000000; nanos += 30_000_000_000L;
} }
if (nanos >= DateTimeUtils.NANOS_PER_DAY) { if (nanos >= DateTimeUtils.NANOS_PER_DAY) {
nanos -= DateTimeUtils.NANOS_PER_DAY; nanos -= DateTimeUtils.NANOS_PER_DAY;
......
...@@ -2234,10 +2234,10 @@ public class Function extends Expression implements FunctionCall { ...@@ -2234,10 +2234,10 @@ public class Function extends Expression implements FunctionCall {
} }
private static double roundMagic(double d) { private static double roundMagic(double d) {
if ((d < 0.0000000000001) && (d > -0.0000000000001)) { if ((d < 0.000_000_000_000_1) && (d > -0.000_000_000_000_1)) {
return 0.0; return 0.0;
} }
if ((d > 1000000000000.) || (d < -1000000000000.)) { if ((d > 1_000_000_000_000d) || (d < -1_000_000_000_000d)) {
return d; return d;
} }
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
......
...@@ -155,8 +155,7 @@ public class IndexCondition { ...@@ -155,8 +155,7 @@ public class IndexCondition {
v = column.convert(v); v = column.convert(v);
valueSet.add(v); valueSet.add(v);
} }
Value[] array = new Value[valueSet.size()]; Value[] array = valueSet.toArray(new Value[valueSet.size()]);
valueSet.toArray(array);
final CompareMode mode = session.getDatabase().getCompareMode(); final CompareMode mode = session.getDatabase().getCompareMode();
Arrays.sort(array, new Comparator<Value>() { Arrays.sort(array, new Comparator<Value>() {
@Override @Override
......
...@@ -143,7 +143,7 @@ public class PageDataIndex extends PageIndex { ...@@ -143,7 +143,7 @@ public class PageDataIndex extends PageIndex {
if (add == 0) { if (add == 0) {
// in the first re-try add a small random number, // in the first re-try add a small random number,
// to avoid collisions after a re-start // to avoid collisions after a re-start
row.setKey((long) (row.getKey() + Math.random() * 10000)); row.setKey((long) (row.getKey() + Math.random() * 10_000));
} else { } else {
row.setKey(row.getKey() + add); row.setKey(row.getKey() + add);
} }
......
...@@ -314,7 +314,7 @@ public class FileStore { ...@@ -314,7 +314,7 @@ public class FileStore {
* @return the retention time * @return the retention time
*/ */
public int getDefaultRetentionTime() { public int getDefaultRetentionTime() {
return 45000; return 45_000;
} }
/** /**
......
...@@ -141,7 +141,7 @@ public final class MVStore { ...@@ -141,7 +141,7 @@ public final class MVStore {
* Used to mark a chunk as free, when it was detected that live bookkeeping * Used to mark a chunk as free, when it was detected that live bookkeeping
* is incorrect. * is incorrect.
*/ */
private static final int MARKED_FREE = 10000000; private static final int MARKED_FREE = 10_000_000;
/** /**
* The background thread, if any. * The background thread, if any.
......
...@@ -1479,7 +1479,7 @@ public class ObjectDataType implements DataType { ...@@ -1479,7 +1479,7 @@ public class ObjectDataType implements DataType {
*/ */
static class SerializedObjectType extends AutoDetectDataType { static class SerializedObjectType extends AutoDetectDataType {
private int averageSize = 10000; private int averageSize = 10_000;
SerializedObjectType(ObjectDataType base) { SerializedObjectType(ObjectDataType base) {
super(base, TYPE_SERIALIZED_OBJECT); super(base, TYPE_SERIALIZED_OBJECT);
......
...@@ -1775,7 +1775,7 @@ public class WebApp { ...@@ -1775,7 +1775,7 @@ public class WebApp {
String d = rs.getString(columnIndex); String d = rs.getString(columnIndex);
if (d == null) { if (d == null) {
return "<i>null</i>"; return "<i>null</i>";
} else if (d.length() > 100000) { } else if (d.length() > 100_000) {
String s; String s;
if (isBinary(rs.getMetaData().getColumnType(columnIndex))) { if (isBinary(rs.getMetaData().getColumnType(columnIndex))) {
s = PageParser.escapeHtml(d.substring(0, 6)) + s = PageParser.escapeHtml(d.substring(0, 6)) +
......
...@@ -491,8 +491,8 @@ public class Data { ...@@ -491,8 +491,8 @@ public class Data {
writeByte((byte) LOCAL_TIME); writeByte((byte) LOCAL_TIME);
ValueTime t = (ValueTime) v; ValueTime t = (ValueTime) v;
long nanos = t.getNanos(); long nanos = t.getNanos();
long millis = nanos / 1000000; long millis = nanos / 1_000_000;
nanos -= millis * 1000000; nanos -= millis * 1_000_000;
writeVarLong(millis); writeVarLong(millis);
writeVarLong(nanos); writeVarLong(nanos);
} else { } else {
...@@ -519,15 +519,15 @@ public class Data { ...@@ -519,15 +519,15 @@ public class Data {
long dateValue = ts.getDateValue(); long dateValue = ts.getDateValue();
writeVarLong(dateValue); writeVarLong(dateValue);
long nanos = ts.getTimeNanos(); long nanos = ts.getTimeNanos();
long millis = nanos / 1000000; long millis = nanos / 1_000_000;
nanos -= millis * 1000000; nanos -= millis * 1_000_000;
writeVarLong(millis); writeVarLong(millis);
writeVarLong(nanos); writeVarLong(nanos);
} else { } else {
Timestamp ts = v.getTimestamp(); Timestamp ts = v.getTimestamp();
writeByte((byte) type); writeByte((byte) type);
writeVarLong(DateTimeUtils.getTimeLocalWithoutDst(ts)); writeVarLong(DateTimeUtils.getTimeLocalWithoutDst(ts));
writeVarInt(ts.getNanos() % 1000000); writeVarInt(ts.getNanos() % 1_000_000);
} }
break; break;
} }
...@@ -758,7 +758,7 @@ public class Data { ...@@ -758,7 +758,7 @@ public class Data {
return ValueDate.fromMillis(DateTimeUtils.getTimeUTCWithoutDst(x)); return ValueDate.fromMillis(DateTimeUtils.getTimeUTCWithoutDst(x));
} }
case LOCAL_TIME: { case LOCAL_TIME: {
long nanos = readVarLong() * 1000000 + readVarLong(); long nanos = readVarLong() * 1_000_000 + readVarLong();
return ValueTime.fromNanos(nanos); return ValueTime.fromNanos(nanos);
} }
case Value.TIME: case Value.TIME:
...@@ -767,7 +767,7 @@ public class Data { ...@@ -767,7 +767,7 @@ public class Data {
DateTimeUtils.getTimeUTCWithoutDst(readVarLong())); DateTimeUtils.getTimeUTCWithoutDst(readVarLong()));
case LOCAL_TIMESTAMP: { case LOCAL_TIMESTAMP: {
long dateValue = readVarLong(); long dateValue = readVarLong();
long nanos = readVarLong() * 1000000 + readVarLong(); long nanos = readVarLong() * 1_000_000 + readVarLong();
return ValueTimestamp.fromDateValueAndNanos(dateValue, nanos); return ValueTimestamp.fromDateValueAndNanos(dateValue, nanos);
} }
case Value.TIMESTAMP: { case Value.TIMESTAMP: {
...@@ -1003,8 +1003,8 @@ public class Data { ...@@ -1003,8 +1003,8 @@ public class Data {
case Value.TIME: case Value.TIME:
if (STORE_LOCAL_TIME) { if (STORE_LOCAL_TIME) {
long nanos = ((ValueTime) v).getNanos(); long nanos = ((ValueTime) v).getNanos();
long millis = nanos / 1000000; long millis = nanos / 1_000_000;
nanos -= millis * 1000000; nanos -= millis * 1_000_000;
return 1 + getVarLongLen(millis) + getVarLongLen(nanos); return 1 + getVarLongLen(millis) + getVarLongLen(nanos);
} }
return 1 + getVarLongLen(DateTimeUtils.getTimeLocalWithoutDst(v.getTime())); return 1 + getVarLongLen(DateTimeUtils.getTimeLocalWithoutDst(v.getTime()));
...@@ -1021,14 +1021,14 @@ public class Data { ...@@ -1021,14 +1021,14 @@ public class Data {
ValueTimestamp ts = (ValueTimestamp) v; ValueTimestamp ts = (ValueTimestamp) v;
long dateValue = ts.getDateValue(); long dateValue = ts.getDateValue();
long nanos = ts.getTimeNanos(); long nanos = ts.getTimeNanos();
long millis = nanos / 1000000; long millis = nanos / 1_000_000;
nanos -= millis * 1000000; nanos -= millis * 1_000_000;
return 1 + getVarLongLen(dateValue) + getVarLongLen(millis) + return 1 + getVarLongLen(dateValue) + getVarLongLen(millis) +
getVarLongLen(nanos); getVarLongLen(nanos);
} }
Timestamp ts = v.getTimestamp(); Timestamp ts = v.getTimestamp();
return 1 + getVarLongLen(DateTimeUtils.getTimeLocalWithoutDst(ts)) + return 1 + getVarLongLen(DateTimeUtils.getTimeLocalWithoutDst(ts)) +
getVarIntLen(ts.getNanos() % 1000000); getVarIntLen(ts.getNanos() % 1_000_000);
} }
case Value.TIMESTAMP_TZ: { case Value.TIMESTAMP_TZ: {
ValueTimestampTimeZone ts = (ValueTimestampTimeZone) v; ValueTimestampTimeZone ts = (ValueTimestampTimeZone) v;
......
...@@ -78,7 +78,7 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -78,7 +78,7 @@ public class LobStorageBackend implements LobStorageInterface {
/** /**
* The size of the chunks we use when storing LOBs inside the database file. * The size of the chunks we use when storing LOBs inside the database file.
*/ */
private static final int BLOCK_LENGTH = 20000; private static final int BLOCK_LENGTH = 20_000;
/** /**
* The size of cache for lob block hashes. Each entry needs 2 longs (16 * The size of cache for lob block hashes. Each entry needs 2 longs (16
......
...@@ -44,7 +44,7 @@ public class FilePathNioMapped extends FilePathNio { ...@@ -44,7 +44,7 @@ public class FilePathNioMapped extends FilePathNio {
*/ */
class FileNioMapped extends FileBase { class FileNioMapped extends FileBase {
private static final long GC_TIMEOUT_MS = 10000; private static final long GC_TIMEOUT_MS = 10_000;
private final String name; private final String name;
private final MapMode mode; private final MapMode mode;
private RandomAccessFile file; private RandomAccessFile file;
......
...@@ -47,7 +47,7 @@ public class TableLink extends Table { ...@@ -47,7 +47,7 @@ public class TableLink extends Table {
private static final int MAX_RETRY = 2; private static final int MAX_RETRY = 2;
private static final long ROW_COUNT_APPROXIMATION = 100000; private static final long ROW_COUNT_APPROXIMATION = 100_000;
private final String originalSchema; private final String originalSchema;
private String driver, url, user, password, originalTable, qualifiedTableName; private String driver, url, user, password, originalTable, qualifiedTableName;
......
...@@ -181,13 +181,13 @@ public class CompressTool { ...@@ -181,13 +181,13 @@ public class CompressTool {
buff[pos++] = (byte) (0x80 | (x >> 8)); buff[pos++] = (byte) (0x80 | (x >> 8));
buff[pos] = (byte) x; buff[pos] = (byte) x;
return 2; return 2;
} else if (x < 0x200000) { } else if (x < 0x20_0000) {
buff[pos++] = (byte) (0xc0 | (x >> 16)); buff[pos++] = (byte) (0xc0 | (x >> 16));
buff[pos++] = (byte) (x >> 8); buff[pos++] = (byte) (x >> 8);
buff[pos] = (byte) x; buff[pos] = (byte) x;
return 3; return 3;
} else if (x < 0x10000000) { } else if (x < 0x1000_0000) {
Bits.writeInt(buff, pos, x | 0xe0000000); Bits.writeInt(buff, pos, x | 0xe000_0000);
return 4; return 4;
} else { } else {
buff[pos++] = (byte) 0xf0; buff[pos++] = (byte) 0xf0;
...@@ -210,9 +210,9 @@ public class CompressTool { ...@@ -210,9 +210,9 @@ public class CompressTool {
return 1; return 1;
} else if (x < 0x4000) { } else if (x < 0x4000) {
return 2; return 2;
} else if (x < 0x200000) { } else if (x < 0x20_0000) {
return 3; return 3;
} else if (x < 0x10000000) { } else if (x < 0x1000_0000) {
return 4; return 4;
} else { } else {
return 5; return 5;
......
...@@ -20,6 +20,68 @@ public final class Bits { ...@@ -20,6 +20,68 @@ public final class Bits {
* h2/src/java9/precompiled/org/h2/util/Bits.class. * h2/src/java9/precompiled/org/h2/util/Bits.class.
*/ */
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as signed.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public static int compareNotNullSigned(byte[] data1, byte[] data2) {
if (data1 == data2) {
return 0;
}
int len = Math.min(data1.length, data2.length);
for (int i = 0; i < len; i++) {
byte b = data1[i];
byte b2 = data2[i];
if (b != b2) {
return b > b2 ? 1 : -1;
}
}
return Integer.signum(data1.length - data2.length);
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as unsigned.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public static int compareNotNullUnsigned(byte[] data1, byte[] data2) {
if (data1 == data2) {
return 0;
}
int len = Math.min(data1.length, data2.length);
for (int i = 0; i < len; i++) {
int b = data1[i] & 0xff;
int b2 = data2[i] & 0xff;
if (b != b2) {
return b > b2 ? 1 : -1;
}
}
return Integer.signum(data1.length - data2.length);
}
/** /**
* Reads a int value from the byte array at the given position in big-endian * Reads a int value from the byte array at the given position in big-endian
* order. * order.
......
...@@ -50,7 +50,7 @@ public class DateTimeUtils { ...@@ -50,7 +50,7 @@ public class DateTimeUtils {
/** /**
* The number of nanoseconds per day. * The number of nanoseconds per day.
*/ */
public static final long NANOS_PER_DAY = MILLIS_PER_DAY * 1000000; public static final long NANOS_PER_DAY = MILLIS_PER_DAY * 1_000_000;
private static final int SHIFT_YEAR = 9; private static final int SHIFT_YEAR = 9;
private static final int SHIFT_MONTH = 5; private static final int SHIFT_MONTH = 5;
...@@ -229,10 +229,10 @@ public class DateTimeUtils { ...@@ -229,10 +229,10 @@ public class DateTimeUtils {
cal.clear(); cal.clear();
cal.setLenient(true); cal.setLenient(true);
long nanos = t.getNanos(); long nanos = t.getNanos();
long millis = nanos / 1000000; long millis = nanos / 1_000_000;
nanos -= millis * 1000000; nanos -= millis * 1_000_000;
long s = millis / 1000; long s = millis / 1_000;
millis -= s * 1000; millis -= s * 1_000;
long m = s / 60; long m = s / 60;
s -= m * 60; s -= m * 60;
long h = m / 60; long h = m / 60;
...@@ -257,10 +257,10 @@ public class DateTimeUtils { ...@@ -257,10 +257,10 @@ public class DateTimeUtils {
cal.setLenient(true); cal.setLenient(true);
long dateValue = ts.getDateValue(); long dateValue = ts.getDateValue();
long nanos = ts.getTimeNanos(); long nanos = ts.getTimeNanos();
long millis = nanos / 1000000; long millis = nanos / 1_000_000;
nanos -= millis * 1000000; nanos -= millis * 1_000_000;
long s = millis / 1000; long s = millis / 1_000;
millis -= s * 1000; millis -= s * 1_000;
long m = s / 60; long m = s / 60;
s -= m * 60; s -= m * 60;
long h = m / 60; long h = m / 60;
...@@ -269,7 +269,7 @@ public class DateTimeUtils { ...@@ -269,7 +269,7 @@ public class DateTimeUtils {
monthFromDateValue(dateValue), dayFromDateValue(dateValue), monthFromDateValue(dateValue), dayFromDateValue(dateValue),
(int) h, (int) m, (int) s, (int) millis); (int) h, (int) m, (int) s, (int) millis);
Timestamp x = new Timestamp(ms); Timestamp x = new Timestamp(ms);
x.setNanos((int) (nanos + millis * 1000000)); x.setNanos((int) (nanos + millis * 1_000_000));
return x; return x;
} }
...@@ -323,7 +323,7 @@ public class DateTimeUtils { ...@@ -323,7 +323,7 @@ public class DateTimeUtils {
cal.setTimeInMillis(x.getTime()); cal.setTimeInMillis(x.getTime());
long dateValue = dateValueFromCalendar(cal); long dateValue = dateValueFromCalendar(cal);
long nanos = nanosFromCalendar(cal); long nanos = nanosFromCalendar(cal);
nanos += x.getNanos() % 1000000; nanos += x.getNanos() % 1_000_000;
return ValueTimestamp.fromDateValueAndNanos(dateValue, nanos); return ValueTimestamp.fromDateValueAndNanos(dateValue, nanos);
} }
...@@ -408,14 +408,14 @@ public class DateTimeUtils { ...@@ -408,14 +408,14 @@ public class DateTimeUtils {
String n = (s.substring(s3 + 1, end) + "000000000").substring(0, 9); String n = (s.substring(s3 + 1, end) + "000000000").substring(0, 9);
nanos = Integer.parseInt(n); nanos = Integer.parseInt(n);
} }
if (hour >= 2000000 || minute < 0 || minute >= 60 || second < 0 if (hour >= 2_000_000 || minute < 0 || minute >= 60 || second < 0
|| second >= 60) { || second >= 60) {
throw new IllegalArgumentException(s); throw new IllegalArgumentException(s);
} }
if (timeOfDay && hour >= 24) { if (timeOfDay && hour >= 24) {
throw new IllegalArgumentException(s); throw new IllegalArgumentException(s);
} }
nanos += ((((hour * 60L) + minute) * 60) + second) * 1000000000; nanos += ((((hour * 60L) + minute) * 60) + second) * 1_000_000_000;
return negative ? -nanos : nanos; return negative ? -nanos : nanos;
} }
...@@ -507,13 +507,13 @@ public class DateTimeUtils { ...@@ -507,13 +507,13 @@ public class DateTimeUtils {
if (tz != null) { if (tz != null) {
if (withTimeZone) { if (withTimeZone) {
if (tz != UTC) { if (tz != UTC) {
long millis = convertDateTimeValueToMillis(tz, dateValue, nanos / 1000000); long millis = convertDateTimeValueToMillis(tz, dateValue, nanos / 1_000_000);
tzMinutes = (short) (tz.getOffset(millis) / 1000 / 60); tzMinutes = (short) (tz.getOffset(millis) / 1000 / 60);
} }
} else { } else {
long millis = convertDateTimeValueToMillis(tz, dateValue, nanos / 1000000); long millis = convertDateTimeValueToMillis(tz, dateValue, nanos / 1_000_000);
dateValue = dateValueFromDate(millis); dateValue = dateValueFromDate(millis);
nanos = nanos % 1000000 + nanosFromDate(millis); nanos = nanos % 1_000_000 + nanosFromDate(millis);
} }
} }
} }
...@@ -1031,9 +1031,9 @@ public class DateTimeUtils { ...@@ -1031,9 +1031,9 @@ public class DateTimeUtils {
* @return the time * @return the time
*/ */
public static Time convertNanoToTime(long nanosSinceMidnight) { public static Time convertNanoToTime(long nanosSinceMidnight) {
long millis = nanosSinceMidnight / 1000000; long millis = nanosSinceMidnight / 1_000_000;
long s = millis / 1000; long s = millis / 1_000;
millis -= s * 1000; millis -= s * 1_000;
long m = s / 60; long m = s / 60;
s -= m * 60; s -= m * 60;
long h = m / 60; long h = m / 60;
...@@ -1246,7 +1246,7 @@ public class DateTimeUtils { ...@@ -1246,7 +1246,7 @@ public class DateTimeUtils {
y--; y--;
m += 12; m += 12;
} }
long a = ((y * 2922L) >> 3) + DAYS_OFFSET[m - 3] + d - 719484; long a = ((y * 2922L) >> 3) + DAYS_OFFSET[m - 3] + d - 719_484;
if (y <= 1582 && ((y < 1582) || (m * 100 + d < 1015))) { if (y <= 1582 && ((y < 1582) || (m * 100 + d < 1015))) {
// Julian calendar (cutover at 1582-10-04 / 1582-10-15) // Julian calendar (cutover at 1582-10-04 / 1582-10-15)
a += 13; a += 13;
...@@ -1272,7 +1272,7 @@ public class DateTimeUtils { ...@@ -1272,7 +1272,7 @@ public class DateTimeUtils {
y--; y--;
m += 12; m += 12;
} }
long a = ((y * 2922L) >> 3) + DAYS_OFFSET[m - 3] + d - 719484; long a = ((y * 2922L) >> 3) + DAYS_OFFSET[m - 3] + d - 719_484;
if (y < 1901 || y > 2099) { if (y < 1901 || y > 2099) {
// Slow mode // Slow mode
a += (y / 400) - (y / 100) + 15; a += (y / 400) - (y / 100) + 15;
...@@ -1287,19 +1287,19 @@ public class DateTimeUtils { ...@@ -1287,19 +1287,19 @@ public class DateTimeUtils {
* @return the date value * @return the date value
*/ */
public static long dateValueFromAbsoluteDay(long absoluteDay) { public static long dateValueFromAbsoluteDay(long absoluteDay) {
long d = absoluteDay + 719468; long d = absoluteDay + 719_468;
long y100 = 0, offset; long y100 = 0, offset;
if (d > 578040) { if (d > 578_040) {
// Gregorian calendar // Gregorian calendar
long y400 = d / 146097; long y400 = d / 146_097;
d -= y400 * 146097; d -= y400 * 146_097;
y100 = d / 36524; y100 = d / 36_524;
d -= y100 * 36524; d -= y100 * 36_524;
offset = y400 * 400 + y100 * 100; offset = y400 * 400 + y100 * 100;
} else { } else {
// Julian calendar // Julian calendar
d += 292200000002L; d += 292_200_000_002L;
offset = -800000000; offset = -800_000_000;
} }
long y4 = d / 1461; long y4 = d / 1461;
d -= y4 * 1461; d -= y4 * 1461;
...@@ -1330,7 +1330,7 @@ public class DateTimeUtils { ...@@ -1330,7 +1330,7 @@ public class DateTimeUtils {
int y = yearFromDateValue(dateValue); int y = yearFromDateValue(dateValue);
int m = monthFromDateValue(dateValue); int m = monthFromDateValue(dateValue);
int d = dayFromDateValue(dateValue); int d = dayFromDateValue(dateValue);
if (y > 0 && y < 10000) { if (y > 0 && y < 10_000) {
StringUtils.appendZeroPadded(buff, 4, y); StringUtils.appendZeroPadded(buff, 4, y);
} else { } else {
buff.append(y); buff.append(y);
...@@ -1358,10 +1358,10 @@ public class DateTimeUtils { ...@@ -1358,10 +1358,10 @@ public class DateTimeUtils {
* get correct result. The simplest way to do this with such constraints is to * get correct result. The simplest way to do this with such constraints is to
* divide -nanos by -1000000. * divide -nanos by -1000000.
*/ */
long ms = -nanos / -1000000; long ms = -nanos / -1_000_000;
nanos -= ms * 1000000; nanos -= ms * 1_000_000;
long s = ms / 1000; long s = ms / 1_000;
ms -= s * 1000; ms -= s * 1_000;
long m = s / 60; long m = s / 60;
s -= m * 60; s -= m * 60;
long h = m / 60; long h = m / 60;
......
...@@ -224,7 +224,7 @@ public class MathUtils { ...@@ -224,7 +224,7 @@ public class MathUtils {
public static int nextPowerOf2(int x) throws IllegalArgumentException { public static int nextPowerOf2(int x) throws IllegalArgumentException {
if (x == 0) { if (x == 0) {
return 1; return 1;
} else if (x < 0 || x > 0x40000000 ) { } else if (x < 0 || x > 0x4000_0000 ) {
throw new IllegalArgumentException("Argument out of range" throw new IllegalArgumentException("Argument out of range"
+ " [0x0-0x40000000]. Argument was: " + x); + " [0x0-0x40000000]. Argument was: " + x);
} }
......
...@@ -44,7 +44,7 @@ public class ThreadDeadlockDetector { ...@@ -44,7 +44,7 @@ public class ThreadDeadlockDetector {
public void run() { public void run() {
checkForDeadlocks(); checkForDeadlocks();
} }
}, 10, 10000); }, 10, 10_000);
} }
/** /**
......
...@@ -126,8 +126,8 @@ public class ToDateParser { ...@@ -126,8 +126,8 @@ public class ToDateParser {
if (timeZone == null) { if (timeZone == null) {
timeZone = TimeZone.getDefault(); timeZone = TimeZone.getDefault();
} }
long millis = DateTimeUtils.convertDateTimeValueToMillis(timeZone, dateValue, nanos / 1000000); long millis = DateTimeUtils.convertDateTimeValueToMillis(timeZone, dateValue, nanos / 1_000_000);
offset = (short) (timeZone.getOffset(millis) / 1000 / 60); offset = (short) (timeZone.getOffset(millis) / 60_000);
} }
return ValueTimestampTimeZone.fromDateValueAndNanos(dateValue, ts.getTimeNanos(), offset); return ValueTimestampTimeZone.fromDateValueAndNanos(dateValue, ts.getTimeNanos(), offset);
} }
......
...@@ -138,60 +138,6 @@ public class Utils { ...@@ -138,60 +138,6 @@ public class Utils {
return bits == 0; return bits == 0;
} }
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the
* content or length of the second array is smaller than the first array, 1
* is returned. If the contents and lengths are the same, 0 is returned.
* <p>
* This method interprets bytes as signed.
*
* @param data1 the first byte array (must not be null)
* @param data2 the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public static int compareNotNullSigned(byte[] data1, byte[] data2) {
if (data1 == data2) {
return 0;
}
int len = Math.min(data1.length, data2.length);
for (int i = 0; i < len; i++) {
byte b = data1[i];
byte b2 = data2[i];
if (b != b2) {
return b > b2 ? 1 : -1;
}
}
return Integer.signum(data1.length - data2.length);
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the
* content or length of the second array is smaller than the first array, 1
* is returned. If the contents and lengths are the same, 0 is returned.
* <p>
* This method interprets bytes as unsigned.
*
* @param data1 the first byte array (must not be null)
* @param data2 the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public static int compareNotNullUnsigned(byte[] data1, byte[] data2) {
if (data1 == data2) {
return 0;
}
int len = Math.min(data1.length, data2.length);
for (int i = 0; i < len; i++) {
int b = data1[i] & 0xff;
int b2 = data2[i] & 0xff;
if (b != b2) {
return b > b2 ? 1 : -1;
}
}
return Integer.signum(data1.length - data2.length);
}
/** /**
* Copy the contents of the source array to the target array. If the size if * Copy the contents of the source array to the target array. If the size if
* the target array is too small, a larger array is created. * the target array is too small, a larger array is created.
......
...@@ -372,11 +372,11 @@ public class Transfer { ...@@ -372,11 +372,11 @@ public class Transfer {
} else if (version >= Constants.TCP_PROTOCOL_VERSION_7) { } else if (version >= Constants.TCP_PROTOCOL_VERSION_7) {
Timestamp ts = v.getTimestamp(); Timestamp ts = v.getTimestamp();
writeLong(DateTimeUtils.getTimeLocalWithoutDst(ts)); writeLong(DateTimeUtils.getTimeLocalWithoutDst(ts));
writeInt(ts.getNanos() % 1000000); writeInt(ts.getNanos() % 1_000_000);
} else { } else {
Timestamp ts = v.getTimestamp(); Timestamp ts = v.getTimestamp();
writeLong(ts.getTime()); writeLong(ts.getTime());
writeInt(ts.getNanos() % 1000000); writeInt(ts.getNanos() % 1_000_000);
} }
break; break;
} }
...@@ -573,10 +573,10 @@ public class Transfer { ...@@ -573,10 +573,10 @@ public class Transfer {
} else if (version >= Constants.TCP_PROTOCOL_VERSION_7) { } else if (version >= Constants.TCP_PROTOCOL_VERSION_7) {
return ValueTimestamp.fromMillisNanos( return ValueTimestamp.fromMillisNanos(
DateTimeUtils.getTimeUTCWithoutDst(readLong()), DateTimeUtils.getTimeUTCWithoutDst(readLong()),
readInt() % 1000000); readInt() % 1_000_000);
} }
return ValueTimestamp.fromMillisNanos(readLong(), return ValueTimestamp.fromMillisNanos(readLong(),
readInt() % 1000000); readInt() % 1_000_000);
} }
case Value.TIMESTAMP_TZ: { case Value.TIMESTAMP_TZ: {
return ValueTimestampTimeZone.fromDateValueAndNanos(readLong(), return ValueTimestampTimeZone.fromDateValueAndNanos(readLong(),
......
...@@ -10,6 +10,7 @@ import java.sql.SQLException; ...@@ -10,6 +10,7 @@ import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
import org.h2.util.Bits;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
...@@ -93,9 +94,9 @@ public class ValueBytes extends Value { ...@@ -93,9 +94,9 @@ public class ValueBytes extends Value {
protected int compareSecure(Value v, CompareMode mode) { protected int compareSecure(Value v, CompareMode mode) {
byte[] v2 = ((ValueBytes) v).value; byte[] v2 = ((ValueBytes) v).value;
if (mode.isBinaryUnsigned()) { if (mode.isBinaryUnsigned()) {
return Utils.compareNotNullUnsigned(value, v2); return Bits.compareNotNullUnsigned(value, v2);
} }
return Utils.compareNotNullSigned(value, v2); return Bits.compareNotNullSigned(value, v2);
} }
@Override @Override
......
...@@ -48,7 +48,7 @@ public class ValueDecimal extends Value { ...@@ -48,7 +48,7 @@ public class ValueDecimal extends Value {
/** /**
* The maximum scale of a BigDecimal value. * The maximum scale of a BigDecimal value.
*/ */
private static final int BIG_DECIMAL_SCALE_MAX = 100000; private static final int BIG_DECIMAL_SCALE_MAX = 100_000;
private final BigDecimal value; private final BigDecimal value;
private String valueString; private String valueString;
......
...@@ -11,6 +11,7 @@ import java.sql.Types; ...@@ -11,6 +11,7 @@ import java.sql.Types;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
import org.h2.store.DataHandler; import org.h2.store.DataHandler;
import org.h2.util.Bits;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
...@@ -131,8 +132,7 @@ public class ValueJavaObject extends ValueBytes { ...@@ -131,8 +132,7 @@ public class ValueJavaObject extends ValueBytes {
if (o1.equals(o2)) { if (o1.equals(o2)) {
return 0; return 0;
} }
return Bits.compareNotNullSigned(getBytesNoCopy(), v.getBytesNoCopy());
return Utils.compareNotNullSigned(getBytesNoCopy(), v.getBytesNoCopy());
} }
return h1 > h2 ? 1 : -1; return h1 > h2 ? 1 : -1;
......
...@@ -26,6 +26,7 @@ import org.h2.store.FileStoreOutputStream; ...@@ -26,6 +26,7 @@ import org.h2.store.FileStoreOutputStream;
import org.h2.store.RangeInputStream; import org.h2.store.RangeInputStream;
import org.h2.store.RangeReader; import org.h2.store.RangeReader;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.util.Bits;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.SmallLRUCache; import org.h2.util.SmallLRUCache;
...@@ -674,7 +675,7 @@ public class ValueLob extends Value { ...@@ -674,7 +675,7 @@ public class ValueLob extends Value {
return Integer.signum(getString().compareTo(v.getString())); return Integer.signum(getString().compareTo(v.getString()));
} }
byte[] v2 = v.getBytesNoCopy(); byte[] v2 = v.getBytesNoCopy();
return Utils.compareNotNullSigned(getBytes(), v2); return Bits.compareNotNullSigned(getBytesNoCopy(), v2);
} }
@Override @Override
......
...@@ -27,6 +27,7 @@ import org.h2.store.LobStorageFrontend; ...@@ -27,6 +27,7 @@ import org.h2.store.LobStorageFrontend;
import org.h2.store.LobStorageInterface; import org.h2.store.LobStorageInterface;
import org.h2.store.RangeReader; import org.h2.store.RangeReader;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.util.Bits;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -363,7 +364,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, ...@@ -363,7 +364,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
return Integer.signum(getString().compareTo(v.getString())); return Integer.signum(getString().compareTo(v.getString()));
} }
byte[] v2 = v.getBytesNoCopy(); byte[] v2 = v.getBytesNoCopy();
return Utils.compareNotNullSigned(getBytes(), v2); return Bits.compareNotNullSigned(getBytesNoCopy(), v2);
} }
@Override @Override
......
...@@ -70,7 +70,7 @@ public class ValueTime extends Value { ...@@ -70,7 +70,7 @@ public class ValueTime extends Value {
*/ */
public static ValueTime fromNanos(long nanos) { public static ValueTime fromNanos(long nanos) {
if (!SysProperties.UNLIMITED_TIME_RANGE) { if (!SysProperties.UNLIMITED_TIME_RANGE) {
if (nanos < 0L || nanos >= 86400000000000L) { if (nanos < 0L || nanos >= DateTimeUtils.NANOS_PER_DAY) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
DateTimeUtils.appendTime(builder, nanos); DateTimeUtils.appendTime(builder, nanos);
throw DbException.get(ErrorCode.INVALID_DATETIME_CONSTANT_2, throw DbException.get(ErrorCode.INVALID_DATETIME_CONSTANT_2,
......
...@@ -88,7 +88,7 @@ public class ValueTimestamp extends Value { ...@@ -88,7 +88,7 @@ public class ValueTimestamp extends Value {
*/ */
public static ValueTimestamp get(Timestamp timestamp) { public static ValueTimestamp get(Timestamp timestamp) {
long ms = timestamp.getTime(); long ms = timestamp.getTime();
long nanos = timestamp.getNanos() % 1000000; long nanos = timestamp.getNanos() % 1_000_000;
long dateValue = DateTimeUtils.dateValueFromDate(ms); long dateValue = DateTimeUtils.dateValueFromDate(ms);
nanos += DateTimeUtils.nanosFromDate(ms); nanos += DateTimeUtils.nanosFromDate(ms);
return fromDateValueAndNanos(dateValue, nanos); return fromDateValueAndNanos(dateValue, nanos);
......
...@@ -54,7 +54,7 @@ public class ValueUuid extends Value { ...@@ -54,7 +54,7 @@ public class ValueUuid extends Value {
// version 4 (random) // version 4 (random)
high = (high & (~0xf000L)) | 0x4000L; high = (high & (~0xf000L)) | 0x4000L;
// variant (Leach-Salz) // variant (Leach-Salz)
low = (low & 0x3fffffffffffffffL) | 0x8000000000000000L; low = (low & 0x3fff_ffff_ffff_ffffL) | 0x8000_0000_0000_0000L;
return new ValueUuid(high, low); return new ValueUuid(high, low);
} }
......
...@@ -30,7 +30,7 @@ public class DirectInsert { ...@@ -30,7 +30,7 @@ public class DirectInsert {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
DeleteDbFiles.execute("~", "test", true); DeleteDbFiles.execute("~", "test", true);
String url = "jdbc:h2:~/test"; String url = "jdbc:h2:~/test";
initialInsert(url, 200000); initialInsert(url, 200_000);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
createAsSelect(url, true); createAsSelect(url, true);
createAsSelect(url, false); createAsSelect(url, false);
......
...@@ -81,8 +81,7 @@ public class SpellChecker { ...@@ -81,8 +81,7 @@ public class SpellChecker {
// System.out.println(unused); // System.out.println(unused);
if (printDictionary) { if (printDictionary) {
System.out.println("USED WORDS"); System.out.println("USED WORDS");
String[] list = new String[used.size()]; String[] list = used.toArray(new String[used.size()]);
used.toArray(list);
Arrays.sort(list); Arrays.sort(list);
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
for (String s : list) { for (String s : list) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论