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

Cleanup.

上级 9f217915
......@@ -3871,7 +3871,7 @@ public class Parser {
}
return parseCreateTable(false, false, cached);
} else {
boolean hash = false, primaryKey = false, unique = false, spatial = false;;
boolean hash = false, primaryKey = false, unique = false, spatial = false;
String indexName = null;
Schema oldSchema = null;
boolean ifNotExists = false;
......
......@@ -101,7 +101,8 @@ public class Comparison extends Condition {
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;
......
......@@ -90,6 +90,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
* Create a duplicate key exception with a message that contains the index
* name.
*
* @param key the key values
* @return the exception
*/
protected DbException getDuplicateKeyException(String key) {
......
......@@ -148,7 +148,8 @@ public class IndexCursor implements Cursor {
}
if (!alwaysFalse) {
if (intersects != null && index instanceof SpatialTreeIndex) {
cursor = ((SpatialTreeIndex)index).findByGeometry(tableFilter, intersects);
cursor = ((SpatialTreeIndex) index).findByGeometry(tableFilter,
intersects);
} else {
cursor = index.find(tableFilter, start, end);
}
......
......@@ -60,6 +60,7 @@ public class IndexType {
*
* @param persistent if the index is persistent
* @param hash if a hash index should be used
* @param spatial if a spatial index should be used
* @return the index type
*/
public static IndexType createNonUnique(boolean persistent, boolean hash, boolean spatial) {
......
......@@ -10,17 +10,21 @@ import org.h2.result.SearchRow;
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 {
/**
* 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
* result.
*
* @param filter the table filter (which possibly knows
* 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
* conditions)
* @param intersection the geometry which values should intersect with, or
* null for anything
* @return the cursor to iterate over the results
*/
Cursor findByGeometry(TableFilter filter, SearchRow intersection);
}
......@@ -104,20 +104,21 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
@SuppressWarnings("unchecked")
private Cursor find() {
// FIXME: ideally I need external iterators, 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 use an external iterator,
// but let's see if we can get it working first
// 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
java.util.List<Row> list = root.queryAll();
return new ListCursor(list, true/*first*/);
List<Row> list = root.queryAll();
return new ListCursor(list, true /*first*/);
}
@SuppressWarnings("unchecked")
@Override
public Cursor findByGeometry(TableFilter filter, SearchRow intersection) {
// FIXME: ideally I need external iterators, but let's see if we can get
// it working first
java.util.List<Row> list;
// TODO use an external iterator,
// but let's see if we can get it working first
List<Row> list;
if (intersection != null) {
list = root.query(getEnvelope(intersection));
} else {
......@@ -163,8 +164,8 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
throw DbException.throwInternalError();
}
// FIXME: ideally I need external iterators, but let's see if we can get
// it working first
// TODO use an external iterator,
// but let's see if we can get it working first
@SuppressWarnings("unchecked")
List<Row> list = root.queryAll();
......@@ -186,6 +187,9 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
return 0;
}
/**
* A cursor of a fixed list of rows.
*/
private static final class ListCursor implements Cursor {
private final List<Row> rows;
private int index;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论