Database Reference
In-Depth Information
Simply replace build.newGraphDatabase(); in your older code base with
BatchInserters.batchDatabase( "/graph.db"); and now you can use the
APIs of GraphDatabaseService . Do not forget to add dbService.shutdown()
at the end of the code and you are done; however, this ease and simplicity comes with a
cost and the cost is that there are few operations that are not supported by this service.
The following is the list of such operations:
Transaction.finish() / Transaction.close() or Transac-
tion.success()
Node.delete() and Node.traverse()
Transaction.failure() will generate a NotInTransaction exception
Relationship.delete()
• Event handlers and indexes are not supported
getRelationshipTypes() , getAllNodes() , and getAllRelation-
ships() of GraphDatabaseService are also not supported
Batch indexing
As we have BatchInserter for inserting the data in batches, in the same manner
Neo4j provides BatchInserterIndex for indexing the dataset during the insertion
process. The following sample code demonstrates the use of BatchInserterIndex :
Import java.util.Map;
import org.neo4j.helpers.collection.MapUtil;
import
org.neo4j.index.lucene.unsafe.batchinsert.LuceneBatchInserterIndexProvider;
import org.neo4j.unsafe.batchinsert.BatchInserter;
import org.neo4j.unsafe.batchinsert.BatchInserterIndex;
import
org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider;
import org.neo4j.unsafe.batchinsert.BatchInserters;
public class Neo4jBatchIndexer {
public void batchIndexer() throws Exception {
// "/graph.db" should be replaced with the path of your
Neo4j Database.
Search WWH ::




Custom Search