Hi,

Any changes to the database, as adding Vertex/Edge types, needs to be done 
outside the transaction.

I'm inserting new records in a batch and to solve this, in that situation, 
I pre-iterate through the batch to check for new types, create them and 
then start a transaction to insert.

Does that clarify anything?

Regards,
  -Stefán

On Wednesday, 9 April 2014 07:10:13 UTC, Marc Tigges wrote:
>
> Hallo,
>
> im getting a warning for each vertex typ i want to create: 
>
> WARNING: Committing the active transaction to create vertex type 
> 'american_football' as subclass of 'V'. To avoid this behavior do it 
> outside the transaction
>
> My code looks like that at the moment:
>
> public class GraphOperationsDAO extends GraphOperations {
> private long statementCounter = 0;
> private long statementCounterKum = 0;
> private String pathToOrientDB = null;
> private OrientGraph graph = null;
>  public GraphOperationsDAO(String pathToOrientDB) {
> this.pathToOrientDB = pathToOrientDB;
> }
>  @Override
> public void openGraph() {
> this.graph = new OrientGraph(this.pathToOrientDB, "admin", "admin");
> }
>
> @Override
> public void commitGraph() {
> if(this.graph != null) {
> this.graph.commit();
> }
> }
>
> @Override
> public void rollbackGraph() {
> if(this.graph != null) {
> this.graph.rollback();
> }
> }
>  @Override
> public void closeGraph() {
> if(this.graph != null) {
> this.graph.commit();
> this.graph.shutdown();
> }
> }
>  @Override
> public void createVertexClass(String name, String parent) {
> this.graph.createVertexType(name, parent);
>  this.inkrementStatementCounter();
> }
>
> @Override
> public void createVertex(String id, String className) {
> Vertex newVertex = this.graph.addVertex("class:" + className);
> newVertex.setProperty("ID", id);
>  this.inkrementStatementCounter();
> }
>  @Override
> public void createEdgeClass(String name, String parent) {
> this.graph.createEdgeType(name, parent);
>  this.inkrementStatementCounter();
> }
>
> @Override
> public void createEdge(String edgeName, String outID, String outClass, 
> String inID, String inClass, String property) {
> Vertex outVertex = null;
> Vertex inVertex = null;
> Edge edge = null;
>  for(Vertex vertex : this.graph.getVerticesOfClass(outClass)) {
> if(vertex.getProperty("ID").equals(outID)) {
> outVertex = vertex;
> }
> }
>  for(Vertex vertex : this.graph.getVerticesOfClass(inClass)) {
> if(vertex.getProperty("ID").equals(inID)) {
> inVertex = vertex;
> }
> }
>  edge = this.graph.addEdge(null, outVertex, inVertex, edgeName);
>  if(property != null) {
> if(DataType.isInteger(property)) {
> edge.setProperty("value", Integer.valueOf(property));
> } else if(DataType.isDouble(property)) {
> edge.setProperty("value", Double.valueOf(property));
> } else if(DataType.isBoolean(property)) {
> edge.setProperty("value", Boolean.valueOf(property));
> } else if(DataType.isDate(property)) {
> edge.setProperty("value", Date.valueOf(property));
> } else {
> edge.setProperty("value", property);
> }
> }
>  this.inkrementStatementCounter();
> }
>  private void inkrementStatementCounter() {
> if(this.statementCounter == 1000) {
> this.commitGraph();
>  this.statementCounter = 0;
>  System.out.println("Parsed Lines: " + this.statementCounterKum);
> }
>  this.statementCounter++;
> this.statementCounterKum++;
> }
> }
>
> Can i just ignore that warning or do i have to change something? How can i 
> create my vertex types outside of the transaction?
>

-- 

--- 
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.

Reply via email to