提交 10fa11b8 authored 作者: Thomas Mueller's avatar Thomas Mueller

Limit line length to 80 characters (comments) and 100 (code)

上级 9ade2f38
......@@ -138,7 +138,8 @@ public class RuleFixed implements Rule {
}
break;
case AZ_UNDERSCORE:
if (s.length() > 0 && (Character.isLetter(s.charAt(0)) || s.charAt(0) == '_')) {
if (s.length() > 0 &&
(Character.isLetter(s.charAt(0)) || s.charAt(0) == '_')) {
s = s.substring(1);
}
if (s.length() == 0) {
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.expression;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.expression;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.expression;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.expression;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.index;
......
......@@ -284,7 +284,8 @@ public class DataUtils {
* @param len the number of characters
* @return the byte buffer
*/
public static ByteBuffer writeStringData(ByteBuffer buff, String s, int len) {
public static ByteBuffer writeStringData(ByteBuffer buff,
String s, int len) {
buff = DataUtils.ensureCapacity(buff, 3 * len);
for (int i = 0; i < len; i++) {
int c = s.charAt(i);
......@@ -345,7 +346,8 @@ public class DataUtils {
* @param out the output stream
* @param x the value
*/
public static void writeVarLong(OutputStream out, long x) throws IOException {
public static void writeVarLong(OutputStream out, long x)
throws IOException {
while ((x & ~0x7f) != 0) {
out.write((byte) (0x80 | (x & 0x7f)));
x >>>= 7;
......@@ -418,7 +420,8 @@ public class DataUtils {
}
throw newIllegalStateException(
ERROR_READING_FAILED,
"Reading from {0} failed; file length {1} read length {2} at {3}",
"Reading from {0} failed; file length {1} " +
"read length {2} at {3}",
file, size, dst.remaining(), pos, e);
}
}
......@@ -534,7 +537,8 @@ public class DataUtils {
* @param type the page type (1 for node, 0 for leaf)
* @return the position
*/
public static long getPagePos(int chunkId, int offset, int length, int type) {
public static long getPagePos(int chunkId, int offset,
int length, int type) {
long pos = (long) chunkId << 38;
pos |= (long) offset << 6;
pos |= encodeLength(length) << 1;
......@@ -712,8 +716,8 @@ public class DataUtils {
* @param message the message
* @return the exception
*/
public static UnsupportedOperationException newUnsupportedOperationException(
String message) {
public static UnsupportedOperationException
newUnsupportedOperationException(String message) {
return new UnsupportedOperationException(formatMessage(0, message));
}
......
......@@ -148,11 +148,13 @@ public class FileStore {
}
} catch (OverlappingFileLockException e) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_FILE_LOCKED, "The file is locked: {0}", fileName, e);
DataUtils.ERROR_FILE_LOCKED,
"The file is locked: {0}", fileName, e);
}
if (fileLock == null) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_FILE_LOCKED, "The file is locked: {0}", fileName);
DataUtils.ERROR_FILE_LOCKED,
"The file is locked: {0}", fileName);
}
fileSize = file.size();
} catch (IOException e) {
......
......@@ -930,7 +930,8 @@ public class MVMap<K, V> extends AbstractMap<K, V>
protected void waitUntilWritten(long version) {
if (readOnly) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_INTERNAL, "Waiting for writes to a read-only map");
DataUtils.ERROR_INTERNAL,
"Waiting for writes to a read-only map");
}
while (currentWriteVersion == version) {
Thread.yield();
......@@ -997,7 +998,8 @@ public class MVMap<K, V> extends AbstractMap<K, V>
public MVMap<K, V> openVersion(long version) {
if (readOnly) {
throw DataUtils.newUnsupportedOperationException(
"This map is read-only; need to call the method on the writable map");
"This map is read-only; need to call " +
"the method on the writable map");
}
DataUtils.checkArgument(version >= createVersion,
"Unknown version {0}; this map was created in version is {1}",
......
......@@ -164,7 +164,8 @@ public class MVStore {
* is the unsaved version, the value is the map of chunks. The maps contains
* the number of freed entries per chunk. Access is synchronized.
*/
private final ConcurrentHashMap<Long, HashMap<Integer, Chunk>> freedPageSpace =
private final ConcurrentHashMap<Long,
HashMap<Integer, Chunk>> freedPageSpace =
new ConcurrentHashMap<Long, HashMap<Integer, Chunk>>();
/**
......@@ -508,9 +509,11 @@ public class MVStore {
fileHeaderBlocks.get(buff);
// the following can fail for various reasons
try {
String s = new String(buff, 0, BLOCK_SIZE, DataUtils.LATIN).trim();
String s = new String(buff, 0, BLOCK_SIZE,
DataUtils.LATIN).trim();
HashMap<String, String> m = DataUtils.parseMap(s);
int blockSize = DataUtils.readHexInt(m, "blockSize", BLOCK_SIZE);
int blockSize = DataUtils.readHexInt(
m, "blockSize", BLOCK_SIZE);
if (blockSize != BLOCK_SIZE) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_UNSUPPORTED_FORMAT,
......@@ -521,7 +524,8 @@ public class MVStore {
m.remove("fletcher");
s = s.substring(0, s.lastIndexOf("fletcher") - 1);
byte[] bytes = s.getBytes(DataUtils.LATIN);
int checksum = DataUtils.getFletcher32(bytes, bytes.length / 2 * 2);
int checksum = DataUtils.getFletcher32(bytes,
bytes.length / 2 * 2);
if (check != checksum) {
continue;
}
......@@ -546,7 +550,8 @@ public class MVStore {
if (format > FORMAT_WRITE && !fileStore.isReadOnly()) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_UNSUPPORTED_FORMAT,
"The write format {0} is larger than the supported format {1}, " +
"The write format {0} is larger " +
"than the supported format {1}, " +
"and the file was not opened in read-only mode",
format, FORMAT_WRITE);
}
......@@ -554,7 +559,8 @@ public class MVStore {
if (format > FORMAT_READ) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_UNSUPPORTED_FORMAT,
"The read format {0} is larger than the supported format {1}",
"The read format {0} is larger " +
"than the supported format {1}",
format, FORMAT_READ);
}
lastStoredVersion = -1;
......@@ -610,7 +616,8 @@ public class MVStore {
}
lastChunk = header;
newestVersion = header.version;
if (header.next == 0 || header.next >= fileStore.size() / BLOCK_SIZE) {
if (header.next == 0 ||
header.next >= fileStore.size() / BLOCK_SIZE) {
// no (valid) next
break;
}
......@@ -1018,7 +1025,8 @@ public class MVStore {
// calculate and set the likely next position
if (reuseSpace) {
int predictBlocks = c.len;
long predictedNextStart = fileStore.allocate(predictBlocks * BLOCK_SIZE);
long predictedNextStart = fileStore.allocate(
predictBlocks * BLOCK_SIZE);
fileStore.free(predictedNextStart, predictBlocks * BLOCK_SIZE);
c.next = predictedNextStart / BLOCK_SIZE;
} else {
......@@ -1045,7 +1053,8 @@ public class MVStore {
// the last prediction did not matched
needHeader = true;
} else {
long headerVersion = DataUtils.readHexLong(fileHeader, "version", 0);
long headerVersion = DataUtils.readHexLong(
fileHeader, "version", 0);
if (lastChunk.version - headerVersion > 20) {
// we write after at least 20 entries
needHeader = true;
......@@ -1531,7 +1540,8 @@ public class MVStore {
int pageLength = buff.getInt();
if (pageLength <= 0) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_FILE_CORRUPT, "Page length {0}", pageLength);
DataUtils.ERROR_FILE_CORRUPT,
"Page length {0}", pageLength);
}
buff.getShort();
int mapId = DataUtils.readVarInt(buff);
......@@ -1789,7 +1799,8 @@ public class MVStore {
if (oldMeta == null) {
return false;
}
for (Iterator<String> it = oldMeta.keyIterator("chunk."); it.hasNext();) {
for (Iterator<String> it = oldMeta.keyIterator("chunk.");
it.hasNext();) {
String chunkKey = it.next();
if (!chunkKey.startsWith("chunk.")) {
break;
......@@ -1968,7 +1979,8 @@ public class MVStore {
}
private void revertTemp(long storeVersion) {
for (Iterator<Long> it = freedPageSpace.keySet().iterator(); it.hasNext();) {
for (Iterator<Long> it = freedPageSpace.keySet().iterator();
it.hasNext();) {
long v = it.next();
if (v > storeVersion) {
continue;
......
......@@ -87,7 +87,8 @@ public class MVStoreTool {
block.position(0);
Chunk c = Chunk.readChunkHeader(block, pos);
int length = c.len * MVStore.BLOCK_SIZE;
pw.printf("%n%0" + len + "x chunkHeader %s%n", pos, c.toString());
pw.printf("%n%0" + len + "x chunkHeader %s%n",
pos, c.toString());
ByteBuffer chunk = ByteBuffer.allocate(length);
DataUtils.readFully(file, pos, chunk);
int p = block.position();
......@@ -104,7 +105,8 @@ public class MVStoreTool {
boolean compressed = (type & 2) != 0;
boolean node = (type & 1) != 0;
pw.printf(
"+%0" + len + "x %s, map %x, %d entries, %d bytes%n",
"+%0" + len +
"x %s, map %x, %d entries, %d bytes%n",
p,
(node ? "node" : "leaf") +
(compressed ? " compressed" : ""),
......@@ -138,14 +140,17 @@ public class MVStoreTool {
// meta map node
for (int i = 0; i < entries; i++) {
long cp = children[i];
pw.printf(" %d children < %s @ chunk %x +%0" + len + "x%n",
pw.printf(" %d children < %s @ " +
"chunk %x +%0" +
len + "x%n",
counts[i],
keys[i],
DataUtils.getPageChunkId(cp),
DataUtils.getPageOffset(cp));
}
long cp = children[entries];
pw.printf(" %d children >= %s @ chunk %x +%0" + len + "x%n",
pw.printf(" %d children >= %s @ chunk %x +%0" +
len + "x%n",
counts[entries],
keys[entries],
DataUtils.getPageChunkId(cp),
......@@ -158,14 +163,16 @@ public class MVStoreTool {
values[i] = v;
}
for (int i = 0; i < entries; i++) {
pw.println(" " + keys[i] + " = " + values[i]);
pw.println(" " + keys[i] +
" = " + values[i]);
}
}
} else {
if (node) {
for (int i = 0; i <= entries; i++) {
long cp = children[i];
pw.printf(" %d children @ chunk %x +%0" + len + "x%n",
pw.printf(" %d children @ chunk %x +%0" +
len + "x%n",
counts[i],
DataUtils.getPageChunkId(cp),
DataUtils.getPageOffset(cp));
......
......@@ -34,7 +34,8 @@ public class OffHeapStore extends FileStore {
public ByteBuffer readFully(long pos, int len) {
Entry<Long, ByteBuffer> memEntry = memory.floorEntry(pos);
if (memEntry == null) {
throw DataUtils.newIllegalStateException(DataUtils.ERROR_READING_FAILED,
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_READING_FAILED,
"Could not read from position {0}", pos);
}
readCount++;
......@@ -53,7 +54,8 @@ public class OffHeapStore extends FileStore {
if (buff == null) {
// nothing was written (just allocated)
} else if (buff.remaining() != length) {
throw DataUtils.newIllegalStateException(DataUtils.ERROR_READING_FAILED,
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_READING_FAILED,
"Partial remove is not supported at position {0}", pos);
}
}
......@@ -117,8 +119,10 @@ public class OffHeapStore extends FileStore {
}
ByteBuffer buff = memory.get(pos);
if (buff.capacity() > size) {
throw DataUtils.newIllegalStateException(DataUtils.ERROR_READING_FAILED,
"Could not truncate to {0}; partial truncate is not supported", pos);
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_READING_FAILED,
"Could not truncate to {0}; " +
"partial truncate is not supported", pos);
}
it.remove();
}
......
......@@ -138,10 +138,10 @@ public class Page {
* @param memory the memory used in bytes
* @return the page
*/
public static Page create(MVMap<?, ?> map, long version,
int keyCount, Object[] keys, Object[] values,
int childCount, long[] children, Page[] childrenPages, long[] counts,
long totalCount, int sharedFlags, int memory) {
public static Page create(MVMap<?, ?> map, long version, int keyCount,
Object[] keys, Object[] values, int childCount, long[] children,
Page[] childrenPages, long[] counts, long totalCount,
int sharedFlags, int memory) {
Page p = new Page(map, version);
// the position is 0
p.keyCount = keyCount;
......@@ -479,7 +479,8 @@ public class Page {
if (c != childrenPages[index] || c.getPos() != children[index]) {
if ((sharedFlags & SHARED_CHILDREN) != 0) {
children = Arrays.copyOf(children, children.length);
childrenPages = Arrays.copyOf(childrenPages, childrenPages.length);
childrenPages = Arrays.copyOf(childrenPages,
childrenPages.length);
sharedFlags &= ~SHARED_CHILDREN;
}
children[index] = c.getPos();
......@@ -590,8 +591,10 @@ public class Page {
public void insertLeaf(int index, Object key, Object value) {
if (((sharedFlags & SHARED_KEYS) == 0) && keys.length > keyCount + 1) {
if (index < keyCount) {
System.arraycopy(keys, index, keys, index + 1, keyCount - index);
System.arraycopy(values, index, values, index + 1, keyCount - index);
System.arraycopy(keys, index, keys, index + 1,
keyCount - index);
System.arraycopy(values, index, values, index + 1,
keyCount - index);
}
} else {
int len = keyCount + 6;
......@@ -633,7 +636,8 @@ public class Page {
children = newChildren;
Page[] newChildrenPages = new Page[childCount + 1];
DataUtils.copyWithGap(childrenPages, newChildrenPages, childCount, index);
DataUtils.copyWithGap(childrenPages, newChildrenPages, childCount,
index);
newChildrenPages[index] = childPage;
childrenPages = newChildrenPages;
......@@ -659,9 +663,11 @@ public class Page {
int keyIndex = index >= keyCount ? index - 1 : index;
Object old = keys[keyIndex];
addMemory(-map.getKeyType().getMemory(old));
if ((sharedFlags & SHARED_KEYS) == 0 && keys.length > keyCount - 4) {
if ((sharedFlags & SHARED_KEYS) == 0 &&
keys.length > keyCount - 4) {
if (keyIndex < keyCount - 1) {
System.arraycopy(keys, keyIndex + 1, keys, keyIndex, keyCount - keyIndex - 1);
System.arraycopy(keys, keyIndex + 1, keys, keyIndex, keyCount -
keyIndex - 1);
}
keys[keyCount - 1] = null;
} else {
......@@ -674,9 +680,11 @@ public class Page {
if (values != null) {
old = values[index];
addMemory(-map.getValueType().getMemory(old));
if ((sharedFlags & SHARED_VALUES) == 0 && values.length > keyCount - 4) {
if ((sharedFlags & SHARED_VALUES) == 0 &&
values.length > keyCount - 4) {
if (index < keyCount - 1) {
System.arraycopy(values, index + 1, values, index, keyCount - index - 1);
System.arraycopy(values, index + 1, values, index,
keyCount - index - 1);
}
values[keyCount - 1] = null;
} else {
......@@ -776,7 +784,8 @@ public class Page {
buff.get(comp);
int l = compLen + lenAdd;
buff = ByteBuffer.allocate(l);
compressor.expand(comp, 0, compLen, buff.array(), buff.arrayOffset(), l);
compressor.expand(comp, 0, compLen, buff.array(),
buff.arrayOffset(), l);
}
map.getKeyType().read(buff, keys, len, true);
if (!node) {
......
......@@ -164,7 +164,8 @@ public class StreamStore {
return eof;
}
private static byte[] read(InputStream in, byte[] target) throws IOException {
private static byte[] read(InputStream in, byte[] target)
throws IOException {
int copied = 0;
int remaining = target.length;
while (remaining > 0) {
......@@ -470,7 +471,8 @@ public class StreamStore {
}
default:
throw DataUtils.newIllegalArgumentException(
"Unsupported id {0}", Arrays.toString(idBuffer.array()));
"Unsupported id {0}",
Arrays.toString(idBuffer.array()));
}
}
return null;
......
......@@ -94,7 +94,8 @@ public class CacheLongKeyLIRS<V> {
this.stackMoveDistance = stackMoveDistance;
segments = new Segment[segmentCount];
clear();
this.segmentShift = Integer.numberOfTrailingZeros(segments[0].entries.length);
this.segmentShift = Integer.numberOfTrailingZeros(
segments[0].entries.length);
}
/**
......@@ -929,11 +930,13 @@ public class CacheLongKeyLIRS<V> {
ArrayList<Long> keys = new ArrayList<Long>();
if (cold) {
Entry<V> start = nonResident ? queue2 : queue;
for (Entry<V> e = start.queueNext; e != start; e = e.queueNext) {
for (Entry<V> e = start.queueNext; e != start;
e = e.queueNext) {
keys.add(e.key);
}
} else {
for (Entry<V> e = stack.stackNext; e != stack; e = e.stackNext) {
for (Entry<V> e = stack.stackNext; e != stack;
e = e.stackNext) {
keys.add(e.key);
}
}
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.mvstore.db;
......
......@@ -177,7 +177,9 @@ public class MVTable extends TableBase {
if (checkDeadlock) {
ArrayList<Session> sessions = checkDeadlock(session, null, null);
if (sessions != null) {
throw DbException.get(ErrorCode.DEADLOCK_1, getDeadlockDetails(sessions));
throw DbException.get(
ErrorCode.DEADLOCK_1,
getDeadlockDetails(sessions));
}
} else {
// check for deadlocks from now on
......@@ -188,7 +190,8 @@ public class MVTable extends TableBase {
// try at least one more time
max = now + session.getLockTimeout();
} else if (now >= max) {
traceLock(session, exclusive, "timeout after " + session.getLockTimeout());
traceLock(session, exclusive,
"timeout after " + session.getLockTimeout());
throw DbException.get(ErrorCode.LOCK_TIMEOUT_1, getName());
}
try {
......@@ -299,7 +302,8 @@ public class MVTable extends TableBase {
private void traceLock(Session session, boolean exclusive, String s) {
if (traceLock.isDebugEnabled()) {
traceLock.debug("{0} {1} {2} {3}", session.getId(),
exclusive ? "exclusive write lock" : "shared read lock", s, getName());
exclusive ? "exclusive write lock" : "shared read lock",
s, getName());
}
}
......@@ -612,10 +616,13 @@ public class MVTable extends TableBase {
if (de.getErrorCode() == ErrorCode.DUPLICATE_KEY_1) {
for (int j = 0; j < indexes.size(); j++) {
Index index = indexes.get(j);
if (index.getIndexType().isUnique() && index instanceof MultiVersionIndex) {
if (index.getIndexType().isUnique() &&
index instanceof MultiVersionIndex) {
MultiVersionIndex mv = (MultiVersionIndex) index;
if (mv.isUncommittedFromOtherSession(session, row)) {
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, index.getName());
throw DbException.get(
ErrorCode.CONCURRENT_UPDATE_1,
index.getName());
}
}
}
......@@ -697,7 +704,8 @@ public class MVTable extends TableBase {
}
database.getMvStore().removeTable(this);
super.removeChildrenAndResources(session);
// go backwards because database.removeIndex will call table.removeIndex
// go backwards because database.removeIndex will
// call table.removeIndex
while (indexes.size() > 1) {
Index index = indexes.get(1);
if (index.getName() != null) {
......@@ -708,7 +716,8 @@ public class MVTable extends TableBase {
for (SchemaObject obj : database.getAllSchemaObjects(DbObject.INDEX)) {
Index index = (Index) obj;
if (index.getTable() == this) {
DbException.throwInternalError("index not dropped: " + index.getName());
DbException.throwInternalError(
"index not dropped: " + index.getName());
}
}
}
......
......@@ -73,7 +73,8 @@ public class MVTableEngine implements TableEngine {
if (key != null) {
char[] password = new char[key.length / 2];
for (int i = 0; i < password.length; i++) {
password[i] = (char) (((key[i + i] & 255) << 16) | ((key[i + i + 1]) & 255));
password[i] = (char) (((key[i + i] & 255) << 16) |
((key[i + i + 1]) & 255));
}
builder.encryptionKey(password);
}
......@@ -96,12 +97,18 @@ public class MVTableEngine implements TableEngine {
int errorCode = DataUtils.getErrorCode(e.getMessage());
if (errorCode == DataUtils.ERROR_FILE_CORRUPT) {
if (key != null) {
throw DbException.get(ErrorCode.FILE_ENCRYPTION_ERROR_1, e, fileName);
throw DbException.get(
ErrorCode.FILE_ENCRYPTION_ERROR_1,
e, fileName);
}
} else if (errorCode == DataUtils.ERROR_FILE_LOCKED) {
throw DbException.get(ErrorCode.DATABASE_ALREADY_OPEN_1, e, fileName);
throw DbException.get(
ErrorCode.DATABASE_ALREADY_OPEN_1,
e, fileName);
}
throw DbException.get(ErrorCode.FILE_CORRUPTED_1, e, fileName);
throw DbException.get(
ErrorCode.FILE_CORRUPTED_1,
e, fileName);
}
}
db.setMvStore(store);
......
......@@ -59,7 +59,8 @@ public class TransactionStore {
/**
* The map of maps.
*/
private HashMap<Integer, MVMap<Object, VersionedValue>> maps = New.hashMap();
private HashMap<Integer, MVMap<Object, VersionedValue>> maps =
New.hashMap();
private final DataType dataType;
......@@ -192,7 +193,8 @@ public class TransactionStore {
status = (Integer) data[0];
name = (String) data[1];
}
Transaction t = new Transaction(this, transactionId, status, name, logId);
Transaction t = new Transaction(this, transactionId, status,
name, logId);
list.add(t);
key = undoLog.ceilingKey(getOperationId(transactionId + 1, 0));
}
......@@ -227,7 +229,8 @@ public class TransactionStore {
* @param t the transaction
*/
synchronized void storeTransaction(Transaction t) {
if (t.getStatus() == Transaction.STATUS_PREPARED || t.getName() != null) {
if (t.getStatus() == Transaction.STATUS_PREPARED ||
t.getName() != null) {
Object[] v = { t.getStatus(), t.getName() };
preparedTransactions.put(t.getId(), v);
}
......@@ -251,7 +254,8 @@ public class TransactionStore {
if (undoLog.containsKey(undoKey)) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_TRANSACTION_STILL_OPEN,
"An old transaction with the same id is still open: {0}",
"An old transaction with the same id " +
"is still open: {0}",
t.getId());
}
}
......@@ -303,7 +307,8 @@ public class TransactionStore {
if (op == null) {
// partially committed: load next
undoKey = undoLog.ceilingKey(undoKey);
if (undoKey == null || getTransactionId(undoKey) != t.getId()) {
if (undoKey == null ||
getTransactionId(undoKey) != t.getId()) {
break;
}
logId = getLogId(undoKey) - 1;
......@@ -460,7 +465,8 @@ public class TransactionStore {
if (op == null) {
// partially rolled back: load previous
undoKey = undoLog.floorKey(undoKey);
if (undoKey == null || getTransactionId(undoKey) != t.getId()) {
if (undoKey == null ||
getTransactionId(undoKey) != t.getId()) {
break;
}
logId = getLogId(undoKey) + 1;
......@@ -513,7 +519,8 @@ public class TransactionStore {
if (op == null) {
// partially rolled back: load previous
undoKey = undoLog.floorKey(undoKey);
if (undoKey == null || getTransactionId(undoKey) != t.getId()) {
if (undoKey == null ||
getTransactionId(undoKey) != t.getId()) {
break;
}
logId = getLogId(undoKey);
......@@ -528,7 +535,8 @@ public class TransactionStore {
current.mapName = m.getName();
current.key = op[1];
VersionedValue oldValue = (VersionedValue) op[2];
current.value = oldValue == null ? null : oldValue.value;
current.value = oldValue == null ?
null : oldValue.value;
return;
}
}
......@@ -712,7 +720,8 @@ public class TransactionStore {
public <K, V> TransactionMap<K, V> openMap(String name,
DataType keyType, DataType valueType) {
checkNotClosed();
MVMap<K, VersionedValue> map = store.openMap(name, keyType, valueType);
MVMap<K, VersionedValue> map = store.openMap(name, keyType,
valueType);
int mapId = map.getId();
return new TransactionMap<K, V>(this, map, mapId);
}
......@@ -725,7 +734,8 @@ public class TransactionStore {
* @param map the base map
* @return the transactional map
*/
public <K, V> TransactionMap<K, V> openMap(MVMap<K, VersionedValue> map) {
public <K, V> TransactionMap<K, V> openMap(
MVMap<K, VersionedValue> map) {
checkNotClosed();
int mapId = map.getId();
return new TransactionMap<K, V>(this, map, mapId);
......@@ -1521,14 +1531,16 @@ public class TransactionStore {
}
@Override
public void read(ByteBuffer buff, Object[] obj, int len, boolean key) {
public void read(ByteBuffer buff, Object[] obj,
int len, boolean key) {
for (int i = 0; i < len; i++) {
obj[i] = read(buff);
}
}
@Override
public void write(WriteBuffer buff, Object[] obj, int len, boolean key) {
public void write(WriteBuffer buff, Object[] obj,
int len, boolean key) {
for (int i = 0; i < len; i++) {
write(buff, obj[i]);
}
......@@ -1604,14 +1616,16 @@ public class TransactionStore {
}
@Override
public void read(ByteBuffer buff, Object[] obj, int len, boolean key) {
public void read(ByteBuffer buff, Object[] obj,
int len, boolean key) {
for (int i = 0; i < len; i++) {
obj[i] = read(buff);
}
}
@Override
public void write(WriteBuffer buff, Object[] obj, int len, boolean key) {
public void write(WriteBuffer buff, Object[] obj,
int len, boolean key) {
for (int i = 0; i < len; i++) {
write(buff, obj[i]);
}
......
......@@ -385,8 +385,10 @@ public class ValueDataType implements DataType {
while (rs.next()) {
buff.put((byte) 1);
for (int i = 0; i < columnCount; i++) {
int t = org.h2.value.DataType.getValueTypeFromResultSet(meta, i + 1);
Value val = org.h2.value.DataType.readValue(null, rs, i + 1, t);
int t = org.h2.value.DataType.
getValueTypeFromResultSet(meta, i + 1);
Value val = org.h2.value.DataType.readValue(
null, rs, i + 1, t);
writeValue(buff, val);
}
}
......
......@@ -63,7 +63,8 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
public RTreeCursor findIntersectingKeys(SpatialKey x) {
return new RTreeCursor(root, x) {
@Override
protected boolean check(boolean leaf, SpatialKey key, SpatialKey test) {
protected boolean check(boolean leaf, SpatialKey key,
SpatialKey test) {
return keyType.isOverlap(key, test);
}
};
......
......@@ -278,7 +278,8 @@ public class SpatialDataType implements DataType {
float min = boundsInner.min(bestDim);
float max = boundsInner.max(bestDim);
int firstIndex = -1, lastIndex = -1;
for (int i = 0; i < list.size() && (firstIndex < 0 || lastIndex < 0); i++) {
for (int i = 0; i < list.size() &&
(firstIndex < 0 || lastIndex < 0); i++) {
SpatialKey o = (SpatialKey) list.get(i);
if (firstIndex < 0 && o.max(bestDim) == min) {
firstIndex = i;
......
......@@ -432,7 +432,8 @@ public class ObjectDataType implements DataType {
}
@Override
public void write(WriteBuffer buff, Object[] obj, int len, boolean key) {
public void write(WriteBuffer buff, Object[] obj,
int len, boolean key) {
for (int i = 0; i < len; i++) {
write(buff, obj[i]);
}
......@@ -444,7 +445,8 @@ public class ObjectDataType implements DataType {
}
@Override
public void read(ByteBuffer buff, Object[] obj, int len, boolean key) {
public void read(ByteBuffer buff, Object[] obj,
int len, boolean key) {
for (int i = 0; i < len; i++) {
obj[i] = read(buff);
}
......
......@@ -357,7 +357,8 @@ public class DateTimeUtils {
if (hour < 0 || hour > 23) {
throw e;
}
return getTimeTry(true, tz, year, month, day, hour, minute, second, millis);
return getTimeTry(true, tz, year, month, day, hour, minute,
second, millis);
} else if (message.indexOf("DAY_OF_MONTH") > 0) {
int maxDay;
if (month == 2) {
......@@ -372,9 +373,11 @@ public class DateTimeUtils {
// using the timezone Brasilia and others,
// for example for 2042-10-12 00:00:00.
hour += 6;
return getTimeTry(true, tz, year, month, day, hour, minute, second, millis);
return getTimeTry(true, tz, year, month, day, hour, minute,
second, millis);
} else {
return getTimeTry(true, tz, year, month, day, hour, minute, second, millis);
return getTimeTry(true, tz, year, month, day, hour, minute,
second, millis);
}
}
}
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.util;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.util;
......
......@@ -117,7 +117,8 @@ public class CreateScriptFile {
} else {
out = FileUtils.newOutputStream(fileName, false);
out = new BufferedOutputStream(out, Constants.IO_BUFFER_SIZE);
out = CompressTool.wrapOutputStream(out, compressionAlgorithm, "script.sql");
out = CompressTool.wrapOutputStream(out,
compressionAlgorithm, "script.sql");
}
return new PrintWriter(new OutputStreamWriter(out, charset));
} catch (Exception e) {
......@@ -145,7 +146,8 @@ public class CreateScriptFile {
byte[] key = SHA256.getKeyPasswordHash("script", password.toCharArray());
FileStore store = FileStore.open(null, fileName, "rw", cipher, key);
store.init();
in = new FileStoreInputStream(store, null, compressionAlgorithm != null, false);
in = new FileStoreInputStream(store, null,
compressionAlgorithm != null, false);
in = new BufferedInputStream(in, Constants.IO_BUFFER_SIZE_COMPRESS);
} else {
in = FileUtils.newInputStream(fileName);
......
......@@ -56,7 +56,9 @@ public class CsvSample {
ResultSetMetaData meta = rs.getMetaData();
while (rs.next()) {
for (int i = 0; i < meta.getColumnCount(); i++) {
System.out.println(meta.getColumnLabel(i + 1) + ": " + rs.getString(i + 1));
System.out.println(
meta.getColumnLabel(i + 1) + ": " +
rs.getString(i + 1));
}
System.out.println();
}
......
......@@ -397,7 +397,8 @@ public class SQLInjection {
stat.execute("CREATE CONSTANT HASH_ITERATIONS VALUE 100");
stat.execute("CREATE CONSTANT HASH_ALGORITHM VALUE 'SHA256'");
stat.execute("UPDATE USERS2 SET " +
"HASH=HASH(HASH_ALGORITHM, STRINGTOUTF8('abc' || SALT), HASH_ITERATIONS) " +
"HASH=HASH(HASH_ALGORITHM, " +
"STRINGTOUTF8('abc' || SALT), HASH_ITERATIONS) " +
"WHERE ID=1");
String user = input("user?");
String password = input("password?");
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.bench;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.db;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.db;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.db;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.db;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.store;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.unit;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
......
......@@ -190,8 +190,8 @@ public class CheckTextFiles {
lastWasWhitespace = false;
line++;
int lineLength = i - startLinePos;
if (lineLength > MAX_SOURCE_LINE_SIZE) {
if (file.getName().endsWith(".java")) {
if (lineLength > MAX_SOURCE_LINE_SIZE) {
fail(file, "line too long: " + lineLength, line);
}
}
......
......@@ -944,7 +944,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
*/
void setMaxMemory(long maxMemory) {
if (maxMemory <= 0) {
throw new IllegalArgumentException("Max memory must be larger than 0");
throw new IllegalArgumentException(
"Max memory must be larger than 0");
}
this.maxMemory = maxMemory;
}
......@@ -957,7 +958,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
*/
void setAverageMemory(int averageMemory) {
if (averageMemory <= 0) {
throw new IllegalArgumentException("Average memory must be larger than 0");
throw new IllegalArgumentException(
"Average memory must be larger than 0");
}
this.averageMemory = averageMemory;
}
......
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: James Moger
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: James Moger
*/
package org.h2.jaqu;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论