提交 764c9495 authored 作者: Thomas Mueller's avatar Thomas Mueller

Formatting, javadocs, improve testability

上级 8f38fa77
......@@ -62,7 +62,7 @@ public class JdbcArray extends TraceObject implements Array {
public Object getArray(Map<String, Class<?>> map) throws SQLException {
try {
debugCode("getArray("+quoteMap(map)+");");
checkMap(map);
JdbcConnection.checkMap(map);
checkClosed();
return get();
} catch (Exception e) {
......@@ -105,7 +105,7 @@ public class JdbcArray extends TraceObject implements Array {
try {
debugCode("getArray(" + index + ", " + count + ", " + quoteMap(map)+");");
checkClosed();
checkMap(map);
JdbcConnection.checkMap(map);
return get(index, count);
} catch (Exception e) {
throw logAndConvert(e);
......@@ -176,7 +176,7 @@ public class JdbcArray extends TraceObject implements Array {
try {
debugCode("getResultSet("+quoteMap(map)+");");
checkClosed();
checkMap(map);
JdbcConnection.checkMap(map);
return getResultSet(get(), 0);
} catch (Exception e) {
throw logAndConvert(e);
......@@ -198,7 +198,7 @@ public class JdbcArray extends TraceObject implements Array {
try {
debugCode("getResultSet("+index+", " + count+");");
checkClosed();
return getResultSet(get(index, count), index);
return getResultSet(get(index, count), index - 1);
} catch (Exception e) {
throw logAndConvert(e);
}
......@@ -221,8 +221,8 @@ public class JdbcArray extends TraceObject implements Array {
try {
debugCode("getResultSet("+index+", " + count+", " + quoteMap(map)+");");
checkClosed();
checkMap(map);
return getResultSet(get(index, count), index);
JdbcConnection.checkMap(map);
return getResultSet(get(index, count), index - 1);
} catch (Exception e) {
throw logAndConvert(e);
}
......@@ -274,12 +274,6 @@ public class JdbcArray extends TraceObject implements Array {
return subset;
}
private static void checkMap(Map<String, Class<?>> map) {
if (map != null && map.size() > 0) {
throw DbException.getUnsupportedException("map.size > 0");
}
}
/**
* INTERNAL
*/
......
......@@ -1807,7 +1807,13 @@ public class JdbcConnection extends TraceObject implements Connection {
}
//*/
private static void checkMap(Map<String, Class<?>> map) {
/**
* Check that the given type map is either null or empty.
*
* @param map the type map
* @throws DbException if the map is not empty
*/
static void checkMap(Map<String, Class<?>> map) {
if (map != null && map.size() > 0) {
throw DbException.getUnsupportedException("map.size > 0");
}
......
......@@ -215,7 +215,6 @@ public class JdbcDataSource extends TraceObject
/**
* Get the current URL.
* <p>
* This method does the same as getURL, but this methods signature conforms
* the JavaBean naming convention.
*
......@@ -228,7 +227,6 @@ public class JdbcDataSource extends TraceObject
/**
* Set the current URL.
* <p>
* This method does the same as setURL, but this methods signature conforms
* the JavaBean naming convention.
*
......
......@@ -39,8 +39,19 @@ import org.h2.value.ValueNull;
*/
public class MVPrimaryIndex extends BaseIndex {
/**
* The minimum long value.
*/
static final ValueLong MIN = ValueLong.get(Long.MIN_VALUE);
/**
* The maximum long value.
*/
static final ValueLong MAX = ValueLong.get(Long.MAX_VALUE);
/**
* The zero long value.
*/
static final ValueLong ZERO = ValueLong.get(0);
private final MVTable mvTable;
......
......@@ -116,6 +116,13 @@ public class TransactionStore {
this.maxTransactionId = max;
}
/**
* Combine the transaction id and the log id to an operation id.
*
* @param transactionId the transaction id
* @param logId the log id
* @return the operation id
*/
static long getOperationId(int transactionId, long logId) {
DataUtils.checkArgument(transactionId >= 0 && transactionId < (1 << 24),
"Transaction id out of range: {0}", transactionId);
......@@ -124,10 +131,22 @@ public class TransactionStore {
return ((long) transactionId << 40) | logId;
}
/**
* Get the transaction id for the given operation id.
*
* @param operationId the operation id
* @return the transaction id
*/
static int getTransactionId(long operationId) {
return (int) (operationId >>> 40);
}
/**
* Get the log id for the given operation id.
*
* @param operationId the operation id
* @return the log id
*/
static long getLogId(long operationId) {
return operationId & ((1L << 40) - 1);
}
......@@ -248,6 +267,13 @@ public class TransactionStore {
}
}
/**
* Remove the given map.
*
* @param <K> the key type
* @param <V> the value type
* @param map the map
*/
synchronized <K, V> void removeMap(TransactionMap<K, V> map) {
maps.remove(map.mapId);
store.removeMap(map.map);
......@@ -302,7 +328,17 @@ public class TransactionStore {
endTransaction(t);
}
synchronized <K> MVMap<K, VersionedValue> openMap(String name, DataType keyType, DataType valueType) {
/**
* Open the map with the given name.
*
* @param <K> the key type
* @param name the map name
* @param keyType the key type
* @param valueType the value type
* @return the map
*/
synchronized <K> MVMap<K, VersionedValue> openMap(String name,
DataType keyType, DataType valueType) {
if (keyType == null) {
keyType = new ObjectDataType();
}
......@@ -328,6 +364,12 @@ public class TransactionStore {
return map;
}
/**
* Open the map with the given id.
*
* @param mapId the id
* @return the map
*/
synchronized MVMap<Object, VersionedValue> openMap(int mapId) {
MVMap<Object, VersionedValue> map = maps.get(mapId);
if (map != null) {
......@@ -1061,6 +1103,14 @@ public class TransactionStore {
return getValue(key, maxLog, data);
}
/**
* Get the versioned value for the given key.
*
* @param key the key
* @param maxLog the maximum log id of the entry
* @param data the value stored in the main map
* @return the value
*/
VersionedValue getValue(K key, long maxLog, VersionedValue data) {
while (true) {
if (data == null) {
......@@ -1239,6 +1289,12 @@ public class TransactionStore {
return wrapIterator(it, includeUncommitted);
}
/**
* Iterate over entries.
*
* @param from the first key to return
* @return the iterator
*/
public Iterator<Entry<K, V>> entryIterator(K from) {
final Cursor<K, VersionedValue> cursor = map.cursor(from);
return new Iterator<Entry<K, V>>() {
......
......@@ -173,7 +173,8 @@ public class FunctionTable extends Table {
}
/**
* Read the result from the function. This method buffers the result in a temporary file.
* Read the result from the function. This method buffers the result in a
* temporary file.
*
* @param session the session
* @return the result
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论