0

How to make schema less titan graph?How to set schema-default propery ? Please suggest a way?Here is my code :

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();
    }
    }

How to set scheme-default configuration? how to set it to default so that automatic schemas are generated?Please suggest a way or any alternative ?

abi_pat
  • 572
  • 2
  • 12
  • 35

1 Answers1

1

Titan is set in that configuration by default. To elaborate, this settings schema.default is set to blueprints automatically. To force schema definition, you need to set that value to none. The docs read:

Configures the DefaultSchemaMaker to be used by this graph. If set to none, automatic schema creation is disabled. Defaults to a blueprints compatible schema maker with MULTI edge labels and SINGLE property keys

To enforce a schema you need to do this:

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

and to use the "default" schema creation system you should do:

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

All that said, it is generally a bad idea to allow Titan to create the schema for anything except very simple cases. If you don't provide Titan a schema, you will lose many optimizations and features that Titan provides and therefore you performance may not be as good as it possible could be.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • In my program I am setting conf.setProperty("schema.default","blueprints"); but still its not working. – abi_pat Nov 27 '14 at 12:47
  • and what are the features I will not be able to use if I use ("schema.default","none") – abi_pat Nov 27 '14 at 12:52
  • You shouldnt need to even set it. It is set to that value by default. Types will be added automatically as you add keys. If you don't specify a schema you won't get optimizations from vertex centric indices (or any indices for that matter). You should review the docs to learn more.http://s3.thinkaurelius.com/docs/titan/0.5.2/schema.html – stephen mallette Nov 27 '14 at 15:29
  • Thanks for the reply but since i am performing indexing so would I be able to index that new added property by adding key – abi_pat Nov 28 '14 at 05:46
  • Just because you specify `blueprints` for the `schema.default` setting doesn't mean that you can't specify indices and other schema elements. It just means that if in your code you add a new property key, Titan will auto-type it for you. If you set to `none` it will throw an exception. – stephen mallette Nov 28 '14 at 13:01
  • I am not able to get you can you please give me a example it would really be helpful – abi_pat Nov 28 '14 at 13:54
  • there really is no "example". all i'm saying is that just because you choose to use `blueprints` as your setting doesn't mean that you can't still create indices and types. using `blueprints` only means that if a type is not present when you add a new key, Titan will create a default type for you (which will generally be unoptimized). – stephen mallette Nov 28 '14 at 14:25