2016-04-08 2 views
2

年 - >月 - >日 - >時 - >分 - >秒のOrientDB時系列を作成したいとします。OrientDB時系列を取り込む方法は?

OrientDB wikiの例では、クラスの作成方法と検索の管理方法のみを示しています。

this codeを使用してグラフを取り込もうとしましたが、別のユーザーがhereと言っているように、このアプローチでは時間制限がある場合は2分以上が必要です。秒のレベルで、同様の方法は約12時間を必要とします。

正常ですか?よりよいアプローチはありますか? 私の質問に答えるすべての人にありがとう。

PS:私は既にthe Milan 2014 slidesを読んでいますが、構造(私が明確にしている)とデータを取得する方法についてのみ説明しています。

答えて

0

このコードで試してみることはできますか?

import java.util.ArrayList; 
import java.util.HashMap; 
import java.util.List; 
import java.util.Map; 

import com.orientechnologies.orient.client.remote.OServerAdmin; 
import com.orientechnologies.orient.core.metadata.schema.OClass; 
import com.orientechnologies.orient.core.metadata.schema.OType; 
import com.tinkerpop.blueprints.impls.orient.OrientGraph; 
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx; 
import com.tinkerpop.blueprints.impls.orient.OrientVertex; 

public class TimesSeriesMain { 

    public static void main(String[] args) { 

     OServerAdmin serverAdmin; 
     try { 
      serverAdmin = new OServerAdmin("remote:localhost/myTimeSeries").connect("root", "root"); 
      if(!serverAdmin.existsDatabase()){ 

       serverAdmin.createDatabase("myTimeSeries", "graph", "plocal"); 

       OrientGraphNoTx graph_c=new OrientGraphNoTx("remote:localhost/myTimeSeries"); 

       OClass hour_c=graph_c.createVertexType("Hour", "V"); 
       hour_c.createProperty("value", OType.INTEGER); 

       OClass day_c=graph_c.createVertexType("Day", "V"); 
       day_c.createProperty("hour", OType.LINKSET, hour_c); 

       OClass month_c=graph_c.createVertexType("Month", "V"); 
       month_c.createProperty("day", OType.LINKMAP, day_c); 

       OClass year_c=graph_c.createVertexType("Year", "V"); 
       year_c.createProperty("value", OType.INTEGER); 
       year_c.createProperty("month", OType.LINKMAP, month_c); 

       graph_c.shutdown(); 

       OrientGraph graph=new OrientGraph("remote:localhost/myTimeSeries"); 

       long start = System.currentTimeMillis(); 

       for (int yy = 2015; yy < 2016; yy++){   
        Map<Integer, OrientVertex> months = new HashMap<>(); 
        for (int mm = 0; mm < 12; mm++){ 
         Map<Integer, OrientVertex> days = new HashMap<>(); 
         for (int dd = 1; dd < 32; dd++){ 
          List<OrientVertex> hours = new ArrayList<OrientVertex>(); 
          for (int i = 0; i < 24; i++){ 
           OrientVertex hour=graph.addVertex("class:Hour"); 
           hour.setProperty("value",i); 
           hours.add(hour); 
          } 
          OrientVertex day=graph.addVertex("class:Day"); 
          day.setProperties("hour",hours); 
          days.put(dd,day); 
         } 
         OrientVertex month=graph.addVertex("class:Month"); 
         month.setProperties("day",days); 
         months.put(mm,month); 
        } 
        OrientVertex year=graph.addVertex("class:Year"); 
        year.setProperties("value",yy); 
        year.setProperties("month",months);  
       } 

       long end=System.currentTimeMillis(); 

       System.out.println(((end-start)) + " millisec") ; 

       graph.shutdown(); 
      } 
     }   
     catch(Exception e){ 
      System.out.println(e); 
     } 
    } 
} 

はそれがお役に立てば幸いです。

+0

ご意見ありがとうございました。速度の変化は印象的です(262ms)。なぜそんなに変わるのですか? – Stefano

関連する問題