gpt4 book ai didi

java - 如何解决异常 "Trying to create a schema with a partial (join) attribute index on the default date field ' dtg'”

转载 作者:行者123 更新时间:2023-12-02 13:40:41 25 4
gpt4 key购买 nike

我正在使用Geomesa Native API在java中执行accumulo客户端。以下是java客户端代码:

package org.locationtech.geomesa.api;
import java.time.ZonedDateTime;
import java.util.*;
import org.geotools.geometry.jts.JTSFactoryFinder;

import com.google.gson.Gson;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
public class GeomesaAccumuloClient {
public static void main(String args[]){
System.out.println("hello1");
try {
GeoMesaIndex<DomainObject> index =
AccumuloGeoMesaIndex.build(
"asd",
"localhost:2181",
"hps",
"root", "9869547580",
false,
new DomainObjectValueSerializer(),
new DefaultSimpleFeatureView<DomainObject>("aj_p"));
}
catch(Throwable t) {
System.err.println("Uncaught exception is detected! " + t
+ " st: "+ Arrays.toString(t.getStackTrace()));
}
}
public static class DomainObject {
public final String id;
public final int intValue;
public final double doubleValue;

public DomainObject(String id, int intValue, double doubleValue) {
this.id = id;
this.intValue = intValue;
this.doubleValue = doubleValue;
}
}
public static class DomainObjectValueSerializer implements ValueSerializer<DomainObject> {
public static final Gson gson = new Gson();
@Override
public byte[] toBytes(DomainObject o) {
System.out.println(gson.toJson(o).toString());
return gson.toJson(o).getBytes();
}

@Override
public DomainObject fromBytes(byte[] bytes) {
return gson.fromJson(new String(bytes), DomainObject.class);
}
}
private static Date date(String s) {
return Date.from(ZonedDateTime.parse(s).toInstant());
}
}

但是当我使用命令执行这个文件时

accumulo org.locationtech.geomesa.api.GeomesaAccumuloClient

我遇到以下异常:

suresh@hpss-MacBook-Air:~/accumulo-1.8.0/lib/ext $ accumulo org.locationtech.geomesa.api.GeomesaAccumuloClient
hello1
2017-03-13 00:35:26,433 [imps.CuratorFrameworkImpl] INFO : Starting
2017-03-13 00:35:26,445 [state.ConnectionStateManager] INFO : State change: CONNECTED
Uncaught exception is detected! java.lang.IllegalArgumentException: Trying to create a schema with a partial (join) attribute index on the default date field 'dtg'. This may cause whole-world queries with time bounds to be much slower. If this is intentional, you may override this message by putting Boolean.TRUE into the SimpleFeatureType user data under the key 'override.index.dtg.join' before calling createSchema. Otherwise, please either specify a full attribute index or remove it entirely. st: [org.locationtech.geomesa.utils.index.TemporalIndexCheck$$anonfun$validateDtgIndex$1.apply(GeoMesaSchemaValidator.scala:102), org.locationtech.geomesa.utils.index.TemporalIndexCheck$$anonfun$validateDtgIndex$1.apply(GeoMesaSchemaValidator.scala:98), scala.Option.foreach(Option.scala:257), org.locationtech.geomesa.utils.index.TemporalIndexCheck$.validateDtgIndex(GeoMesaSchemaValidator.scala:98), org.locationtech.geomesa.utils.index.GeoMesaSchemaValidator$.validate(GeoMesaSchemaValidator.scala:30), org.locationtech.geomesa.index.geotools.GeoMesaDataStore.createSchema(GeoMesaDataStore.scala:141), org.locationtech.geomesa.accumulo.data.AccumuloDataStore.createSchema(AccumuloDataStore.scala:129), org.locationtech.geomesa.api.AccumuloGeoMesaIndex.<init>(AccumuloGeoMesaIndex.scala:45), org.locationtech.geomesa.api.AccumuloGeoMesaIndex$.buildWithView(AccumuloGeoMesaIndex.scala:165), org.locationtech.geomesa.api.AccumuloGeoMesaIndex$.build(AccumuloGeoMesaIndex.scala:146), org.locationtech.geomesa.api.AccumuloGeoMesaIndex.build(AccumuloGeoMesaIndex.scala), org.locationtech.geomesa.api.GeomesaAccumuloClient.main(GeomesaAccumuloClient.java:15), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.lang.reflect.Method.invoke(Method.java:498), org.apache.accumulo.start.Main$2.run(Main.java:157), java.lang.Thread.run(Thread.java:745)]

最佳答案

我已经在 GeoMesa 1.3.0 和 1.3.1 的副本上测试了您的代码,但无法直接重现您的问题。然而,我认为正在发生的事情是你以某种方式混合了新旧 jar 。在1.3.x系列中

new DefaultSimpleFeatureView<DomainObject>("aj_p")

无效,因为 DefaultSimpleFeatureView 不接受参数,导致编译失败。删除“aj_p”并运行

accumulo -add ./geomesa-native-api_2.11-1.3.1.jar org.locationtech.geomesa.api.GeomesaAccumuloClient

似乎工作正常,测试表出现在我的 Accumulo 实例的表中。

我建议验证类路径上的 jar,也许重新安装或下载 GeoMesa jar。

关于java - 如何解决异常 "Trying to create a schema with a partial (join) attribute index on the default date field ' dtg'”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42751990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com