Geomesa:有没有一种方法可以在不丢失数据的情况下创建、删除Geomesa中的索引?或者我需要重新创建一个模式



我有一个带geometrya的cassandra,在那里我有下一个模式

~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra describe-schema -P localhost:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder 
INFO  Describing attributes of feature 'SignalBuilder'
geo           | Point   (Spatio-temporally indexed)
time          | Date    (Spatio-temporally indexed) (Attribute indexed)
cam           | String  (Attribute indexed) (Attribute indexed)
imei          | String  (Attribute indexed)
dir           | Double  
alt           | Double  
vlc           | Double  
sl            | Integer 
ds            | Integer 
dir_y         | Double  
poi_azimuth_x | Double  
poi_azimuth_y | Double  
User data:
geomesa.attr.splits     | 4
geomesa.feature.expiry  | time(30 days)
geomesa.index.dtg       | time
geomesa.indices         | z3:7:3:geo:time,attr:8:3:time,attr:8:3:cam,attr:8:3:cam:time,attr:8:3:imei
geomesa.stats.enable    | true
geomesa.table.partition | time
geomesa.z.splits        | 4
geomesa.z3.interval     | week

有没有一种方法可以在z3之外创建z2索引,并删除cam属性索引,只保留cam:time属性索引,而不会丢失数据库中的数据?如果我已经有cam:time索引,那么time属性索引是否是不必要的?

第页。S.为什么这个查询使用z2索引,而不是z3?

~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra explain -P 10.200.217.24:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder -q "Bbox(geo,1,1,2,2) and time > 123333"; 
Planning 'SignalBuilder' BBOX(geo, 1.0,1.0,2.0,2.0) AND time > 1970-01-01T00:02:03.333+00:00
Original filter: BBOX(geo, 1.0,1.0,2.0,2.0) AND time > 123333
Hints: bin[false] arrow[false] density[false] stats[false] sampling[none]
Sort: none
Transforms: none
Max features: none
Strategy selection:
Query processing took 21ms for 1 options
Filter plan: FilterPlan[Z2Index(geo)[BBOX(geo, 1.0,1.0,2.0,2.0)][time > 1970-01-01T00:02:03.333+00:00](1.2)]
Strategy selection took 2ms for 1 options
Strategy 1 of 1: Z2Index(geo)
Strategy filter: Z2Index(geo)[BBOX(geo, 1.0,1.0,2.0,2.0)][time > 1970-01-01T00:02:03.333+00:00](1.2)
Geometries: FilterValues(List(POLYGON ((1 1, 2 1, 2 2, 1 2, 1 1))),true,false)
Plan: org.locationtech.geomesa.cassandra.data.StatementPlan
Tables: 
Ranges (0): 
Client-side filter: BBOX(geo, 1.0,1.0,2.0,2.0) AND time > 1970-01-01T00:02:03.333+00:00
Reduce: class:LocalTransformReducer, state:{name=SignalBuilder, tnam=, tsft=, tdef=, hint=RETURN_SFT,"SignalBuilder,""*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double;geomesa.stats.enable='true',geomesa.z.splits='4',geomesa.feature.expiry='time(30 days)',geomesa.table.partition='time',geomesa.index.dtg='time',geomesa.indices='z3:7:3:geo:time,z2:5:3:geo,attr:8:3:time,attr:8:3:cam,attr:8:3:cam:time',geomesa.attr.splits='4',geomesa.z3.interval='week'""", spec=*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double;geomesa.stats.enable='true',geomesa.z.splits='4',geomesa.feature.expiry='time(30 days)',geomesa.table.partition='time',geomesa.index.dtg='time',geomesa.indices='z3:7:3:geo:time,z2:5:3:geo,attr:8:3:time,attr:8:3:cam,attr:8:3:cam:time',geomesa.attr.splits='4',geomesa.z3.interval='week', filt=BBOX(geo, 1.0,1.0,2.0,2.0) AND time > 1970-01-01T00:02:03.333+00:00}
Plan creation took 110ms
Query planning took 294ms

这将涉及几个步骤。您可能想在尝试之前备份您的数据,以防出现问题。首先,您希望使用updateSchema来添加新索引和删除旧索引,并将现有索引设置为";只读";模式您可以使用GeoMesa CLIscala-console命令运行以下命令:

val sft = SimpleFeatureTypes.mutable(ds.getSchema("SignalBuilder"))
// 5 is the latest version of the z2 index as of now
// 1 sets the indices to read only mode
sft.getUserData.put("geomesa.indices", "z3:7:1:geo:time,z2:5:3:geo,attr:8:1:time,attr:8:1:cam:time,attr:8:1:imei")
ds.updateSchema(sft.getTypeName, sft)

在此之后,您将需要重新摄取数据以填充z2索引。一旦填充了索引,就需要再次更新模式,将索引设置回读/写模式:

val sft = SimpleFeatureTypes.mutable(ds.getSchema("SignalBuilder"))
// 5 is the latest version of the z2 index as of now
// 3 sets the indices to read/write mode
sft.getUserData.put("geomesa.indices", "z3:7:3:geo:time,z2:5:3:geo,attr:8:3:time,attr:8:3:cam:time,attr:8:3:imei")
ds.updateSchema(sft.getTypeName, sft)

请注意,旧的cam索引表仍将存在于Cassandra中,但不会收到任何进一步的更新或用于查询。您可以使用标准的Cassandra技术将其删除。

最新更新