提交 c4a00eb9 authored 作者: Thomas Mueller's avatar Thomas Mueller

Fix formatting.

上级 2526201d
......@@ -512,7 +512,7 @@ public abstract class Query extends Prepared {
public void setSampleSize(Expression sampleSize) {
this.sampleSizeExpr = sampleSize;
}
protected final int getSampleSizeValue(Session session) {
if (sampleSizeExpr == null) {
return 0;
......
......@@ -405,9 +405,9 @@ public class ConnectionInfo implements Cloneable {
public byte[] getFilePasswordHash() {
return filePasswordHash;
}
byte[] getFileEncryptionKey() {
return fileEncryptionKey;
return fileEncryptionKey;
}
/**
......@@ -549,7 +549,7 @@ public class ConnectionInfo implements Cloneable {
public void setFilePasswordHash(byte[] hash) {
this.filePasswordHash = hash;
}
public void setFileEncryptionKey(byte[] key) {
this.fileEncryptionKey = key;
}
......
......@@ -165,7 +165,7 @@ public class Engine implements SessionFactory {
// wait a bit to avoid a busy loop (the method is synchronized)
if (i > 60 * 1000) {
// retry at most 1 minute
throw DbException.get(ErrorCode.DATABASE_ALREADY_OPEN_1,
throw DbException.get(ErrorCode.DATABASE_ALREADY_OPEN_1,
"Waited for database closing longer than 1 minute");
}
try {
......
......@@ -59,7 +59,7 @@ public class FileStore {
* The file.
*/
protected FileChannel file;
/**
* The encrypted file (if encryption is used).
*/
......@@ -228,13 +228,13 @@ public class FileStore {
public FileChannel getFile() {
return file;
}
/**
* Get the encrypted file instance, if encryption is used.
* <p>
* The application may read from the file (for example for online backup),
* but not write to it or truncate it.
*
*
* @return the encrypted file, or null if encryption is not used
*/
public FileChannel getEncryptedFile() {
......
......@@ -688,7 +688,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
if (p.getKeyCount() == 0) {
p.setChild(index, c);
p.setCounts(index, c);
c.removePage();
c.removePage();
} else {
p.remove(index);
}
......
......@@ -332,7 +332,7 @@ public class MVStore {
// setWriteDelay starts the thread, but only if
// the parameter is different than the current value
o = config.get("writeDelay");
int writeDelay = o == null ? 1000 : (Integer) o;
setWriteDelay(writeDelay);
......@@ -486,10 +486,10 @@ public class MVStore {
meta.remove("root." + id);
maps.remove(id);
}
/**
* Check whether a given map exists.
*
*
* @param name the map name
* @return true if it exists
*/
......@@ -651,14 +651,14 @@ public class MVStore {
}
if (fileStore != null && !fileStore.isReadOnly()) {
stopBackgroundThread();
if (currentStoreVersion >= 0) {
// in this case, store is called manually in another thread
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_WRITING_FAILED,
DataUtils.ERROR_WRITING_FAILED,
"Can not close while storing");
}
if (hasUnsavedChanges() || lastCommittedVersion != currentVersion) {
rollbackTo(lastCommittedVersion);
metaChanged = true;
......@@ -824,7 +824,7 @@ public class MVStore {
currentStoreVersion = -1;
}
}
private long storeNow(boolean temp) {
int currentUnsavedPageCount = unsavedPageCount;
long storeVersion = currentStoreVersion;
......@@ -1232,7 +1232,7 @@ public class MVStore {
reuseSpace = true;
for (Chunk c : move) {
if (!chunks.containsKey(c.id)) {
// already removed during the
// already removed during the
// previous store operation
continue;
}
......
......@@ -38,7 +38,7 @@ public class MVStoreTool {
}
}
}
/**
* Read the contents of the file and write them to system out.
*
......@@ -135,10 +135,10 @@ public class MVStoreTool {
counts[i] = s;
}
for (int i = 0; i < len; i++) {
pw.println(" < " + keys[i] + ": " +
pw.println(" < " + keys[i] + ": " +
counts[i] + " -> " + getPosString(children[i]));
}
pw.println(" >= : " +
pw.println(" >= : " +
counts[len] + " -> " + getPosString(children[len]));
} else {
// meta map leaf
......@@ -169,9 +169,9 @@ public class MVStoreTool {
pw.println();
pw.flush();
}
private static String getPosString(long pos) {
return "pos " + pos + ", chunk " + DataUtils.getPageChunkId(pos) +
return "pos " + pos + ", chunk " + DataUtils.getPageChunkId(pos) +
", offset " + DataUtils.getPageOffset(pos);
}
......
......@@ -174,7 +174,7 @@ public class Page {
maxLength = (int) Math.min(fileSize - filePos, maxLength);
int length = maxLength;
if (length < 0) {
throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,
throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,
"Illegal page length {0} reading at {1}; file size {1} ", length, filePos, fileSize);
}
buff = fileStore.readFully(filePos, length);
......
......@@ -129,7 +129,7 @@ public class FilePathCache extends FilePathWrapper {
clearCache(src, position());
return base.write(src);
}
private void clearCache(ByteBuffer src, long position) {
if (cache.size() > 0) {
int len = src.remaining();
......
......@@ -18,13 +18,13 @@ public class FileChannelInputStream extends InputStream {
private final FileChannel channel;
private final boolean closeChannel;
private ByteBuffer buffer;
private long pos;
/**
* Create a new file object input stream from the file channel.
*
*
* @param channel the file channel
* @param closeChannel whether closing the stream should close the channel
*/
......@@ -36,7 +36,7 @@ public class FileChannelInputStream extends InputStream {
@Override
public int read() throws IOException {
if (buffer == null) {
buffer = ByteBuffer.allocate(1);
buffer = ByteBuffer.allocate(1);
}
buffer.rewind();
int len = channel.read(buffer, pos++);
......
......@@ -378,7 +378,7 @@ class FileZip extends FileBase {
}
return null;
}
@Override
protected void implCloseChannel() throws IOException {
if (in != null) {
......
......@@ -206,7 +206,7 @@ public class ChangeFileEncryption extends Tool {
in.init();
copy(fileName, in, encrypt);
}
private void copy(String fileName) throws IOException {
if (FileUtils.isDirectory(fileName)) {
return;
......
......@@ -18,23 +18,49 @@ import org.h2.message.DbException;
* in comments and quotes.
*/
public class ScriptReader {
private final Reader reader;
private char[] buffer;
/** position in the buffer of the next char to be read */
/**
* The position in the buffer of the next char to be read
*/
private int bufferPos;
/** position in the buffer of the statement start */
/**
* The position in the buffer of the statement start
*/
private int bufferStart = -1;
/** position in the buffer of the last available char */
/**
* The position in the buffer of the last available char
*/
private int bufferEnd;
/** true if we have read past the end of file */
/**
* True if we have read past the end of file
*/
private boolean endOfFile;
/** true if we are inside a comment */
/**
* True if we are inside a comment
*/
private boolean insideRemark;
/** Only valid if insideRemark is true. True if we are inside a block comment, false if we are inside a line comment */
/**
* Only valid if insideRemark is true. True if we are inside a block
* comment, false if we are inside a line comment
*/
private boolean blockRemark;
/** true if comments should be skipped completely by this reader. */
/**
* True if comments should be skipped completely by this reader.
*/
private boolean skipRemarks;
/** position in buffer of start of comment */
/**
* The position in buffer of start of comment
*/
private int remarkStart;
/**
......@@ -239,9 +265,9 @@ public class ScriptReader {
if (keep + Constants.IO_BUFFER_SIZE > src.length) {
// protect against NegativeArraySizeException
if (src.length >= Integer.MAX_VALUE / 2) {
throw new IOException("Error in parsing script, " +
"statement size exceeds 1G, " +
"first 80 characters of statement looks like: " +
throw new IOException("Error in parsing script, " +
"statement size exceeds 1G, " +
"first 80 characters of statement looks like: " +
new String(buffer, bufferStart, 80));
}
buffer = new char[src.length * 2];
......
......@@ -712,9 +712,9 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
// synth
new TestBtreeIndex().runTest(this);
new TestDiskFull().runTest(this);
new TestCrashAPI().runTest(this);
new TestFuzzOptimizations().runTest(this);
new TestLimit().runTest(this);
new TestRandomSQL().runTest(this);
......@@ -761,9 +761,9 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new TestFile().runTest(this);
new TestFileLock().runTest(this);
new TestFileLockProcess().runTest(this);
new TestFileLockSerialized().runTest(this);
new TestFtp().runTest(this);
new TestFileSystem().runTest(this);
new TestIntArray().runTest(this);
......
......@@ -46,7 +46,7 @@ public class TestScript extends TestBase {
private String putBack;
private StringBuilder errors;
private ArrayList<String> statements;
private Random random = new Random(1);
/**
......
......@@ -1170,7 +1170,8 @@ public class TestPreparedStatement extends TestBase {
}
private void testPreparedStatementWithLiteralsNone() throws SQLException {
// make sure that when the analyze table kicks in, it works with ALLOW_LITERALS=NONE
// make sure that when the analyze table kicks in,
// it works with ALLOW_LITERALS=NONE
deleteDb("preparedStatement");
Connection conn = getConnection("preparedStatement;ANALYZE_AUTO=100");
conn.createStatement().execute("SET ALLOW_LITERALS NONE");
......@@ -1179,11 +1180,11 @@ public class TestPreparedStatement extends TestBase {
for (int i = 0; i < 200; i++) {
ps.setInt(1, i);
ps.executeUpdate();
}
}
conn.close();
deleteDb("preparedStatement");
}
private void checkBigDecimal(ResultSet rs, String[] value) throws SQLException {
for (String v : value) {
assertTrue(rs.next());
......
......@@ -36,13 +36,13 @@ public class TestKillProcessWhileWriting extends TestBase {
public void test() throws Exception {
fs = FilePathUnstable.register();
test("unstable:memFS:killProcess.h3");
int todo;
// need to test with a file system splits writes into blocks of 4 KB
FilePathCrypt.register();
test("unstable:crypt:0007:memFS:killProcess.h3");
}
public void test(String fileName) throws Exception {
for (seed = 0; seed < 10; seed++) {
this.fileName = fileName;
......@@ -55,7 +55,7 @@ public class TestKillProcessWhileWriting extends TestBase {
}
}
}
private void test(int x) throws Exception {
FileUtils.delete(fileName);
fs.setDiskFullCount(x);
......@@ -69,8 +69,8 @@ public class TestKillProcessWhileWriting extends TestBase {
fs.setDiskFullCount(0);
verify();
}
}
}
private int write() {
MVStore s;
MVMap<Integer, byte[]> m;
......@@ -127,9 +127,9 @@ public class TestKillProcessWhileWriting extends TestBase {
return op;
}
}
private void verify() {
MVStore s;
MVMap<Integer, byte[]> m;
......
......@@ -96,7 +96,7 @@ public class TestMVStore extends TestBase {
// longer running tests
testLargerThan2G();
}
private void testRemoveMap() throws Exception {
String fileName = getBaseDir() + "/testCloseMap.h3";
FileUtils.delete(fileName);
......@@ -104,23 +104,23 @@ public class TestMVStore extends TestBase {
fileName(fileName).
open();
MVMap<Integer, Integer> map;
map = s.openMap("data");
map.put(1, 1);
assertEquals(1, map.get(1).intValue());
s.store();
map.removeMap();
s.store();
map = s.openMap("data");
assertTrue(map.isEmpty());
map.put(2, 2);
s.store();
s.close();
}
private void testIsEmpty() throws Exception {
MVStore s = new MVStore.Builder().
pageSplitSize(50).
......@@ -643,7 +643,7 @@ public class TestMVStore extends TestBase {
}
}
s.close();
FilePath f = FilePath.get(fileName);
int blockSize = 4 * 1024;
// test corrupt file headers
......
......@@ -28,7 +28,7 @@ public class TestRandomMapOps extends TestBase {
/**
* Run just this test.
*
*
* @param a ignored
*/
public static void main(String... a) throws Exception {
......@@ -168,14 +168,14 @@ public class TestRandomMapOps extends TestBase {
s.store();
s.close();
}
private static MVStore openStore(String fileName) {
MVStore s = new MVStore.Builder().fileName(fileName).
pageSplitSize(50).writeDelay(0).open();
pageSplitSize(50).writeDelay(0).open();
s.setRetentionTime(0);
return s;
}
private void assertEqualsMapValues(byte[] x, byte[] y) {
if (x == null || y == null) {
if (x != y) {
......@@ -185,17 +185,17 @@ public class TestRandomMapOps extends TestBase {
assertEquals(x.length, y.length);
}
}
/**
* Log the operation
*
*
* @param op the operation id
* @param k the key
* @param v the value
* @param msg the message
*/
private static void log(int op, int k, byte[] v, String msg) {
// msg = MessageFormat.format(msg, k,
// msg = MessageFormat.format(msg, k,
// v == null ? null : "new byte[" + v.length + "]");
// System.out.println(msg + "; // op " + op);
}
......
......@@ -52,7 +52,7 @@ public class TestStreamStore extends TestBase {
testWithFullMap();
testLoop();
}
private void testReadCount() throws IOException {
String fileName = getBaseDir() + "/testReadCount.h3";
FileUtils.delete(fileName);
......@@ -69,7 +69,7 @@ public class TestStreamStore extends TestBase {
MVMap<Long, byte[]> map = s.openMap("data");
assertTrue("size: " + map.size(), map.sizeAsLong() >= 100);
s.close();
s = new MVStore.Builder().
fileName(fileName).
open();
......@@ -86,7 +86,7 @@ public class TestStreamStore extends TestBase {
assertTrue("size: " + map.size(), map.sizeAsLong() >= 200);
s.close();
}
private static StreamStore getAutoCommitStreamStore(final MVStore s) {
MVMap<Long, byte[]> map = s.openMap("data");
return new StreamStore(map) {
......
......@@ -106,14 +106,14 @@ public class TestFileSystem extends TestBase {
FileUtils.delete(getBaseDir() + "/fs");
}
}
private void testZipFileSystem(String prefix) throws IOException {
Random r = new Random(1);
for (int i = 0; i < 5; i++) {
testZipFileSystem(prefix, r);
}
}
private void testZipFileSystem(String prefix, Random r) throws IOException {
byte[] data = new byte[r.nextInt(16 * 1024)];
long x = r.nextLong();
......@@ -693,13 +693,13 @@ public class TestFileSystem extends TestBase {
FileUtils.delete(s);
}
}
private static ByteBuffer createSlicedBuffer(byte[] buffer, int offset, int len) {
ByteBuffer byteBuff = ByteBuffer.wrap(buffer);
byteBuff.position(offset);
// force the arrayOffset to be non-0
byteBuff = byteBuff.slice();
byteBuff.limit(len);
byteBuff.limit(len);
return byteBuff;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论