hi,
my graph model of my project consist of three custom vertex classes:
Person, Location and Content. Recently i migrated my code to 1.7.3 from
1.7.rc2, we are also using Lucene based index for Content class, ever since
we added that we are getting this Exception :
com.orientechnologies.orient.core.exception.OStorageException: Error during
transaction commit.
at
com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.commit(OLocalPaginatedStorage.java:1096)
at
com.orientechnologies.orient.core.tx.OTransactionOptimistic.doCommit(OTransactionOptimistic.java:132)
at
com.orientechnologies.orient.core.tx.OTransactionOptimistic.commit(OTransactionOptimistic.java:105)
at
com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.commit(ODatabaseRecordTx.java:142)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:504)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:496)
at
com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.commit(ONetworkProtocolBinary.java:1096)
at
com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:344)
at
com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.java:169)
at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:45)
Caused by: java.lang.IllegalArgumentException: targetGen=122 was never
returned by the ReferenceManager instance (current gen=35)
at
org.apache.lucene.search.ControlledRealTimeReopenThread.waitForGeneration(ControlledRealTimeReopenThread.java:160)
at
org.apache.lucene.search.ControlledRealTimeReopenThread.waitForGeneration(ControlledRealTimeReopenThread.java:135)
at
com.orientechnologies.lucene.manager.OLuceneIndexManagerAbstract.getSearcher(OLuceneIndexManagerAbstract.java:135)
at
com.orientechnologies.lucene.manager.OLuceneFullTextIndexManager.getResults(OLuceneFullTextIndexManager.java:131)
at
com.orientechnologies.lucene.manager.OLuceneFullTextIndexManager.get(OLuceneFullTextIndexManager.java:99)
at
com.orientechnologies.lucene.OLuceneIndexEngine.get(OLuceneIndexEngine.java:153)
at
com.orientechnologies.orient.core.index.OIndexMultiValues.putInSnapshot(OIndexMultiValues.java:137)
at
com.orientechnologies.orient.core.index.OIndexAbstract.applyIndexTxEntry(OIndexAbstract.java:954)
at
com.orientechnologies.orient.core.index.OIndexAbstract.addTxOperation(OIndexAbstract.java:679)
at
com.orientechnologies.orient.core.tx.OTransactionOptimistic$CommitIndexesCallback.run(OTransactionOptimistic.java:256)
at
com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.commit(OLocalPaginatedStorage.java:1082)
... 9 more
did search for a few minutes in Google but could't find anything useful.
have attached my dao file where in im adding the model object to graph
vertices
lucene index command :
CREATE INDEX INDX_CONTENT_TEXT ON Content (content) FULLTEXT ENGINE LUCENE;
--
---
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/d/optout.
import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.biomorf.cip.graph.helper.CIPGraphDBHealper;
import com.biomorf.cip.common.exception.CIPException;
import com.biomorf.cip.common.model.CIPContent;
import com.biomorf.cip.common.model.CIPLocation;
import com.biomorf.cip.common.model.CIPPayload;
import com.biomorf.cip.common.model.CIPUser;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
public class CIPGraphDAO {
public void createGraph(CIPPayload data) throws CIPException {
OrientGraph graph = null;
String source = data.getSource();
try {
graph = CIPGraphDBHealper.connect();
CIPLocation location = data.getGeoLocation();
Vertex locationVertex = null, contentVertex = null,
userVertex = null;
if ((location != null) && !location.isNull()) {
locationVertex = getLocationVertex(location,
graph);
}
CIPContent content = data.getContent();
if ((content != null) &&
(StringUtils.isNotBlank(content.getId()))) {
contentVertex = getContentVertex(graph,
content, source);
}
CIPUser user = data.getUserInfo();
if ((user != null) &&
(StringUtils.isNotBlank(user.getUserId()) && (Long.valueOf(user.getUserId()) >
0L))) {
userVertex = createUser(graph, user, source);
}
if (locationVertex != null) {
graph.addEdge(null, userVertex, locationVertex,
"lives_at");
}
if ((null != contentVertex) && (null != userVertex)) {
graph.addEdge(null, contentVertex, userVertex,
"posted_by");
}
graph.commit();
} catch (Exception e) {
e.printStackTrace();
throw new CIPException(e);
} finally {
if (graph != null) {
CIPGraphDBHealper.disconnect(graph);
}
}
}
private Vertex getLocationVertex(CIPLocation location, OrientGraph
graph) {
Vertex locationVertex = graph.addVertex("class:Location");
if (isNotNull(location.getAddress())) {
locationVertex.setProperty("address",
def(location.getAddress()));
}
if (isNotNull(location.getCity())) {
locationVertex.setProperty("city",
def(location.getCity()));
}
if (isNotNull(location.getState())) {
locationVertex.setProperty("state",
def(location.getState()));
}
if (isNotNull(location.getLatitude())) {
locationVertex.setProperty("latitude",
def(location.getLatitude()));
}
if (isNotNull(location.getLongitude())) {
locationVertex.setProperty("longitude",
def(location.getLongitude()));
}
if (isNotNull(location.getCountry())) {
locationVertex.setProperty("country",
def(location.getCountry()));
}
if (isNotNull(location.getZip())) {
locationVertex.setProperty("zip",
def(location.getZip()));
}
if (isNotNull(location.getTimezone())) {
locationVertex.setProperty("timezone",
def(location.getTimezone()));
}
return locationVertex;
}
@SuppressWarnings("unchecked")
private Vertex getContentVertex(OrientGraph graph, CIPContent content,
String source) {
Vertex contentVertex = null;
String contentSearchQuery = "select from Content where
content_id =" + "'" + content.getId() + "'";
Iterable<Vertex> result = (Iterable<Vertex>) graph.command(new
OCommandSQL(contentSearchQuery)).execute();
if ((result != null) && result.iterator().hasNext()) {
contentVertex = result.iterator().next();
} else {
contentVertex = graph.addVertex("class:Content",
"content_id", content.getId());
contentVertex = setContentVertexProperty(contentVertex,
content, graph, source);
}
return contentVertex;
}
private Vertex setContentVertexProperty(Vertex contentVertex,
CIPContent content, OrientGraph graph, String source) {
if (isNotNull(content.getOriginalContent())) {
contentVertex.setProperty("content",
QueryParser.escape(def(content.getOriginalContent())));
}
if (isNotNull(content.getLanguage())) {
contentVertex.setProperty("language",
def(content.getLanguage()));
}
if (isNotNull(content.getParentContentId())) {
Vertex parentVertex = getParentContentVertex(content,
graph);
if ((null != parentVertex) &&
StringUtils.isNotBlank(content.getContentType())) {
graph.addEdge(null, parentVertex,
contentVertex, content.getContentType());
contentVertex.setProperty("parentContentId",
def(content.getParentContentId()));
}
}
if (isNotNull(content.getIsRetweet())) {
contentVertex.setProperty("isReTweet",
content.getIsRetweet());
}
if (isNotNull(content.getIsReply())) {
contentVertex.setProperty("isReply",
content.getIsReply());
}
if (isNotNull(content.getContentUrl())) {
contentVertex.setProperty("contentURL",
def(content.getContentUrl()));
}
if (isNotNull(source)) {
contentVertex.setProperty("source", def(source));
}
if (isNotNull(content.getTime())) {
contentVertex.setProperty("time", content.getTime());
}
return contentVertex;
}
@SuppressWarnings("unchecked")
private Vertex getParentContentVertex(CIPContent content, OrientGraph
graph) {
Vertex parentVertex = null;
String parentContentSearchQuery = "select from Content where
content_id =" + "'" + content.getParentContentId()
+ "'";
Iterable<Vertex> result = (Iterable<Vertex>) graph.command(new
OCommandSQL(parentContentSearchQuery)).execute();
if ((result != null) && result.iterator().hasNext()) {
parentVertex = result.iterator().next();
}
return parentVertex;
}
@SuppressWarnings({ "unchecked" })
private Vertex createUser(OrientGraph graph, CIPUser user, String
source) {
Vertex userVertex = null;
String userSearchQuery = "select from Person where userId =" +
defLong(user.getUserId());
Iterable<Vertex> result = (Iterable<Vertex>) graph.command(new
OCommandSQL(userSearchQuery)).execute();
if ((result != null) && result.iterator().hasNext()) {
userVertex = result.iterator().next();
if (StringUtils.isNotBlank(user.getKloutScore())) {
Float score = new
Float(def(user.getKloutScore()));
if (score > 0.0) {
userVertex.setProperty("kloutScore",
score.toString());
}
}
} else {
userVertex = graph.addVertex("class:Person", "userId",
defLong(user.getUserId()));
userVertex = setUserVertexProperty(userVertex, user,
graph, source);
}
return userVertex;
}
/**
* setting User Vertex properties.
*
* @param userVertex
* @param user
* @param graph
* @param source
* @return
*/
private Vertex setUserVertexProperty(Vertex userVertex, CIPUser user,
OrientGraph graph, String source) {
if (isNotNull(user.getUserName())) {
userVertex.setProperty("userName", user.getUserName());
}
if (isNotNull(user.getProfileName())) {
userVertex.setProperty("profileName",
user.getProfileName());
}
if (isNotNull(user.getDescription())) {
userVertex.setProperty("description",
user.getDescription());
}
if (isNotNull(user.getProfileImageUrl())) {
userVertex.setProperty("profileImageUrl",
user.getProfileImageUrl());
}
if (isNotNull(user.getKloutScore())) {
userVertex.setProperty("kloutScore",
user.getKloutScore());
}
if (isNotNull(user.isVerified())) {
userVertex.setProperty("isVerified", user.isVerified());
}
if (isNotNull(source)) {
userVertex.setProperty("source", source);
}
return userVertex;
}
private String def(String value) {
return StringUtils.defaultIfBlank(value, "NA");
}
private Long defLong(String value) {
Long val = 0L;
if (StringUtils.isNotBlank(value) &&
StringUtils.isNumeric(value)) {
val = Long.valueOf(value);
}
return val;
}
private boolean isNotNull(Object field) {
boolean flag = false;
if ((field instanceof String) &&
StringUtils.isNotBlank((String) field)) {
flag = true;
} else if (null != field) {
flag = true;
}
return flag;
}
}