I need to store graph data using Batchinserter efficiently and need to make
sure that it only stores unique nodes. So for this purpose we are using
batchinserter and indexing. But for some strange reasons indexer is not
working properly and does not reloads previous indexes on application
restart. That ultimately allows duplicate nodes to be stored.
Here is my code :
Resource subject = st.getSubject();
Resource predicate = st.getPredicate();
String predicateName = predicate.getLocalName();
RDFNode object = st.getObject();
// Check index for subject
Long subjectNode = null;
if(subject.isURIResource()){
subjectNode = tmpIndex.get(subject.getURI());
IndexHits<Long> hit = index.get(NeoGraph.LABEL_URI, subject.getURI());
System.out.println("Hit for: " + subject.getURI() + " is:" +
hit.size());
if(hit.hasNext()){
subjectNode = hit.next();
}
else{
Map<String, Object> props = new HashMap<String, Object>();
props.put(NeoGraph.LABEL_URI, subject.getURI());
subjectNode = db.createNode(props);
Label label = DynamicLabel.label(NeoGraph.LABEL_URI);
db.setNodeLabels(subjectNode, label);
index.updateOrAdd(subjectNode, props);
addedNodes++;
}
}
--
You received this message because you are subscribed to the Google Groups
"Neo4j" 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/d/optout.