如何填充OrientDB时间序列?
我要创建OrientDB时间序列年-->月-->日-->小时-->分钟-->秒 上的示例仅显示如何创建类以及如何管理搜索 我试图使用填充图,但正如另一位用户所说,如果时间有限,这种方法需要超过2分钟。以秒为单位,类似的方法需要大约12小时 这正常吗?有更好的方法吗? 谢谢各位回答我的问题如何填充OrientDB时间序列?,orientdb,Orientdb,我要创建OrientDB时间序列年-->月-->日-->小时-->分钟-->秒 上的示例仅显示如何创建类以及如何管理搜索 我试图使用填充图,但正如另一位用户所说,如果时间有限,这种方法需要超过2分钟。以秒为单位,类似的方法需要大约12小时 这正常吗?有更好的方法吗? 谢谢各位回答我的问题 PS:我已经读过了,但它只解释了结构(我已经很清楚)和检索数据的方法 你能试试这个代码吗 import java.util.ArrayList; import java.util.HashMap; import
PS:我已经读过了,但它只解释了结构(我已经很清楚)和检索数据的方法 你能试试这个代码吗
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);
}
}
}
import java.util.ArrayList;
导入java.util.HashMap;
导入java.util.List;
导入java.util.Map;
导入com.orientechnologies.orient.client.remote.OServerAdmin;
导入com.orientechnologies.orient.core.metadata.schema.OClass;
导入com.orientechnologies.orient.core.metadata.schema.OType;
导入com.tinkerpop.blueprints.impls.orient.OrientGraph;
导入com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
导入com.tinkerop.blueprints.impls.orient.OrientVertex;
公共类时间序列主{
公共静态void main(字符串[]args){
OServerAdminServerAdmin;
试一试{
serverAdmin=new-OServerAdmin(“远程:localhost/myTimeSeries”).connect(“根”,“根”);
如果(!serverAdmin.existsDatabase()){
createDatabase(“myTimeSeries”、“graph”、“plocal”);
OrientGraphNoTx graph_c=新的OrientGraphNoTx(“远程:本地主机/myTimeSeries”);
OClass hour_c=图形_c.createVertexType(“hour”,“V”);
hour_c.createProperty(“值”,OType.INTEGER);
OClass day_c=图形_c.createVertexType(“day”,“V”);
day_c.createProperty(“小时”,OType.LINKSET,小时);
OClass month_c=图形_c.createVertexType(“月”、“V”);
月c.createProperty(“日”,OType.LINKMAP,日c);
OClass year_c=图形_c.createVertexType(“年”,“V”);
年份\u c.createProperty(“值”,OType.INTEGER);
年份c.createProperty(“月份”,OType.LINKMAP,月份c);
图形_c.shutdown();
OrientGraph=新的OrientGraph(“远程:localhost/myTimeSeries”);
长启动=System.currentTimeMillis();
对于(int-yy=2015;yy<2016;yy++){
映射月份=新的HashMap();
对于(int mm=0;mm<12;mm++){
映射天数=新建HashMap();
对于(int-dd=1;dd<32;dd++){
列表小时数=新建ArrayList();
对于(int i=0;i<24;i++){
OrientVertex小时=graph.addVertex(“类:小时”);
小时设置属性(“值”,i);
小时。添加(小时);
}
OrientVertex日=graph.addVertex(“类:日”);
设置属性(“小时”,小时);
天。放(日,天);
}
OrientVertex月=graph.addVertex(“类:月”);
月。设置属性(“日”,天);
月数。放置(毫米,月);
}
OrientVertex年=graph.addVertex(“类:年”);
年份。设定财产(“价值”,yy);
年。设置属性(“月”,月);
}
long end=System.currentTimeMillis();
System.out.println(((结束-开始))+“毫秒”);
graph.shutdown();
}
}
捕获(例外e){
系统输出打印ln(e);
}
}
}
希望能有所帮助。非常感谢您的评论。速度的变化令人印象深刻(262毫秒)。为什么变化这么大?