表格存储服务 CloudTable-GeoMesa命令行简介

时间:2023-11-01 16:16:45

GeoMesa命令行简介

本节介绍常用的GeoMesa命令。更多的GeoMesa命令,请参见https://www.geomesa.org/documentation/user/accumulo/commandline.html

  1. 查看classpath

    执行“classpath”命令,将会返回当前命令行工具的所有classpath信息。

    bin/geomesa-hbase classpath
  2. 创建表

    执行“create-schema”命令创建表,创建表时至少要指定目录名称与表名称,以及表规格。

    bin/geomesa-hbase create-schema -c geomesa -f test -s Who:String,What:java.lang.Long,When:Date,*Where:Point:srid=4326,Why:String
  3. 描述表

    执行“describe-schema”命令获取表描述信息,描述表信息时必须要指定目录名称与表名称。

    bin/geomesa-hbase describe-schema -c geomesa -f test
  4. 批量导入数据

    执行“ingest”命令批量导入数据,导入时需要指定目录名称,表名称,表规格,以及相应的数据转换器等。

    数据(车牌号,车辆颜色,经度,维度,时间):data.csv,并将数据表放在data文件夹中。

    AAA,red,113.918417,22.505892,2017-04-09 18:03:46BBB,white,113.960719,22.556511,2017-04-24 07:38:47CCC,blue,114.088333,22.637222,2017-04-23 15:07:54DDD,yellow,114.195456,22.596103,2017-04-21 21:27:06EEE,black,113.897614,22.551331,2017-04-09 09:34:48

    表结构定义:myschema.sft,并将myschema.sft放在geomesa命令行工具的conf文件夹中。

    geomesa.sfts.cars = {   attributes = [        { name = "carid", type = "String", index = true }        { name = "color", type = "String", index = false }        { name = "time", type = "Date",   index = false }        { name = "geom", type = "Point",  index = true,srid = 4326,default = true }   ]}

    转换器定义:myconvertor.convert,并将myconvertor.convert放在geomesa命令行工具的conf文件夹中。

    geomesa.converters.cars= {      type   = "delimited-text",      format = "CSV",      id-field = "$fid",      fields = [        { name = "fid",     transform = "concat($1,$5)" }        { name = "carid",   transform = "$1::string" }        { name = "color",   transform = "$2::string" }        { name = "lon",     transform = "$3::double" }        { name = "lat",     transform = "$4::double" }         { name = "geom",    transform = "point($lon,$lat)" }        { name = "time",    transform = "date('YYYY-MM-dd HH:mm:ss',$5)" }      ]}

    执行命令导入数据:

    bin/geomesa-hbase ingest -c geomesa -C conf/myconvertor.convert -s conf/myschema.sft data/data.csv

    数据导入其他参数具体说明请参见:https://www.geomesa.org/documentation/user/accumulo/examples.html#ingesting-data

  5. 解释查询

    执行“explain”命令获取指定查询语句执行计划的解释说明,解释语句时必须指定目录名称和表名称,以及给定查询语句。

    bin/geomesa-hbase explain -c geomesa -f cars -q "carid = 'BBB'"
  6. 统计分析

    执行“stats-analyze”命令对数据表进行统计分析,同时还可以进一步执行“stats-bounds”,“stats-count”,“stats-histogram”,“stats-top-k”命令对数据表做更详细的统计。

    bin/geomesa-hbase stats-analyze -c geomesa -f carsbin/geomesa-hbase stats-bounds -c geomesa -f carsbin/geomesa-hbase stats-count -c geomesa -f carsbin/geomesa-hbase stats-histogram -c geomesa -f carsbin/geomesa-hbase stats-top-k -c geomesa -f cars
  7. 导出feature

    执行“export”命令导出feature,导出时必须指定目录名称和表名称,同时还可以根据指定的查询语句进行导出。

    bin/geomesa-hbase export -c geomesa -f cars -q "carid = 'BBB'"
  8. 删除feature

    执行“delete-features”命令删除feature,删除时必须指定目录名称和表名称,同时还可以根据指定的查询语句进行删除。

    bin/geomesa-hbase delete-features -c geomesa -f cars -q "carid = 'BBB'"
  9. 获取目录中的全部表的名称

    执行“get-type-names”命令获取指定目录中的表名称。

    bin/geomesa-hbase get-type-names -c geomesa
  10. 删除表

    执行“remove-schema”命令删除表,删除表示至少要指定表所在的目录与表名称。

    bin/geomesa-hbase remove-schema -c geomesa -f testbin/geomesa-hbase remove-schema -c geomesa -f cars
  11. 删除目录

    执行“delete-catalog”命令删除指定的目录。

    bin/geomesa-hbase delete-catalog -c geomesa
support.huaweicloud.com/usermanual-cloudtable/cloudtable_01_0103.html