Hi all, this is the first version of the new Graph Factory. Any comments are welcome!
TinkerPop Blueprints <https://github.com/tinkerpop/blueprints/wiki> standard doesn't define a proper "Factory" to get graph instances. For this reason OrientDB users that wanted to use a pool of instances had to mix 2 different API: Graph and Document one. Example: ODatabaseDocumentPool pool = new ODatabaseDocumentPool("plocal:/temp/mydb"); OrientGraph g = new OrientGraph(pool.acquire()); *NOTE: You could also use a OGraphDatabase instance in place of ODatabaseDocumentPool, but this API has been deprecated since a long time and will be removed in v1.7. * Now everything is simpler, thanks to the new *OrientGraphFactory* class to manage graphs in easy way (Issue #1971<https://github.com/orientechnologies/orientdb/issues/1971>). These the main features: - by default acts as a factory by creating new database instances every time - can be configured to work as a pool, by recycling database instances - if the database doesn't exist, it's created automatically (but in "remote" mode) - returns transactional and non-transactional instances This is the basic way to create the factory, by using the default "admin" user (with "admin" password by default): OrientGraphFactory factory = new OrientGraphFactory("plocal:/temp/mydb"); But you can also pass user and password: OrientGraphFactory factory = new OrientGraphFactory("plocal:/temp/mydb", "jayminer", "amigarocks"); To work with a recyclable pool of instances with minimum 1, maximum 10 instances: OrientGraphFactory factory = new OrientGraphFactory("plocal:/temp/mydb").setupPool(1, 10); Once the factory is configured you can get a Graph instance to start working. OrientGraphFactory has 2 methods to retrieve a Transactional and Non-Transactional instance: OrientGraph txGraph = factory.getTx(); OrientGraphNoTx noTxGraph = factory.getNoTx(); Or again you can configure in the factory the instances you want and use the get() method everytime: factory.setTransactional(false); OrientGraphNoTx noTxGraph = (OrientGraphNoTx) factory.get(); Once finished to free all the resources (in case of pool usage), call the close(): factory.close(); - See more at: http://www.orientechnologies.com/new-orientdb-graph-factory/#sthash.159abedh.dpuf Lvc@ -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
