diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperator.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperator.java index 199bcded187..00d0387a648 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperator.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperator.java @@ -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(); + } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OScAndOperator.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OScAndOperator.java index 2de5b808bd4..f3d270600f3 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OScAndOperator.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OScAndOperator.java @@ -2,7 +2,10 @@ /* 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.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 { @@ -11,10 +14,24 @@ 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 factories = OSQLEngine.getOperatorFactories(); + while (factories.hasNext()) { + OQueryOperatorFactory factory = factories.next(); + for (OQueryOperator op : factory.getOperators()) { + if ("&&".equals(op.getKeyword())) { + lowLevelOperator = op; + } + } + } } @Override @@ -25,7 +42,7 @@ public boolean execute(Object iLeft, Object iRight) { if (lowLevelOperator == null) { throw new UnsupportedOperationException(); } - return false; + return lowLevelOperator.evaluate(iLeft, iRight); } @Override diff --git a/lucene/src/main/java/com/orientechnologies/spatial/operator/OLuceneOverlapOperator.java b/lucene/src/main/java/com/orientechnologies/spatial/operator/OLuceneOverlapOperator.java index 25de1e2f245..2af2f3045ac 100644 --- a/lucene/src/main/java/com/orientechnologies/spatial/operator/OLuceneOverlapOperator.java +++ b/lucene/src/main/java/com/orientechnologies/spatial/operator/OLuceneOverlapOperator.java @@ -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()); + } }