From 2bec549be71b3b3aa6d819eaa3304a9a5384029d Mon Sep 17 00:00:00 2001 From: zhoney Date: Tue, 21 Aug 2018 19:53:08 +0800 Subject: [PATCH] adapt HugeGraph to tinkerpop tests for mysql backend resolve #20 Change-Id: Ic6441af1115ecaa2f3783d1a5087bb503d5ab9fa --- .../backend/tx/GraphTransaction.java | 28 +++++++++++++------ .../backend/store/mysql/MysqlSessions.java | 1 + .../src/main/resources/fast-methods.filter | 3 ++ .../src/main/resources/methods.filter | 3 ++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java index 71987baefe..0557677dd6 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java @@ -619,8 +619,11 @@ public void addVertexProperty(HugeVertexProperty prop) { vertex.setProperty(prop); return; } + boolean vertexPropertyUpdatable = this.store().features() + .supportsUpdateVertexProperty(); // Check is updating property of added/removed vertex - E.checkArgument(!this.addedVertexes.containsKey(vertex.id()) || + E.checkArgument(!vertexPropertyUpdatable || + !this.addedVertexes.containsKey(vertex.id()) || this.updatedVertexes.containsKey(vertex.id()), "Can't update property '%s' for adding-state vertex", prop.key()); @@ -643,7 +646,7 @@ public void addVertexProperty(HugeVertexProperty prop) { this.propertyUpdated(vertex, vertex.setProperty(prop)); this.indexTx.updateVertexIndex(vertex, false); - if (this.store().features().supportsUpdateVertexProperty()) { + if (vertexPropertyUpdatable) { // Append new property(OUT and IN owner edge) this.doAppend(this.serializer.writeVertexProperty(prop)); } else { @@ -675,8 +678,11 @@ public void removeVertexProperty(HugeVertexProperty prop) { vertex.removeProperty(propKey.id()); return; } + boolean vertexPropertyUpdatable = this.store().features() + .supportsUpdateVertexProperty(); // Check is updating property of added/removed vertex - E.checkArgument(!this.addedVertexes.containsKey(vertex.id()), + E.checkArgument(!vertexPropertyUpdatable || + !this.addedVertexes.containsKey(vertex.id()), "Can't remove property '%s' for adding-state vertex", prop.key()); E.checkArgument(!this.removedVertexes.containsKey(vertex.id()), @@ -693,7 +699,7 @@ public void removeVertexProperty(HugeVertexProperty prop) { this.propertyUpdated(vertex, vertex.removeProperty(propKey.id())); this.indexTx.updateVertexIndex(vertex, false); - if (this.store().features().supportsUpdateVertexProperty()) { + if (vertexPropertyUpdatable) { // Eliminate the property(OUT and IN owner edge) this.doEliminate(this.serializer.writeVertexProperty(prop)); } else { @@ -717,8 +723,11 @@ public void addEdgeProperty(HugeEdgeProperty prop) { edge.setProperty(prop); return; } + boolean edgePropertyUpdatable = this.store().features() + .supportsUpdateEdgeProperty(); // Check is updating property of added/removed edge - E.checkArgument(!this.addedEdges.containsKey(edge.id()) || + E.checkArgument(!edgePropertyUpdatable || + !this.addedEdges.containsKey(edge.id()) || this.updatedEdges.containsKey(edge.id()), "Can't update property '%s' for adding-state edge", prop.key()); @@ -741,7 +750,7 @@ public void addEdgeProperty(HugeEdgeProperty prop) { this.propertyUpdated(edge, edge.setProperty(prop)); this.indexTx.updateEdgeIndex(edge, false); - if (this.store().features().supportsUpdateEdgeProperty()) { + if (edgePropertyUpdatable) { // Append new property(OUT and IN owner edge) this.doAppend(this.serializer.writeEdgeProperty(prop)); this.doAppend(this.serializer.writeEdgeProperty( @@ -774,8 +783,11 @@ public void removeEdgeProperty(HugeEdgeProperty prop) { edge.removeProperty(propKey.id()); return; } + boolean edgePropertyUpdatable = this.store().features() + .supportsUpdateEdgeProperty(); // Check is updating property of added/removed edge - E.checkArgument(!this.addedEdges.containsKey(edge.id()) || + E.checkArgument(!edgePropertyUpdatable || + !this.addedEdges.containsKey(edge.id()) || this.updatedEdges.containsKey(edge.id()), "Can't remove property '%s' for adding-state edge", prop.key()); @@ -793,7 +805,7 @@ public void removeEdgeProperty(HugeEdgeProperty prop) { this.propertyUpdated(edge, edge.removeProperty(propKey.id())); this.indexTx.updateEdgeIndex(edge, false); - if (this.store().features().supportsUpdateEdgeProperty()) { + if (edgePropertyUpdatable) { // Eliminate the property(OUT and IN owner edge) this.doEliminate(this.serializer.writeEdgeProperty(prop)); this.doEliminate(this.serializer.writeEdgeProperty( diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlSessions.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlSessions.java index 8ea6d6250d..655ebaca2a 100644 --- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlSessions.java +++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlSessions.java @@ -301,6 +301,7 @@ public Integer commit() { updated += IntStream.of(statement.executeBatch()).sum(); } this.conn.commit(); + this.conn.setAutoCommit(true); this.clear(); } catch (SQLException e) { throw new BackendException("Failed to commit", e); diff --git a/hugegraph-test/src/main/resources/fast-methods.filter b/hugegraph-test/src/main/resources/fast-methods.filter index 74ab5ed249..cdf3ba15d3 100644 --- a/hugegraph-test/src/main/resources/fast-methods.filter +++ b/hugegraph-test/src/main/resources/fast-methods.filter @@ -63,6 +63,9 @@ org.apache.tinkerpop.gremlin.structure.TransactionTest.shouldExecuteWithCompetin #################### process suite #################### +# multiple source vertices VertexStep with range +org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeTest.Traversals.g_V_repeatXbothX_timesX3X_rangeX5_11X: Range applied to last VertexStep as offset and limit for each Query, rather than result sets + # unsupported automatic edge id, therefore number of edge is wrong org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest.shouldTriggerAddEdge: Unsupported automatic edge id, therefore number of edge is wrong org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest.shouldTriggerAddEdgeByPath: Unsupported automatic edge id, therefore number of edge is wrong diff --git a/hugegraph-test/src/main/resources/methods.filter b/hugegraph-test/src/main/resources/methods.filter index efbc460ddb..89dd73a931 100644 --- a/hugegraph-test/src/main/resources/methods.filter +++ b/hugegraph-test/src/main/resources/methods.filter @@ -63,6 +63,9 @@ org.apache.tinkerpop.gremlin.structure.TransactionTest.shouldExecuteWithCompetin #################### process suite #################### +# multiple source vertices VertexStep with range +org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeTest.Traversals.g_V_repeatXbothX_timesX3X_rangeX5_11X: Range applied to last VertexStep as offset and limit for each Query, rather than result sets + # unsupported automatic edge id, therefore number of edge is wrong org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest.shouldTriggerAddEdge: Unsupported automatic edge id, therefore number of edge is wrong org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest.shouldTriggerAddEdgeByPath: Unsupported automatic edge id, therefore number of edge is wrong