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

Cleanup.

上级 9f217915
...@@ -3871,7 +3871,7 @@ public class Parser { ...@@ -3871,7 +3871,7 @@ public class Parser {
} }
return parseCreateTable(false, false, cached); return parseCreateTable(false, false, cached);
} else { } else {
boolean hash = false, primaryKey = false, unique = false, spatial = false;; boolean hash = false, primaryKey = false, unique = false, spatial = false;
String indexName = null; String indexName = null;
Schema oldSchema = null; Schema oldSchema = null;
boolean ifNotExists = false; boolean ifNotExists = false;
......
...@@ -109,7 +109,7 @@ public class CreateIndex extends SchemaCommand { ...@@ -109,7 +109,7 @@ public class CreateIndex extends SchemaCommand {
public void setSpatial(boolean b) { public void setSpatial(boolean b) {
this.spatial = b; this.spatial = b;
} }
public void setComment(String comment) { public void setComment(String comment) {
this.comment = comment; this.comment = comment;
} }
......
...@@ -292,7 +292,7 @@ public class CreateTable extends SchemaCommand { ...@@ -292,7 +292,7 @@ public class CreateTable extends SchemaCommand {
public void setTableEngineParams(ArrayList<String> tableEngineParams) { public void setTableEngineParams(ArrayList<String> tableEngineParams) {
data.tableEngineParams = tableEngineParams; data.tableEngineParams = tableEngineParams;
} }
public void setHidden(boolean isHidden) { public void setHidden(boolean isHidden) {
data.isHidden = isHidden; data.isHidden = isHidden;
} }
......
...@@ -76,7 +76,7 @@ public class CreateTableData { ...@@ -76,7 +76,7 @@ public class CreateTableData {
* The table engine params to use for creating the table. * The table engine params to use for creating the table.
*/ */
public ArrayList<String> tableEngineParams; public ArrayList<String> tableEngineParams;
/** /**
* The table is hidden. * The table is hidden.
*/ */
......
...@@ -215,7 +215,7 @@ public class ErrorCode { ...@@ -215,7 +215,7 @@ public class ErrorCode {
public static final int NO_DEFAULT_SET_1 = 23507; public static final int NO_DEFAULT_SET_1 = 23507;
/** /**
* The error with code <code>23513</code> is thrown when * The error with code <code>23513</code> is thrown when
* a check constraint is violated. Example: * a check constraint is violated. Example:
* <pre> * <pre>
* CREATE TABLE TEST(ID INT CHECK ID&gt;0); * CREATE TABLE TEST(ID INT CHECK ID&gt;0);
...@@ -229,7 +229,7 @@ public class ErrorCode { ...@@ -229,7 +229,7 @@ public class ErrorCode {
* evaluation of a check constraint resulted in a error. * evaluation of a check constraint resulted in a error.
*/ */
public static final int CHECK_CONSTRAINT_INVALID = 23514; public static final int CHECK_CONSTRAINT_INVALID = 23514;
// 28: invalid authorization specification // 28: invalid authorization specification
/** /**
......
...@@ -101,10 +101,11 @@ public class Comparison extends Condition { ...@@ -101,10 +101,11 @@ public class Comparison extends Condition {
public static final int IN_QUERY = 10; public static final int IN_QUERY = 10;
/** /**
* This is a pseudo comparison type that is only used for spatial index conditions. * This is a pseudo comparison type that is only used for spatial index
* conditions.
*/ */
public static final int SPATIAL_INTERSECTS = 11; public static final int SPATIAL_INTERSECTS = 11;
private final Database database; private final Database database;
private int compareType; private int compareType;
private Expression left; private Expression left;
......
...@@ -90,6 +90,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -90,6 +90,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
* Create a duplicate key exception with a message that contains the index * Create a duplicate key exception with a message that contains the index
* name. * name.
* *
* @param key the key values
* @return the exception * @return the exception
*/ */
protected DbException getDuplicateKeyException(String key) { protected DbException getDuplicateKeyException(String key) {
......
...@@ -61,7 +61,7 @@ public class IndexCondition { ...@@ -61,7 +61,7 @@ public class IndexCondition {
* A bit of a search mask meaning 'spatial intersection'. * A bit of a search mask meaning 'spatial intersection'.
*/ */
public static final int SPATIAL_INTERSECTS = 16; public static final int SPATIAL_INTERSECTS = 16;
private final Column column; private final Column column;
/** /**
* see constants in {@link Comparison} * see constants in {@link Comparison}
...@@ -319,7 +319,7 @@ public class IndexCondition { ...@@ -319,7 +319,7 @@ public class IndexCondition {
return false; return false;
} }
} }
public int getCompareType() { public int getCompareType() {
return compareType; return compareType;
} }
......
...@@ -148,7 +148,8 @@ public class IndexCursor implements Cursor { ...@@ -148,7 +148,8 @@ public class IndexCursor implements Cursor {
} }
if (!alwaysFalse) { if (!alwaysFalse) {
if (intersects != null && index instanceof SpatialTreeIndex) { if (intersects != null && index instanceof SpatialTreeIndex) {
cursor = ((SpatialTreeIndex)index).findByGeometry(tableFilter, intersects); cursor = ((SpatialTreeIndex) index).findByGeometry(tableFilter,
intersects);
} else { } else {
cursor = index.find(tableFilter, start, end); cursor = index.find(tableFilter, start, end);
} }
...@@ -190,7 +191,7 @@ public class IndexCursor implements Cursor { ...@@ -190,7 +191,7 @@ public class IndexCursor implements Cursor {
} }
return row; return row;
} }
private SearchRow getSearchRow(SearchRow row, int columnId, Value v, boolean max) { private SearchRow getSearchRow(SearchRow row, int columnId, Value v, boolean max) {
if (row == null) { if (row == null) {
row = table.getTemplateRow(); row = table.getTemplateRow();
......
...@@ -60,6 +60,7 @@ public class IndexType { ...@@ -60,6 +60,7 @@ public class IndexType {
* *
* @param persistent if the index is persistent * @param persistent if the index is persistent
* @param hash if a hash index should be used * @param hash if a hash index should be used
* @param spatial if a spatial index should be used
* @return the index type * @return the index type
*/ */
public static IndexType createNonUnique(boolean persistent, boolean hash, boolean spatial) { public static IndexType createNonUnique(boolean persistent, boolean hash, boolean spatial) {
...@@ -119,7 +120,7 @@ public class IndexType { ...@@ -119,7 +120,7 @@ public class IndexType {
public boolean isSpatial() { public boolean isSpatial() {
return spatial; return spatial;
} }
/** /**
* Is this index persistent? * Is this index persistent?
* *
......
/* /*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, * Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0 * Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). * (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.index; package org.h2.index;
import org.h2.result.SearchRow; import org.h2.result.SearchRow;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
/** /**
* A spatial index. Spatial indexes are used to speed up searching spatial/geometric data. * A spatial index. Spatial indexes are used to speed up searching
*/ * spatial/geometric data.
public interface SpatialIndex extends Index { */
public interface SpatialIndex extends Index {
/**
* Find a row or a list of rows and create a cursor to iterate over the result. /**
* * Find a row or a list of rows and create a cursor to iterate over the
* @param filter the table filter (which possibly knows * result.
* about additional conditions) *
* @param intersection the geometry which values should intersect with, or null for anything * @param filter the table filter (which possibly knows about additional
* @return the cursor to iterate over the results * conditions)
*/ * @param intersection the geometry which values should intersect with, or
Cursor findByGeometry(TableFilter filter, SearchRow intersection); * null for anything
} * @return the cursor to iterate over the results
*/
Cursor findByGeometry(TableFilter filter, SearchRow intersection);
}
...@@ -74,7 +74,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -74,7 +74,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
root.insert(getEnvelope(row), row); root.insert(getEnvelope(row), row);
rowCount++; rowCount++;
} }
private Envelope getEnvelope(SearchRow row) { private Envelope getEnvelope(SearchRow row) {
Value v = row.getValue(columnIds[0]); Value v = row.getValue(columnIds[0]);
Geometry g = ((ValueGeometry) v).getGeometry(); Geometry g = ((ValueGeometry) v).getGeometry();
...@@ -104,20 +104,21 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -104,20 +104,21 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Cursor find() { private Cursor find() {
// FIXME: ideally I need external iterators, but let's see if we can get // TODO use an external iterator,
// it working first // but let's see if we can get it working first
// FIXME: in the context of a spatial index, a query that uses ">" or "<" has no real meaning, so for now just ignore // TODO in the context of a spatial index,
// a query that uses ">" or "<" has no real meaning, so for now just ignore
// it and return all rows // it and return all rows
java.util.List<Row> list = root.queryAll(); List<Row> list = root.queryAll();
return new ListCursor(list, true/*first*/); return new ListCursor(list, true /*first*/);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Cursor findByGeometry(TableFilter filter, SearchRow intersection) { public Cursor findByGeometry(TableFilter filter, SearchRow intersection) {
// FIXME: ideally I need external iterators, but let's see if we can get // TODO use an external iterator,
// it working first // but let's see if we can get it working first
java.util.List<Row> list; List<Row> list;
if (intersection != null) { if (intersection != null) {
list = root.query(getEnvelope(intersection)); list = root.query(getEnvelope(intersection));
} else { } else {
...@@ -163,11 +164,11 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -163,11 +164,11 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
throw DbException.throwInternalError(); throw DbException.throwInternalError();
} }
// FIXME: ideally I need external iterators, but let's see if we can get // TODO use an external iterator,
// it working first // but let's see if we can get it working first
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Row> list = root.queryAll(); List<Row> list = root.queryAll();
return new ListCursor(list, first); return new ListCursor(list, first);
} }
...@@ -186,6 +187,9 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -186,6 +187,9 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
return 0; return 0;
} }
/**
* A cursor of a fixed list of rows.
*/
private static final class ListCursor implements Cursor { private static final class ListCursor implements Cursor {
private final List<Row> rows; private final List<Row> rows;
private int index; private int index;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论