You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "danielcweber (via GitHub)" <gi...@apache.org> on 2024/08/26 11:14:37 UTC
[PR] Add String IdManager [tinkerpop]
danielcweber opened a new pull request, #2743:
URL: https://github.com/apache/tinkerpop/pull/2743
Add a proper IdManager that creates stringified UUIDs and accepts any non-empty string
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2329601696
> I had a look into the failing checks but they seem unrelated
They do look unrelated so I just restarted the failing actions. I'll merge the PR today then. Thanks Daniel!
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#discussion_r1739050596
##########
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/AbstractTinkerGraph.java:
##########
@@ -563,6 +563,34 @@ public Object convert(final Object id) {
public boolean allow(final Object id) {
return true;
}
+ },
+
+ /**
+ * Manages identifiers of type {@code String}.
+ */
+ STRING {
+ @Override
+ public String getNextId(final AbstractTinkerGraph graph) {
+ return java.util.UUID.randomUUID().toString();
+ }
+
+ @Override
+ public Object convert(final Object id) {
+ if (null == id)
+ return null;
+ else if (id instanceof String) {
+ if (((String)id).isEmpty())
+ throw new IllegalArgumentException("Expected a non-empty string but received an empty string.");
+
+ return id;
+ } else
+ throw new IllegalArgumentException(createErrorMessage(java.lang.String.class, id));
+ }
+
+ @Override
+ public boolean allow(final Object id) {
+ return id instanceof String && !((String)id).isEmpty();
Review Comment:
> I thought about that, but if there's string ids "xxxx-yyyy-...." and "xxxxyyy..." in a database, and your're accepting UUID {xxxx-yyyy....}, which one is it?
That's a good point, but I'm not sure it fully applies here. In embedded mode, you're likely already using Java, and in remote mode, it would be deserialized into a Java UUID. So in the end, Java's string representation of UUID is effectively the correct form.
Anyways, I'm fine with this PR (already voted) without needing this change. Making it less restrictive is something that can easily be done in the future.
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2315790489
Thanks @danielcweber, LGTM.
VOTE +1
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#discussion_r1737861417
##########
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/AbstractTinkerGraph.java:
##########
@@ -563,6 +563,34 @@ public Object convert(final Object id) {
public boolean allow(final Object id) {
return true;
}
+ },
+
+ /**
+ * Manages identifiers of type {@code String}.
+ */
+ STRING {
+ @Override
+ public String getNextId(final AbstractTinkerGraph graph) {
+ return java.util.UUID.randomUUID().toString();
+ }
+
+ @Override
+ public Object convert(final Object id) {
+ if (null == id)
+ return null;
+ else if (id instanceof String) {
+ if (((String)id).isEmpty())
+ throw new IllegalArgumentException("Expected a non-empty string but received an empty string.");
+
+ return id;
+ } else
+ throw new IllegalArgumentException(createErrorMessage(java.lang.String.class, id));
+ }
+
+ @Override
+ public boolean allow(final Object id) {
+ return id instanceof String && !((String)id).isEmpty();
Review Comment:
A quick thought; this seems a bit restrictive since the default returns a UUID string. Maybe this should be extended to support more types? All objects (as in `String.valueOf(Object)`) might be too broad but maybe at least UUID?
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "danielcweber (via GitHub)" <gi...@apache.org>.
danielcweber commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2328403476
It was meant to be on 3.7 which I usually am aware of...will rebase in a minute
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2326984406
Actually I just realized, we might still need some actions from your side @danielcweber, I see your base branch is on 3.7-dev but this PR is against master, which will be for future 4.0 release.
Did you intent for this change to go into master? If so, you can rebase your branch to master. I also don't have any particular concerns with this going into 3.7 either. Let me know your thoughts or if you have any questions around this. Thanks!
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "danielcweber (via GitHub)" <gi...@apache.org>.
danielcweber commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2328546034
I had a look into the failing checks but they seem unrelated
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "danielcweber (via GitHub)" <gi...@apache.org>.
danielcweber commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2328410952
It was based on 3.7 already but became stale. Rebased it and changed the base branch in Github.
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "danielcweber (via GitHub)" <gi...@apache.org>.
danielcweber commented on code in PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#discussion_r1738420161
##########
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/AbstractTinkerGraph.java:
##########
@@ -563,6 +563,34 @@ public Object convert(final Object id) {
public boolean allow(final Object id) {
return true;
}
+ },
+
+ /**
+ * Manages identifiers of type {@code String}.
+ */
+ STRING {
+ @Override
+ public String getNextId(final AbstractTinkerGraph graph) {
+ return java.util.UUID.randomUUID().toString();
+ }
+
+ @Override
+ public Object convert(final Object id) {
+ if (null == id)
+ return null;
+ else if (id instanceof String) {
+ if (((String)id).isEmpty())
+ throw new IllegalArgumentException("Expected a non-empty string but received an empty string.");
+
+ return id;
+ } else
+ throw new IllegalArgumentException(createErrorMessage(java.lang.String.class, id));
+ }
+
+ @Override
+ public boolean allow(final Object id) {
+ return id instanceof String && !((String)id).isEmpty();
Review Comment:
Of course, if we define the canonical string representation to be just the result of toString, there's no ambiguity. I can revise the PR if agreed upon.
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2326959421
VOTE +1. Thanks @danielcweber! I will go ahead and resolve the minor changelog conflict and merge this.
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy merged PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2319942194
VOTE +1
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "danielcweber (via GitHub)" <gi...@apache.org>.
danielcweber commented on code in PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#discussion_r1738414500
##########
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/AbstractTinkerGraph.java:
##########
@@ -563,6 +563,34 @@ public Object convert(final Object id) {
public boolean allow(final Object id) {
return true;
}
+ },
+
+ /**
+ * Manages identifiers of type {@code String}.
+ */
+ STRING {
+ @Override
+ public String getNextId(final AbstractTinkerGraph graph) {
+ return java.util.UUID.randomUUID().toString();
+ }
+
+ @Override
+ public Object convert(final Object id) {
+ if (null == id)
+ return null;
+ else if (id instanceof String) {
+ if (((String)id).isEmpty())
+ throw new IllegalArgumentException("Expected a non-empty string but received an empty string.");
+
+ return id;
+ } else
+ throw new IllegalArgumentException(createErrorMessage(java.lang.String.class, id));
+ }
+
+ @Override
+ public boolean allow(final Object id) {
+ return id instanceof String && !((String)id).isEmpty();
Review Comment:
I thought about that, but if there's string ids "xxxx-yyyy-...." and "xxxxyyy..." in a database, and your're accepting UUID {xxxx-yyyy....}, which one is it?
(The form is obviously a bit off, it's about the hyphens, you get the idea)
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add String IdManager [tinkerpop]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2743:
URL: https://github.com/apache/tinkerpop/pull/2743#issuecomment-2309982842
## [Codecov](https://app.codecov.io/gh/apache/tinkerpop/pull/2743?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 80.37%. Comparing base [(`2d32517`)](https://app.codecov.io/gh/apache/tinkerpop/commit/2d32517b3bca1b00d716b3205c2abdbcd6ed3352?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`9c4a042`)](https://app.codecov.io/gh/apache/tinkerpop/commit/9c4a0423b54dda634576004125dbb76e5a71dc36?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 274 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #2743 +/- ##
============================================
+ Coverage 76.16% 80.37% +4.21%
============================================
Files 1085 27 -1058
Lines 65189 5015 -60174
Branches 7289 0 -7289
============================================
- Hits 49651 4031 -45620
+ Misses 12830 781 -12049
+ Partials 2708 203 -2505
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/tinkerpop/pull/2743?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org