-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TINKERPOP-1483: valueMap should always return string keys #446
Conversation
Hm. This is a hard pill to swallow as its not backwards compatible. I was thinking you were going to go the route of making it |
Well, I wasn't going to change the API on my very first PR :-). The first thing I did with a valueMap result was to iterate on the keys, which crashes... Of course if you want to change the API to |
I've seen lots of code where people actually use
Those people would be in big trouble if we would merge this PR: VOTE: -1 |
Yea, this is a troublesome PR. VOTE -1. |
Fine, but if you don't want to change the implementation to match the interface, you'll have to change the interface of valueMap... Having keys of a type that is not allowed by the actual generic signature of the map is not great... |
To support something like |
What? I'm just saying that currently valueMap returns |
Oh, now I see what you're saying. Yes, this would be the right way to go. The current protected Map<String, E> map(...) {
final Map<Object, Object> map = new HashMap<>();
...
return (Map) map;
} |
Can this PR be updated with Map<Object, Object> or should it be closed and open a new one? |
This is interesting. I was unaware of some or didn't understand some implementation details. Taking a step back and looking at this again, I wonder if the original intent is more correct. Sorry @JPMoresmau We have to ask what is the purpose of Ultimately, the question is with what or how do we expect to access Given: Access by: If the answer is If the answer is In either case, there is no conflict between system-level |
By |
Thanks for the clarification @dkuppitz
VOTE: +1 |
Yea, VOTE +1. |
This requires CHANGELOG and upgrade docs too (unless a committer wants to take responsibility for that). |
@dkuppitz -- will you handle merge and thus, do the CHANGELOG and update the upgrade docs on merge? |
I've updated the changelog and upgrade doc, not sure it's sufficient, please check! thanks! |
@@ -46,6 +46,7 @@ TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET) | |||
* Removed `tryRandomCommit()` from `AbstractGremlinTest`. | |||
* Changed `gremlin-benchmark` system property for the report location to `benchmarkReportDir` for consistency. | |||
* Added SysV and systemd init scripts. | |||
* `valueMap` now returns a `Map<Object,E>` since keys could be `T.id` or `T.label`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it read GraphTraversal.valueMap()
.
@@ -73,6 +73,13 @@ bin/gremlin.sh -e gremlin.groovy | |||
|
|||
See: link:https://issues.apache.org/jira/browse/TINKERPOP-1283[TINKERPOP-1283] | |||
|
|||
ValueMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GraphTraversal valueMap() Signature Updated
@@ -483,7 +483,7 @@ | |||
* @param <E2> the value type of the returned properties | |||
* @return the traversal with an appended {@link PropertyMapStep}. | |||
*/ | |||
public default <E2> GraphTraversal<S, Map<String, E2>> valueMap(final String... propertyKeys) { | |||
public default <E2> GraphTraversal<S, Map<Object, E2>> valueMap(final String... propertyKeys) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this can still be Map<String,E2>
. Its only when you have a boolean
"includeTokens" that its Map<Object,Object>
.
I just realized that |
@@ -42,5 +42,10 @@ public abstract class GroovyValueMapTest { | |||
public Traversal<Vertex, Map<String, List<String>>> get_g_VX1X_outXcreatedX_valueMap(final Object v1Id) { | |||
new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('created').valueMap", "v1Id", v1Id) | |||
} | |||
|
|||
@Override | |||
public Traversal<Vertex, Map<Object, Object>> get_g_V_valueMapToken() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is named wrong, it should be:
get_g_V_hasLabelXpersonX_filterXoutEXcreatedXX_valueMapXtrueX()
*/ | ||
@Test | ||
@LoadGraphWith(MODERN) | ||
public void valueMapHasObjectKeys() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is named wrong, it should be like the traversal generator method name, minus the get_
prefix.
This is looking really good. We need one more VOTE. |
Hold on, I've been busy with other stuff. I will look into this PR today. |
Looked through the code, did some manual test - all good. VOTE: +1 Gonna merge it in a few. |
Code changed, test added