提交 2e16bf59 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix issues with code formatting

上级 35ba0069
...@@ -106,7 +106,8 @@ public class Select extends Query { ...@@ -106,7 +106,8 @@ public class Select extends Query {
*/ */
Object[] currentGroupByExprData; Object[] currentGroupByExprData;
/** /**
* Maps an expression object to an index, to use in accessing the Object[] pointed to by groupByData. * Maps an expression object to an index, to use in accessing the Object[]
* pointed to by groupByData.
*/ */
final HashMap<Expression,Integer> exprToIndexInGroupByData = new HashMap<>(); final HashMap<Expression,Integer> exprToIndexInGroupByData = new HashMap<>();
/** /**
...@@ -1580,11 +1581,13 @@ public class Select extends Query { ...@@ -1580,11 +1581,13 @@ public class Select extends Query {
Value[] row = null; Value[] row = null;
if (previousKeyValues == null) { if (previousKeyValues == null) {
previousKeyValues = keyValues; previousKeyValues = keyValues;
currentGroupByExprData = new Object[Math.max(exprToIndexInGroupByData.size(), expressions.size())]; currentGroupByExprData =new Object[Math.max(exprToIndexInGroupByData.size(),
expressions.size())];
} else if (!Arrays.equals(previousKeyValues, keyValues)) { } else if (!Arrays.equals(previousKeyValues, keyValues)) {
row = createGroupSortedRow(previousKeyValues, columnCount); row = createGroupSortedRow(previousKeyValues, columnCount);
previousKeyValues = keyValues; previousKeyValues = keyValues;
currentGroupByExprData = new Object[Math.max(exprToIndexInGroupByData.size(), expressions.size())]; currentGroupByExprData = new Object[Math.max(exprToIndexInGroupByData.size(),
expressions.size())];
} }
currentGroupRowId++; currentGroupRowId++;
......
...@@ -934,7 +934,8 @@ public class Database implements DataHandler { ...@@ -934,7 +934,8 @@ public class Database implements DataHandler {
} }
if (SysProperties.CHECK2) { if (SysProperties.CHECK2) {
// If we are locking two different databases in the same stack, just ignore it. // If we are locking two different databases in the same stack, just ignore it.
// This only happens in TestLinkedTable where we connect to another h2 DB in the same process. // This only happens in TestLinkedTable where we connect to another h2 DB in the
// same process.
if (META_LOCK_DEBUGGING_DB.get() != null if (META_LOCK_DEBUGGING_DB.get() != null
&& META_LOCK_DEBUGGING_DB.get() != this) { && META_LOCK_DEBUGGING_DB.get() != this) {
final Session prev = META_LOCK_DEBUGGING.get(); final Session prev = META_LOCK_DEBUGGING.get();
......
...@@ -312,9 +312,10 @@ public class PageDataIndex extends PageIndex { ...@@ -312,9 +312,10 @@ public class PageDataIndex extends PageIndex {
public double getCost(Session session, int[] masks, public double getCost(Session session, int[] masks,
TableFilter[] filters, int filter, SortOrder sortOrder, TableFilter[] filters, int filter, SortOrder sortOrder,
AllColumnsForPlan allColumnsSet) { AllColumnsForPlan allColumnsSet) {
// The +200 is so that indexes that can return the same data, but have less columns, will take precedence. // The +200 is so that indexes that can return the same data, but have less
// This all works out easier in the MVStore case, because MVStore uses the same cost calculation // columns, will take precedence. This all works out easier in the MVStore case,
// code for the ScanIndex (i.e. the MVPrimaryIndex) and all other indices. // because MVStore uses the same cost calculation code for the ScanIndex (i.e.
// the MVPrimaryIndex) and all other indices.
return 10 * (tableData.getRowCountApproximation() + return 10 * (tableData.getRowCountApproximation() +
Constants.COST_ROW_OFFSET) + 200; Constants.COST_ROW_OFFSET) + 200;
} }
......
...@@ -28,7 +28,8 @@ public class TestBigResult extends TestBase { ...@@ -28,7 +28,8 @@ public class TestBigResult extends TestBase {
/** /**
* Run just this test. * Run just this test.
* *
* @param a ignored * @param a
* ignored
*/ */
public static void main(String... a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
...@@ -56,13 +57,11 @@ public class TestBigResult extends TestBase { ...@@ -56,13 +57,11 @@ public class TestBigResult extends TestBase {
int len = getSize(1000, 4000); int len = getSize(1000, 4000);
stat.execute("SET MAX_MEMORY_ROWS " + (len / 10)); stat.execute("SET MAX_MEMORY_ROWS " + (len / 10));
stat.execute("CREATE TABLE RECOVERY(TRANSACTION_ID INT, SQL_STMT VARCHAR)"); stat.execute("CREATE TABLE RECOVERY(TRANSACTION_ID INT, SQL_STMT VARCHAR)");
stat.execute("INSERT INTO RECOVERY " + stat.execute("INSERT INTO RECOVERY " + "SELECT X, CASE MOD(X, 2) WHEN 0 THEN 'commit' ELSE 'begin' END "
"SELECT X, CASE MOD(X, 2) WHEN 0 THEN 'commit' ELSE 'begin' END " + + "FROM SYSTEM_RANGE(1, " + len + ")");
"FROM SYSTEM_RANGE(1, "+len+")"); ResultSet rs = stat.executeQuery("SELECT * FROM RECOVERY " + "WHERE SQL_STMT LIKE 'begin%' AND "
ResultSet rs = stat.executeQuery("SELECT * FROM RECOVERY " + + "TRANSACTION_ID NOT IN(SELECT TRANSACTION_ID FROM RECOVERY "
"WHERE SQL_STMT LIKE 'begin%' AND " + + "WHERE SQL_STMT='commit' OR SQL_STMT='rollback')");
"TRANSACTION_ID NOT IN(SELECT TRANSACTION_ID FROM RECOVERY " +
"WHERE SQL_STMT='commit' OR SQL_STMT='rollback')");
int count = 0, last = 1; int count = 0, last = 1;
while (rs.next()) { while (rs.next()) {
assertEquals(last, rs.getInt(1)); assertEquals(last, rs.getInt(1));
...@@ -209,7 +208,8 @@ public class TestBigResult extends TestBase { ...@@ -209,7 +208,8 @@ public class TestBigResult extends TestBase {
assertFalse(rs.next()); assertFalse(rs.next());
} }
private void testSortingAndDistinct2DistinctOnly(Statement stat, String sql, int maxRows, int partCount) throws SQLException { private void testSortingAndDistinct2DistinctOnly(Statement stat, String sql, int maxRows, int partCount)
throws SQLException {
ResultSet rs; ResultSet rs;
stat.execute("SET MAX_MEMORY_ROWS " + maxRows); stat.execute("SET MAX_MEMORY_ROWS " + maxRows);
rs = stat.executeQuery(sql); rs = stat.executeQuery(sql);
...@@ -235,7 +235,8 @@ public class TestBigResult extends TestBase { ...@@ -235,7 +235,8 @@ public class TestBigResult extends TestBase {
assertFalse(rs.next()); assertFalse(rs.next());
} }
private void testSortingAndDistinct3DistinctOnly(Statement stat, String sql, int maxRows, int partCount) throws SQLException { private void testSortingAndDistinct3DistinctOnly(Statement stat, String sql, int maxRows, int partCount)
throws SQLException {
ResultSet rs; ResultSet rs;
stat.execute("SET MAX_MEMORY_ROWS " + maxRows); stat.execute("SET MAX_MEMORY_ROWS " + maxRows);
rs = stat.executeQuery(sql); rs = stat.executeQuery(sql);
...@@ -261,7 +262,8 @@ public class TestBigResult extends TestBase { ...@@ -261,7 +262,8 @@ public class TestBigResult extends TestBase {
assertFalse(rs.next()); assertFalse(rs.next());
} }
private void testSortingAndDistinct4DistinctOnly(Statement stat, String sql, int maxRows, int count) throws SQLException { private void testSortingAndDistinct4DistinctOnly(Statement stat, String sql, int maxRows, int count)
throws SQLException {
stat.execute("SET MAX_MEMORY_ROWS " + maxRows); stat.execute("SET MAX_MEMORY_ROWS " + maxRows);
ResultSet rs = stat.executeQuery(sql); ResultSet rs = stat.executeQuery(sql);
BitSet set = new BitSet(); BitSet set = new BitSet();
...@@ -278,7 +280,8 @@ public class TestBigResult extends TestBase { ...@@ -278,7 +280,8 @@ public class TestBigResult extends TestBase {
assertEquals(count, set.nextClearBit(0)); assertEquals(count, set.nextClearBit(0));
} }
private void testSortingAndDistinct4SortingOnly(Statement stat, String sql, int maxRows, int count) throws SQLException { private void testSortingAndDistinct4SortingOnly(Statement stat, String sql, int maxRows, int count)
throws SQLException {
stat.execute("SET MAX_MEMORY_ROWS " + maxRows); stat.execute("SET MAX_MEMORY_ROWS " + maxRows);
ResultSet rs = stat.executeQuery(sql); ResultSet rs = stat.executeQuery(sql);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
...@@ -377,8 +380,7 @@ public class TestBigResult extends TestBase { ...@@ -377,8 +380,7 @@ public class TestBigResult extends TestBase {
// rs.close(); // rs.close();
conn.close(); conn.close();
deleteDb("bigResult"); deleteDb("bigResult");
ArrayList<String> files = FileLister.getDatabaseFiles(getBaseDir(), ArrayList<String> files = FileLister.getDatabaseFiles(getBaseDir(), "bigResult", true);
"bigResult", true);
if (files.size() > 0) { if (files.size() > 0) {
fail("file not deleted: " + files.get(0)); fail("file not deleted: " + files.get(0));
} }
...@@ -415,15 +417,10 @@ public class TestBigResult extends TestBase { ...@@ -415,15 +417,10 @@ public class TestBigResult extends TestBase {
Connection conn = getConnection("bigResult"); Connection conn = getConnection("bigResult");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST"); stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("CREATE TABLE TEST(" + stat.execute("CREATE TABLE TEST(" + "ID INT PRIMARY KEY, " + "Name VARCHAR(255), " + "FirstName VARCHAR(255), "
"ID INT PRIMARY KEY, " + + "Points INT," + "LicenseID INT)");
"Name VARCHAR(255), " +
"FirstName VARCHAR(255), " +
"Points INT," +
"LicenseID INT)");
int len = getSize(10, 5000); int len = getSize(10, 5000);
PreparedStatement prep = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?, ?, ?, ?)");
"INSERT INTO TEST VALUES(?, ?, ?, ?, ?)");
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
prep.setInt(1, i); prep.setInt(1, i);
prep.setString(2, "Name " + i); prep.setString(2, "Name " + i);
...@@ -474,8 +471,7 @@ public class TestBigResult extends TestBase { ...@@ -474,8 +471,7 @@ public class TestBigResult extends TestBase {
prep.setString(2, "" + i / 200); prep.setString(2, "" + i / 200);
prep.execute(); prep.execute();
} }
Statement s2 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, Statement s2 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet.CONCUR_UPDATABLE);
rs = s2.executeQuery("SELECT NAME FROM DATA"); rs = s2.executeQuery("SELECT NAME FROM DATA");
rs.last(); rs.last();
conn.setAutoCommit(true); conn.setAutoCommit(true);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论