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

Javadocs

上级 d69c4432
......@@ -1913,6 +1913,13 @@ public class Parser {
}
}
/**
* Find out which of the table filters appears first in the "from" clause.
*
* @param o1 the first table filter
* @param o2 the second table filter
* @return -1 if o1 appears first, and 1 if o2 appears first
*/
static int compareTableFilters(TableFilter o1, TableFilter o2) {
assert o1.getOrderInFrom() != o2.getOrderInFrom();
return o1.getOrderInFrom() > o2.getOrderInFrom() ? 1 : -1;
......
......@@ -159,6 +159,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
* @param filters all joined table filters
* @param filter the current table filter index
* @param sortOrder the sort order
* @param isScanIndex whether this is a "table scan" index
* @return the estimated cost
*/
protected final long getCostRangeIndex(int[] masks, long rowCount,
......
......@@ -225,6 +225,14 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
return new ViewCursor(this, result, first, last);
}
/**
* Set the query parameters.
*
* @param session the session
* @param first the lower bound
* @param last the upper bound
* @param intersection the intersection
*/
public void setupQueryParameters(Session session, SearchRow first, SearchRow last,
SearchRow intersection) {
ArrayList<Parameter> paramList = query.getParameters();
......
......@@ -37,6 +37,10 @@ import org.h2.value.ValueLong;
* @author Sergi Vladykin
*/
public final class JoinBatch {
/**
* An empty cursor.
*/
static final Cursor EMPTY_CURSOR = new Cursor() {
@Override
public boolean previous() {
......@@ -64,11 +68,29 @@ public final class JoinBatch {
}
};
/**
* An empty future cursor.
*/
static final Future<Cursor> EMPTY_FUTURE_CURSOR = new DoneFuture<Cursor>(EMPTY_CURSOR);
/**
* The top cursor.
*/
Future<Cursor> viewTopFutureCursor;
/**
* The top filter.
*/
JoinFilter top;
/**
* The filters.
*/
JoinFilter[] filters;
/**
* Whether this is a batched subquery.
*/
boolean batchedSubQuery;
private boolean started;
......@@ -125,6 +147,8 @@ public final class JoinBatch {
}
/**
* Register the table filter and lookup batch.
*
* @param filter table filter
* @param lookupBatch lookup batch
*/
......@@ -135,8 +159,10 @@ public final class JoinBatch {
}
/**
* Get the value for the given column.
*
* @param filterId table filter id
* @param column column
* @param column the column
* @return column value for current row
*/
public Value getValue(int filterId, Column column) {
......
......@@ -123,8 +123,8 @@ public class TableFilter implements ColumnResolver {
* @param alias the alias name
* @param rightsChecked true if rights are already checked
* @param select the select statement
* @param orderInFrom Original order number of this table filter in FROM
* clause.
* @param orderInFrom original order number (index) of this table filter in
* FROM clause (0, 1, 2,...)
*/
public TableFilter(Session session, Table table, String alias,
boolean rightsChecked, Select select, int orderInFrom) {
......@@ -140,6 +140,12 @@ public class TableFilter implements ColumnResolver {
this.orderInFrom = orderInFrom;
}
/**
* Get the order number (index) of this table filter in the "from" clause of
* the query.
*
* @return the index (0, 1, 2,...)
*/
public int getOrderInFrom() {
return orderInFrom;
}
......@@ -375,6 +381,8 @@ public class TableFilter implements ColumnResolver {
* Attempt to initialize batched join.
*
* @param jb join batch if it is already created
* @param filters the table filters
* @param filter the filter index (0, 1,...)
* @return join batch if query runs over index which supports batched
* lookups, {@code null} otherwise
*/
......@@ -555,6 +563,13 @@ public class TableFilter implements ColumnResolver {
// scanCount);
}
/**
* Whether the current value of the condition is true, or there is no
* condition.
*
* @param condition the condition (null for no condition)
* @return true if yes
*/
boolean isOk(Expression condition) {
if (condition == null) {
return true;
......
......@@ -414,6 +414,11 @@ public class TableView extends Table {
invalidate();
}
/**
* Clear the cached indexes for all sessions.
*
* @param database the database
*/
public static void clearIndexCaches(Database database) {
for (Session s : database.getSessions(true)) {
s.clearViewIndexCache();
......
......@@ -906,12 +906,17 @@ public class DateTimeUtils {
}
/**
* Adds the number of months to the date. If the resulting month's number of days is less than the original's day-of-month, the resulting
* Adds the number of months to the date. If the resulting month's number of
* days is less than the original's day-of-month, the resulting
* day-of-months gets adjusted accordingly:
*
* <br>
* 30.04.2007 - 2 months = 28.02.2007
*
* @param refDate the original date
* @param nrOfMonthsToAdd the number of months to add
* @return the new timestamp
*/
public static Timestamp addMonths(final Timestamp refDate, final int nrOfMonthsToAdd) {
public static Timestamp addMonths(Timestamp refDate, int nrOfMonthsToAdd) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(refDate);
calendar.add(Calendar.MONTH, nrOfMonthsToAdd);
......
......@@ -137,6 +137,12 @@ public class ToDateParser {
return p;
}
/**
* Remove a token from a string.
*
* @param inputFragmentStr the input fragment
* @param formatFragment the format fragment
*/
void remove(String inputFragmentStr, String formatFragment) {
if (inputFragmentStr != null && inputStr.length() >= inputFragmentStr.length()) {
inputStr = inputStr.substring(inputFragmentStr.length());
......@@ -167,11 +173,25 @@ public class ToDateParser {
return sb.toString();
}
/**
* Parse a string as a timestamp with the given format.
*
* @param input the input
* @param format the format
* @return the timestamp
*/
public static Timestamp toTimestamp(String input, String format) {
ToDateParser parser = getTimestampParser(input, format);
return parser.getResultingTimestamp();
}
/**
* Parse a string as a date with the given format.
*
* @param input the input
* @param format the format
* @return the date as a timestamp
*/
public static Timestamp toDate(String input, String format) {
ToDateParser parser = getDateParser(input, format);
return parser.getResultingTimestamp();
......
......@@ -96,7 +96,9 @@ public final class ValueTimestampUtc extends Value {
/**
* Time in nanoseconds since 1 Jan 1970 i.e. similar format to
* System.currentTimeMillis()
* System.currentTimeMillis().
*
* @return the number of milliseconds
*/
public long getUtcDateTimeNanos() {
return utcDateTimeNanos;
......@@ -105,11 +107,18 @@ public final class ValueTimestampUtc extends Value {
/**
* Time in milliseconds since 1 Jan 1970 i.e. same format as
* System.currentTimeMillis()
*
* @return the number of milliseconds
*/
public long getUtcDateTimeMillis() {
return utcDateTimeNanos / 1000 / 1000;
}
/**
* Get the number of nanoseconds since the last full millisecond.
*
* @return the number of nanoseconds
*/
int getNanosSinceLastMillis() {
return (int) (utcDateTimeNanos % (1000 * 1000));
}
......
......@@ -21,6 +21,9 @@ import javax.tools.Diagnostic;
*/
public class TestAnnotationProcessor extends AbstractProcessor {
/**
* The message key.
*/
public static final String MESSAGES_KEY =
TestAnnotationProcessor.class.getName() + "-messages";
......
......@@ -1414,23 +1414,31 @@ public class TestFunctions extends TestBase implements AggregateFunction {
Timestamp expected;
// 01-Aug-03 + 3 months = 01-Nov-03
date = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2003-08-01").getTime());
expected = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2003-11-01").getTime());
date = new Timestamp(
new SimpleDateFormat("yyyy-MM-dd").parse("2003-08-01").getTime());
expected = new Timestamp(
new SimpleDateFormat("yyyy-MM-dd").parse("2003-11-01").getTime());
assertEquals(expected, DateTimeUtils.addMonths(new Timestamp(date.getTime()), 3));
// 31-Jan-03 + 1 month = 28-Feb-2003
date = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2003-01-31").getTime());
expected = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2003-02-28").getTime());
date = new Timestamp(
new SimpleDateFormat("yyyy-MM-dd").parse("2003-01-31").getTime());
expected = new Timestamp(
new SimpleDateFormat("yyyy-MM-dd").parse("2003-02-28").getTime());
assertEquals(expected, DateTimeUtils.addMonths(new Timestamp(date.getTime()), 1));
// 21-Aug-2003 - 3 months = 21-May-2003
date = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2003-08-21").getTime());
expected = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2003-05-21").getTime());
date = new Timestamp(
new SimpleDateFormat("yyyy-MM-dd").parse("2003-08-21").getTime());
expected = new Timestamp(
new SimpleDateFormat("yyyy-MM-dd").parse("2003-05-21").getTime());
assertEquals(expected, DateTimeUtils.addMonths(new Timestamp(date.getTime()), -3));
// 21-Aug-2003 00:00:00:333 - 3 months = 21-May-2003 00:00:00:333
date = new Timestamp(new SimpleDateFormat("yyyy-MM-dd SSS").parse("2003-08-21 333").getTime());
expected = new Timestamp(new SimpleDateFormat("yyyy-MM-dd SSS").parse("2003-05-21 333").getTime());
date = new Timestamp(
new SimpleDateFormat("yyyy-MM-dd SSS").parse("2003-08-21 333").getTime());
expected = new Timestamp(
new SimpleDateFormat("yyyy-MM-dd SSS").parse("2003-05-21 333").getTime());
assertEquals(expected, DateTimeUtils.addMonths(new Timestamp(date.getTime()), -3));
}
......
......@@ -49,6 +49,9 @@ public class TestRowFactory extends TestBase {
*/
public static class MyTestRowFactory extends RowFactory {
/**
* A simple counter.
*/
static final AtomicInteger COUNTER = new AtomicInteger();
@Override
......
......@@ -684,6 +684,12 @@ public class TestTableEngines extends TestBase {
}
}
/**
* A static assertion method.
*
* @param condition the condition
* @param message the error message
*/
static void assert0(boolean condition, String message) {
if (!condition) {
throw new AssertionError(message);
......
......@@ -52,7 +52,7 @@ public class TestView extends TestBase {
deleteDb("view");
}
public void testSubQueryViewIndexCache() throws SQLException {
private void testSubQueryViewIndexCache() throws SQLException {
if (config.networked) {
return;
}
......
......@@ -1055,7 +1055,8 @@ public class TestPreparedStatement extends TestBase {
Statement stat = conn.createStatement();
stat.execute("CREATE SEQUENCE SEQ");
stat.execute("CREATE TABLE TEST(ID INT)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)");
PreparedStatement prep = conn.prepareStatement(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)");
prep.addBatch();
prep.addBatch();
prep.addBatch();
......
......@@ -122,6 +122,12 @@ public class TestMvcc4 extends TestBase {
setup.close();
}
/**
* Wait for the given thread to block on synchronizing on the database
* object.
*
* @param t the thread
*/
static void waitForThreadToBlockOnDB(Thread t) {
while (true) {
// TODO must not use getAllStackTraces, as the method names are
......
......@@ -783,3 +783,4 @@ diagnostic filer stamp turn going cancellation fetched produced incurring
interpreter batching fewer runners imperial correspond nine purge meridian
calendars moscow messager lookups unhandled buddha parslet
tzh roc xii tzm viii myydd mar vii
cristan branda fabien adam bio gomes mahon steven aug meijer lisboa todescato
......@@ -484,7 +484,8 @@ public class Doclet {
&& method.parameters().length == 0
&& returnType != null
&& returnType.toString().equals("boolean");
if (!setterOrGetter) {
boolean enumValueMethod = name.equals("values") || name.equals("valueOf");
if (!setterOrGetter && !enumValueMethod) {
addError("Undocumented method " + " ("
+ getLink(clazz, method.position().line()) + ") "
+ clazz + "." + name + " " + raw);
......
......@@ -530,7 +530,7 @@ public class ArchiveTool {
dataOut.flush();
}
static long openSegments(List<Long> segmentStart, TreeSet<ChunkStream> segmentIn,
private static long openSegments(List<Long> segmentStart, TreeSet<ChunkStream> segmentIn,
String tempFileName, boolean readKey) throws IOException {
long inPos = 0;
int bufferTotal = 64 * 1024 * 1024;
......@@ -549,7 +549,7 @@ public class ArchiveTool {
return inPos;
}
static Iterator<Chunk> merge(final TreeSet<ChunkStream> segmentIn, final Log log) {
private static Iterator<Chunk> merge(final TreeSet<ChunkStream> segmentIn, final Log log) {
return new Iterator<Chunk>() {
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论