提交 6089c852 authored 作者: Thomas Mueller's avatar Thomas Mueller

Formatting / Javadocs

上级 5d727252
...@@ -61,7 +61,7 @@ public class BackupCommand extends Prepared { ...@@ -61,7 +61,7 @@ public class BackupCommand extends Prepared {
try { try {
Store store = db.getMvStore(); Store store = db.getMvStore();
if (store != null) { if (store != null) {
store.store(); store.flush();
} }
String name = db.getName(); String name = db.getName();
name = FileUtils.getName(name); name = FileUtils.getName(name);
......
...@@ -43,7 +43,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -43,7 +43,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
private boolean closed; private boolean closed;
private boolean needRebuild; private boolean needRebuild;
private boolean persistent;
/** /**
* Constructor. * Constructor.
...@@ -52,8 +51,8 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -52,8 +51,8 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
* @param id the index id * @param id the index id
* @param indexName the index name * @param indexName the index name
* @param columns the indexed columns (only one geometry column allowed) * @param columns the indexed columns (only one geometry column allowed)
* @param persistent whether the index should be persisted
* @param indexType the index type (only spatial index) * @param indexType the index type (only spatial index)
* @param persistent whether the index data should be persisted
* @param create whether to create a new index * @param create whether to create a new index
* @param session the session. * @param session the session.
*/ */
...@@ -80,7 +79,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -80,7 +79,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
} }
initBaseIndex(table, id, indexName, columns, indexType); initBaseIndex(table, id, indexName, columns, indexType);
this.needRebuild = create; this.needRebuild = create;
this.persistent = persistent;
this.table = table; this.table = table;
if (!database.isStarting()) { if (!database.isStarting()) {
if (columns[0].column.getType() != Value.GEOMETRY) { if (columns[0].column.getType() != Value.GEOMETRY) {
...@@ -111,11 +109,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -111,11 +109,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
@Override @Override
public void close(Session session) { public void close(Session session) {
if (persistent) {
store.store();
} else {
store.close(); store.close();
}
closed = true; closed = true;
} }
......
...@@ -36,6 +36,12 @@ public class Sequence extends SchemaObjectBase { ...@@ -36,6 +36,12 @@ public class Sequence extends SchemaObjectBase {
/** /**
* Creates a new sequence for an auto-increment column. * Creates a new sequence for an auto-increment column.
*
* @param schema the schema
* @param id the object id
* @param name the sequence name
* @param startValue the first value to return
* @param increment the increment count
*/ */
public Sequence(Schema schema, int id, String name, long startValue, long increment) { public Sequence(Schema schema, int id, String name, long startValue, long increment) {
this(schema, id, name, startValue, increment, null, null, null, false, true); this(schema, id, name, startValue, increment, null, null, null, false, true);
...@@ -43,6 +49,18 @@ public class Sequence extends SchemaObjectBase { ...@@ -43,6 +49,18 @@ public class Sequence extends SchemaObjectBase {
/** /**
* Creates a new sequence. * Creates a new sequence.
*
* @param schema the schema
* @param id the object id
* @param name the sequence name
* @param startValue the first value to return
* @param increment the increment count
* @param cacheSize the number of entries to pre-fetch
* @param minValue the minimum value
* @param maxValue the maximum value
* @param cycle whether to jump back to the min value if needed
* @param belongsToTable whether this sequence belongs to a table (for
* auto-increment columns)
*/ */
public Sequence(Schema schema, int id, String name, Long startValue, Long increment, Long cacheSize, public Sequence(Schema schema, int id, String name, Long startValue, Long increment, Long cacheSize,
Long minValue, Long maxValue, boolean cycle, boolean belongsToTable) { Long minValue, Long maxValue, boolean cycle, boolean belongsToTable) {
...@@ -98,9 +116,9 @@ public class Sequence extends SchemaObjectBase { ...@@ -98,9 +116,9 @@ public class Sequence extends SchemaObjectBase {
} }
/** /**
* Validates the specified prospective start value, min value, max value and increment relative * Validates the specified prospective start value, min value, max value and
* to each other, since each of their respective validities are contingent on the values of the * increment relative to each other, since each of their respective
* other parameters. * validities are contingent on the values of the other parameters.
* *
* @param value the prospective start value * @param value the prospective start value
* @param minValue the prospective min value * @param minValue the prospective min value
...@@ -118,11 +136,11 @@ public class Sequence extends SchemaObjectBase { ...@@ -118,11 +136,11 @@ public class Sequence extends SchemaObjectBase {
BigInteger.valueOf(maxValue).subtract(BigInteger.valueOf(minValue))) < 0; BigInteger.valueOf(maxValue).subtract(BigInteger.valueOf(minValue))) < 0;
} }
private long getDefaultMinValue(long increment) { private static long getDefaultMinValue(long increment) {
return increment >= 0 ? 1 : Long.MIN_VALUE; return increment >= 0 ? 1 : Long.MIN_VALUE;
} }
private long getDefaultMaxValue(long increment) { private static long getDefaultMaxValue(long increment) {
return increment >= 0 ? Long.MAX_VALUE : -1; return increment >= 0 ? Long.MAX_VALUE : -1;
} }
......
...@@ -232,6 +232,7 @@ java org.h2.test.TestAll timer ...@@ -232,6 +232,7 @@ java org.h2.test.TestAll timer
*/ */
;
private static final boolean MV_STORE = true; private static final boolean MV_STORE = true;
/** /**
...@@ -772,9 +773,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -772,9 +773,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new TestFile().runTest(this); new TestFile().runTest(this);
new TestFileLock().runTest(this); new TestFileLock().runTest(this);
new TestFileLockProcess().runTest(this); new TestFileLockProcess().runTest(this);
new TestFileLockSerialized().runTest(this); new TestFileLockSerialized().runTest(this);
new TestFtp().runTest(this); new TestFtp().runTest(this);
new TestFileSystem().runTest(this); new TestFileSystem().runTest(this);
new TestIntArray().runTest(this); new TestIntArray().runTest(this);
...@@ -804,7 +803,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -804,7 +803,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new TestStringUtils().runTest(this); new TestStringUtils().runTest(this);
new TestTools().runTest(this); new TestTools().runTest(this);
new TestTraceSystem().runTest(this); new TestTraceSystem().runTest(this);
; // TODO
new TestUpgrade().runTest(this); new TestUpgrade().runTest(this);
new TestUtils().runTest(this); new TestUtils().runTest(this);
new TestValue().runTest(this); new TestValue().runTest(this);
new TestValueHashMap().runTest(this); new TestValueHashMap().runTest(this);
......
...@@ -46,6 +46,11 @@ import org.h2.value.ValueLob; ...@@ -46,6 +46,11 @@ import org.h2.value.ValueLob;
*/ */
public class TestLob extends TestBase { public class TestLob extends TestBase {
private static final String MORE_THAN_128_CHARS =
"12345678901234567890123456789012345678901234567890" +
"12345678901234567890123456789012345678901234567890" +
"12345678901234567890123456789";
/** /**
* Run just this test. * Run just this test.
* *
...@@ -1487,8 +1492,6 @@ public class TestLob extends TestBase { ...@@ -1487,8 +1492,6 @@ public class TestLob extends TestBase {
conn.close(); conn.close();
} }
private static final String MORE_THAN_128_CHARS = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
private void testCommitOnExclusiveConnection() throws Exception { private void testCommitOnExclusiveConnection() throws Exception {
deleteDb("lob"); deleteDb("lob");
Connection conn = getConnection("lob;EXCLUSIVE=1"); Connection conn = getConnection("lob;EXCLUSIVE=1");
...@@ -1498,8 +1501,11 @@ public class TestLob extends TestBase { ...@@ -1498,8 +1501,11 @@ public class TestLob extends TestBase {
conn.setAutoCommit(false); conn.setAutoCommit(false);
statement.execute("insert into TEST (COL, LOB) values (1, '" + MORE_THAN_128_CHARS + "')"); statement.execute("insert into TEST (COL, LOB) values (1, '" + MORE_THAN_128_CHARS + "')");
statement.execute("update TEST set COL=2"); statement.execute("update TEST set COL=2");
// statement.execute("commit"); // OK // OK
conn.commit(); // KO : should not hang // statement.execute("commit");
// KO : should not hang
conn.commit();
conn.close(); conn.close();
} }
} }
/*
* 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: Cemo
*/
package org.h2.test.db; package org.h2.test.db;
import org.h2.test.TestBase; import org.h2.test.TestBase;
......
...@@ -156,12 +156,17 @@ public class TestSequence extends TestBase { ...@@ -156,12 +156,17 @@ public class TestSequence extends TestBase {
private void testCreateWithMinValue() throws SQLException { private void testCreateWithMinValue() throws SQLException {
test("create sequence s minvalue 3", null, 3, 4, 5, 6); test("create sequence s minvalue 3", null, 3, 4, 5, 6);
test("create sequence s minvalue -3 increment by -1 cycle", null, -1, -2, -3, -1); test("create sequence s minvalue -3 increment by -1 cycle", null, -1, -2, -3, -1);
test("create sequence s minvalue -3 increment by -1", "Sequence \"S\" has run out of numbers", -1, -2, -3); test("create sequence s minvalue -3 increment by -1",
test("create sequence s minvalue -3 increment by -1 nocycle", "Sequence \"S\" has run out of numbers", -1, -2, -3); "Sequence \"S\" has run out of numbers", -1, -2, -3);
test("create sequence s minvalue -3 increment by -1 no cycle", "Sequence \"S\" has run out of numbers", -1, -2, -3); test("create sequence s minvalue -3 increment by -1 nocycle",
"Sequence \"S\" has run out of numbers", -1, -2, -3);
test("create sequence s minvalue -3 increment by -1 no cycle",
"Sequence \"S\" has run out of numbers", -1, -2, -3);
test("create sequence s minvalue -3 increment by -1 nocache cycle", null, -1, -2, -3, -1); test("create sequence s minvalue -3 increment by -1 nocache cycle", null, -1, -2, -3, -1);
test("create sequence s minvalue -3 increment by -1 nocache", "Sequence \"S\" has run out of numbers", -1, -2, -3); test("create sequence s minvalue -3 increment by -1 nocache",
test("create sequence s minvalue -3 increment by -1 nocache nocycle", "Sequence \"S\" has run out of numbers", -1, -2, -3); "Sequence \"S\" has run out of numbers", -1, -2, -3);
test("create sequence s minvalue -3 increment by -1 nocache nocycle",
"Sequence \"S\" has run out of numbers", -1, -2, -3);
test("create sequence s minvalue -3 increment by -1 no cache no cycle", test("create sequence s minvalue -3 increment by -1 no cache no cycle",
"Sequence \"S\" has run out of numbers", -1, -2, -3); "Sequence \"S\" has run out of numbers", -1, -2, -3);
} }
...@@ -169,13 +174,19 @@ public class TestSequence extends TestBase { ...@@ -169,13 +174,19 @@ public class TestSequence extends TestBase {
private void testCreateWithMaxValue() throws SQLException { private void testCreateWithMaxValue() throws SQLException {
test("create sequence s maxvalue -3 increment by -1", null, -3, -4, -5, -6); test("create sequence s maxvalue -3 increment by -1", null, -3, -4, -5, -6);
test("create sequence s maxvalue 3 cycle", null, 1, 2, 3, 1); test("create sequence s maxvalue 3 cycle", null, 1, 2, 3, 1);
test("create sequence s maxvalue 3", "Sequence \"S\" has run out of numbers", 1, 2, 3); test("create sequence s maxvalue 3",
test("create sequence s maxvalue 3 nocycle", "Sequence \"S\" has run out of numbers", 1, 2, 3); "Sequence \"S\" has run out of numbers", 1, 2, 3);
test("create sequence s maxvalue 3 no cycle", "Sequence \"S\" has run out of numbers", 1, 2, 3); test("create sequence s maxvalue 3 nocycle",
"Sequence \"S\" has run out of numbers", 1, 2, 3);
test("create sequence s maxvalue 3 no cycle",
"Sequence \"S\" has run out of numbers", 1, 2, 3);
test("create sequence s maxvalue 3 nocache cycle", null, 1, 2, 3, 1); test("create sequence s maxvalue 3 nocache cycle", null, 1, 2, 3, 1);
test("create sequence s maxvalue 3 nocache", "Sequence \"S\" has run out of numbers", 1, 2, 3); test("create sequence s maxvalue 3 nocache",
test("create sequence s maxvalue 3 nocache nocycle", "Sequence \"S\" has run out of numbers", 1, 2, 3); "Sequence \"S\" has run out of numbers", 1, 2, 3);
test("create sequence s maxvalue 3 no cache no cycle", "Sequence \"S\" has run out of numbers", 1, 2, 3); test("create sequence s maxvalue 3 nocache nocycle",
"Sequence \"S\" has run out of numbers", 1, 2, 3);
test("create sequence s maxvalue 3 no cache no cycle",
"Sequence \"S\" has run out of numbers", 1, 2, 3);
} }
private void testCreationErrors() throws SQLException { private void testCreationErrors() throws SQLException {
...@@ -215,8 +226,10 @@ public class TestSequence extends TestBase { ...@@ -215,8 +226,10 @@ public class TestSequence extends TestBase {
Connection conn = getConnection("sequence"); Connection conn = getConnection("sequence");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create sequence a"); stat.execute("create sequence a");
stat.execute("create sequence b start with 5 increment by 2 minvalue 3 maxvalue 7 cycle nocache"); stat.execute("create sequence b start with 5 increment by 2 " +
stat.execute("create sequence c start with 3 increment by 1 minvalue 2 maxvalue 9 nocycle cache 2"); "minvalue 3 maxvalue 7 cycle nocache");
stat.execute("create sequence c start with 3 increment by 1 " +
"minvalue 2 maxvalue 9 nocycle cache 2");
stat.execute("create sequence d nomaxvalue no minvalue no cache nocycle"); stat.execute("create sequence d nomaxvalue no minvalue no cache nocycle");
stat.execute("create sequence e cache 1"); stat.execute("create sequence e cache 1");
List<String> script = new ArrayList<String>(); List<String> script = new ArrayList<String>();
...@@ -226,8 +239,10 @@ public class TestSequence extends TestBase { ...@@ -226,8 +239,10 @@ public class TestSequence extends TestBase {
} }
Collections.sort(script); Collections.sort(script);
assertEquals("CREATE SEQUENCE PUBLIC.A START WITH 1;", script.get(0)); assertEquals("CREATE SEQUENCE PUBLIC.A START WITH 1;", script.get(0));
assertEquals("CREATE SEQUENCE PUBLIC.B START WITH 5 INCREMENT BY 2 MINVALUE 3 MAXVALUE 7 CYCLE CACHE 1;", script.get(1)); assertEquals("CREATE SEQUENCE PUBLIC.B START WITH 5 INCREMENT BY 2 " +
assertEquals("CREATE SEQUENCE PUBLIC.C START WITH 3 MINVALUE 2 MAXVALUE 9 CACHE 2;", script.get(2)); "MINVALUE 3 MAXVALUE 7 CYCLE CACHE 1;", script.get(1));
assertEquals("CREATE SEQUENCE PUBLIC.C START WITH 3 MINVALUE 2 MAXVALUE 9 CACHE 2;",
script.get(2));
assertEquals("CREATE SEQUENCE PUBLIC.D START WITH 1 CACHE 1;", script.get(3)); assertEquals("CREATE SEQUENCE PUBLIC.D START WITH 1 CACHE 1;", script.get(3));
assertEquals("CREATE SEQUENCE PUBLIC.E START WITH 1 CACHE 1;", script.get(4)); assertEquals("CREATE SEQUENCE PUBLIC.E START WITH 1 CACHE 1;", script.get(4));
conn.close(); conn.close();
......
...@@ -207,7 +207,10 @@ public class TestView extends TestBase { ...@@ -207,7 +207,10 @@ public class TestView extends TestBase {
deleteDb("view"); deleteDb("view");
} }
/** make sure that when we change a view, that change in reflected in other sessions command cache */ /**
* Make sure that when we change a view, that change in reflected in other
* sessions command cache.
*/
private void testViewAlterAndCommandCache() throws SQLException { private void testViewAlterAndCommandCache() throws SQLException {
deleteDb("view"); deleteDb("view");
Connection conn = getConnection("view"); Connection conn = getConnection("view");
...@@ -227,4 +230,5 @@ public class TestView extends TestBase { ...@@ -227,4 +230,5 @@ public class TestView extends TestBase {
conn.close(); conn.close();
deleteDb("view"); deleteDb("view");
} }
} }
...@@ -423,8 +423,6 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> { ...@@ -423,8 +423,6 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
*/ */
static class Segment<K, V> { static class Segment<K, V> {
final CacheLIRS<K, V> cache;
/** /**
* The number of (hot, cold, and non-resident) entries in the map. * The number of (hot, cold, and non-resident) entries in the map.
*/ */
...@@ -450,6 +448,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> { ...@@ -450,6 +448,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
*/ */
long usedMemory; long usedMemory;
private final CacheLIRS<K, V> cache;
/** /**
* How many other item are to be moved to the top of the stack before * How many other item are to be moved to the top of the stack before
* the current item is moved. * the current item is moved.
...@@ -507,6 +507,7 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> { ...@@ -507,6 +507,7 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
/** /**
* Create a new cache. * Create a new cache.
* *
* @param cache the cache
* @param maxMemory the maximum memory to use * @param maxMemory the maximum memory to use
* @param averageMemory the average memory usage of an object * @param averageMemory the average memory usage of an object
* @param stackMoveDistance the number of other entries to be moved to * @param stackMoveDistance the number of other entries to be moved to
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论