Skip to content

Commit 99291c7

Browse files
committed
GEOMESA-3560 Change default attribute index tiering to temporal only (#3511)
1 parent 48826fd commit 99291c7

File tree

6 files changed

+39
-20
lines changed

6 files changed

+39
-20
lines changed

docs/user/datastores/index_creation.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ type may be indexed individually. See :ref:`specifying_indices`, below, for deta
4444
List type attributes may be indexed, but querying a list-type index may result in duplicate results. If
4545
duplicate results are a problem, users should implement their own de-duplication logic for list queries.
4646

47-
Attribute indices also support a secondary, tiered index structure. This can improve attribute queries
48-
that also contain a spatial and/or temporal predicate. Unless configured differently, the default geometry
49-
and date attributes will be used to create a secondary Z3 or XZ3 index.
47+
Attribute indices also support a secondary, tiered index structure. This can improve attribute queries that also contain a
48+
spatial and/or temporal predicate. Unless configured differently, the default date attribute will be used to create a secondary
49+
temporal index.
5050

5151
.. note::
5252

@@ -81,7 +81,7 @@ Multiple indices on a single attribute may be separated with a comma (``,``).
8181

8282
For attribute indices, if secondary geometry and date attributes are specified, the secondary index will be Z3 or XZ3, as
8383
appropriate. If just a geometry is specified, the secondary index will be Z2 or XZ2, as appropriate. If just a date
84-
is specified, the secondary index will be an ordered temporal index.
84+
is specified, the secondary index will be a temporal index.
8585

8686
The ID index does not correspond to any attribute, but it can be disabled through the feature-level user-data key
8787
``id.index.enabled=false``.

docs/user/upgrade/6.0.0.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ Kafka Zookeeper Deprecation
1717
As Kafka 4+ no longer supports Zookeeper, GeoMesa has deprecated support for using Zookeeper with the Kafka data store. See
1818
:ref:`no_zookeeper` for details on migrating.
1919

20+
Default Secondary Attribute Index Changes
21+
-----------------------------------------
22+
23+
When creating attribute indices, the default secondary index will now be a date-only index, instead of a spatio-temporal index
24+
(e.g. ``attr:foo:dtg`` instead of ``attr:foo:geom:dtg``). The old behavior can still be achieved by configuring secondary
25+
attributes - see :ref:`specifying_indices` for details.
26+
2027
Dependency Version Upgrades
2128
---------------------------
2229

geomesa-accumulo/geomesa-accumulo-datastore/src/test/scala/org/locationtech/geomesa/accumulo/data/AccumuloDataStoreAtomicWriteTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class AccumuloDataStoreAtomicWriteTest extends Specification with TestWithMultip
7474
ConditionalWriteStatus("id", "insert", ConditionalWriter.Status.REJECTED),
7575
ConditionalWriteStatus("z2:geom", "insert", ConditionalWriter.Status.REJECTED),
7676
ConditionalWriteStatus("z3:geom:dtg", "insert", ConditionalWriter.Status.REJECTED),
77-
ConditionalWriteStatus("attr:name:geom:dtg", "insert", ConditionalWriter.Status.REJECTED),
77+
ConditionalWriteStatus("attr:name:dtg", "insert", ConditionalWriter.Status.REJECTED),
7878
)
7979
)
8080
}
@@ -160,7 +160,7 @@ class AccumuloDataStoreAtomicWriteTest extends Specification with TestWithMultip
160160
ConditionalWriteStatus("id", "update", ConditionalWriter.Status.REJECTED),
161161
ConditionalWriteStatus("z2:geom", "delete", ConditionalWriter.Status.REJECTED),
162162
ConditionalWriteStatus("z3:geom:dtg", "delete", ConditionalWriter.Status.REJECTED),
163-
ConditionalWriteStatus("attr:name:geom:dtg", "delete", ConditionalWriter.Status.REJECTED),
163+
ConditionalWriteStatus("attr:name:dtg", "delete", ConditionalWriter.Status.REJECTED),
164164
)
165165
)
166166
}
@@ -198,7 +198,7 @@ class AccumuloDataStoreAtomicWriteTest extends Specification with TestWithMultip
198198
ConditionalWriteStatus("id", "delete", ConditionalWriter.Status.REJECTED),
199199
ConditionalWriteStatus("z2:geom", "delete", ConditionalWriter.Status.REJECTED),
200200
ConditionalWriteStatus("z3:geom:dtg", "delete", ConditionalWriter.Status.REJECTED),
201-
ConditionalWriteStatus("attr:name:geom:dtg", "delete", ConditionalWriter.Status.REJECTED),
201+
ConditionalWriteStatus("attr:name:dtg", "delete", ConditionalWriter.Status.REJECTED),
202202
)
203203
)
204204
}

geomesa-accumulo/geomesa-accumulo-datastore/src/test/scala/org/locationtech/geomesa/accumulo/index/AttributeIndexStrategyTest.scala

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import org.locationtech.geomesa.index.utils.{ExplainNull, Explainer}
3535
import org.locationtech.geomesa.index.view.MergedDataStoreViewFactory
3636
import org.locationtech.geomesa.utils.bin.BinaryOutputEncoder
3737
import org.locationtech.geomesa.utils.collection.CloseableIterator
38-
import org.locationtech.geomesa.utils.geotools.{CRS_EPSG_4326, FeatureUtils, SimpleFeatureTypes}
38+
import org.locationtech.geomesa.utils.geotools.{CRS_EPSG_4326, FeatureUtils, SchemaBuilder, SimpleFeatureTypes}
3939
import org.locationtech.geomesa.utils.index.IndexMode
4040
import org.locationtech.geomesa.utils.io.WithClose
4141
import org.locationtech.geomesa.utils.text.WKTUtils
@@ -51,10 +51,22 @@ import scala.collection.JavaConverters._
5151
@RunWith(classOf[JUnitRunner])
5252
class AttributeIndexStrategyTest extends Specification with TestWithFeatureType with LazyLogging {
5353

54-
override val spec = "name:String:index=full,age:Integer:index=join,count:Long:index=join," +
55-
"weight:Double:index=join,height:Float:index=join,admin:Boolean:index=join," +
56-
"*geom:Point:srid=4326,dtg:Date,indexedDtg:Date:index=join,fingers:List[String]:index=join," +
57-
"toes:List[Double]:index=join,track:String,geom2:Point:srid=4326;geomesa.indexes.enabled='attr,id'"
54+
override val spec =
55+
SchemaBuilder.builder()
56+
.addString("name").withIndex("attr:geom:dtg")
57+
.addInt("age").withIndex("join:geom:dtg")
58+
.addLong("count").withIndex("join:geom:dtg")
59+
.addDouble("weight").withIndex("join:geom:dtg")
60+
.addFloat("height").withIndex("join:geom:dtg")
61+
.addBoolean("admin").withIndex("join:geom:dtg")
62+
.addPoint("geom", default = true).withIndex("none")
63+
.addDate("dtg", default = true)
64+
.addDate("indexedDtg").withIndex("join:geom:dtg")
65+
.addList[String]("fingers").withIndex("join:geom:dtg")
66+
.addList[Double]("toes").withIndex("join:geom:dtg")
67+
.addString("track")
68+
.addPoint("geom2").withIndex("none")
69+
.spec
5870

5971
val aliceGeom = WKTUtils.read("POINT(45.0 49.0)")
6072
val billGeom = WKTUtils.read("POINT(46.0 49.0)")

geomesa-index-api/src/main/scala/org/locationtech/geomesa/index/index/attribute/AttributeIndex.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ object AttributeIndex extends ConfiguredIndex {
125125
}
126126

127127
private def defaultTiers(sft: SimpleFeatureType, primary: AttributeDescriptor): Seq[String] =
128-
Seq(primary.getLocalName) ++ Seq(sft.getGeomField).filter(_ != null) ++ sft.getDtgField.filter(_ != primary.getLocalName)
128+
Seq(primary.getLocalName) ++ sft.getDtgField.filter(_ != primary.getLocalName).orElse(Option(sft.getGeomField))
129129

130130
/**
131131
* Checks if the given field is attribute indexed

geomesa-index-api/src/test/scala/org/locationtech/geomesa/index/index/ConfigurableIndicesTest.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ class ConfigurableIndicesTest extends Specification with LazyLogging {
3535
// creates a default attribute index on name and an implicit default z3 and z2 index on geom
3636
ds.createSchema(SimpleFeatureTypes.createType("test1", "name:String:index=true,dtg:Date,*geom:Point:srid=4326"))
3737
// creates an attribute index on name (with a secondary date index), and a z3 index on geom and dtg
38-
ds.createSchema(SimpleFeatureTypes.createType("test2", "name:String:index='attr:dtg',dtg:Date,*geom:Point:srid=4326:index='z3:dtg'"))
38+
ds.createSchema(SimpleFeatureTypes.createType("test2", "name:String:index='attr:geom:dtg',dtg:Date,*geom:Point:srid=4326:index='z3:dtg'"))
3939
// creates an attribute index on name (with a secondary date index), and a z3 index on geom and dtg and disables the ID index
4040
ds.createSchema(SimpleFeatureTypes.createType("test3", "name:String:index='attr:dtg',dtg:Date,*geom:Point:srid=4326:index='z3:dtg';id.index.enabled=false"))
41-
getIndexConfig(ds.getSchema("test1")) mustEqual Seq("attr=name:geom:dtg", "id=", "z2=geom", "z3=geom:dtg")
42-
getIndexConfig(ds.getSchema("test2")) mustEqual Seq("attr=name:dtg", "id=", "z3=geom:dtg")
41+
getIndexConfig(ds.getSchema("test1")) mustEqual Seq("attr=name:dtg", "id=", "z2=geom", "z3=geom:dtg")
42+
getIndexConfig(ds.getSchema("test2")) mustEqual Seq("attr=name:geom:dtg", "id=", "z3=geom:dtg")
4343
getIndexConfig(ds.getSchema("test3")) mustEqual Seq("attr=name:dtg", "z3=geom:dtg")
4444
}
4545
}
4646

4747
"support configurable indices with SchemaBuilder" in {
4848
val sft =
4949
SchemaBuilder.builder()
50-
.addString("name").withIndex("attr:dtg") // creates an attribute index on name, with a secondary date index
50+
.addString("name").withIndex("attr:geom:dtg") // creates an attribute index on name, with a secondary date index
5151
.addInt("age").withIndex() // creates an attribute index on age, with a default secondary index
5252
.addDate("dtg") // not a primary index
5353
.addPoint("geom", default = true).withIndices("z3:dtg", "z2") // creates a z3 index with dtg, and a z2 index
@@ -56,7 +56,7 @@ class ConfigurableIndicesTest extends Specification with LazyLogging {
5656
.build("test1")
5757
WithClose(new TestGeoMesaDataStore(true)) { ds =>
5858
ds.createSchema(sft)
59-
getIndexConfig(ds.getSchema("test1")) mustEqual Seq("attr=age:geom:dtg", "attr=name:dtg", "z2=geom", "z3=geom:dtg")
59+
getIndexConfig(ds.getSchema("test1")) mustEqual Seq("attr=age:dtg", "attr=name:geom:dtg", "z2=geom", "z3=geom:dtg")
6060
}
6161
}
6262

@@ -65,7 +65,7 @@ class ConfigurableIndicesTest extends Specification with LazyLogging {
6565
s"""{
6666
| type-name = test1
6767
| attributes = [
68-
| { name = "name", type = "String", index = "attr:dtg" } // creates an attribute index on name, with a secondary date index
68+
| { name = "name", type = "String", index = "attr:geom:dtg" } // creates an attribute index on name, with a secondary date index
6969
| { name = "age", type = "Int", index = "true" } // creates an attribute index on age, with a default secondary index
7070
| { name = "dtg", type = "Date" } // not a primary index
7171
| { name = "geom", type = "Point", srid = "4326", index = "z3:dtg,z2" } // creates a z3 index with dtg, and a z2 index
@@ -78,7 +78,7 @@ class ConfigurableIndicesTest extends Specification with LazyLogging {
7878
val sft = SimpleFeatureTypes.createType(ConfigFactory.parseString(config), path = None)
7979
WithClose(new TestGeoMesaDataStore(true)) { ds =>
8080
ds.createSchema(sft)
81-
getIndexConfig(ds.getSchema("test1")) mustEqual Seq("attr=age:geom:dtg", "attr=name:dtg", "z2=geom", "z3=geom:dtg")
81+
getIndexConfig(ds.getSchema("test1")) mustEqual Seq("attr=age:dtg", "attr=name:geom:dtg", "z2=geom", "z3=geom:dtg")
8282
}
8383
}
8484
}

0 commit comments

Comments
 (0)