如何使模式少泰坦图?如何设置模式默认属性?

问题描述 投票:0回答:1

如何使模式更少的泰坦图?如何设置模式默认属性? 请建议一种方法?这是我的代码:

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配置?如何将其设置为默认值以便生成自动模式?请建议一种方法或任何替代方案?

graph-databases titan schemaless
1个回答
1
投票

Titan 默认设置在该配置中。 详细来说,此设置

schema.default
自动设置为
blueprints
。 要强制模式定义,您需要将该值设置为
none
docs 内容如下:

配置此图要使用的 DefaultSchemaMaker。如果设置为 无,自动模式创建被禁用。默认为蓝图 具有多边缘标签和单属性的兼容模式生成器 键

要强制执行模式,您需要执行以下操作:

conf.setProperty("schema.default","none");

要使用“默认”模式创建系统,您应该这样做:

conf.setProperty("schema.default","blueprints");

总而言之,允许 Titan 为除非常简单的情况之外的任何内容创建模式通常是一个坏主意。 如果您不向 Titan 提供架构,您将失去 Titan 提供的许多优化和功能,因此您的性能可能不会那么好。

© www.soinside.com 2019 - 2024. All rights reserved.