提交 8825c9ce authored 作者: Thomas Mueller's avatar Thomas Mueller

Documentation.

上级 9e771b50
......@@ -46,8 +46,8 @@ Other software most likely also works, but is not tested as much.
<p>
As this database is written in Java, it can run on many different platforms.
It is tested with Java 6 and 7.
Currently, the database is developed and tested on Windows 8
and Mac OS X using Java 6, but it also works in many other operating systems
Currently, the database is developed and tested on Windows 8
and Mac OS X using Java 6, but it also works in many other operating systems
and using other Java runtime environments.
All major operating systems (Windows XP, Windows Vista, Windows 7, Mac OS, Ubuntu,...) are supported.
</p>
......
......@@ -149,7 +149,7 @@ public class SysProperties {
* H2 Console: session timeout in milliseconds. The default is 30 minutes.
*/
public static final int CONSOLE_TIMEOUT = Utils.getProperty("h2.consoleTimeout", 30 * 60 * 1000);
/**
* System property <code>h2.dataSourceTraceLevel</code> (default: 1).<br />
* The trace level of the data source implementation. Default is 1 for
......
......@@ -1236,7 +1236,7 @@ public class Session extends SessionWithState {
/**
* Get the transaction to use for this session.
*
*
* @param store the store
* @return the transaction
*/
......
......@@ -2345,7 +2345,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
String m = getMode();
if (m.equals("MySQL")) {
return true;
}
}
return false;
}
......@@ -2386,7 +2386,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
String m = getMode();
if (m.equals("MySQL")) {
return true;
}
}
return false;
}
......@@ -2401,7 +2401,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
String m = getMode();
if (m.equals("MySQL")) {
return false;
}
}
return true;
}
......@@ -2972,7 +2972,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public String toString() {
return getTraceObjectName() + ": " + conn;
}
private String getMode() throws SQLException {
if (mode == null) {
PreparedStatement prep = conn.prepareStatement(
......
......@@ -592,7 +592,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
/**
* Check whether the two values are equal.
*
*
* @param a the first value
* @param b the second value
* @return true if they are equal
......
......@@ -18,7 +18,7 @@ import org.h2.util.New;
* A store that supports concurrent transactions.
*/
public class TransactionStore {
private static final String LAST_TRANSACTION_ID = "lastTransactionId";
/**
......@@ -101,10 +101,10 @@ public class TransactionStore {
}
}
}
/**
* Get the list of currently open transactions.
*
*
* @return the list of transactions
*/
public synchronized List<Transaction> getOpenTransactions() {
......@@ -141,10 +141,10 @@ public class TransactionStore {
openTransactionMap.put(transactionId, t);
return t;
}
/**
* Prepare a transaction.
*
*
* @param transactionId the transaction id
*/
void prepare(long transactionId) {
......@@ -152,11 +152,11 @@ public class TransactionStore {
Object[] v = { Transaction.STATUS_PREPARED, old[1] };
openTransactions.put(transactionId, v);
store.commit();
}
}
/**
* Set the name of a transaction.
*
*
* @param transactionId the transaction id
* @param name the new name
*/
......@@ -165,7 +165,7 @@ public class TransactionStore {
Object[] v = { old[0], name };
openTransactions.put(transactionId, v);
store.commit();
}
}
/**
* Commit a transaction.
......@@ -261,7 +261,7 @@ public class TransactionStore {
* A transaction.
*/
public static class Transaction {
/**
* The status of an open transaction.
*/
......@@ -291,9 +291,9 @@ public class TransactionStore {
* The transaction id.
*/
final long transactionId;
private int status;
private String name;
private long logId;
......@@ -305,39 +305,39 @@ public class TransactionStore {
this.name = name;
this.logId = logId;
}
/**
* Get the transaction id.
*
*
* @return the transaction id
*/
public long getId() {
return transactionId;
}
/**
* Get the transaction status.
*
*
* @return the status
*/
public int getStatus() {
return status;
}
/**
* Set the name of the transaction.
*
*
* @param name the new name
*/
public void setName(String name) {
checkOpen();
checkOpen();
store.setTransactionName(transactionId, name);
this.name = name;
}
/**
* Get the name of the transaction.
*
*
* @return name the name
*/
public String getName() {
......@@ -398,7 +398,7 @@ public class TransactionStore {
/**
* Roll back to the given savepoint. This is only allowed if the
* transaction is open.
*
*
* @param savepointId the savepoint id
*/
public void rollbackToSavepoint(long savepointId) {
......@@ -426,7 +426,7 @@ public class TransactionStore {
status = STATUS_CLOSED;
}
}
/**
* Roll the transaction back. Afterwards, this transaction is closed.
*/
......@@ -459,7 +459,7 @@ public class TransactionStore {
private Transaction transaction;
private final int mapId;
/**
* The map used for writing (the latest version).
* <p>
......@@ -467,14 +467,14 @@ public class TransactionStore {
* Value: { transactionId, oldVersion, value }
*/
private final MVMap<K, Object[]> mapWrite;
/**
* The map used for reading (possibly an older version). Reading is done
* on an older version so that changes are not immediately visible, to
* support statement processing (for example
* "update test set id = id + 1").
* <p>
* Key: key the key of the data.
* Key: key the key of the data.
* Value: { transactionId, oldVersion, value }
*/
private final MVMap<K, Object[]> mapRead;
......@@ -489,7 +489,7 @@ public class TransactionStore {
mapRead = mapWrite;
}
}
/**
* Get the size of the map as seen by this transaction.
*
......@@ -530,7 +530,7 @@ public class TransactionStore {
* <p>
* If the row is locked, this method will retry until the row could be
* updated or until a lock timeout.
*
*
* @param key the key
* @param value the new value (not null)
* @throws IllegalStateException if a lock timeout occurs
......@@ -539,7 +539,7 @@ public class TransactionStore {
DataUtils.checkArgument(value != null, "The value may not be null");
return set(key, value);
}
private V set(K key, V value) {
checkOpen();
long start = 0;
......@@ -571,13 +571,13 @@ public class TransactionStore {
}
}
}
/**
* Try to remove the value for the given key.
* <p>
* This will fail if the row is locked by another transaction (that
* means, if another open transaction changed the row).
*
*
* @param key the key
* @return whether the entry could be removed
*/
......@@ -599,12 +599,12 @@ public class TransactionStore {
DataUtils.checkArgument(value != null, "The value may not be null");
return trySet(key, value, false);
}
/**
* Try to set or remove the value. When updating only unchanged entries,
* then the value is only changed if it was not changed after opening
* the map.
*
*
* @param key the key
* @param value the new value (null to remove the value)
* @param onlyIfUnchanged only set the value if it was not changed (by
......@@ -620,7 +620,7 @@ public class TransactionStore {
long tx = (Long) current[0];
if (tx == transaction.transactionId) {
if (value == null) {
// ignore removing an entry
// ignore removing an entry
// if it was added or changed
// in the same statement
return true;
......@@ -698,7 +698,7 @@ public class TransactionStore {
/**
* Get the value for the given key at the time when this map was opened.
*
*
* @param key the key
* @return the value or null
*/
......@@ -715,7 +715,7 @@ public class TransactionStore {
public V getLatest(K key) {
return get(key, mapWrite);
}
/**
* Get the value for the given key.
*
......@@ -758,7 +758,7 @@ public class TransactionStore {
/**
* Open the map to store the data.
*
*
* @param <A> the key type
* @param <B> the value type
* @param name the map name
......
......@@ -322,7 +322,7 @@ public class MVPrimaryIndex extends BaseIndex {
public boolean isRowIdIndex() {
return true;
}
/**
* Get the map to store the data.
*
......
......@@ -295,7 +295,7 @@ public class MVSecondaryIndex extends BaseIndex {
}
}
/**
* Get the map to store the data.
*
......
......@@ -672,17 +672,17 @@ public class MVTable extends TableBase {
public void checkRename() {
// ok
}
/**
* Get the transaction to use for this session.
*
*
* @param session the session
* @return the transaction
*/
Transaction getTransaction(Session session) {
return session.getTransaction(store);
}
public TransactionStore getStore() {
return store;
}
......
......@@ -139,7 +139,7 @@ public class MVTableEngine implements TableEngine {
* The store.
*/
private final MVStore store;
/**
* The transaction store.
*/
......
......@@ -236,7 +236,7 @@ public class TestCompatibility extends TestBase {
conn = getConnection("compatibility;MODE=MYSQL");
stat = conn.createStatement();
testLog(Math.log(10), stat);
DatabaseMetaData meta = conn.getMetaData();
assertTrue(meta.storesLowerCaseIdentifiers());
assertTrue(meta.storesLowerCaseQuotedIdentifiers());
......
......@@ -45,7 +45,7 @@ public class TestTransactionStore extends TestBase {
testSingleConnection();
testCompareWithPostgreSQL();
}
/**
* Tests behavior when used for a sequence of SQL statements. Each statement
* uses a savepoint. Within a statement, changes by the statement itself are
......@@ -63,14 +63,14 @@ public class TestTransactionStore extends TestBase {
TransactionMap<String, String> m;
long startUpdate;
long version;
tx = ts.begin();
// start of statement
// create table test
startUpdate = tx.setSavepoint();
tx.openMap("test");
// start of statement
// insert into test(id, name) values(1, 'Hello'), (2, 'World')
startUpdate = tx.setSavepoint();
......@@ -81,10 +81,10 @@ public class TestTransactionStore extends TestBase {
// not seen yet (within the same statement)
assertNull(m.get("1"));
assertNull(m.get("2"));
// start of statement
startUpdate = tx.setSavepoint();
version = s.getCurrentVersion();
version = s.getCurrentVersion();
// now we see the newest version
m = tx.openMap("test", version);
assertEquals("Hello", m.get("1"));
......@@ -98,25 +98,25 @@ public class TestTransactionStore extends TestBase {
// already updated by this statement, so it has no effect
// but still returns true because it was changed by this transaction
assertTrue(m.trySet("2", null, true));
assertTrue(m.trySet("3", "World", true));
// not seen within this statement
assertEquals("Hello", m.get("1"));
assertEquals("World", m.get("2"));
assertNull(m.get("3"));
// start of statement
startUpdate = tx.setSavepoint();
version = s.getCurrentVersion();
version = s.getCurrentVersion();
m = tx.openMap("test", version);
// select * from test
assertNull(m.get("1"));
assertEquals("Hello", m.get("2"));
assertEquals("World", m.get("3"));
// start of statement
startUpdate = tx.setSavepoint();
version = s.getCurrentVersion();
version = s.getCurrentVersion();
m = tx.openMap("test", version);
// update test set id = 1
// should fail: duplicate key
......@@ -125,30 +125,30 @@ public class TestTransactionStore extends TestBase {
assertTrue(m.trySet("3", null, true));
assertFalse(m.trySet("1", "World", true));
tx.rollbackToSavepoint(startUpdate);
version = s.getCurrentVersion();
version = s.getCurrentVersion();
m = tx.openMap("test", version);
assertNull(m.get("1"));
assertEquals("Hello", m.get("2"));
assertEquals("World", m.get("3"));
tx.commit();
ts.close();
s.close();
}
}
private void testTwoPhaseCommit() throws Exception {
String fileName = getBaseDir() + "/testTwoPhaseCommit.h3";
FileUtils.delete(fileName);
MVStore s;
TransactionStore ts;
Transaction tx;
Transaction txOld;
TransactionMap<String, String> m;
List<Transaction> list;
s = MVStore.open(fileName);
ts = new TransactionStore(s);
tx = ts.begin();
......@@ -166,7 +166,7 @@ public class TestTransactionStore extends TestBase {
s.commit();
ts.close();
s.close();
s = MVStore.open(fileName);
ts = new TransactionStore(s);
tx = ts.begin();
......@@ -188,7 +188,7 @@ public class TestTransactionStore extends TestBase {
txOld.rollback();
s.commit();
s.close();
s = MVStore.open(fileName);
ts = new TransactionStore(s);
tx = ts.begin();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论