Skip to content

Commit

Permalink
refactoring / javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
aeberhart committed Jan 13, 2025
1 parent 4ce3783 commit 88de29a
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions dashjoin-core/src/main/java/org/dashjoin/util/OpenCypher.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import org.dashjoin.util.OpenCypherQuery.Chain;
import jakarta.ws.rs.core.SecurityContext;

/**
* simple opencypher query engine
*/
public class OpenCypher {

/**
Expand Down Expand Up @@ -156,21 +159,32 @@ static class Binding {
class Path {
List<Binding> bindings;

Binding lastBinding() {
return bindings.get(bindings.size() - 1);
}

Pattern lastPattern() {
return lastBinding().pattern;
}

/**
* we're at the last pattern and satisfied the lower "from" count
*/
boolean isSolution() {
Pattern last = bindings.get(bindings.size() - 1).pattern;
Pattern last = lastPattern();
if (last.isLast)
if (last.relation != null)
if (numberOfMatches() < last.relation.from)
return false;
return bindings.get(bindings.size() - 1).pattern.isLast;
return last.isLast;
}

/**
* how often did the last pattern match
*/
int numberOfMatches() {

Pattern last = bindings.get(bindings.size() - 1).pattern;
Pattern last = lastPattern();

int count = 0;
for (Binding b : bindings)
Expand All @@ -186,13 +200,10 @@ int numberOfMatches() {
*/
List<Pattern> candidatePatterns() {

Pattern last = bindings.get(bindings.size() - 1).pattern;
Pattern last = lastPattern();
Pattern next = last.next;

int count = 0;
for (Binding b : bindings)
if (b.pattern == last)
count++;
int count = numberOfMatches();

if (last.relation == null)
// we are at the start, return next if there is one
Expand Down Expand Up @@ -233,7 +244,7 @@ void search(List<Map<String, Object>> res) throws Exception {
for (Pattern pattern : candidatePatterns()) {
if (pattern == null)
continue;
Binding b = bindings.get(bindings.size() - 1);
Binding b = lastBinding();

if (pattern.relation.left2right == null || pattern.relation.left2right) {
if (pattern.relation.name == null) {
Expand Down

0 comments on commit 88de29a

Please sign in to comment.