neo4j/community — pull request #73 by FaKod (2011-10-24 12:54:42+00:00)
Title: Batch Inserter, Node Property error

Working with GraphDatabaseService created from BatchInserter Node Property are not written to disk.
The code (JavaMain) below prints out:

2 has property keys [2, 1]
2 has property keys []

This is because the shutdown chain finally ends in Class LruCache and calls cache.clean(). It seems that removeEldestEntry is not called in this case. So the changed Node properties are not "flushed".

This changeset solves this issue. This works for my testcase but I cant execute all Unit Tests while building Neo4j....

public class JavaMain {
public static void main(String[] args) {

String path = "/tmp/temp-neo-batch-test";

BatchInserter inserter = new BatchInserterImpl(path);
BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(inserter);
String name = "users";
BatchInserterIndex index = provider.nodeIndex(name, LuceneIndexImplementation.EXACT_CONFIG);

GraphDatabaseService gds = inserter.getGraphDbService();

Node myNode = gds.createNode();
long id = myNode.getId();

myNode.setProperty("1", "one");
myNode.setProperty("2", "two");

index.flush();
System.out.println(myNode.getId() + " has property keys " + myNode.getPropertyKeys());

provider.shutdown();
inserter.shutdown();

GraphDatabaseService db = new EmbeddedGraphDatabase(path);
Node node1 = db.getNodeById(id);
System.out.println(node1.getId() + " has property keys " + node1.getPropertyKeys());
db.shutdown();
}
}