Github user twilmes commented on a diff in the pull request:
https://github.com/apache/tinkerpop/pull/891#discussion_r204067177
--- Diff:
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLWriter.java
---
@@ -218,20 +220,33 @@ private void writeTypes(final Map<String, String>
identifiedVertexKeyTypes,
final Map<String, String>
identifiedEdgeKeyTypes,
final XMLStreamWriter writer) throws
XMLStreamException {
// <key id="weight" for="edge" attr.name="weight"
attr.type="float"/>
- final Collection<String> vertexKeySet =
getVertexKeysAndNormalizeIfRequired(identifiedVertexKeyTypes);
+ Collection<String> vertexKeySet =
getVertexKeysAndNormalizeIfRequired(identifiedVertexKeyTypes);
+ Collection<String> edgeKeySet =
getEdgeKeysAndNormalizeIfRequired(identifiedEdgeKeyTypes);
+ // in case vertex and edge may have the same attribute name, the
key id in graphml have to be different
+ intersection = CollectionUtils.intersection(vertexKeySet,
edgeKeySet);
+ // speeding-up later checks
+ if(intersection.isEmpty()){
+ intersection = null;
+ }
for (String key : vertexKeySet) {
writer.writeStartElement(GraphMLTokens.KEY);
- writer.writeAttribute(GraphMLTokens.ID, key);
+ if(intersection != null && intersection.contains(key)){
--- End diff --
Maybe here and below you could set a key variable once, something like:
```
String keyVal = key;
if (!intersection.isEmpty() && intersection.contains(key)) {
keyVal = key.concat(GraphMLTokens.VERTEX_SUFFIX)
}
writer.writeAttribute(GraphMLTokens.ID, key);
```
---