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

--no commit message

--no commit message
上级 4b0fe6a5
......@@ -547,14 +547,6 @@ public class Select extends Query {
}
}
cost = preparePlan();
if (sort != null && !isQuickQuery && !isGroupQuery && !distinct) {
Index index = getSortIndex();
Index current = topTableFilter.getIndex();
if (index != null && (current.getIndexType().isScan() || current == index)) {
topTableFilter.setIndex(index);
sortUsingIndex = true;
}
}
if (SysProperties.OPTIMIZE_DISTINCT && distinct && !isGroupQuery && filters.size() == 1 && expressions.size() == 1 && condition == null) {
Expression expr = (Expression) expressions.get(0);
expr = expr.getNonAliasExpression();
......@@ -578,6 +570,14 @@ public class Select extends Query {
}
}
}
if (sort != null && !isQuickQuery && !isGroupQuery && (!distinct || isDistinctQuery)) {
Index index = getSortIndex();
Index current = topTableFilter.getIndex();
if (index != null && (current.getIndexType().isScan() || current == index)) {
topTableFilter.setIndex(index);
sortUsingIndex = true;
}
}
}
public double getCost() {
......
......@@ -149,8 +149,7 @@ java org.h2.test.TestAll timer
/*
(code coverage: limit, sample-size)
add tests with select distinct type
check no more @author
staging.trace.db.gz
......
......@@ -70,6 +70,18 @@ public class TestOptimizations extends TestBase {
check(i, rs.getInt(1));
}
checkFalse(rs.next());
rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE LIMIT 5 OFFSET 2");
for (int i = 2; i < 7; i++) {
rs.next();
check(i, rs.getInt(1));
}
checkFalse(rs.next());
rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE LIMIT 0 OFFSET 0 SAMPLE_SIZE 3");
for (int i = 0; i < 3; i++) {
rs.next();
check(i, rs.getInt(1));
}
checkFalse(rs.next());
conn.close();
}
......
......@@ -21,6 +21,9 @@ import org.h2.util.IOUtils;
import org.h2.util.NetUtils;
import org.h2.util.StringUtils;
/**
* A simple standalone FTP client.
*/
public class FtpClient {
private Socket socket;
private BufferedReader reader;
......
......@@ -11,9 +11,8 @@ import org.h2.test.TestBase;
import org.h2.util.BitField;
/**
* @author Thomas
* A unit test for bit fields.
*/
public class TestBitField extends TestBase {
public void test() throws Exception {
......
......@@ -11,6 +11,9 @@ import java.util.Random;
import org.h2.test.TestBase;
/**
* Tests the cache.
*/
public class TestCache extends TestBase {
public void test() throws Exception {
......
......@@ -9,67 +9,11 @@ import java.util.Random;
import org.h2.test.TestBase;
import org.h2.tools.CompressTool;
/**
* Data compression tests.
*/
public class TestCompress extends TestBase {
public static void main(String[] a) throws Exception {
byte[] data = new byte[1000];
long total = 0;
for (int i = 100; i < 104; i++) {
long time = System.currentTimeMillis();
for (int j = 0; j < 10000000; j++) {
// System.arraycopy(data, 0, data, 100, 11);
// for (int k = 0, n = 100; k < 11; k++) {
// data[k] = data[n++];
// }
int outPos = 0, ctrl = 100, len = i;
// do {
// switch((len - outPos) & 7) {
// case 0:
// data[outPos] = data[outPos++ + ctrl];
// case 7:
// data[outPos] = data[outPos++ + ctrl];
// case 6:
// data[outPos] = data[outPos++ + ctrl];
// case 5:
// data[outPos] = data[outPos++ + ctrl];
// case 4:
// data[outPos] = data[outPos++ + ctrl];
// case 3:
// data[outPos] = data[outPos++ + ctrl];
// case 2:
// data[outPos] = data[outPos++ + ctrl];
// case 1:
// data[outPos] = data[outPos++ + ctrl];
// }
// } while(outPos < len);
//
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
while (outPos < len - 8) {
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
}
while (outPos < len) {
data[outPos] = data[outPos++ + ctrl];
}
}
// now: 8907/11859, switch: 9078/14782
long t = (System.currentTimeMillis() - time);
total += t;
System.out.println("i: " + i + " time: " + t);
}
System.out.println("total: " + total);
}
public void test() throws Exception {
if (config.big) {
for (int i = 0; i < 100; i++) {
......
......@@ -18,9 +18,8 @@ import org.h2.value.ValueNull;
import org.h2.value.ValueString;
/**
* @author Thomas
* Data page tests.
*/
public class TestDataPage extends TestBase implements DataHandler {
boolean text;
......
......@@ -11,6 +11,12 @@ import org.h2.test.TestBase;
import org.h2.util.DateTimeUtils;
import org.h2.value.Value;
/**
* Tests the data parsing.
* The problem is that some dates are not allowed because of the summer time change.
* Most countries change at 2 o'clock in the morning to 3 o'clock, but some
* (for example Chile) change at midnight. Non-lenient parsing wouldn't work in this case.
*/
public class TestDate extends TestBase {
public void test() throws Exception {
......
......@@ -13,6 +13,10 @@ import java.sql.SQLException;
import org.h2.api.DatabaseEventListener;
import org.h2.test.TestBase;
/**
* Tests the flag db_close_on_exit.
* A new process is started.
*/
public class TestExit extends TestBase implements DatabaseEventListener {
public void test() throws Exception {
......
......@@ -12,6 +12,9 @@ import org.h2.test.TestBase;
import org.h2.util.FileUtils;
import org.h2.value.Value;
/**
* Tests the in-memory file system.
*/
public class TestFile extends TestBase implements DataHandler {
public void test() throws Exception {
......
......@@ -11,7 +11,8 @@ import org.h2.store.FileLock;
import org.h2.test.TestBase;
/**
* @author Thomas
* Tests the database file locking facility.
* Both lock files and sockets locking is tested.
*/
public class TestFileLock extends TestBase implements Runnable {
......
......@@ -19,6 +19,9 @@ import org.h2.store.fs.FileObject;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase;
/**
* Tests various file system.
*/
public class TestFileSystem extends TestBase {
public void test() throws Exception {
......
......@@ -10,6 +10,9 @@ import org.h2.server.ftp.FtpServer;
import org.h2.test.TestBase;
import org.h2.tools.Server;
/**
* Tests the FTP server tool.
*/
public class TestFtp extends TestBase implements FtpEventListener {
private FtpEvent lastEvent;
......
......@@ -9,6 +9,9 @@ import java.util.Random;
import org.h2.test.TestBase;
import org.h2.util.IntArray;
/**
* Tests the IntArray class.
*/
public class TestIntArray extends TestBase {
public void test() throws Exception {
......
......@@ -9,6 +9,9 @@ import java.util.Random;
import org.h2.test.TestBase;
import org.h2.util.IntIntHashMap;
/**
* Tests the IntHashMap class.
*/
public class TestIntIntHashMap extends TestBase {
Random rand = new Random();
......
......@@ -11,6 +11,9 @@ import java.sql.SQLException;
import org.h2.test.TestBase;
/**
* Tests the multi-threaded kernel feature.
*/
public class TestMultiThreadedKernel extends TestBase implements Runnable {
private String url, user, password;
......
......@@ -14,6 +14,10 @@ import org.h2.test.TestBase;
import org.h2.value.Value;
import org.h2.value.ValueString;
/**
* Tests numeric overflow on various data types.
* Other than in Java, overflow is detected and an exception is thrown.
*/
public class TestOverflow extends TestBase {
public void test() throws Exception {
......
......@@ -9,7 +9,7 @@ import org.h2.test.TestBase;
import org.h2.value.CompareMode;
/**
* @author Thomas
* Tests LIKE pattern matching.
*/
public class TestPattern extends TestBase {
......
......@@ -12,6 +12,9 @@ import java.io.StringReader;
import org.h2.test.TestBase;
import org.h2.util.IOUtils;
/**
* Tests the stream to UTF-8 reader conversion.
*/
public class TestReader extends TestBase {
public void test() throws Exception {
......
......@@ -12,6 +12,9 @@ import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles;
import org.h2.util.StringUtils;
/**
* Tests the sample apps.
*/
public class TestSampleApps extends TestBase {
public void test() throws Exception {
......
......@@ -10,6 +10,9 @@ import java.util.Random;
import org.h2.test.TestBase;
import org.h2.util.ScriptReader;
/**
* Tests the script reader tool that breaks up SQL scripts in statements.
*/
public class TestScriptReader extends TestBase {
public void test() throws Exception {
......
......@@ -11,9 +11,8 @@ import org.h2.test.TestBase;
import org.h2.util.ByteUtils;
/**
* @author Thomas
* Tests various security primitives.
*/
public class TestSecurity extends TestBase {
public void test() throws Exception {
......
......@@ -12,6 +12,9 @@ import org.h2.compress.LZFInputStream;
import org.h2.compress.LZFOutputStream;
import org.h2.test.TestBase;
/**
* Tests the LZF stream.
*/
public class TestStreams extends TestBase {
public void test() throws Exception {
......
......@@ -9,6 +9,9 @@ import java.util.Random;
import org.h2.test.TestBase;
import org.h2.util.StringCache;
/**
* Tests the string cache facility.
*/
public class TestStringCache extends TestBase {
public static void main(String[] args) throws Exception {
......
......@@ -12,6 +12,9 @@ import java.util.Random;
import org.h2.test.TestBase;
import org.h2.util.StringUtils;
/**
* Tests string utility methods.
*/
public class TestStringUtils extends TestBase {
public void test() throws Exception {
......
......@@ -30,6 +30,9 @@ import org.h2.tools.Script;
import org.h2.tools.Server;
import org.h2.util.Resources;
/**
* Tests the database tools.
*/
public class TestTools extends TestBase {
private Server server;
......
......@@ -7,6 +7,9 @@ package org.h2.test.unit;
import org.h2.test.TestBase;
import org.h2.value.ValueUuid;
/**
* Tests features of values.
*/
public class TestValue extends TestBase {
public void test() throws Exception {
......
......@@ -18,6 +18,9 @@ import org.h2.value.CompareMode;
import org.h2.value.Value;
import org.h2.value.ValueInt;
/**
* Tests the value hash map.
*/
public class TestValueHashMap extends TestBase implements DataHandler {
CompareMode compareMode = new CompareMode(null, null);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论