@Value.Enclosing public abstract class SpatialRules extends Object
The rules allow Calcite to use spatial indexes. For example the following query:
SELECT ... FROM Restaurants AS r WHERE ST_DWithin(ST_Point(10, 20), ST_Point(r.longitude, r.latitude), 5)
is rewritten to
SELECT ... FROM Restaurants AS r WHERE (r.h BETWEEN 100 AND 150 OR r.h BETWEEN 170 AND 185) AND ST_DWithin(ST_Point(10, 20), ST_Point(r.longitude, r.latitude), 5)
if there is the constraint
CHECK (h = Hilbert(8, r.longitude, r.latitude))
If the Restaurants table is sorted on h then the latter
query can be answered using two limited range-scans, and so is much more
efficient.
Note that the original predicate
ST_DWithin(ST_Point(10, 20), ST_Point(r.longitude, r.latitude), 5)
is still present, but is evaluated after the approximate predicate has
eliminated many potential matches.
| Modifier and Type | Class and Description |
|---|---|
static class |
SpatialRules.FilterHilbertRule
Rule that converts ST_DWithin in a Filter condition into a predicate on
a Hilbert curve.
|
| Modifier and Type | Field and Description |
|---|---|
static RelOptRule |
INSTANCE |
public static final RelOptRule INSTANCE
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.