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

Documentation.

上级 43701f3f
......@@ -155,8 +155,8 @@ NODATA will not emit INSERT statements.
If the DROP option is specified, drop statements are created for tables, views,
and sequences. If the block size is set, CLOB and BLOB values larger than this
size are split into separate blocks.
BLOCKSIZE is used when writing out LOB data, and specifies the point at the
values transition from being inserted as inline values, to be inserted using
BLOCKSIZE is used when writing out LOB data, and specifies the point at the
values transition from being inserted as inline values, to be inserted using
out-of-line commands.
If no file name is specified, the
......@@ -1268,7 +1268,7 @@ SET LOCK_TIMEOUT 1000
"Commands (Other)","SET MAX_LENGTH_INPLACE_LOB","
SET MAX_LENGTH_INPLACE_LOB int
","
Sets the maximum size of an in-place LOB object.
Sets the maximum size of an in-place LOB object.
If the 'h2.lobInDatabase' property is true, this is the maximum length of an LOB that is stored with the record itself,
and the default value is 128.
......
......@@ -138,7 +138,7 @@ should never be used for columns with a maximum size below about 200 bytes.
The best threshold depends on the use case; reading in-place objects is faster
than reading from separate files, but slows down the performance of operations
that don't involve this column.
<p>
</p><p>
It is possible to configure the database to store LOB objects outside the database file,
see the <a href="../javadoc/org/h2/constant/SysProperties.html#h2.lobInDatabase">h2.lobInDatabase</a> property.
</p>
......
......@@ -23,7 +23,7 @@ Change Log
in a strange exception of the type "column x must be included in the group by list".
</li><li>Issue 454: Use Charset for type-safety.
</li><li>Queries with both LIMIT and OFFSET could throw an IllegalArgumentException.
</li><li>MVStore: multiple issues were fixed: 460, 461, 462.
</li><li>MVStore: multiple issues were fixed: 460, 461, 462.
</li><li>MVStore: larger stores (multiple GB) are now much faster.
</li><li>When using local temporary tables and not dropping them manually before closing the session,
and then killing the process could result in a database that couldn't be opened (except when using
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -96,8 +96,8 @@ public class CreateView extends SchemaCommand {
}
querySQL = select.getPlanSQL();
}
// The view creates a Prepared command object, which belongs to a session, so we pass
// the system session down.
// The view creates a Prepared command object, which belongs to a
// session, so we pass the system session down.
Session sysSession = db.getSystemSession();
try {
if (view == null) {
......
......@@ -265,7 +265,7 @@ public class Database implements DataHandler {
}
powerOffCount = count;
}
public MVTableEngine.Store getMvStore() {
return mvStore;
}
......
......@@ -107,7 +107,7 @@ public class Session extends SessionWithState {
private int objectId;
private final int queryCacheSize;
private SmallLRUCache<String, Command> queryCache;
private Transaction transaction;
private long startStatement = -1;
......@@ -578,15 +578,15 @@ public class Session extends SessionWithState {
}
}
}
@Override
public boolean hasPendingTransaction() {
return undoLog.size() > 0;
}
/**
* Create a savepoint to allow rolling back to this state.
*
*
* @return the savepoint
*/
public Savepoint setSavepoint() {
......@@ -1020,7 +1020,7 @@ public class Session extends SessionWithState {
public LobStorageBackend getLobStorageBackend() {
return database.getLobStorage();
}
/**
* Remember that the given LOB value must be un-linked (disconnected from
* the table) at commit.
......@@ -1334,18 +1334,18 @@ public class Session extends SessionWithState {
startStatement = -1;
closeTemporaryResults();
}
/**
* Represents a savepoint (a position in a transaction to where one can roll
* back to).
*/
public static class Savepoint {
/**
* The undo log index.
*/
int logIndex;
/**
* The transaction savepoint id.
*/
......
......@@ -67,10 +67,10 @@ public interface SessionInterface extends Closeable {
* @return the data handler
*/
DataHandler getDataHandler();
/**
* Check whether this session has a pending transaction.
*
*
* @return true if it has
*/
boolean hasPendingTransaction();
......
......@@ -1291,7 +1291,7 @@ public class MVStore {
// to support reading old versions and rollback
if (pos == 0) {
// the value could be smaller than 0 because
// in some cases a page is allocated without a store
// in some cases a page is allocated without a store
unsavedPageCount = Math.max(0, unsavedPageCount - 1);
return;
}
......
......@@ -121,7 +121,7 @@ public class MVPrimaryIndex extends BaseIndex {
}
}
}
TransactionMap<Value, Value> map = getMap(session);
Value key = ValueLong.get(row.getKey());
Value old = map.getLatest(key);
......@@ -268,7 +268,7 @@ public class MVPrimaryIndex extends BaseIndex {
// TODO estimate disk space usage
return 0;
}
public String getMapName() {
return mapName;
}
......@@ -311,7 +311,7 @@ public class MVPrimaryIndex extends BaseIndex {
TransactionMap<Value, Value> map = getMap(session);
return new MVStoreCursor(session, map.keyIterator(ValueLong.get(first)), last);
}
@Override
public boolean isRowIdIndex() {
return true;
......
......@@ -242,7 +242,7 @@ public class MVSecondaryIndex extends BaseIndex {
public void checkRename() {
// ok
}
/**
* Get the map to store the data.
*
......
......@@ -58,7 +58,7 @@ public class MVTable extends TableBase {
private int nextAnalyze;
private boolean containsLargeObject;
private Column rowIdColumn;
private final TransactionStore store;
/**
......@@ -95,7 +95,7 @@ public class MVTable extends TableBase {
rowCount = primaryIndex.getRowCount(session);
indexes.add(primaryIndex);
}
public String getMapName() {
return primaryIndex.getMapName();
}
......@@ -308,12 +308,12 @@ public class MVTable extends TableBase {
public boolean isLockedExclusively() {
return lockExclusive != null;
}
@Override
public boolean isLockedExclusivelyBy(Session session) {
return lockExclusive == session;
}
@Override
public void unlock(Session s) {
if (database != null) {
......
......@@ -88,7 +88,7 @@ public class MVTableEngine implements TableEngine {
this.transactionStore = new TransactionStore(store,
new ValueDataType(null, null, null));
}
public MVStore getStore() {
return store;
}
......@@ -96,11 +96,11 @@ public class MVTableEngine implements TableEngine {
public TransactionStore getTransactionStore() {
return transactionStore;
}
public List<MVTable> getTables() {
return openTables;
}
/**
* Store all pending changes.
*/
......@@ -111,7 +111,7 @@ public class MVTableEngine implements TableEngine {
store.store();
}
}
/**
* Close the store, without persisting changes.
*/
......
......@@ -64,7 +64,7 @@ public class TransactionStore {
private long lastTransactionIdStored;
private long lastTransactionId;
private long firstOpenTransaction = -1;
/**
......@@ -171,7 +171,7 @@ public class TransactionStore {
int status = Transaction.STATUS_OPEN;
return new Transaction(this, transactionId, status, null, 0);
}
private void commitIfNeeded() {
if (store.getUnsavedPageCount() > MAX_UNSAVED_PAGES) {
store.commit();
......@@ -190,7 +190,7 @@ public class TransactionStore {
preparedTransactions.put(t.getId(), v);
}
}
/**
* Log an entry.
*
......@@ -225,7 +225,7 @@ public class TransactionStore {
for (long logId = 0; logId < maxLogId; logId++) {
long[] undoKey = new long[] {
t.getId(), logId };
commitIfNeeded();
commitIfNeeded();
Object[] op = undoLog.get(undoKey);
int opType = (Integer) op[0];
if (opType == Transaction.OP_REMOVE) {
......@@ -247,11 +247,11 @@ public class TransactionStore {
}
endTransaction(t);
}
/**
* Check whether the given transaction id is still open and contains log
* entries.
*
*
* @param transactionId the transaction id
* @return true if it is open
*/
......@@ -273,10 +273,10 @@ public class TransactionStore {
key = undoLog.higherKey(key);
return key != null && key[0] == transactionId;
}
/**
* End this transaction
*
*
* @param t the transaction
*/
void endTransaction(Transaction t) {
......@@ -298,7 +298,7 @@ public class TransactionStore {
*/
void rollbackTo(Transaction t, long maxLogId, long toLogId) {
for (long logId = maxLogId - 1; logId >= toLogId; logId--) {
commitIfNeeded();
commitIfNeeded();
Object[] op = undoLog.get(new long[] {
t.getId(), logId });
int mapId = ((Integer) op[1]).intValue();
......@@ -319,10 +319,10 @@ public class TransactionStore {
undoLog.remove(op);
}
}
/**
* Get the set of changed maps.
*
*
* @param t the transaction
* @param maxLogId the maximum log id
* @param toLogId the minimum log id
......@@ -387,7 +387,7 @@ public class TransactionStore {
* The log id of the last entry in the undo log map.
*/
long logId;
private int status;
private String name;
......@@ -408,7 +408,7 @@ public class TransactionStore {
public int getStatus() {
return status;
}
void setStatus(int status) {
this.status = status;
}
......@@ -510,7 +510,7 @@ public class TransactionStore {
store.rollbackTo(this, logId, savepointId);
logId = savepointId;
}
/**
* Roll the transaction back. Afterwards, this transaction is closed.
*/
......@@ -519,11 +519,11 @@ public class TransactionStore {
store.rollbackTo(this, logId, 0);
store.endTransaction(this);
}
/**
* Get the set of changed maps starting at the given savepoint up to
* now.
*
*
* @param savepointId the savepoint id, 0 meaning the beginning of the
* transaction
* @return the set of changed maps
......@@ -540,7 +540,7 @@ public class TransactionStore {
throw DataUtils.newIllegalStateException("Transaction is closed");
}
}
/**
* Check whether this transaction is open or prepared.
*/
......@@ -567,7 +567,7 @@ public class TransactionStore {
* Value: { transactionId, oldVersion, value }
*/
final MVMap<K, VersionedValue> map;
private Transaction transaction;
private final int mapId;
......@@ -589,26 +589,26 @@ public class TransactionStore {
map = transaction.store.store.openMap(name, builder);
mapId = map.getId();
}
private TransactionMap(Transaction transaction, MVMap<K, VersionedValue> map, int mapId) {
this.transaction = transaction;
this.map = map;
this.mapId = mapId;
}
/**
* Set the savepoint. Afterwards, reads are based on the specified
* savepoint.
*
*
* @param savepoint the savepoint
*/
public void setSavepoint(long savepoint) {
this.readLogId = savepoint;
}
/**
* Get a clone of this map for the given transaction.
*
*
* @param transaction the transaction
* @param savepoint the savepoint
* @return the map
......@@ -858,7 +858,7 @@ public class TransactionStore {
VersionedValue data = getValue(key, maxLogId);
return data == null ? null : (V) data.value;
}
private VersionedValue getValue(K key, long maxLog) {
VersionedValue data = map.get(key);
while (true) {
......@@ -954,11 +954,11 @@ public class TransactionStore {
return new Iterator<K>() {
private final Cursor<K> cursor = map.keyIterator(from);
private K current;
{
fetchNext();
}
private void fetchNext() {
while (cursor.hasNext()) {
current = cursor.next();
......@@ -1029,40 +1029,40 @@ public class TransactionStore {
}
}
/**
* A versioned value (possibly null). It contains a pointer to the old
* value, and the value itself.
*/
static class VersionedValue {
/**
* The transaction id.
*/
public long transactionId;
/**
* The log id.
*/
public long logId;
/**
* The value.
*/
public Object value;
}
/**
* The value type for a versioned value.
*/
public static class VersionedValueType implements DataType {
private final DataType valueType;
VersionedValueType(DataType valueType) {
this.valueType = valueType;
}
@Override
public int getMemory(Object obj) {
VersionedValue v = (VersionedValue) obj;
......@@ -1101,8 +1101,8 @@ public class TransactionStore {
v.logId = DataUtils.readVarLong(buff);
v.value = valueType.read(buff);
return v;
}
}
}
/**
......
......@@ -15,7 +15,7 @@ public interface DataType {
/**
* Compare two keys.
*
*
* @param a the first key
* @param b the second key
* @return -1 if the first key is smaller, 1 if larger, and 0 if equal
......
......@@ -141,7 +141,7 @@ public class Sequence extends SchemaObjectBase {
value = realValue;
}
}
/**
* Flush the current value to disk and close this object.
*/
......
......@@ -59,7 +59,7 @@ public class LobStorageBackend implements LobStorageInterface {
* bytes), therefore, the size 4096 means 64 KB.
*/
private static final int HASH_CACHE_SIZE = 4 * 1024;
private Connection conn;
private final HashMap<String, PreparedStatement> prepared = New.hashMap();
private long nextBlock;
......@@ -559,7 +559,7 @@ public class LobStorageBackend implements LobStorageInterface {
}
}
}
/**
* An input stream that reads from a LOB.
*/
......@@ -697,7 +697,7 @@ public class LobStorageBackend implements LobStorageInterface {
}
}
/**
* An input stream that reads the data from a reader.
*/
......
......@@ -21,7 +21,7 @@ import org.h2.value.ValueLobDb;
* This is the front-end i.e. the client side of the LOB storage.
*/
public class LobStorageFrontend implements LobStorageInterface {
/**
* The table id for session variables (LOBs not assigned to a table).
*/
......@@ -45,9 +45,10 @@ public class LobStorageFrontend implements LobStorageInterface {
*/
@Override
public void removeLob(long lob) {
// TODO this should not be called at all, but that's a refactoring for another day
// TODO this should not be called at all,
// but that's a refactoring for another day
}
/**
* Get the input stream for the given lob.
*
......@@ -68,7 +69,7 @@ public class LobStorageFrontend implements LobStorageInterface {
public ValueLobDb copyLob(int type, long oldLobId, int tableId, long length) {
throw new UnsupportedOperationException();
}
@Override
public void setTable(long lobId, int tableIdSessionVariable) {
throw new UnsupportedOperationException();
......@@ -102,7 +103,7 @@ public class LobStorageFrontend implements LobStorageInterface {
}
return ValueLob.createClob(reader, maxLength, handler);
}
/**
* Create a LOB object that fits in memory.
......
/*
* 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.store;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import org.h2.value.Value;
import org.h2.value.ValueLobDb;
/**
* A mechanism to store and retrieve lob data.
*/
public interface LobStorageInterface {
/**
* Create a CLOB object.
*
* @param reader the reader
* @param maxLength the maximum length (-1 if not known)
* @return the LOB
*/
Value createClob(Reader reader, long maxLength);
/**
* Create a BLOB object.
*
* @param in the input stream
* @param maxLength the maximum length (-1 if not known)
* @return the LOB
*/
Value createBlob(InputStream in, long maxLength);
/**
* Copy a lob.
*
* @param type the type
* @param oldLobId the old lob id
* @param tableId the new table id
* @param length the length
* @return the new lob
*/
ValueLobDb copyLob(int type, long oldLobId, int tableId, long length);
/**
* Get the input stream for the given lob.
*
* @param lobId the lob id
* @param hmac the message authentication code (for remote input streams)
* @param byteCount the number of bytes to read, or -1 if not known
* @return the stream
*/
InputStream getInputStream(long lobId, byte[] hmac, long byteCount) throws IOException;
/**
* Set the table reference of this lob.
*
* @param lobId the lob
* @param table the table
*/
void setTable(long lobId, int table);
/**
* Delete a LOB from the database.
*
* @param lob the lob id
*/
void removeLob(long lob);
}
/*
* 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.store;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import org.h2.value.Value;
import org.h2.value.ValueLobDb;
/**
* A mechanism to store and retrieve lob data.
*/
public interface LobStorageInterface {
/**
* Create a CLOB object.
*
* @param reader the reader
* @param maxLength the maximum length (-1 if not known)
* @return the LOB
*/
Value createClob(Reader reader, long maxLength);
/**
* Create a BLOB object.
*
* @param in the input stream
* @param maxLength the maximum length (-1 if not known)
* @return the LOB
*/
Value createBlob(InputStream in, long maxLength);
/**
* Copy a lob.
*
* @param type the type
* @param oldLobId the old lob id
* @param tableId the new table id
* @param length the length
* @return the new lob
*/
ValueLobDb copyLob(int type, long oldLobId, int tableId, long length);
/**
* Get the input stream for the given lob.
*
* @param lobId the lob id
* @param hmac the message authentication code (for remote input streams)
* @param byteCount the number of bytes to read, or -1 if not known
* @return the stream
*/
InputStream getInputStream(long lobId, byte[] hmac, long byteCount)
throws IOException;
/**
* Set the table reference of this lob.
*
* @param lobId the lob
* @param table the table
*/
void setTable(long lobId, int table);
/**
* Delete a LOB from the database.
*
* @param lob the lob id
*/
void removeLob(long lob);
}
package org.h2.store;
import java.io.IOException;
import java.io.InputStream;
/**
* An input stream that reads from a remote LOB.
*/
class LobStorageRemoteInputStream extends InputStream {
/**
* The data handler.
*/
private final DataHandler handler;
/**
* The lob id.
*/
private final long lob;
private final byte[] hmac;
/**
* The position.
*/
private long pos;
/**
* The remaining bytes in the lob.
*/
private long remainingBytes;
public LobStorageRemoteInputStream(DataHandler handler, long lob, byte[] hmac, long byteCount) {
this.handler = handler;
this.lob = lob;
this.hmac = hmac;
remainingBytes = byteCount;
}
@Override
public int read() throws IOException {
byte[] buff = new byte[1];
int len = read(buff, 0, 1);
return len < 0 ? len : (buff[0] & 255);
}
@Override
public int read(byte[] buff) throws IOException {
return read(buff, 0, buff.length);
}
@Override
public int read(byte[] buff, int off, int length) throws IOException {
if (length == 0) {
return 0;
}
length = (int) Math.min(length, remainingBytes);
if (length == 0) {
return -1;
}
length = handler.readLob(lob, hmac, pos, buff, off, length);
remainingBytes -= length;
if (length == 0) {
return -1;
}
pos += length;
return length;
}
@Override
public long skip(long n) {
remainingBytes -= n;
pos += n;
return n;
}
/*
* 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.store;
import java.io.IOException;
import java.io.InputStream;
/**
* An input stream that reads from a remote LOB.
*/
class LobStorageRemoteInputStream extends InputStream {
/**
* The data handler.
*/
private final DataHandler handler;
/**
* The lob id.
*/
private final long lob;
private final byte[] hmac;
/**
* The position.
*/
private long pos;
/**
* The remaining bytes in the lob.
*/
private long remainingBytes;
public LobStorageRemoteInputStream(DataHandler handler, long lob, byte[] hmac, long byteCount) {
this.handler = handler;
this.lob = lob;
this.hmac = hmac;
remainingBytes = byteCount;
}
@Override
public int read() throws IOException {
byte[] buff = new byte[1];
int len = read(buff, 0, 1);
return len < 0 ? len : (buff[0] & 255);
}
@Override
public int read(byte[] buff) throws IOException {
return read(buff, 0, buff.length);
}
@Override
public int read(byte[] buff, int off, int length) throws IOException {
if (length == 0) {
return 0;
}
length = (int) Math.min(length, remainingBytes);
if (length == 0) {
return -1;
}
length = handler.readLob(lob, hmac, pos, buff, off, length);
remainingBytes -= length;
if (length == 0) {
return -1;
}
pos += length;
return length;
}
@Override
public long skip(long n) {
remainingBytes -= n;
pos += n;
return n;
}
}
\ No newline at end of file
......@@ -83,7 +83,7 @@ public class SourceCompiler {
compiled.put(packageAndClassName, clazz);
return clazz;
}
ClassLoader classLoader = new ClassLoader(getClass().getClassLoader()) {
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
......@@ -262,11 +262,11 @@ public class SourceCompiler {
throw DbException.get(ErrorCode.SYNTAX_ERROR_1, err);
}
}
/**
* Access the groovy compiler using reflection, so that we do not gain a compile-time dependency
* unnecessarily.
* Access the Groovy compiler using reflection, so that we do not gain a
* compile-time dependency unnecessarily.
*/
private static final class GroovyCompiler {
private static final Object LOADER;
......@@ -279,17 +279,18 @@ public class SourceCompiler {
// create an instance of ImportCustomizer
Class<?> importCustomizerClass = Class.forName("org.codehaus.groovy.control.customizers.ImportCustomizer");
Object importCustomizer = Utils.newInstance("org.codehaus.groovy.control.customizers.ImportCustomizer");
// Call the method ImportCustomizer#addImports(String[])
// Call the method ImportCustomizer.addImports(String[])
String[] importsArray = new String[] { "java.sql.Connection", "java.sql.Types", "java.sql.ResultSet",
"groovy.sql.Sql", "org.h2.tools.SimpleResultSet" };
Utils.callMethod(importCustomizer, "addImports", new Object[] { importsArray });
// Call the method CompilerConfiguration#addCompilationCustomizers(ImportCustomizer...)
// Call the method
// CompilerConfiguration.addCompilationCustomizers(ImportCustomizer...)
Object importCustomizerArray = java.lang.reflect.Array.newInstance(importCustomizerClass, 1);
java.lang.reflect.Array.set(importCustomizerArray, 0, importCustomizer);
Object configuration = Utils.newInstance("org.codehaus.groovy.control.CompilerConfiguration");
Utils.callMethod(configuration, "addCompilationCustomizers", new Object[] { importCustomizerArray });
ClassLoader parent = GroovyCompiler.class.getClassLoader();
tmpLoader = Utils.newInstance("groovy.lang.GroovyClassLoader", parent, configuration);
} catch (Exception ex) {
......
......@@ -989,7 +989,7 @@ public abstract class Value {
/**
* Mark any underlying resource as 'not linked to any table'. For values
* that are kept fully in memory this method has no effect.
*
*
* @param handler the data handler
*/
public void unlink(DataHandler handler) {
......
......@@ -149,7 +149,7 @@ public class ValueLob extends Value {
int tableId, int objectId, long precision, boolean compression, String fileName) {
return new ValueLob(type, handler, fileName, tableId, objectId, false/*linked*/, precision, compression);
}
/**
* Create a CLOB value from a stream.
*
......@@ -785,7 +785,7 @@ public class ValueLob extends Value {
}
return 140;
}
/**
* Remove all lobs for a given table id.
*
......
......@@ -31,7 +31,8 @@ import org.h2.util.StringUtils;
import org.h2.util.Utils;
/**
* An alternate LOB implementation, where LOB data is stored inside the database, instead of in external files.
* An alternate LOB implementation, where LOB data is stored inside the
* database, instead of in external files.
*/
public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlob {
......@@ -504,7 +505,8 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
}
}
private void createTempFromStream(byte[] buff, int len, InputStream in, long remaining, DataHandler h) throws IOException {
private void createTempFromStream(byte[] buff, int len, InputStream in,
long remaining, DataHandler h) throws IOException {
FileStoreOutputStream out = initTemp(h);
boolean compress = h.getLobCompressionAlgorithm(Value.BLOB) != null;
try {
......
......@@ -100,8 +100,10 @@ public class TestCluster extends TestBase {
String url2 = "jdbc:h2:tcp://localhost:" + port2 + "/test";
String urlCluster = "jdbc:h2:tcp://" + serverList + "/test";
Server server1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", getBaseDir() + "/node1").start();
Server server2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2 , "-baseDir", getBaseDir() + "/node2").start();
Server server1 = org.h2.tools.Server.createTcpServer(
"-tcpPort", "" + port1, "-baseDir", getBaseDir() + "/node1").start();
Server server2 = org.h2.tools.Server.createTcpServer(
"-tcpPort", "" + port2 , "-baseDir", getBaseDir() + "/node2").start();
CreateCluster.main("-urlSource", url1, "-urlTarget", url2, "-user", user, "-password", password, "-serverList",
serverList);
......@@ -134,7 +136,7 @@ public class TestCluster extends TestBase {
rs.next();
assertEquals(5, rs.getInt(1));
conn.close();
server1.stop();
server2.stop();
deleteFiles();
......@@ -301,13 +303,13 @@ public class TestCluster extends TestBase {
// test the cluster connection
check(connApp, len, "'" + serverList + "'");
connApp.close();
// test a non-admin user
String user2 = "test", password2 = getPassword("test");
connApp = DriverManager.getConnection(urlCluster, user2, password2);
check(connApp, len, "'" + serverList + "'");
connApp.close();
n1.stop();
// test non-admin cluster connection if only one server runs
......
......@@ -256,7 +256,7 @@ public class TestCompatibility extends TestBase {
// we used to have an NullPointerException in the MetaTable.checkIndex() method
rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME > 'aaaa'");
rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME < 'aaaa'");
stat.execute("CREATE TABLE TEST_1(ID INT PRIMARY KEY) ENGINE=InnoDb");
stat.execute("CREATE TABLE TEST_2(ID INT PRIMARY KEY) ENGINE=MyISAM");
stat.execute("CREATE TABLE TEST_3(ID INT PRIMARY KEY) ENGINE=InnoDb charset=UTF8");
......
......@@ -822,7 +822,7 @@ public class TestOptimizations extends TestBase {
stat.execute("create table test(id int primary key, name varchar(255))");
stat.execute("insert into test values(1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5')");
ResultSet rs = stat.executeQuery("EXPLAIN PLAN FOR SELECT * FROM test WHERE ID=1 OR ID=2 OR ID=3 OR ID=4 OR ID=5");
rs.next();
assertContains(rs.getString(1), "ID IN(1, 2, 3, 4, 5)");
......
......@@ -185,8 +185,8 @@ public class TestCancel extends TestBase {
executeQuery("SELECT VISIT(ID), (SELECT SUM(X) " +
"FROM SYSTEM_RANGE(1, 10000) WHERE X<>ID) FROM TEST ORDER BY ID");
} finally {
cancel.stopNow();
cancel.join();
cancel.stopNow();
cancel.join();
}
if (lastVisited == 0) {
i += 10;
......
......@@ -975,5 +975,5 @@ public class TestMetaData extends TestBase {
conn.close();
deleteDb("metaData");
}
}
......@@ -171,7 +171,7 @@ public class TestMVStore extends TestBase {
String fileName = getBaseDir() + "/testWriteDelay.h3";
MVStore s;
MVMap<Integer, String> m;
FileUtils.delete(fileName);
s = new MVStore.Builder().writeDelay(0).
fileName(fileName).open();
......@@ -184,7 +184,7 @@ public class TestMVStore extends TestBase {
m = s.openMap("data");
assertEquals(1, m.size());
s.close();
FileUtils.delete(fileName);
s = new MVStore.Builder().
writeDelay(1).
......@@ -483,16 +483,16 @@ public class TestMVStore extends TestBase {
for (int i = 0; i < 100; i += 2) {
map.put(i, 10 * i);
}
Cursor<Integer> c = map.keyIterator(50);
// skip must reset the root of the cursor
c.skip(10);
for (int i = 70; i < 100; i += 2) {
assertTrue(c.hasNext());
assertEquals(i, c.next().intValue());
}
}
assertFalse(c.hasNext());
for (int i = -1; i < 100; i++) {
long index = map.getKeyIndex(i);
if (i < 0 || (i % 2) != 0) {
......@@ -538,17 +538,17 @@ public class TestMVStore extends TestBase {
MVMap<Integer, Integer> map = s.openMap("test");
map.put(10, 100);
map.put(20, 200);
assertEquals(10, map.firstKey().intValue());
assertEquals(20, map.lastKey().intValue());
assertEquals(20, map.ceilingKey(15).intValue());
assertEquals(20, map.ceilingKey(20).intValue());
assertEquals(10, map.floorKey(15).intValue());
assertEquals(10, map.floorKey(10).intValue());
assertEquals(20, map.higherKey(10).intValue());
assertEquals(10, map.lowerKey(20).intValue());
final MVMap<Integer, Integer> m = map;
assertEquals(10, m.ceilingKey(null).intValue());
assertEquals(10, m.higherKey(null).intValue());
......
......@@ -61,7 +61,7 @@ public class TestMVTableEngine extends TestBase {
dbName += ";LOCK_MODE=0";
// dbName += ";LOG=0";
testSpeed(dbName);
int test;
int test;
//Profiler prof = new Profiler().startCollecting();
dbName = "mvstore" +
";DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine";
......@@ -72,7 +72,7 @@ int test;
}
FileUtils.deleteRecursive(getBaseDir(), true);
}
private void testSpeed(String dbName) throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
......@@ -80,11 +80,11 @@ int test;
String url = getURL(dbName, true);
String user = getUser();
String password = getPassword();
//Profiler prof = new Profiler();
//prof.sumClasses=true;
//prof.startCollecting();
conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement();
long time = System.currentTimeMillis();
......@@ -94,35 +94,20 @@ int test;
stat.execute("create table test(id int primary key, name varchar)");
PreparedStatement prep = conn
.prepareStatement("insert into test values(?, ?)");
// -mx4g
// fast size
// 10 / 800000
// 1272 mvstore;LOCK_MODE=0 before
// 1449 mvstore;LOCK_MODE=0 after
// 1076 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 before
// 1086 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 after
// 100 / 800000
// 2010 mvstore;LOCK_MODE=0 before
// 2261 mvstore;LOCK_MODE=0 after
// 1536 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 before
// 1546 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 after
prep.setString(2, new String(new char[10]).replace((char) 0, 'x'));
// for (int i = 0; i < 20000; i++) {
for (int i = 0; i < 800000; i++) {
prep.setInt(1, i);
prep.execute();
}
System.out.println((System.currentTimeMillis() - time) + " " + dbName + " before");
conn.close();
//System.out.println(prof.getTop(10));
//System.out.println(prof.getTop(10));
System.out.println((System.currentTimeMillis() - time) + " " + dbName + " after");
}
private void testAutoCommit() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
......@@ -150,7 +135,7 @@ int test;
rs = stat.executeQuery("select count(*) from test");
rs.next();
assertEquals(1, rs.getInt(1));
conn.close();
}
......@@ -168,7 +153,7 @@ int test;
stat.execute("drop table test");
conn.close();
}
private void testBlob() throws SQLException, IOException {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
......@@ -217,7 +202,7 @@ int test;
conn.close();
FileUtils.deleteRecursive(getBaseDir(), true);
}
private void testExclusiveLock() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
......@@ -488,7 +473,7 @@ int test;
assertEquals(1, rs.getInt(1));
assertEquals("Hello", rs.getString(2));
assertEquals(1, rs.getInt(3));
stat.execute("update test set name = 'Hello' where id = 1");
if (!config.memory) {
......
......@@ -51,7 +51,7 @@ public class TestTransactionStore extends TestBase {
testSingleConnection();
testCompareWithPostgreSQL();
}
private void testGetModifiedMaps() {
MVStore s = MVStore.open(null);
TransactionStore ts = new TransactionStore(s);
......@@ -59,7 +59,7 @@ public class TestTransactionStore extends TestBase {
TransactionMap<String, String> m1, m2, m3;
long sp;
TreeSet<String> changed;
tx = ts.begin();
m1 = tx.openMap("m1");
m2 = tx.openMap("m2");
......@@ -84,7 +84,7 @@ public class TestTransactionStore extends TestBase {
changed = new TreeSet<String>(tx.getChangedMaps(0));
assertEquals("[m1]", changed.toString());
tx.commit();
s.close();
}
......@@ -94,20 +94,20 @@ public class TestTransactionStore extends TestBase {
Transaction tx, tx2;
TransactionMap<String, String> m, m2;
Iterator<String> it, it2;
tx = ts.begin();
m = tx.openMap("test");
m.put("1", "Hello");
m.put("2", "World");
m.put("3", ".");
tx.commit();
tx2 = ts.begin();
m2 = tx2.openMap("test");
m2.remove("2");
m2.put("3", "!");
m2.put("4", "?");
tx = ts.begin();
m = tx.openMap("test");
it = m.keyIterator(null);
......@@ -127,7 +127,7 @@ public class TestTransactionStore extends TestBase {
assertTrue(it2.hasNext());
assertEquals("4", it2.next());
assertFalse(it2.hasNext());
s.close();
}
......
......@@ -148,7 +148,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
stat.execute("insert into test values (space(2000))");
}
stat.execute("checkpoint");
InputStream in = FileUtils.newInputStream(getBaseDir() +
InputStream in = FileUtils.newInputStream(getBaseDir() +
"/pageStoreLogLimitFalsePositive.trace.db");
String s = IOUtils.readStringAndClose(new InputStreamReader(in), -1);
assertFalse(s.indexOf("Transaction log could not be truncated") > 0);
......
......@@ -62,7 +62,7 @@ public class TestShell extends TestBase {
shell.runTool("-help");
s = new String(buff.toByteArray());
assertContains(s, "Interactive command line tool to access a database using JDBC.");
test(true);
test(false);
}
......
......@@ -362,7 +362,7 @@ public class Doclet {
}
}
}
private static String getLink(ClassDoc clazz, int line) {
String c = clazz.name();
int x = c.lastIndexOf('.');
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论