Errors when trying addVertex() and makeType()

I am spec-ing out a new database in for our SQLServer based on a requirements doc for a new website. In an effort to learn Titan, I thought it would fun to do so by using it to document the schema.

My vertices would represent a Table; the edges would be to document relationships between tables and to show User Permissions required to fulfill the requirements. Eventually this could grow to add verticies for the various web pages and the edges to show which tables are used.

My question is this: Is my environment setup ok, as I keep getting errors trying to create my own schema? Or am I doing it wrong?

I downloaded TitanDB (downloaded 0.5.4), was able to import the GraphOfTheGods and play around with that.

Now I am trying to build my own graph and am getting an exception whilst trying to add a Vertex.

gremlin> g = TitanFactory.build();
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> g.set("storage.backend","cassandra");
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> g.set("storage.hostname", IP.ADD.RESS.HERE);
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> g.open();
==>titangraph[Cassandra:[IP.ADD.RESS.HERE]]
gremlin> g.addVertex()
No signature of method: com.thinkaurelius.titan.core.TitanFactory$Builder.addVertex() is applicable for arguments types: () values: []
gremlin> g.addVertex(null)
No signature of method: com.thinkaurelius.titan.core.TitanFactory$Builder.addVertex() is applicable for arguments types: (null) values: [null]

After the .open();, I see a new keyspace named "titan" in the storage engine.

So I found this (thinking that I needed define the type): How to Define Data Type for Titan Graph DB Vertex?.

When I tried this: gremlin> graph.makeType().name("name").dataType(String.class).functional().makePropertyKey()

I get this: groovysh_parse: 83: expecting anything but ''\n''; got it anyway @ line 83, column 79. functional().makePropertyKey()

Thanks for any help or guidance to tutorials on creating ones own graph structure.

Upvotes: 1

Views: 215

Answers (1)

Pomme.Verte
Pomme.Verte

Reputation: 1782

The problem is that TitanFactory.build() returns a TitanFactory$Builder and not a titangraph. It is the .open() that generates the titangraph instance you want to use.

To do what you want you need to change things around to:

gremlin> graphBuilder = TitanFactory.build();
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> graphBuilder.set("storage.backend","cassandra");
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> graphBuilder.set("storage.hostname", IP.ADD.RESS.HERE);
==>com.thinkaurelius.titan.core.TitanFactory$Builder@1950e8ac
gremlin> g = graphBuilder.open();
==>titangraph[Cassandra:[IP.ADD.RESS.HERE]]
gremlin> g.addVertex()

And it should work as expected.

Upvotes: 1

Related Questions