Skip to content
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

Add GraphSON 2 support for JanusGraph predicates #1060 #1061

Merged
merged 1 commit into from
Jun 11, 2018

Conversation

FlorianHockmann
Copy link
Member

This adds GraphSON support for JanusGraph predicates (Text and Geo) which is necessary to use them in GLVs.

I only implemented this for GraphSON 2 as it looks like GraphSON 3 currently doesn't even work with the default TinkerPop predicates (P.within(), P.gt(), ...). At least the test I added for that (testTinkerPopPredicatesAsGraphSON) fails with GraphSON 3 independent of my code changes.
Would be good to hear from someone with more knowledge of JanusGraph I/O if I'm doing something wrong here. When there are more problems with GraphSON 3 then a separate PR for that might be a good idea but I marked this PR as WIP until that has been clarified.

Issue: #1060


Thank you for contributing to JanusGraph!

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there an issue associated with this PR? Is it referenced in the commit message?
  • Does your PR body contain #xyz where xyz is the issue number you are trying to resolve?
  • Has your PR been rebased against the latest commit within the target branch (typically master)?
  • Is your initial contribution a single, squashed commit?

For code changes:

  • Have you written and/or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE.txt file, including the main LICENSE.txt file in the root of this repository?
  • If applicable, have you updated the NOTICE.txt file, including the main NOTICE.txt file found in the root of this repository?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?
  • If this PR is a documentation-only change, have you added a [skip ci]
    tag to the first line of your commit message to avoid spending CPU cycles in
    Travis CI when no code, tests, or build configuration are modified?

Note:

Please ensure that once the PR is submitted, you check Travis CI for build issues and submit an update to your PR as soon as possible.

@janusgraph-bot janusgraph-bot added the cla: yes This PR is compliant with the CLA label May 13, 2018
@FlorianHockmann FlorianHockmann changed the title [WIP] Add GraphSON 2 support for JanusGraph predicates #1060 Add GraphSON 2 support for JanusGraph predicates #1060 May 18, 2018
@FlorianHockmann
Copy link
Member Author

I looked a bit more into the issue with GraphSON 3 and confirmed that it has nothing to do with predicates. JanusGraph just can't deserialize GraphSON 3 right now. The tests I added even failed for a traversal like g.V() as the resulting serialized RequestMessage wraps the Bytecode now in a map which wasn't the case for GraphSON 2:

{
    "requestId": {
        "@type": "g:UUID",
        "@value": "164c5471-60f3-4f54-9f02-17918e5fe60b"
    },
    "op": "bytecode",
    "processor": "traversal",
    "args": {
        "@type": "g:Map",
        "@value": [
            "gremlin",
            {
                "@type": "g:Bytecode",
                "@value": {
                    "step": [
                        [
                            "V"
                        ]
                    ]
                }
            }
        ]
    }
}

I created #1075 for GraphSON 3 support. So this PR is now ready for review.

@pluradj pluradj added this to the Release v0.3.0 milestone May 22, 2018
@janusgraph-bot janusgraph-bot added the cla: yes This PR is compliant with the CLA label May 23, 2018
Copy link
Member

@pluradj pluradj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple small fixes to do, otherwise nice work on this @FlorianHockmann!

I verified this manually with Gremlin Server configured with GraphSONMessageSerializerV2d0 as the only serializer then connected from Gremlin Console using the same serializer in the remote-objects.yaml.

@@ -0,0 +1,91 @@
package org.janusgraph.graphdb.tinkerpop.io.graphson;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to include the JanusGraph copyright header


for (GraphTraversal traversal : traversals) {
Bytecode expectedBytecode = traversal.asAdmin().getBytecode();
RequestMessage requestMessage = RequestMessage.build(Tokens.OPS_BYTECODE).processor("traversal")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "traversal" with a constant GraphSONTokens.TRAVERSAL

Signed-off-by: Florian Hockmann <fh@florian-hockmann.de>
@FlorianHockmann
Copy link
Member Author

I just amended my commit to include the two changes you requested, @pluradj.

Copy link
Member

@pluradj pluradj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @FlorianHockmann

@pluradj pluradj requested a review from a team June 7, 2018 19:42
Copy link
Contributor

@twilmes twilmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks @FlorianHockmann

@janusgraph-bot janusgraph-bot added the cla: yes This PR is compliant with the CLA label Jun 11, 2018
@pluradj pluradj merged commit 28ab9ca into JanusGraph:master Jun 11, 2018
@FlorianHockmann FlorianHockmann deleted the graphson-predicates branch June 11, 2018 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This PR is compliant with the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants