首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Geomesa:是否有一种方法可以在不丢失数据的情况下创建、删除geomesa中的索引?还是我需要重新创建一个模式?

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

Stack Overflow用户
提问于 2022-01-12 14:23:19
回答 1查看 75关注 0票数 0

我有一个卡桑德拉,里面有下一个模式

代码语言:javascript
复制
 ~  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之外的z3索引,并且删除cam属性索引仍然只保留cam:time属性索引,而不丢失db中的数据?如果我已经有了time索引,那么是否没有必要使用cam:time属性索引?

为什么这个查询使用的是z2索引而不是z3?

代码语言:javascript
复制
~  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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-14 00:00:12

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

代码语言:javascript
复制
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索引。一旦填充了索引,您将需要再次更新模式,以将索引设置为读/写模式:

代码语言:javascript
复制
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中,但不会收到任何进一步的更新或用于查询。你可以用标准的卡桑德拉技术把它放下。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70683229

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档