提交 065aa507 authored 作者: Thomas Mueller's avatar Thomas Mueller

Prepare release.

上级 121598c2
......@@ -2930,7 +2930,7 @@ CHAR(65)
CONCAT(string, string [,...])
","
Combines strings.
Unlike with the operator ""||"", NULL parameters are ignored,
Unlike with the operator ""||"", NULL parameters are ignored,
and do not cause the result to become NULL.
This method returns a string.
","
......@@ -2941,7 +2941,7 @@ CONCAT(NAME, '!')
CONCAT_WS(separatorString, string, string [,...])
","
Combines strings with separator.
Unlike with the operator ""||"", NULL parameters are ignored,
Unlike with the operator ""||"", NULL parameters are ignored,
and do not cause the result to become NULL.
This method returns a string.
","
......
......@@ -53,15 +53,15 @@ Change Log
</li><li>Fix a NullPointerException when attempting to add foreign key reference to a view.
</li><li>Add sufficient ClientInfo support to our javax.sql.Connection implementation to make WebSphere happy.
</li><li>Issue 482: class LobStorageBackend$LobInputStream does not override the method InputStream.available().
</li><li>Fix corruption resulting from a mix of the "WRITE_DELAY=0" option
</li><li>Fix corruption resulting from a mix of the "WRITE_DELAY=0" option
and "SELECT DISTINCT" queries that don't fit in memory.
</li><li>Fix the combination of updating a table which contains an LOB,
</li><li>Fix the combination of updating a table which contains an LOB,
and reading from the LOB at the same time.
Previously it would throw an exception, now it works.
</li><li>Issue 484: In the H2 Console tool, all schemas starting with "INFO" where hidden.
Now they are hidden only if the database is not H2. Patch from "mgcodeact"/"cumer d"
</li><li>MySQL compatibiltity, support the "AUTO_INCREMENT=3" part of the CREATE TABLE statement.
</li><li>Issue 486: MySQL compatibiltity, support the "DEFAULT CHARSET" part of the CREATE TABLE statement.
</li><li>MySQL compatibility, support the "AUTO_INCREMENT=3" part of the CREATE TABLE statement.
</li><li>Issue 486: MySQL compatibility, support the "DEFAULT CHARSET" part of the CREATE TABLE statement.
</li><li>Issue 487: support the MySQL "SET foreign_key_checks = 0" command
</li><li>Issue 490: support MySQL "USING BTREE" index declaration
</li><li>Issue 485: Database get corrupted when column is renamed for which check constraint was defined inside create table statement.
......
......@@ -28,7 +28,7 @@ public interface AggregateFunction {
* the input data. The method should check here if the number of parameters
* passed is correct, and if not it should throw an exception.
*
* @param inputTypes the SQL type of the parameters, {@link java.sql.Types}
* @param inputTypes the SQL type of the parameters, {@link java.sql.Types}
* @return the SQL type of the result
*/
int getType(int[] inputTypes) throws SQLException;
......
......@@ -47,7 +47,8 @@ public class AlterTableRenameColumn extends DefineCommand {
Database db = session.getDatabase();
session.getUser().checkRight(table, Right.ALL);
table.checkSupportAlter();
// we need to update CHECK constraint since it might reference the name of the column
// we need to update CHECK constraint
// since it might reference the name of the column
Expression newCheckExpr = column.getCheckConstraint(session, newName);
table.renameColumn(column, newName);
column.removeCheckConstraint();
......
......@@ -280,7 +280,7 @@ public class Database implements DataHandler {
public void exceptionThrown(Exception e) {
setBackgroundException(DbException.convert(e));
}
});
}
......@@ -1819,7 +1819,7 @@ public class Database implements DataHandler {
}
session.setAllCommitted();
}
private void throwLastBackgroundException() {
if (backgroundException != null) {
// we don't care too much about concurrency here,
......@@ -1832,7 +1832,7 @@ public class Database implements DataHandler {
}
}
}
public void setBackgroundException(DbException e) {
if (backgroundException == null) {
backgroundException = e;
......
......@@ -28,48 +28,48 @@ public class DataUtils {
* An error occurred while reading from the file.
*/
public static final int ERROR_READING_FAILED = 1;
/**
* An error occurred when trying to write to the file.
*/
public static final int ERROR_WRITING_FAILED = 2;
/**
* An internal error occurred. This could be a bug, or a memory corruption
* (for example caused by out of memory).
*/
public static final int ERROR_INTERNAL = 3;
/**
* The object is already closed.
*/
public static final int ERROR_CLOSED = 4;
/**
* The file format is not supported.
*/
public static final int ERROR_UNSUPPORTED_FORMAT = 5;
/**
* The file is corrupt or (for encrypted files) the encryption key is wrong.
*/
public static final int ERROR_FILE_CORRUPT = 6;
/**
* The file is locked.
*/
public static final int ERROR_FILE_LOCKED = 7;
/**
* An error occurred when serializing or de-serializing.
*/
public static final int ERROR_SERIALIZATION = 8;
/**
* The transaction store is corrupt.
*/
public static final int ERROR_TRANSACTION_CORRUPT = 100;
/**
* A lock timeout occurred.
*/
......@@ -687,6 +687,7 @@ public class DataUtils {
/**
* Create a new IllegalStateException.
*
* @param errorCode the error code
* @param message the message
* @param arguments the arguments
* @return the exception
......@@ -708,7 +709,7 @@ public class DataUtils {
}
return e;
}
private static String formatMessage(int errorCode, String message, Object... arguments) {
// convert arguments to strings, to avoid locale specific formatting
for (int i = 0; i < arguments.length; i++) {
......@@ -717,15 +718,15 @@ public class DataUtils {
arguments[i] = a == null ? "null" : a.toString();
}
}
return MessageFormat.format(message, arguments) +
return MessageFormat.format(message, arguments) +
" [" + Constants.VERSION_MAJOR + "." +
Constants.VERSION_MINOR + "." + Constants.BUILD_ID +
"/" + errorCode + "]";
Constants.VERSION_MINOR + "." + Constants.BUILD_ID +
"/" + errorCode + "]";
}
/**
* Get the error code from an exception message.
*
*
* @param m the message
* @return the error code, or 0 if none
*/
......
......@@ -19,20 +19,20 @@ public class FreeSpaceBitSet {
* The first usable block.
*/
private final int firstFreeBlock;
/**
* The block size in bytes.
*/
private final int blockSize;
/**
* The bit set.
*/
private final BitSet set = new BitSet();
/**
* Create a new free space map.
*
*
* @param firstFreeBlock the first free block
* @param blockSize the block size
*/
......@@ -41,7 +41,7 @@ public class FreeSpaceBitSet {
this.blockSize = blockSize;
clear();
}
/**
* Reset the list.
*/
......@@ -49,10 +49,10 @@ public class FreeSpaceBitSet {
set.clear();
set.set(0, firstFreeBlock);
}
/**
* Check whether one of the blocks is in use.
*
*
* @param pos the position in bytes
* @param length the number of bytes
* @return true if a block is in use
......@@ -67,10 +67,10 @@ public class FreeSpaceBitSet {
}
return true;
}
/**
* Check whether one of the blocks is free.
*
*
* @param pos the position in bytes
* @param length the number of bytes
* @return true if a block is free
......@@ -99,48 +99,48 @@ public class FreeSpaceBitSet {
int end = set.nextSetBit(start + 1);
if (end < 0 || end - start >= blocks) {
set.set(start, start + blocks);
return getPos(start);
return getPos(start);
}
i = end;
}
}
/**
* Mark the space as in use.
*
*
* @param pos the position in bytes
* @param length the number of bytes
*/
public synchronized void markUsed(long pos, int length) {
int start = getBlock(pos);
int blocks = getBlockCount(length);
int blocks = getBlockCount(length);
set.set(start, start + blocks);
}
/**
* Mark the space as free.
*
*
* @param pos the position in bytes
* @param length the number of bytes
*/
public synchronized void free(long pos, int length) {
int start = getBlock(pos);
int blocks = getBlockCount(length);
int blocks = getBlockCount(length);
set.clear(start, start + blocks);
}
private long getPos(int block) {
return (long) block * (long) blockSize;
}
private int getBlock(long pos) {
return (int) (pos / blockSize);
}
private int getBlockCount(int length) {
return MathUtils.roundUpInt(length, blockSize) / blockSize;
}
@Override
public String toString() {
StringBuilder buff = new StringBuilder("[");
......
......@@ -161,7 +161,7 @@ public class MVStore {
*/
private final ConcurrentHashMap<Integer, Chunk> chunks =
new ConcurrentHashMap<Integer, Chunk>();
/**
* The free spaces between the chunks. The first block to use is block 2
* (the first two blocks are the file header).
......@@ -235,7 +235,7 @@ public class MVStore {
* The delay in milliseconds to automatically store changes.
*/
private int writeDelay = 1000;
private ExceptionListener backgroundExceptionListener;
MVStore(HashMap<String, Object> config) {
......@@ -441,7 +441,7 @@ public class MVStore {
/**
* Open the store.
*
*
* @throws IllegalStateException if the file is corrupt, or an exception
* occurred while opening
* @throws IllegalArgumentException if the directory does not exist
......@@ -932,7 +932,7 @@ public class MVStore {
int chunkLength = buff.position();
// round to the next block,
// round to the next block,
// and one additional block for the file header
int length = MathUtils.roundUpInt(chunkLength, BLOCK_SIZE) + BLOCK_SIZE;
if (length > buff.capacity()) {
......@@ -972,7 +972,7 @@ public class MVStore {
buff.position(0);
fileWriteCount++;
DataUtils.writeFully(file, filePos, buff);
fileSize = Math.max(fileSize, filePos + buff.position());
if (buff.capacity() <= 4 * 1024 * 1024) {
writeBuffer = buff;
......@@ -1457,10 +1457,11 @@ public class MVStore {
}
return v;
}
/**
* Set the listener to be used for exceptions that occur in the background thread.
*
* Set the listener to be used for exceptions that occur in the background
* thread.
*
* @param backgroundExceptionListener the listener
*/
public void setBackgroundExceptionListener(
......@@ -1804,7 +1805,7 @@ public class MVStore {
/**
* Set the read cache size in MB.
*
*
* @param mb the cache size in MB.
*/
public void setCacheSize(long mb) {
......
......@@ -31,10 +31,10 @@ import org.h2.util.New;
* A table engine that internally uses the MVStore.
*/
public class MVTableEngine implements TableEngine {
/**
* Initialize the MVStore.
*
*
* @param db the database
* @return the store
*/
......@@ -197,7 +197,7 @@ public class MVTableEngine implements TableEngine {
public void initTransactions() {
List<Transaction> list = transactionStore.getOpenTransactions();
for (Transaction t : list) {
if (t.getStatus() == Transaction.STATUS_COMITTING) {
if (t.getStatus() == Transaction.STATUS_COMMITTING) {
t.commit();
} else if (t.getStatus() != Transaction.STATUS_PREPARED) {
t.rollback();
......
......@@ -45,7 +45,7 @@ public class TransactionStore {
/**
* The undo log.
* If the first entry for a transaction doesn't have a logId of 0, then
* the transaction is committing (partially committed).
* the transaction is committing (partially committed).
* Key: [ transactionId, logId ], value: [ opType, mapId, key, oldValue ].
*/
final MVMap<long[], Object[]> undoLog;
......@@ -147,7 +147,7 @@ public class TransactionStore {
if (undoLog.containsKey(key)) {
status = Transaction.STATUS_OPEN;
} else {
status = Transaction.STATUS_COMITTING;
status = Transaction.STATUS_COMMITTING;
}
name = null;
} else {
......@@ -239,7 +239,7 @@ public class TransactionStore {
return;
}
synchronized (undoLog) {
t.setStatus(Transaction.STATUS_COMITTING);
t.setStatus(Transaction.STATUS_COMMITTING);
for (long logId = 0; logId < maxLogId; logId++) {
commitIfNeeded();
long[] undoKey = new long[] { t.getId(), logId };
......@@ -504,7 +504,7 @@ public class TransactionStore {
* closed while the transaction is committing. When opening a store,
* such transactions should be committed.
*/
public static final int STATUS_COMITTING = 3;
public static final int STATUS_COMMITTING = 3;
/**
* The operation type for changes in a map.
......
......@@ -8,6 +8,7 @@ package org.h2.mvstore.rtree;
import java.util.ArrayList;
import java.util.Iterator;
import org.h2.mvstore.CursorPos;
import org.h2.mvstore.DataUtils;
import org.h2.mvstore.MVMap;
......@@ -61,7 +62,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
* @param x the rectangle
* @return the iterator
*/
public Iterator<SpatialKey> findIntersectingKeys(SpatialKey x) {
public RTreeCursor findIntersectingKeys(SpatialKey x) {
checkOpen();
return new RTreeCursor(root, x) {
@Override
......@@ -77,7 +78,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
* @param x the rectangle
* @return the iterator
*/
public Iterator<SpatialKey> findContainedKeys(SpatialKey x) {
public RTreeCursor findContainedKeys(SpatialKey x) {
checkOpen();
return new RTreeCursor(root, x) {
@Override
......@@ -483,7 +484,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
* A cursor to iterate over a subset of the keys.
*/
static class RTreeCursor implements Iterator<SpatialKey> {
private final SpatialKey filter;
private CursorPos pos;
private SpatialKey current;
......@@ -494,7 +495,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
this.root = root;
this.filter = filter;
}
@Override
public boolean hasNext() {
if (!initialized) {
......@@ -505,7 +506,13 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
}
return current != null;
}
/**
* Skip over that many entries. This method is relatively fast (for this map
* implementation) even if many entries need to be skipped.
*
* @param n the number of entries to skip
*/
public void skip(long n) {
while (hasNext() && n-- > 0) {
fetchNext();
......@@ -521,13 +528,13 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
fetchNext();
return c;
}
@Override
public void remove() {
throw DataUtils.newUnsupportedOperationException(
"Removing is not supported");
}
/**
* Fetch the next entry if there is one.
*/
......@@ -563,7 +570,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
}
current = null;
}
// if(pos==null || pos.page != p) {
// pos = new CursorPos(p, i + 1, pos);
// } else {
......@@ -574,8 +581,8 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
// break;
// }
// }
//
//
// if (pos.index < pos.page.getKeyCount()) {
// pos.index++;
// }
......@@ -645,13 +652,13 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
// }
// }
// }
// }
//
// }
//
// @Override
// protected void min(Page p, SpatialKey x) {
// // x
// }
//
//
// protected void min3(Page p, SpatialKey x) {
// while (true) {
// if (p.isLeaf()) {
......@@ -698,7 +705,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
// }
// current = null;
// }
}
@Override
......
......@@ -153,7 +153,8 @@ public class ResultTempTable implements ResultExternal {
}
try {
Database database = session.getDatabase();
// Need to lock because not all of the code-paths that reach here have already taken this lock,
// Need to lock because not all of the code-paths
// that reach here have already taken this lock,
// notably via the close() paths.
synchronized (session) {
synchronized (database) {
......
......@@ -597,7 +597,7 @@ public class PgServerThread implements Runnable {
}
}
}
private static void checkParamLength(int expected, int got) {
if (expected != got) {
throw DbException.getInvalidValueException("paramLen", got);
......
......@@ -61,7 +61,7 @@ public class LobStorageBackend implements LobStorageInterface {
JdbcConnection conn;
final Database database;
private final HashMap<String, PreparedStatement> prepared = New.hashMap();
private long nextBlock;
private final CompressTool compress = CompressTool.getInstance();
......@@ -156,7 +156,7 @@ public class LobStorageBackend implements LobStorageInterface {
/**
* Remove all LOBs for this table.
*
*
* @param tableId the table id
*/
public void removeAllForTable(int tableId) {
......@@ -185,7 +185,7 @@ public class LobStorageBackend implements LobStorageInterface {
/**
* Read a block of data from the given LOB.
*
*
* @param block the block number
* @return the block (expanded if stored compressed)
*/
......@@ -217,7 +217,7 @@ public class LobStorageBackend implements LobStorageInterface {
* Retrieve the sequence id and position that is smaller than the requested
* position. Those values can be used to quickly skip to a given position
* without having to read all data.
*
*
* @param lob the lob
* @param pos the required position
* @return null if the data is not available, or an array of two elements:
......@@ -244,6 +244,12 @@ public class LobStorageBackend implements LobStorageInterface {
}
}
/**
* Create a prepared statement, or re-use an existing one.
*
* @param sql the SQL statement
* @return the prepared statement
*/
PreparedStatement prepare(String sql) throws SQLException {
if (SysProperties.CHECK2) {
if (!Thread.holdsLock(database)) {
......@@ -257,6 +263,12 @@ public class LobStorageBackend implements LobStorageInterface {
return prep;
}
/**
* Allow to re-use the prepared statement.
*
* @param sql the SQL statement
* @param prep the prepared statement
*/
void reuse(String sql, PreparedStatement prep) {
if (SysProperties.CHECK2) {
if (!Thread.holdsLock(database)) {
......@@ -465,7 +477,7 @@ public class LobStorageBackend implements LobStorageInterface {
/**
* Store a block in the LOB storage.
*
*
* @param lobId the lob id
* @param seq the sequence number
* @param pos the position within the lob
......@@ -572,12 +584,12 @@ public class LobStorageBackend implements LobStorageInterface {
* to the table that contains the LOB column from changing the data under us.
*/
private final long[] lobMapBlocks;
/**
* index into the lobMapBlocks array.
*/
private int lobMapIndex;
/**
* The remaining bytes in the lob.
*/
......@@ -612,7 +624,7 @@ public class LobStorageBackend implements LobStorageInterface {
reuse(sql, prep);
}
this.remainingBytes = byteCount;
String sql = "SELECT COUNT(*) FROM " + LOB_MAP + " WHERE LOB = ?";
PreparedStatement prep = prepare(sql);
prep.setLong(1, lobId);
......
......@@ -563,11 +563,14 @@ public class Column {
checkConstraintSQL = getCheckConstraintSQL(session, name);
}
/**
* Remove the check constraint if there is one.
*/
public void removeCheckConstraint() {
checkConstraint = null;
checkConstraintSQL = null;
}
/**
* Get the check constraint expression for this column if set.
*
......
......@@ -28,7 +28,7 @@ public abstract class TableBase extends Table {
private final String tableEngine;
/** Provided table parameters */
private List<String> tableEngineParams = new ArrayList<String>();
private final boolean globalTemporary;
public TableBase(CreateTableData data) {
......
......@@ -211,12 +211,13 @@ public class SourceCompiler {
ByteArrayOutputStream buff = new ByteArrayOutputStream();
try {
ProcessBuilder builder = new ProcessBuilder();
// The javac executable allows some of it's flags to be smuggled in via environment variables.
// But if it sees those flags, it will write out a message to stderr, which messes up our
// parsing of the output.
// The javac executable allows some of it's flags
// to be smuggled in via environment variables.
// But if it sees those flags, it will write out a message
// to stderr, which messes up our parsing of the output.
builder.environment().remove("JAVA_TOOL_OPTIONS");
builder.command(args);
Process p = builder.start();
copyInThread(p.getInputStream(), buff);
copyInThread(p.getErrorStream(), buff);
......
......@@ -40,20 +40,20 @@ import org.h2.util.Utils;
* and can convert between Java objects and Values.
*/
public class DataType {
/**
* This constant is used to represent the type of a ResultSet. There is no
* equivalent java.sql.Types value, but Oracle uses it to represent a
* ResultSet (OracleTypes.CURSOR = -10).
*/
public static final int TYPE_RESULT_SET = -10;
/**
* The Geometry class. This object is null if the jts jar file is not in the
* classpath.
*/
public static final Class<?> GEOMETRY_CLASS;
private static final String GEOMETRY_CLASS_NAME = "com.vividsolutions.jts.geom.Geometry";
/**
......@@ -169,7 +169,7 @@ public class DataType {
* The number of bytes required for an object.
*/
public int memory;
static {
Class<?> g;
try {
......@@ -960,7 +960,7 @@ public class DataType {
return ValueJavaObject.getNoCopy(x, null);
}
}
private static boolean isGeometry(Object x) {
if (x == null || GEOMETRY_CLASS == null) {
return false;
......
......@@ -41,7 +41,7 @@ public class ValueGeometry extends Value {
public static ValueGeometry getFromGeometry(Object o) {
return get((Geometry) o);
}
private static ValueGeometry get(Geometry g) {
return (ValueGeometry) Value.cache(new ValueGeometry(g));
}
......
......@@ -128,7 +128,7 @@ public class TestAlter extends TestBase {
execute("insert into test values(3)");
stat.execute("drop table test");
}
private void testAlterTableDropIdentityColumn() throws SQLException {
stat.execute("create table test(id int auto_increment, name varchar)");
stat.execute("alter table test drop column id");
......
......@@ -101,7 +101,7 @@ public class TestCases extends TestBase {
testBinaryCollation();
deleteDb("cases");
}
private void testEmptyStatements() throws SQLException {
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......
......@@ -272,7 +272,7 @@ public class TestCompatibility extends TestBase {
// this maps to SET REFERENTIAL_INTEGRITY TRUE/FALSE
stat.execute("SET foreign_key_checks = 0");
stat.execute("SET foreign_key_checks = 1");
// Check if mysql comments are supported, ensure clean connection
conn.close();
conn = getConnection("compatibility;MODE=MYSQL");
......
......@@ -1473,5 +1473,5 @@ public class TestLob extends TestBase {
r.close();
conn.close();
}
}
}
......@@ -83,7 +83,7 @@ public class TestTableEngines extends TestBase {
assertEquals("param2", EndlessTableEngine.createTableData.tableEngineParams.get(1));
conn.close();
if (!config.memory) {
// Test serialisation of table parameters
// Test serialization of table parameters
EndlessTableEngine.createTableData.tableEngineParams.clear();
conn = getConnection("tableEngine");
assertEquals(2, EndlessTableEngine.createTableData.tableEngineParams.size());
......
......@@ -16,12 +16,12 @@ import org.h2.util.MathUtils;
* A list that maintains ranges of free space (in blocks).
*/
public class FreeSpaceList {
/**
* The first usable block.
*/
private final int firstFreeBlock;
/**
* The block size in bytes.
*/
......@@ -43,10 +43,10 @@ public class FreeSpaceList {
*/
public synchronized void clear() {
freeSpaceList.clear();
freeSpaceList.add(new BlockRange(firstFreeBlock,
freeSpaceList.add(new BlockRange(firstFreeBlock,
Integer.MAX_VALUE - firstFreeBlock));
}
/**
* Allocate a number of blocks and mark them as used.
*
......@@ -67,6 +67,12 @@ public class FreeSpaceList {
"Could not find a free page to allocate");
}
/**
* Mark the space as in use.
*
* @param pos the position in bytes
* @param length the number of bytes
*/
public synchronized void markUsed(long pos, int length) {
int start = (int) (pos / blockSize);
int required = getBlockCount(length);
......@@ -112,6 +118,12 @@ public class FreeSpaceList {
}
}
/**
* Mark the space as free.
*
* @param pos the position in bytes
* @param length the number of bytes
*/
public synchronized void free(long pos, int length) {
int start = (int) (pos / blockSize);
int required = getBlockCount(length);
......@@ -158,7 +170,7 @@ public class FreeSpaceList {
BlockRange newRange = new BlockRange(start, required);
freeSpaceList.add(i, newRange);
}
private int getBlockCount(int length) {
if (length <= 0) {
throw DataUtils.newIllegalStateException(
......@@ -199,7 +211,7 @@ public class FreeSpaceList {
}
return start + "-" + (start + length - 1);
}
}
}
......@@ -15,12 +15,12 @@ import org.h2.util.MathUtils;
* A list that maintains ranges of free space (in blocks) in a file.
*/
public class FreeSpaceTree {
/**
* The first usable block.
*/
private final int firstFreeBlock;
/**
* The block size in bytes.
*/
......@@ -45,7 +45,7 @@ public class FreeSpaceTree {
*/
public synchronized void clear() {
freeSpace.clear();
freeSpace.add(new BlockRange(firstFreeBlock,
freeSpace.add(new BlockRange(firstFreeBlock,
Integer.MAX_VALUE - firstFreeBlock));
}
......@@ -73,7 +73,13 @@ public class FreeSpaceTree {
}
return pos;
}
/**
* Mark the space as in use.
*
* @param pos the position in bytes
* @param length the number of bytes
*/
public synchronized void markUsed(long pos, int length) {
int start = getBlock(pos);
int blocks = getBlockCount(length);
......@@ -103,7 +109,13 @@ public class FreeSpaceTree {
prev.blocks = start - prev.start;
}
}
/**
* Mark the space as free.
*
* @param pos the position in bytes
* @param length the number of bytes
*/
public synchronized void free(long pos, int length) {
int start = getBlock(pos);
int blocks = getBlockCount(length);
......@@ -134,15 +146,15 @@ public class FreeSpaceTree {
}
freeSpace.add(x);
}
private long getPos(int block) {
return (long) block * (long) blockSize;
}
private int getBlock(long pos) {
return (int) (pos / blockSize);
}
private int getBlockCount(int length) {
if (length <= 0) {
throw DataUtils.newIllegalStateException(
......@@ -175,7 +187,7 @@ public class FreeSpaceTree {
this.start = start;
this.blocks = blocks;
}
@Override
public int compareTo(BlockRange o) {
return start < o.start ? -1 : start > o.start ? 1 : 0;
......
......@@ -81,7 +81,7 @@ public class TestDataUtils extends TestBase {
assertEquals("1,2", m.get("c"));
assertEquals("\"test\"", m.get("d"));
}
private void testMapRandomized() {
Random r = new Random(1);
String chars = "a_1,\\\":";
......
......@@ -26,20 +26,20 @@ public class TestFreeSpace extends TestBase {
testMemoryUsage();
testPerformance();
}
@Override
public void test() throws Exception {
testSimple();
testRandomized();
}
private static void testPerformance() {
for (int i = 0; i < 10; i++) {
long t = System.currentTimeMillis();
FreeSpaceBitSet f = new FreeSpaceBitSet(0, 4096);
// 75 ms
// FreeSpaceList f = new FreeSpaceList(0, 4096);
// 13868 ms
......@@ -58,18 +58,18 @@ public class TestFreeSpace extends TestBase {
System.out.println(System.currentTimeMillis() - t);
}
}
private static void testMemoryUsage() {
// 16 GB file size
long size = 16L * 1024 * 1024 * 1024;
System.gc();
System.gc();
long first = Utils.getMemoryUsed();
long first = Utils.getMemoryUsed();
FreeSpaceBitSet f = new FreeSpaceBitSet(0, 4096);
// 512 KB
// FreeSpaceTree f = new FreeSpaceTree(0, 4096);
// 64 MB
......@@ -105,7 +105,7 @@ public class TestFreeSpace extends TestBase {
assertEquals(f1.toString(), f2.toString());
assertEquals(f1.toString(), f3.toString());
}
private void testRandomized() {
FreeSpaceBitSet f1 = new FreeSpaceBitSet(2, 8);
FreeSpaceList f2 = new FreeSpaceList(2, 8);
......
......@@ -273,7 +273,7 @@ public class TestMVRTree extends TestMVStore {
testRandom(true);
testRandom(false);
}
private void testRandomFind() {
MVStore s = openStore(null);
MVRTreeMap<Integer> m = s.openMap("data",
......@@ -284,7 +284,7 @@ public class TestMVRTree extends TestMVStore {
int id = x * max + y;
SpatialKey k = new SpatialKey(id, x, x, y, y);
m.put(k, id);
}
}
}
Random rand = new Random(1);
int operationCount = 1000;
......@@ -316,7 +316,7 @@ public class TestMVRTree extends TestMVStore {
count++;
}
assertEquals(intersecting, count);
}
}
}
private void testRandom(boolean quadraticSplit) {
......
......@@ -266,7 +266,7 @@ public class TestMVStore extends TestBase {
encryptionKey(passwordChars).open();
fail();
} catch (IllegalStateException e) {
assertEquals(DataUtils.ERROR_FILE_CORRUPT,
assertEquals(DataUtils.ERROR_FILE_CORRUPT,
DataUtils.getErrorCode(e.getMessage()));
}
assertEquals(0, passwordChars[0]);
......
......@@ -88,7 +88,7 @@ public class TestMVTableEngine extends TestBase {
}
}
}
private void testTwoPhaseCommit() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
......@@ -204,7 +204,7 @@ public class TestMVTableEngine extends TestBase {
stat.execute("insert into test values(1)");
stat.execute("shutdown immediately");
JdbcUtils.closeSilently(conn);
conn = getConnection(url);
stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select row_count_estimate " +
......
......@@ -55,7 +55,7 @@ public class TestTransactionStore extends TestBase {
testSingleConnection();
testCompareWithPostgreSQL();
}
private void testStopWhileCommitting() throws Exception {
String fileName = getBaseDir() + "/testStopWhileCommitting.h3";
FileUtils.delete(fileName);
......@@ -106,7 +106,7 @@ public class TestTransactionStore extends TestBase {
List<Transaction> list = ts.getOpenTransactions();
if (list.size() != 0) {
tx = list.get(0);
if (tx.getStatus() == Transaction.STATUS_COMITTING) {
if (tx.getStatus() == Transaction.STATUS_COMMITTING) {
i++;
}
}
......@@ -116,7 +116,7 @@ public class TestTransactionStore extends TestBase {
FileUtils.delete(fileName);
assertFalse(FileUtils.exists(fileName));
s.close();
FileUtils.delete(fileName);
FileUtils.delete(fileName);
}
}
......
......@@ -566,7 +566,7 @@ public class TestFileLockSerialized extends TestBase {
stat.execute("insert into test values(" + i + ", " + i + ")");
}
importFinishedLatch.countDown();
select1FinishedLatch.await();
stat.execute("update test set id2=999 where id=500");
......@@ -601,7 +601,7 @@ public class TestFileLockSerialized extends TestBase {
}
};
selectTask.execute();
importUpdateTask.get();
selectTask.get();
deleteDb("fileLockSerialized");
......
......@@ -46,7 +46,7 @@ public class TestPgServer extends TestBase {
testCancelQuery();
testBinaryTypes();
}
private boolean getPgJdbcDriver() {
try {
Class.forName("org.postgresql.Driver");
......@@ -146,7 +146,7 @@ public class TestPgServer extends TestBase {
prep.setNull(1, Types.VARCHAR);
rs = prep.executeQuery();
assertFalse(rs.next());
prep = conn.prepareStatement("insert into test values(?, ?)");
ParameterMetaData meta = prep.getParameterMetaData();
assertEquals(2, meta.getParameterCount());
......@@ -314,7 +314,7 @@ public class TestPgServer extends TestBase {
if (!getPgJdbcDriver()) {
return;
}
Server server = Server.createPgServer("-pgPort", "5535", "-pgDaemon", "-key", "test", "mem:test");
server.start();
try {
......
......@@ -524,8 +524,8 @@ public class Build extends BuildBase {
mkdir("docs/javadoc");
javadoc("-sourcepath", "src/main", "org.h2.jdbc", "org.h2.jdbcx",
"org.h2.tools", "org.h2.api", "org.h2.constant", "org.h2.fulltext",
"-classpath",
"ext/" + getLuceneJar() +
"-classpath",
"ext/" + getLuceneJar() +
File.pathSeparator + "ext/jts-1.13.jar",
"-docletpath", "bin" + File.pathSeparator + "temp",
"-doclet", "org.h2.build.doclet.Doclet");
......
......@@ -730,7 +730,6 @@ customizers retains scalability assuming gili cancelled departments juerg
franklin indicated offending unimplemented executors dumping variants
presence spiess azeckoski aaron cowwoc decompiles canceling vividsolutions
quadtree envelope geometry polygon typname intersects wkt intersects wkb
coordinate geometric rates cope attempting sphere hyde clinton
computation varies
coordinate geometric rates cope attempting sphere hyde clinton taskkill
mgcodeact cumer reach notably computation varies smuggled stderr sees messes
nico devel
......@@ -19,7 +19,7 @@ public class JavaProcessKiller {
/**
* Kill a certain Java process. The JDK (jps) needs to be in the path.
*
*
* @param args the Java process name as listed by jps -l. If not set the
* Java processes are listed
*/
......@@ -27,7 +27,7 @@ public class JavaProcessKiller {
public static void main(String... args) {
new JavaProcessKiller().run(args);
}
private void run(String... args) {
TreeMap<Integer, String> map = getProcesses();
System.out.println("Processes:");
......@@ -67,7 +67,7 @@ public class JavaProcessKiller {
System.out.println("Processes now:");
System.out.println(map);
}
private static TreeMap<Integer, String> getProcesses() {
String processList = exec("jps", "-l");
String[] processes = processList.split("\n");
......@@ -83,7 +83,7 @@ public class JavaProcessKiller {
}
return map;
}
private static String exec(String... args) {
ByteArrayOutputStream err = new ByteArrayOutputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
......@@ -122,5 +122,5 @@ public class JavaProcessKiller {
}
}.run();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论