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

Formatting / javadocs.

上级 9b215d2e
...@@ -884,7 +884,8 @@ public class Parser { ...@@ -884,7 +884,8 @@ public class Parser {
} }
boolean b = session.getAllowLiterals(); boolean b = session.getAllowLiterals();
try { try {
// need to temporarily turn this on, in case we are in ALLOW_LITERALS_NUMBERS mode // need to temporarily enable it, in case we are in
// ALLOW_LITERALS_NUMBERS mode
session.setAllowLiterals(true); session.setAllowLiterals(true);
return prepare(session, buff.toString(), paramValues); return prepare(session, buff.toString(), paramValues);
} finally { } finally {
......
...@@ -213,7 +213,7 @@ public abstract class Query extends Prepared { ...@@ -213,7 +213,7 @@ public abstract class Query extends Prepared {
public boolean isDistinct() { public boolean isDistinct() {
return distinct; return distinct;
} }
/** /**
* Whether results need to support random access. * Whether results need to support random access.
* *
...@@ -486,7 +486,7 @@ public abstract class Query extends Prepared { ...@@ -486,7 +486,7 @@ public abstract class Query extends Prepared {
public Expression getOffset() { public Expression getOffset() {
return offsetExpr; return offsetExpr;
} }
public void setLimit(Expression limit) { public void setLimit(Expression limit) {
this.limitExpr = limit; this.limitExpr = limit;
} }
...@@ -494,7 +494,7 @@ public abstract class Query extends Prepared { ...@@ -494,7 +494,7 @@ public abstract class Query extends Prepared {
public Expression getLimit() { public Expression getLimit() {
return limitExpr; return limitExpr;
} }
/** /**
* Add a parameter to the parameter list. * Add a parameter to the parameter list.
* *
......
...@@ -130,7 +130,7 @@ public class Select extends Query { ...@@ -130,7 +130,7 @@ public class Select extends Query {
public ArrayList<Expression> getGroupBy() { public ArrayList<Expression> getGroupBy() {
return group; return group;
} }
public HashMap<Expression, Object> getCurrentGroup() { public HashMap<Expression, Object> getCurrentGroup() {
return currentGroup; return currentGroup;
} }
...@@ -1093,7 +1093,7 @@ public class Select extends Query { ...@@ -1093,7 +1093,7 @@ public class Select extends Query {
public Expression getHaving() { public Expression getHaving() {
return having; return having;
} }
public int getColumnCount() { public int getColumnCount() {
return visibleColumnCount; return visibleColumnCount;
} }
......
...@@ -130,7 +130,7 @@ public final class CompressLZF implements Compressor { ...@@ -130,7 +130,7 @@ public final class CompressLZF implements Compressor {
private static int first(ByteBuffer in, int inPos) { private static int first(ByteBuffer in, int inPos) {
return (in.get(inPos) << 8) | (in.get(inPos + 1) & 255); return (in.get(inPos) << 8) | (in.get(inPos + 1) & 255);
} }
/** /**
* Shift v 1 byte left, add value at index inPos+2. * Shift v 1 byte left, add value at index inPos+2.
*/ */
...@@ -144,7 +144,7 @@ public final class CompressLZF implements Compressor { ...@@ -144,7 +144,7 @@ public final class CompressLZF implements Compressor {
private static int next(int v, ByteBuffer in, int inPos) { private static int next(int v, ByteBuffer in, int inPos) {
return (v << 8) | (in.get(inPos + 2) & 255); return (v << 8) | (in.get(inPos + 2) & 255);
} }
/** /**
* Compute the address in the hash table. * Compute the address in the hash table.
*/ */
...@@ -251,8 +251,17 @@ public final class CompressLZF implements Compressor { ...@@ -251,8 +251,17 @@ public final class CompressLZF implements Compressor {
return outPos; return outPos;
} }
public int compress(ByteBuffer in, int inLen, byte[] out, int outPos) { /**
int inPos = 0; * Compress a number of bytes.
*
* @param in the input data
* @param out the output area
* @param outPos the offset at the output array
* @return the end position
*/
public int compress(ByteBuffer in, byte[] out, int outPos) {
int inPos = in.position();
int inLen = in.capacity() - inPos;
if (cachedHashTable == null) { if (cachedHashTable == null) {
cachedHashTable = new int[HASH_SIZE]; cachedHashTable = new int[HASH_SIZE];
} }
...@@ -349,7 +358,7 @@ public final class CompressLZF implements Compressor { ...@@ -349,7 +358,7 @@ public final class CompressLZF implements Compressor {
} }
return outPos; return outPos;
} }
public void expand(byte[] in, int inPos, int inLen, byte[] out, int outPos, int outLen) { public void expand(byte[] in, int inPos, int inLen, byte[] out, int outPos, int outLen) {
// if ((inPos | outPos | outLen) < 0) { // if ((inPos | outPos | outLen) < 0) {
if (inPos < 0 || outPos < 0 || outLen < 0) { if (inPos < 0 || outPos < 0 || outLen < 0) {
...@@ -397,7 +406,16 @@ public final class CompressLZF implements Compressor { ...@@ -397,7 +406,16 @@ public final class CompressLZF implements Compressor {
} while (outPos < outLen); } while (outPos < outLen);
} }
public void expand(ByteBuffer in, int inPos, int inLen, ByteBuffer out, int outPos, int outLen) { /**
* Expand a number of compressed bytes.
*
* @param in the compressed data
* @param out the output area
*/
public static void expand(ByteBuffer in, ByteBuffer out) {
int inPos = in.position();
int outPos = out.position();
int outLen = out.capacity() - outPos;
// if ((inPos | outPos | outLen) < 0) { // if ((inPos | outPos | outLen) < 0) {
if (inPos < 0 || outPos < 0 || outLen < 0) { if (inPos < 0 || outPos < 0 || outLen < 0) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
...@@ -443,7 +461,7 @@ public final class CompressLZF implements Compressor { ...@@ -443,7 +461,7 @@ public final class CompressLZF implements Compressor {
} }
} while (outPos < outLen); } while (outPos < outLen);
} }
public int getAlgorithm() { public int getAlgorithm() {
return Compressor.LZF; return Compressor.LZF;
} }
......
...@@ -444,11 +444,11 @@ public class ErrorCode { ...@@ -444,11 +444,11 @@ public class ErrorCode {
* represent the hexadecimal encoded bytes. * represent the hexadecimal encoded bytes.
*/ */
public static final int HEX_STRING_WRONG_1 = 90004; public static final int HEX_STRING_WRONG_1 = 90004;
/** /**
* The error with code <code>90005</code> is thrown when * The error with code <code>90005</code> is thrown when
* trying to create a trigger and using the combination of SELECT and FOR EACH ROW, * trying to create a trigger and using the combination of SELECT
* which we do not support. * and FOR EACH ROW, which we do not support.
*/ */
public static final int TRIGGER_SELECT_AND_ROW_BASED_NOT_SUPPORTED = 90005; public static final int TRIGGER_SELECT_AND_ROW_BASED_NOT_SUPPORTED = 90005;
......
...@@ -588,7 +588,7 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -588,7 +588,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
} }
return false; return false;
} }
private boolean equalsValue(Object a, Object b) { private boolean equalsValue(Object a, Object b) {
if (a == b) { if (a == b) {
return true; return true;
......
...@@ -355,7 +355,8 @@ public class MVStore { ...@@ -355,7 +355,8 @@ public class MVStore {
* It contains the following entries: * It contains the following entries:
* *
* <pre> * <pre>
* map.{name} = {map metadata} * name.{name} = {mapId}
* map.{mapId} = {map metadata}
* root.{mapId} = {root position} * root.{mapId} = {root position}
* chunk.{chunkId} = {chunk metadata} * chunk.{chunkId} = {chunk metadata}
* </pre> * </pre>
......
...@@ -460,7 +460,7 @@ class FileNioMemData { ...@@ -460,7 +460,7 @@ class FileNioMemData {
ByteBuffer out = ByteBuffer.allocateDirect(BLOCK_SIZE); ByteBuffer out = ByteBuffer.allocateDirect(BLOCK_SIZE);
if (d != COMPRESSED_EMPTY_BLOCK) { if (d != COMPRESSED_EMPTY_BLOCK) {
synchronized (LZF) { synchronized (LZF) {
LZF.expand(d, 0, d.capacity(), out, 0, BLOCK_SIZE); CompressLZF.expand(d, out);
} }
} }
data[page] = out; data[page] = out;
...@@ -475,7 +475,7 @@ class FileNioMemData { ...@@ -475,7 +475,7 @@ class FileNioMemData {
static void compress(ByteBuffer[] data, int page) { static void compress(ByteBuffer[] data, int page) {
ByteBuffer d = data[page]; ByteBuffer d = data[page];
synchronized (LZF) { synchronized (LZF) {
int len = LZF.compress(d, BLOCK_SIZE, BUFFER, 0); int len = LZF.compress(d, BUFFER, 0);
d = ByteBuffer.allocateDirect(len); d = ByteBuffer.allocateDirect(len);
d.put(BUFFER, 0, len); d.put(BUFFER, 0, len);
data[page] = d; data[page] = d;
...@@ -516,7 +516,7 @@ class FileNioMemData { ...@@ -516,7 +516,7 @@ class FileNioMemData {
expand(data, lastPage); expand(data, lastPage);
ByteBuffer d = data[lastPage]; ByteBuffer d = data[lastPage];
for (int i = (int) (newLength & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) { for (int i = (int) (newLength & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) {
d.put(i, (byte)0); d.put(i, (byte) 0);
} }
if (compress) { if (compress) {
compressLater(data, lastPage); compressLater(data, lastPage);
......
...@@ -163,7 +163,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -163,7 +163,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
} }
conn.close(); conn.close();
} }
private void testViewTrigger() throws SQLException { private void testViewTrigger() throws SQLException {
Connection conn; Connection conn;
Statement stat; Statement stat;
......
...@@ -81,12 +81,12 @@ public class TestMetaData extends TestBase { ...@@ -81,12 +81,12 @@ public class TestMetaData extends TestBase {
rs.next(); rs.next();
assertEquals("PUBLIC", rs.getString("TABLE_SCHEM")); assertEquals("PUBLIC", rs.getString("TABLE_SCHEM"));
assertFalse(rs.next()); assertFalse(rs.next());
rs = meta.getSchemas(null, "PUBLIC"); rs = meta.getSchemas(null, "PUBLIC");
rs.next(); rs.next();
assertEquals("PUBLIC", rs.getString("TABLE_SCHEM")); assertEquals("PUBLIC", rs.getString("TABLE_SCHEM"));
assertFalse(rs.next()); assertFalse(rs.next());
rs = meta.getTableTypes(); rs = meta.getTableTypes();
rs.next(); rs.next();
assertEquals("SYSTEM TABLE", rs.getString("TABLE_TYPE")); assertEquals("SYSTEM TABLE", rs.getString("TABLE_TYPE"));
...@@ -892,7 +892,7 @@ public class TestMetaData extends TestBase { ...@@ -892,7 +892,7 @@ public class TestMetaData extends TestBase {
assertTrue(rs.next()); assertTrue(rs.next());
assertEquals("PUBLIC", rs.getString(1)); assertEquals("PUBLIC", rs.getString(1));
assertFalse(rs.next()); assertFalse(rs.next());
rs = meta.getCatalogs(); rs = meta.getCatalogs();
assertResultSetMeta(rs, 1, new String[] { "TABLE_CAT" }, new int[] { Types.VARCHAR }, null, null); assertResultSetMeta(rs, 1, new String[] { "TABLE_CAT" }, new int[] { Types.VARCHAR }, null, null);
assertResultSetOrdered(rs, new String[][] { { CATALOG } }); assertResultSetOrdered(rs, new String[][] { { CATALOG } });
......
...@@ -79,7 +79,7 @@ public class TestMVStore extends TestBase { ...@@ -79,7 +79,7 @@ public class TestMVStore extends TestBase {
testCloseTwice(); testCloseTwice();
testSimple(); testSimple();
} }
private void testAtomicOperations() { private void testAtomicOperations() {
String fileName = getBaseDir() + "/testAtomicOperations.h3"; String fileName = getBaseDir() + "/testAtomicOperations.h3";
FileUtils.delete(fileName); FileUtils.delete(fileName);
...@@ -89,30 +89,30 @@ public class TestMVStore extends TestBase { ...@@ -89,30 +89,30 @@ public class TestMVStore extends TestBase {
fileName(fileName). fileName(fileName).
open(); open();
m = s.openMap("data"); m = s.openMap("data");
// putIfAbsent // putIfAbsent
assertNull(m.putIfAbsent(1, new byte[1])); assertNull(m.putIfAbsent(1, new byte[1]));
assertEquals(1, m.putIfAbsent(1, new byte[2]).length); assertEquals(1, m.putIfAbsent(1, new byte[2]).length);
assertEquals(1, m.get(1).length); assertEquals(1, m.get(1).length);
// replace // replace
assertNull(m.replace(2, new byte[2])); assertNull(m.replace(2, new byte[2]));
assertNull(m.get(2)); assertNull(m.get(2));
assertEquals(1, m.replace(1, new byte[2]).length); assertEquals(1, m.replace(1, new byte[2]).length);
assertEquals(2, m.replace(1, new byte[3]).length); assertEquals(2, m.replace(1, new byte[3]).length);
assertEquals(3, m.replace(1, new byte[1]).length); assertEquals(3, m.replace(1, new byte[1]).length);
// replace with oldValue // replace with oldValue
assertFalse(m.replace(1, new byte[2], new byte[10])); assertFalse(m.replace(1, new byte[2], new byte[10]));
assertTrue(m.replace(1, new byte[1], new byte[2])); assertTrue(m.replace(1, new byte[1], new byte[2]));
assertTrue(m.replace(1, new byte[2], new byte[1])); assertTrue(m.replace(1, new byte[2], new byte[1]));
// remove // remove
assertFalse(m.remove(1, new byte[2])); assertFalse(m.remove(1, new byte[2]));
assertTrue(m.remove(1, new byte[1])); assertTrue(m.remove(1, new byte[1]));
s.close(); s.close();
FileUtils.delete(fileName); FileUtils.delete(fileName);
} }
private void testWriteBuffer() throws IOException { private void testWriteBuffer() throws IOException {
......
...@@ -16,7 +16,6 @@ import java.util.Date; ...@@ -16,7 +16,6 @@ import java.util.Date;
import java.util.Random; import java.util.Random;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.Utils; import org.h2.util.Utils;
import org.junit.Test;
/** /**
* Tests reflection utilities. * Tests reflection utilities.
...@@ -37,7 +36,6 @@ public class TestUtils extends TestBase { ...@@ -37,7 +36,6 @@ public class TestUtils extends TestBase {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
@Test
public void test() throws Exception { public void test() throws Exception {
testSortTopN(); testSortTopN();
testSortTopNRandom(); testSortTopNRandom();
...@@ -64,7 +62,7 @@ public class TestUtils extends TestBase { ...@@ -64,7 +62,7 @@ public class TestUtils extends TestBase {
assertEquals(x, y); assertEquals(x, y);
} }
} }
private void testSortTopN() { private void testSortTopN() {
Comparator<Integer> comp = new Comparator<Integer>() { Comparator<Integer> comp = new Comparator<Integer>() {
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论