2017-07-29 29 views
0

這是以前刪除的帖子的縮小版本。我已閱讀其他文章和orientdb wiki以及linkedin演示文稿。沒有超過我目前的進展。時間系列插入

我的問題是2倍。

1)將數據鏈接到時間序列類的正確方法和最佳實踐是什麼?

2)這可以在插入時用鉤子完成嗎?

下面您會看到源數據模型,時間序列類和圖表。

數據模型不斷更新,每天產生幾百萬條記錄。

源數據模型

 { 
      "@type": "d", 
      "@rid": "#507:788457", 
      "@version": 2, 
      "@class": "Live", 
      "MarketName": "BTC-OMNI", 
      "High": 0.01398825, 
      "Low": 0.0117, 
      "Volume": 1121.38384722, 
      "Last": 0.01254396, 
      "Bid": 0.01219709, 
      "Ask": 0.01254377, 
      "BaseVolume": 14.52156426, 
      "TimeStamp": "2017-07-28T16:51:07.853", 
      "year": 2017, 
      "month": 7, 
      "day": 28, 
      "hour": 16, 
      "minute": 51 
      "@fieldTypes": "High=d,Low=d,Volume=d,Last=d,Bid=d,Ask=d,BaseVolume=d,Year=d,Month=d,Day=d,Hour=d,Minute=d" 
     } 

時間序列類

CREATE CLASS Year 
CREATE CLASS Month 
CREATE CLASS Day 
CREATE CLASS Hour 
CREATE CLASS Minute 

圖的什麼,我想實現

enter image description here

回答

0

找到了一個使用orientjs livequery的解決方案。

有人可以確認這是否是一個合理的方式來做到這一點?

有一個實時查詢監聽插入到您的源類,更新插入時間序列表。

所有時間序列類都在插入時使用源記錄進行更新。

db.liveQuery('LIVE SELECT FROM live ') 

    .on('live-insert', function(data){ 
     var r = data.cluster; 
     var id = data.position; 
     var rid = '#'+r+':'+id; 


     var umin = 'update Year set month[' + data.content.month + '].day[' + data.content.day + '].hour[' + shour + '].minute[' + data.content.minute + '].live = ' + rid + ' where year = ' + data.content.year 
     var uhour = 'update Year set month[' + data.content.month + '].day[' + data.content.day + '].hour[' + shour + '].live = ' + rid + ' where year = ' + data.content.year 
     var uday = 'update Year set month[' + data.content.month + '].day[' + data.content.day + '].live = ' + rid + ' where year = ' + data.content.year 
     var umon = 'update Year set month[' + data.content.month + '].live = ' + rid + ' where year = ' + data.content.year 

     db.query(umin) 
      .then((updatedmin) => {console.log('updated minutes')}) 
     db.query(uhour) 
      .then((updatedhour) => {console.log('updated hours')}) 
     db.query(uday) 
      .then((updateday) => {console.log('updated day')}) 
     db.query(umon) 
      .then((updatedmon) => {console.log('updated month')}) 



    });