andreachild commented on code in PR #3161:
URL: https://github.com/apache/tinkerpop/pull/3161#discussion_r2216896726
##########
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerTransactionGraph.java:
##########
@@ -152,11 +152,19 @@ public Vertex addVertex(final Object... keyValues) {
if (container != null && container.get() != null)
throw Exceptions.vertexWithIdAlreadyExists(idValue);
+ long version = txNumber;
+ if (container != null && container.isDeleted() &&
container.getModified() != null) {
+ // vertex being added was previously deleted
+ // we need to reference the version from the deleted state when
adding the vertex back
+ version = container.getModified().version();
+ container.unmarkDeleted((TinkerTransaction) tx());
+ }
+
// no existing container, let's use new one
if (container == null)
container = newContainer;
- final TinkerVertex vertex = new TinkerVertex(idValue, label, this,
txNumber);
+ final TinkerVertex vertex = new TinkerVertex(idValue, label, this,
version);
Review Comment:
From my understanding the transaction number is specifically not set on the
vertex until commit is called and until then, the vertex should retain the
original version (except when adding a brand new vertex which will by default
have a version set to the transaction number).
```
public void commit(final long txVersion) {
updateUsesCount();
if (isDeletedInTx.get()) {
// created and deleted in same tx
if (null != element)
element.removed = true;
element = null;
isDeleted = true;
} else if (isModifiedInTx.get()){
element = transactionUpdatedValue.get();
element.currentVersion = txVersion;
}
reset();
}
```
Did I misunderstand?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]