Skip to content

Commit

Permalink
feat: read support for '&&' operator for lucene geo overlap in the ne…
Browse files Browse the repository at this point in the history
…w query engine
  • Loading branch information
tglman committed Nov 12, 2024
1 parent 6b558bd commit 0714584
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,12 @@ public boolean canBeMerged() {
public boolean isSupportingBinaryEvaluate() {
return false;
}

public String getKeyword() {
return keyword;
}

public boolean evaluate(Object iLeft, Object iRight) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;

import com.orientechnologies.orient.core.sql.OSQLEngine;
import com.orientechnologies.orient.core.sql.executor.metadata.OIndexFinder.Operation;
import com.orientechnologies.orient.core.sql.operator.OQueryOperator;
import com.orientechnologies.orient.core.sql.operator.OQueryOperatorFactory;
import java.util.Iterator;
import java.util.Map;

public class OScAndOperator extends SimpleNode implements OBinaryCompareOperator {
Expand All @@ -12,18 +15,32 @@ public class OScAndOperator extends SimpleNode implements OBinaryCompareOperator

public OScAndOperator(int id) {
super(id);
initOperator();
}

public OScAndOperator(OrientSql p, int id) {
super(p, id);
initOperator();
}

protected void initOperator() {
Iterator<OQueryOperatorFactory> factories = OSQLEngine.getOperatorFactories();
while (factories.hasNext()) {
OQueryOperatorFactory factory = factories.next();
for (OQueryOperator op : factory.getOperators()) {
if ("&&".equals(op.getKeyword())) {
lowLevelOperator = op;
}
}
}
}

@Override
public boolean execute(Object iLeft, Object iRight) {
if (lowLevelOperator == null) {
throw new UnsupportedOperationException();
}
return false;
return lowLevelOperator.evaluate(iLeft, iRight);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,22 @@ public Object evaluateRecord(

return SpatialOperation.BBoxIntersects.evaluate(shape, shape1.getBoundingBox());
}

@Override
public boolean evaluate(Object iLeft, Object iRight) {
Shape shape = factory.fromObject(iLeft);

// TODO { 'shape' : { 'type' : 'LineString' , 'coordinates' : [[1,2],[4,6]]} }
// TODO is not translated in map but in array[ { 'type' : 'LineString' , 'coordinates' :
// [[1,2],[4,6]]} ]
Object filter;
if (iRight instanceof Collection) {
filter = ((Collection) iRight).iterator().next();
} else {
filter = iRight;
}
Shape shape1 = factory.fromObject(filter);

return SpatialOperation.BBoxIntersects.evaluate(shape, shape1.getBoundingBox());
}
}

0 comments on commit 0714584

Please sign in to comment.