Skip to content

Commit

Permalink
Support new text predicates via JanusGraph Server
Browse files Browse the repository at this point in the history
The predicates added in #2559 were not supported by
`JanusGraphPSerializer` and could thus not be used when connecting via
remote to JanusGraph Server.

Fixes #4275

Signed-off-by: Florian Hockmann <[email protected]>
  • Loading branch information
FlorianHockmann committed Feb 28, 2024
1 parent ec236f6 commit a24d5d6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,21 @@ public static boolean checkForJanusGraphPredicate(String predicateName) {
case "geoWithin":
case "geoContains":
case "textContains":
case "textNotContains":
case "textContainsFuzzy":
case "textNotContainsFuzzy":
case "textContainsPrefix":
case "textNotContainsPrefix":
case "textContainsRegex":
case "textNotContainsRegex":
case "textContainsPhrase":
case "textNotContainsPhrase":
case "textFuzzy":
case "textNotFuzzy":
case "textPrefix":
case "textNotPrefix":
case "textRegex":
case "textNotRegex":
return true;
default:
return false;
Expand All @@ -76,18 +85,36 @@ public static JanusGraphP createPredicateWithValue(String predicateName, Object
return Geo.geoContains(value);
case "textContains":
return Text.textContains(value);
case "textNotContains":
return Text.textNotContains(value);

Check warning on line 89 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L89

Added line #L89 was not covered by tests
case "textContainsFuzzy":
return Text.textContainsFuzzy(value);
case "textNotContainsFuzzy":
return Text.textNotContainsFuzzy(value);

Check warning on line 93 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L93

Added line #L93 was not covered by tests
case "textContainsPrefix":
return Text.textContainsPrefix(value);
case "textNotContainsPrefix":
return Text.textNotContainsPrefix(value);

Check warning on line 97 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L97

Added line #L97 was not covered by tests
case "textContainsRegex":
return Text.textContainsRegex(value);
case "textNotContainsRegex":
return Text.textNotContainsRegex(value);

Check warning on line 101 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L101

Added line #L101 was not covered by tests
case "textContainsPhrase":
return Text.textContainsPhrase(value);

Check warning on line 103 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L103

Added line #L103 was not covered by tests
case "textNotContainsPhrase":
return Text.textNotContainsPhrase(value);

Check warning on line 105 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L105

Added line #L105 was not covered by tests
case "textFuzzy":
return Text.textFuzzy(value);
case "textNotFuzzy":
return Text.textNotFuzzy(value);

Check warning on line 109 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L109

Added line #L109 was not covered by tests
case "textPrefix":
return Text.textPrefix(value);
case "textNotPrefix":
return Text.textNotPrefix(value);

Check warning on line 113 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L113

Added line #L113 was not covered by tests
case "textRegex":
return Text.textRegex(value);
case "textNotRegex":
return Text.textNotRegex(value);

Check warning on line 117 in janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphPSerializer.java#L117

Added line #L117 was not covered by tests
default:
throw new UnsupportedOperationException("Matched predicate {" + predicateName + "} is not support by JanusGraphPSerializer");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,21 @@ private static Stream<JanusGraphP> janusGraphPProvider() {
Geo.geoDisjoint(Geoshape.circle(37.97, 23.72, 50)),
Geo.geoContains(Geoshape.point(37.97, 23.72)),
Text.textContains("neptune"),
Text.textNotContains("neptune"),
Text.textContainsPrefix("nep"),
Text.textNotContainsPrefix("nep"),
Text.textContainsRegex("nep.*"),
Text.textNotContainsRegex("nep.*"),
Text.textContainsPhrase("neptune,pluto"),
Text.textNotContainsPhrase("neptune,pluto"),
Text.textPrefix("n"),
Text.textNotPrefix("n"),
Text.textRegex(".*n.*"),
Text.textNotRegex(".*n.*"),
Text.textContainsFuzzy("neptun"),
Text.textFuzzy("nepitne")
Text.textNotContainsFuzzy("neptun"),
Text.textFuzzy("nepitne"),
Text.textNotFuzzy("nepitne")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public void testJanusGraphPredicatesAsGraphSON(GraphSONVersion graphSONVersion)
g.E().has("place", Geo.geoDisjoint(Geoshape.circle(37.97, 23.72, 50))),
g.V().has("place", Geo.geoContains(Geoshape.point(37.97, 23.72))),
g.V().has("name", Text.textContains("neptune")), g.V().has("name", Text.textContainsPrefix("nep")),
g.V().has("name", Text.textNotContains("neptune")), g.V().has("name", Text.textNotContainsPrefix("nep")),
g.V().has("name", Text.textContainsRegex("nep.*")), g.V().has("name", Text.textPrefix("n")),
g.V().has("name", Text.textRegex(".*n.*")), g.V().has("name", Text.textContainsFuzzy("neptun")),
g.V().has("name", Text.textFuzzy("nepitne")) };
Expand Down

0 comments on commit a24d5d6

Please sign in to comment.