2017-03-12 1 views
0

Geomesa Native APIを使用してjavaでaccumuloクライアントを実行しています。続いてJavaクライアント・コードです:例外を解決する方法 "デフォルトの日付フィールド 'dtg'に部分(結合)属性インデックスを持つスキーマを作成しようとしています"

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 

を使用してこのファイルを実行し、私は次の例外取得しています:私はあなたのコードをテストしてみた

[email protected]:~/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)] 
+0

この質問はScalaと何が関係がありますか? – pedrofurla

+0

どのバージョンのGeoMesaが使用されていますか?すばやく見ると、デフォルトのGeoMesa Native APIコードが使用するSFT定義には小さなバグがあるようです。 – GeoMesaJim

+0

@GeoMesaJim GeoMesaツールバージョン:1.3.0 IDをコミットします。geomesa_2.11-1.3.0 ビルド日付:2017-01-19T16:24: 支店dc5246614da274264319c3c4c0711fe925403af6 02から0500 –

答えて

1

をGeoMesa 1.3.0および1.3.1のコピーで、問題を直接再現することはできません。しかし、何が起きているかは、古いジャーと新しいジャーが混在していると思います。 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を再インストールまたはダウンロードすることをお勧めします。

+0

問題の原因を指摘していただきありがとうございます。クラスパス上のjarファイルを確認する方法と、それを修正する方法を教えてください。 –

+0

これを行うにはいくつかの方法があります。クラスパスはhttps://www.mkyong.com/java/how-to-print-out-the-current-project-classpath/で記述されています。javaを実行する前にclasspathを出力するようにaccumuloスクリプトを変更することもできますコマンド。これは何かを知るための発見をするかもしれません。それらを修正するには、jarファイルを1.3.x行のものに置き換えるか、クラスパスに最初に含まれていることを確認します。 –

+0

解決済み! それはバージョンの問題でした。バージョン1.3.0でテストされ、期待どおりに動作する –

関連する問題