0

How can I disable automatic type creation in Titan?

I modified the GraphOfTheGodsFactory example to this effect, by inserting the line

config.setProperty(GraphDatabaseConfiguration.AUTO_TYPE_KEY, "none");

but this does not seem to have the desired effect, as per the rexster console below:

rexster[groovy]> saturn = g.V("name", "saturn").next()
==>v[4]
rexster[groovy]> saturn.setProperty("someNewProp", "xyz")
==>null
rexster[groovy]> saturn.map
==>{someNewProp=xyz, name=saturn, age=10000, type=titan}
rexster[groovy]> saturn.addEdge("someNewLabel", g.V("name", "cerberus").next())
==>e[1G51-4-7I][4-someNewLabel->44]
rexster[groovy]> g.config.defaultTypeMaker
==>com.thinkaurelius.titan.graphdb.blueprints.BlueprintsDefaultTypeMaker@5b97e4fa

I am using titan-server-0.4.2.

mitchus
  • 4,677
  • 3
  • 35
  • 70

1 Answers1

1

I'm not clear on how you are creating your graph instance with the GraphOfTheGodsFactory and how you are connecting the graph in Rexster, but assuming you ran your modified GraphOfTheGodsFactory, created the graph and then connected it to Rexster to that graph, you would also need to set auto-type to none in rexster.xml for that setting to be respected by Rexster.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thanks for your reply. I create the graph by compiling and running the modified GraphOfTheGodsFactory, and then I connect to it from a Rexster console, using the command `g = TitanFactory.open("/tmp/titangotg")`. So if I understand correctly, Rexster has to be told the config of the graph it connects to? – mitchus Apr 08 '14 at 11:22
  • Ok...now I understand. You need to supply a properties file to `TitanFactory.open()`. In that properties file you should include configuration options for your BerkeleyDB graph at `/tmp/titangotg` as well as your `auto-type=none` setting. The `auto-type` setting is not persisted with the graph on creation. It must be configured for each graph instance that is opened. – stephen mallette Apr 08 '14 at 11:44
  • I see. Is there a way to write the config to file at the time of creation? – mitchus Apr 08 '14 at 12:09
  • If you really wanted to write out the `BaseConfiguration` instance, it's just an Apache Configuration object (http://commons.apache.org/proper/commons-configuration/apidocs/index.html), so one way would be to just do: `ConfigurationConverter.getProperties(config)` which will give you a standard `java.util.Properties` object. From there you can write to `OutputStream`. There are likely other ways to do this with the Apache Configuration classes as well, but this was the first one that came to mind. – stephen mallette Apr 08 '14 at 12:27
  • That raises a `ConversionException`, but anyway, thanks for your explanations and help. – mitchus Apr 08 '14 at 12:51
  • Huh....i'm sure you can get it to write out to a standard properties file. In the worst case, just iterate the keys/values and write them to a file manually. – stephen mallette Apr 08 '14 at 12:53