提交 5c555202 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Formatting, Javadocs

上级 986af2a3
......@@ -144,6 +144,7 @@ public class Driver implements java.sql.Driver {
* [Not supported]
*/
/*## Java 1.7 ##
@Override
public Logger getParentLogger() {
return null;
}
......
......@@ -1913,7 +1913,7 @@ public class Parser {
}
}
private static int compareTableFilters(TableFilter o1, TableFilter o2) {
static int compareTableFilters(TableFilter o1, TableFilter o2) {
assert o1.getOrderInFrom() != o2.getOrderInFrom();
return o1.getOrderInFrom() > o2.getOrderInFrom() ? 1 : -1;
}
......
......@@ -9,7 +9,6 @@ import org.h2.command.dml.Query;
import org.h2.engine.Session;
import org.h2.result.LocalResult;
import org.h2.table.ColumnResolver;
import org.h2.table.SubQueryInfo;
import org.h2.table.TableFilter;
import org.h2.util.StringUtils;
import org.h2.value.Value;
......
......@@ -13,7 +13,6 @@ import org.h2.index.IndexCondition;
import org.h2.message.DbException;
import org.h2.result.LocalResult;
import org.h2.table.ColumnResolver;
import org.h2.table.SubQueryInfo;
import org.h2.table.TableFilter;
import org.h2.util.StringUtils;
import org.h2.value.Value;
......
......@@ -12,7 +12,6 @@ import org.h2.engine.Session;
import org.h2.message.DbException;
import org.h2.result.ResultInterface;
import org.h2.table.ColumnResolver;
import org.h2.table.SubQueryInfo;
import org.h2.table.TableFilter;
import org.h2.value.Value;
import org.h2.value.ValueArray;
......
......@@ -29,7 +29,7 @@ public interface IndexLookupBatch {
* @param last the last row, or null for no limit
* @return {@code false} if this search row pair is known to produce no results
* and thus the given row pair was not added
* @see Index#find(TableFilter, SearchRow, SearchRow)
* @see Index#find(org.h2.table.TableFilter, SearchRow, SearchRow)
*/
boolean addSearchRows(SearchRow first, SearchRow last);
......
......@@ -171,8 +171,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
return (Query) p;
}
private Cursor findRecursive(Session session, SearchRow first, SearchRow last,
SearchRow intersection) {
private Cursor findRecursive(SearchRow first, SearchRow last) {
assert recursive;
LocalResult recResult = view.getRecursiveResult();
if (recResult != null) {
......@@ -266,7 +265,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
private Cursor find(Session session, SearchRow first, SearchRow last,
SearchRow intersection) {
if (recursive) {
return findRecursive(session, first, last, intersection);
return findRecursive(first, last);
}
setupQueryParameters(session, first, last, intersection);
LocalResult result = query.query(0);
......
......@@ -25,7 +25,7 @@ public abstract class RowFactory {
/**
* Default implementation of row factory.
*/
private static final class DefaultRowFactory extends RowFactory {
static final class DefaultRowFactory extends RowFactory {
@Override
public Row createRow(Value[] data, int memory) {
return new RowImpl(data, memory);
......
......@@ -33,6 +33,7 @@ public class RowImpl extends Row {
*
* @return a new row with the same data
*/
@Override
public Row getCopy() {
Value[] d2 = new Value[data.length];
System.arraycopy(data, 0, d2, 0, data.length);
......@@ -54,6 +55,7 @@ public class RowImpl extends Row {
return version;
}
@Override
public void setVersion(int version) {
this.version = version;
}
......@@ -79,6 +81,7 @@ public class RowImpl extends Row {
* @param dummy the template buffer
* @return the number of bytes
*/
@Override
public int getByteCount(Data dummy) {
int size = 0;
for (Value v : data) {
......@@ -96,6 +99,7 @@ public class RowImpl extends Row {
}
}
@Override
public boolean isEmpty() {
return data == null;
}
......@@ -145,14 +149,17 @@ public class RowImpl extends Row {
return buff.append(')').toString();
}
@Override
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
@Override
public void setSessionId(int sessionId) {
this.sessionId = sessionId;
}
@Override
public int getSessionId() {
return sessionId;
}
......@@ -160,14 +167,17 @@ public class RowImpl extends Row {
/**
* This record has been committed. The session id is reset.
*/
@Override
public void commit() {
this.sessionId = 0;
}
@Override
public boolean isDeleted() {
return deleted;
}
@Override
public Value[] getValueList() {
return data;
}
......
......@@ -37,7 +37,7 @@ import org.h2.value.ValueLong;
* @author Sergi Vladykin
*/
public final class JoinBatch {
private static final Cursor EMPTY_CURSOR = new Cursor() {
static final Cursor EMPTY_CURSOR = new Cursor() {
@Override
public boolean previous() {
return false;
......@@ -64,13 +64,12 @@ public final class JoinBatch {
}
};
private static final Future<Cursor> EMPTY_FUTURE_CURSOR = new DoneFuture<Cursor>(EMPTY_CURSOR);
static final Future<Cursor> EMPTY_FUTURE_CURSOR = new DoneFuture<Cursor>(EMPTY_CURSOR);
private boolean batchedSubQuery;
private Future<Cursor> viewTopFutureCursor;
private JoinFilter[] filters;
private JoinFilter top;
Future<Cursor> viewTopFutureCursor;
JoinFilter top;
JoinFilter[] filters;
boolean batchedSubQuery;
private boolean started;
......@@ -177,7 +176,7 @@ public final class JoinBatch {
/**
* Get next row from the join batch.
*
* @return
* @return true if there is a next row
*/
public boolean next() {
if (!started) {
......@@ -411,13 +410,12 @@ public final class JoinBatch {
* Table filter participating in batched join.
*/
private static final class JoinFilter {
private final TableFilter filter;
private final JoinFilter join;
private final int id;
private final IndexLookupBatch lookupBatch;
final IndexLookupBatch lookupBatch;
final int id;
final JoinFilter join;
final TableFilter filter;
private JoinFilter(IndexLookupBatch lookupBatch, TableFilter filter, JoinFilter join) {
JoinFilter(IndexLookupBatch lookupBatch, TableFilter filter, JoinFilter join) {
this.filter = filter;
this.id = filter.getJoinFilterId();
this.join = join;
......@@ -425,32 +423,32 @@ public final class JoinBatch {
assert lookupBatch != null || id == 0;
}
private void reset(boolean beforeQuery) {
void reset(boolean beforeQuery) {
if (lookupBatch != null) {
lookupBatch.reset(beforeQuery);
}
}
private Row getNullRow() {
Row getNullRow() {
return filter.getTable().getNullRow();
}
private boolean isOuterJoin() {
boolean isOuterJoin() {
return filter.isJoinOuter();
}
private boolean isBatchFull() {
boolean isBatchFull() {
return lookupBatch.isBatchFull();
}
private boolean isOk(boolean ignoreJoinCondition) {
boolean isOk(boolean ignoreJoinCondition) {
boolean filterOk = filter.isOk(filter.getFilterCondition());
boolean joinOk = filter.isOk(filter.getJoinCondition());
return filterOk && (ignoreJoinCondition || joinOk);
}
private boolean collectSearchRows() {
boolean collectSearchRows() {
assert !isBatchFull();
IndexCursor c = filter.getIndexCursor();
c.prepare(filter.getSession(), filter.getIndexConditions());
......@@ -460,11 +458,11 @@ public final class JoinBatch {
return lookupBatch.addSearchRows(c.getStart(), c.getEnd());
}
private List<Future<Cursor>> find() {
List<Future<Cursor>> find() {
return lookupBatch.find();
}
private JoinRow find(JoinRow current) {
JoinRow find(JoinRow current) {
assert current != null;
// lookupBatch is allowed to be empty when we have some null-rows and forced find call
......@@ -520,6 +518,9 @@ public final class JoinBatch {
private static final long S_MASK = 3;
JoinRow prev;
JoinRow next;
/**
* May contain one of the following:
* <br/>- {@code null}: means that we need to get future cursor for this row
......@@ -530,13 +531,10 @@ public final class JoinBatch {
private Object[] row;
private long state;
private JoinRow prev;
private JoinRow next;
/**
* @param row Row.
*/
private JoinRow(Object[] row) {
JoinRow(Object[] row) {
this.row = row;
}
......@@ -563,22 +561,22 @@ public final class JoinBatch {
state += i << (joinFilterId << 1);
}
private void updateRow(int joinFilterId, Object x, long oldState, long newState) {
void updateRow(int joinFilterId, Object x, long oldState, long newState) {
assert getState(joinFilterId) == oldState : "old state: " + getState(joinFilterId);
row[joinFilterId] = x;
incrementState(joinFilterId, newState - oldState);
assert getState(joinFilterId) == newState : "new state: " + getState(joinFilterId);
}
private Object row(int joinFilterId) {
Object row(int joinFilterId) {
return row[joinFilterId];
}
private boolean isRow(int joinFilterId) {
boolean isRow(int joinFilterId) {
return getState(joinFilterId) == S_ROW;
}
private boolean isFuture(int joinFilterId) {
boolean isFuture(int joinFilterId) {
return getState(joinFilterId) == S_FUTURE;
}
......@@ -586,15 +584,15 @@ public final class JoinBatch {
return getState(joinFilterId) == S_CURSOR;
}
private boolean isComplete() {
boolean isComplete() {
return isRow(row.length - 1);
}
private boolean isDropped() {
boolean isDropped() {
return row == null;
}
private void drop() {
void drop() {
if (prev != null) {
prev.next = next;
}
......@@ -610,7 +608,7 @@ public final class JoinBatch {
* @param jfId The last fetched filter id.
* @return The copy.
*/
private JoinRow copyBehind(int jfId) {
JoinRow copyBehind(int jfId) {
assert isCursor(jfId);
assert jfId + 1 == row.length || row[jfId + 1] == null;
......@@ -651,7 +649,7 @@ public final class JoinBatch {
private final List<Future<Cursor>> result = new SingletonList<Future<Cursor>>();
private FakeLookupBatch(TableFilter filter) {
FakeLookupBatch(TableFilter filter) {
this.filter = filter;
}
......@@ -697,7 +695,7 @@ public final class JoinBatch {
/**
* Simple singleton list.
*/
private static final class SingletonList<E> extends AbstractList<E> {
static final class SingletonList<E> extends AbstractList<E> {
private E element;
@Override
......@@ -843,7 +841,7 @@ public final class JoinBatch {
* View index lookup batch for a simple SELECT.
*/
private final class ViewIndexLookupBatch extends ViewIndexLookupBatchBase<QueryRunner> {
private ViewIndexLookupBatch(ViewIndex viewIndex) {
ViewIndexLookupBatch(ViewIndex viewIndex) {
super(viewIndex);
}
......@@ -882,12 +880,13 @@ public final class JoinBatch {
* Query runner.
*/
private final class QueryRunner extends QueryRunnerBase {
private Future<Cursor> topFutureCursor;
Future<Cursor> topFutureCursor;
public QueryRunner(ViewIndex viewIndex) {
super(viewIndex);
}
@Override
protected void clear() {
super.clear();
topFutureCursor = null;
......@@ -916,15 +915,15 @@ public final class JoinBatch {
*/
private static final class ViewIndexLookupBatchUnion
extends ViewIndexLookupBatchBase<QueryRunnerUnion> {
private ArrayList<JoinFilter> filters;
private ArrayList<JoinBatch> joinBatches;
ArrayList<JoinFilter> filters;
ArrayList<JoinBatch> joinBatches;
private boolean onlyBatchedQueries = true;
protected ViewIndexLookupBatchUnion(ViewIndex viewIndex) {
super(viewIndex);
}
private boolean initialize() {
boolean initialize() {
return collectJoinBatches(viewIndex.getQuery()) && joinBatches != null;
}
......@@ -1005,8 +1004,8 @@ public final class JoinBatch {
* Query runner for UNION.
*/
private static class QueryRunnerUnion extends QueryRunnerBase {
Future<Cursor>[] topFutureCursors;
private ViewIndexLookupBatchUnion batchUnion;
private Future<Cursor>[] topFutureCursors;
@SuppressWarnings("unchecked")
public QueryRunnerUnion(ViewIndexLookupBatchUnion batchUnion) {
......
......@@ -240,6 +240,16 @@ public abstract class Table extends SchemaObjectBase {
*/
public abstract Index getScanIndex(Session session);
/**
* Get the scan index for this table.
*
* @param session the session
* @param masks the search mask
* @param filters the table filters
* @param filter the filer index
* @param sortOrder the sort order
* @return the scan index
*/
public Index getScanIndex(Session session, int[] masks,
TableFilter[] filters, int filter, SortOrder sortOrder) {
return getScanIndex(session);
......
......@@ -21,7 +21,6 @@ import org.h2.index.Index;
import org.h2.index.IndexCondition;
import org.h2.index.IndexCursor;
import org.h2.index.IndexLookupBatch;
import org.h2.index.ScanIndex;
import org.h2.index.ViewIndex;
import org.h2.message.DbException;
import org.h2.result.Row;
......@@ -374,7 +373,6 @@ public class TableFilter implements ColumnResolver {
/**
* Attempt to initialize batched join.
*
* @param id join filter id (index of this table filter in join list)
* @param jb join batch if it is already created
* @return join batch if query runs over index which supports batched lookups, {@code null} otherwise
*/
......
......@@ -366,7 +366,7 @@ public class SourceCompiler {
boolean syntaxError = false;
final BufferedReader reader = new BufferedReader(new StringReader(output));
try {
for (String line; (line = reader.readLine()) != null; ) {
for (String line; (line = reader.readLine()) != null;) {
if (line.startsWith("Note:") || line.startsWith("warning:")) {
// just a warning (e.g. unchecked or unsafe operations)
} else {
......
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.ap;
import java.util.ArrayList;
......@@ -11,10 +16,14 @@ import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
/**
* An annotation processor for testing.
*/
public class TestAnnotationProcessor extends AbstractProcessor {
public static final String MESSAGES_KEY = TestAnnotationProcessor.class.getName() + "-messages";
@Override
public Set<String> getSupportedAnnotationTypes() {
for (OutputMessage outputMessage : findMessages()) {
......@@ -24,15 +33,15 @@ public class TestAnnotationProcessor extends AbstractProcessor {
return Collections.emptySet();
}
private List<OutputMessage> findMessages() {
private static List<OutputMessage> findMessages() {
final String messagesStr = System.getProperty(MESSAGES_KEY);
if (messagesStr == null || messagesStr.isEmpty()) {
return Collections.emptyList();
} else {
final List<OutputMessage> outputMessages = new ArrayList<OutputMessage>();
}
List<OutputMessage> outputMessages = new ArrayList<OutputMessage>();
for (String msg : messagesStr.split("\\|")) {
final String[] split = msg.split(",");
String[] split = msg.split(",");
if (split.length == 2) {
outputMessages.add(new OutputMessage(Diagnostic.Kind.valueOf(split[0]), split[1]));
} else {
......@@ -42,8 +51,8 @@ public class TestAnnotationProcessor extends AbstractProcessor {
return outputMessages;
}
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
......@@ -53,11 +62,14 @@ public class TestAnnotationProcessor extends AbstractProcessor {
return false;
}
/**
* An output message.
*/
private static class OutputMessage {
public final Diagnostic.Kind kind;
public final String message;
private OutputMessage(Diagnostic.Kind kind, String message) {
OutputMessage(Diagnostic.Kind kind, String message) {
this.kind = kind;
this.message = message;
}
......
......@@ -49,7 +49,7 @@ public class TestRowFactory extends TestBase {
*/
public static class MyTestRowFactory extends RowFactory {
private static final AtomicInteger COUNTER = new AtomicInteger();
static final AtomicInteger COUNTER = new AtomicInteger();
@Override
public Row createRow(Value[] data, int memory) {
......
......@@ -27,7 +27,6 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import org.h2.api.TableEngine;
import org.h2.command.ddl.CreateTableData;
import org.h2.engine.Constants;
import org.h2.engine.Session;
import org.h2.expression.Expression;
import org.h2.index.BaseIndex;
......@@ -468,7 +467,7 @@ public class TestTableEngines extends TestBase {
deleteDb("testBatchedJoin");
}
private void forceJoinOrder(Statement s, boolean force) throws SQLException {
private static void forceJoinOrder(Statement s, boolean force) throws SQLException {
s.executeUpdate("SET FORCE_JOIN_ORDER " + force);
}
......@@ -663,7 +662,7 @@ public class TestTableEngines extends TestBase {
}
}
private static void assert0(boolean condition, String message) {
static void assert0(boolean condition, String message) {
if (!condition) {
throw new AssertionError(message);
}
......@@ -686,7 +685,7 @@ public class TestTableEngines extends TestBase {
}
}
private String generateQuery(int t, int tables) {
private static String generateQuery(int t, int tables) {
final int withLeft = 1;
final int withFalse = 2;
final int withWhere = 4;
......@@ -1284,16 +1283,16 @@ public class TestTableEngines extends TestBase {
* An index that internally uses a tree set.
*/
private static class TreeSetIndex extends BaseIndex implements Comparator<SearchRow> {
private static AtomicInteger lookupBatches = new AtomicInteger();
/**
* Executor service to test batched joins.
*/
private static ExecutorService exec;
static ExecutorService exec;
static AtomicInteger lookupBatches = new AtomicInteger();
private final TreeSet<SearchRow> set = new TreeSet<SearchRow>(this);
int preferedBatchSize;
private int preferedBatchSize;
final TreeSet<SearchRow> set = new TreeSet<SearchRow>(this);
TreeSetIndex(Table t, String name, IndexColumn[] cols, IndexType type) {
initBaseIndex(t, 0, name, cols, type);
......@@ -1529,7 +1528,7 @@ public class TestTableEngines extends TestBase {
/**
*/
private static class IteratorCursor implements Cursor {
private Iterator<SearchRow> it;
Iterator<SearchRow> it;
private Row current;
public IteratorCursor(Iterator<SearchRow> it) {
......
......@@ -71,6 +71,7 @@ public class TestMvcc4 extends TestBase {
final Thread mainThread = Thread.currentThread();
final CountDownLatch executedUpdate = new CountDownLatch(1);
new Thread() {
@Override
public void run() {
try {
Connection c2 = getConnection("mvcc4");
......@@ -96,6 +97,7 @@ public class TestMvcc4 extends TestBase {
try {
executedUpdate.await();
} catch (InterruptedException e) {
// ignore
}
// Execute an update. This should initially fail, and enter the waiting
......@@ -120,7 +122,7 @@ public class TestMvcc4 extends TestBase {
setup.close();
}
private static void waitForThreadToBlockOnDB(Thread t) {
static void waitForThreadToBlockOnDB(Thread t) {
while (true) {
// TODO must not use getAllStackTraces, as the method names are
// implementation details
......@@ -135,6 +137,7 @@ public class TestMvcc4 extends TestBase {
try {
Thread.sleep(10);
} catch (InterruptedException e1) {
// ignore
}
}
}
......
......@@ -315,9 +315,8 @@ public class BuildBase {
newArgs.add(script);
newArgs.addAll(args);
return exec("cmd", newArgs);
} else {
return exec(script, args);
}
return exec(script, args);
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论