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

Documentation.

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