如何使架构更少titan图?如何设置架构默认属性? 请建议一种方法?这是我的代码:
try{
//timestamp,1416375283,ipaddress,2097152002,mobilenumber,966566564213,eventname,1000
// TODO Auto-generated method stub
FileInputStream fstream = new FileInputStream("/root/edges_sorted.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String csv = "/root/log.CSV";
FileWriter writer = new FileWriter(csv);
Configuration conf = new BaseConfiguration();
conf.setProperty("storage.backend","hbase");
conf.setProperty("storage.hostname","192.168.51.98");
conf.setProperty("storage.batch-loading","true");
conf.setProperty("storage.batch-loading",true);
conf.setProperty("storage.buffer-size",3024000);
conf.setProperty("storage.tablename",graphName);
conf.setProperty("ids.block-size", 1000000);
conf.setProperty("ids.flush ", true);
//set the db cache
conf.setProperty("cache.db-cache",true);
//set the cache size
conf.setProperty("cache.db-cache-size",0.5);
conf.setProperty("storage.hbase.region-count",3);
conf.setProperty("storage.hbase.skip-schema-check", false);
conf.setProperty("storage.index.titan5.backend","elasticsearch");
conf.setProperty("storage.index.titan5.hostname", "192.168.51.95");
conf.setProperty("storage.index.titan5.client-only", false);
conf.setProperty("storage.index.titan5.cluster-name","titancluster");
conf.setProperty("storage.index.titan5.index-name", indexName);
conf.setProperty("graph.set-vertex-id",true);
conf.setProperty("attributes.allow-all",true);
conf.setProperty("schema.default",false);
TitanGraph titanGraph = TitanFactory.open(conf);
titanGraph.makeLabel("reason").manyToMany().make();
titanGraph.makeLabel("many").manyToMany().make();
BatchGraph<TitanGraph> titanBatchGraph=new BatchGraph<TitanGraph>(titanGraph,VertexIDType.NUMBER,batchsize);
titanBatchGraph.setLoadingFromScratch(true);
String locations[]=CreateDummy1.getCircleList();
String strLine1="";
int circleindex=0;
int count=0;
Vertex vertex;
Vertex vertex2;
count ++;
if(circleindex==locations.length)
circleindex=0;
vertex=titanBatchGraph.getVertex(1);
if(vertex==null){
vertex = titanBatchGraph.addVertex(1);
vertex.setProperty("n",1);
vertex.setProperty("a",100);
}
vertex2=titanBatchGraph.getVertex(2);
if(vertex2==null){
count++;
vertex2 = titanBatchGraph.addVertex(2);
vertex2.setProperty("n",2);
vertex2.setProperty("a", 10000);
}
Edge edge= titanBatchGraph.addEdge(1,vertex,vertex2,"reason");
edge.setProperty("ti",1);
edge.setProperty("s", 5);
//second edge
vertex=titanBatchGraph.getVertex(1);
if(vertex==null){
vertex = titanBatchGraph.addVertex(1);
vertex.setProperty("n",1);
vertex.setProperty("a",100);
}
else
{
vertex.setProperty("n1", 45);
}
vertex2=titanBatchGraph.getVertex(2);
if(vertex2==null){
count++;
vertex2 = titanBatchGraph.addVertex(2);
vertex2.setProperty("n",2);
vertex2.setProperty("a", 10000);
}
Edge edge1= titanBatchGraph.addEdge(2,vertex,vertex2,"reason");
edge1.setProperty("ti",2);
edge1.setProperty("s",6);
titanBatchGraph.commit();
titanBatchGraph.shutdown();
}
catch(Exception e)
{
e.printStackTrace();
}
}
如何设置scheme-default配置?如何将其设置为默认值以便生成自动模式?请建议一种方法或任何替代方法?
答案 0 :(得分:1)
默认情况下,Titan在该配置中设置。为了详细说明,此设置schema.default
会自动设置为blueprints
。要强制架构定义,您需要将该值设置为none
。 docs读到:
配置此图表使用的DefaultSchemaMaker。如果设置为 none,禁用自动模式创建。默认为蓝图 具有MULTI边缘标签和SINGLE属性的兼容模式制作器 键
要强制执行架构,您需要执行此操作:
conf.setProperty("schema.default","none");
并使用&#34;默认&#34;你应该做的架构创建系统:
conf.setProperty("schema.default","blueprints");
所有这一切,除了非常简单的情况外,允许Titan为任何事物创建模式通常是一个坏主意。如果您没有为Titan提供架构,那么您将失去Titan提供的许多优化和功能,因此您的表现可能不会尽可能好。