Fixed a bug when creating an MBR over a circle.
Change-Id: Iff883cbcbcfa759e2dc046fec6d1dbb256649500
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/113
Reviewed-by: Pouria Pirzadeh <pouria.pirzadeh@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ddl.aql
new file mode 100644
index 0000000..52fa76f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.ddl.aql
@@ -0,0 +1,19 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as closed {
+ id: int32,
+ point: point,
+ kwds: string,
+ line1: line,
+ line2: line,
+ poly1: polygon,
+ poly2: polygon,
+ rec: rectangle,
+ circle: circle
+}
+
+create dataset MyData(MyRecord)
+ primary key id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.update.aql
new file mode 100644
index 0000000..d845d68
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.2.update.aql
@@ -0,0 +1,6 @@
+use dataverse test;
+
+load dataset MyData
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ddl.aql
new file mode 100644
index 0000000..b6a123e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.3.ddl.aql
@@ -0,0 +1,3 @@
+use dataverse test;
+
+create index rtree_index_point on MyData(point) type rtree;
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.query.aql
new file mode 100644
index 0000000..31064ab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.4.query.aql
@@ -0,0 +1,6 @@
+use dataverse test;
+
+for $o in dataset('MyData')
+where spatial-intersect($o.point, create-circle(create-point(5.0,5.0), 0.5))
+order by $o.id
+return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.adm b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.adm
new file mode 100644
index 0000000..058a335
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-circular-query/rtree-secondary-index-circular-query.1.adm
@@ -0,0 +1,2 @@
+{ "id": 13 }
+{ "id": 14 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index a927e94..d4facd7 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -2430,6 +2430,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="index-selection">
+ <compilation-unit name="rtree-secondary-index-circular-query">
+ <output-dir compare="Text">rtree-secondary-index-circular-query</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="index-selection">
<compilation-unit name="disjunctive-predicate-1">
<output-dir compare="Text">disjunctive-predicate-1</output-dir>
</compilation-unit>
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/CreateMBREvalFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
index 9d6d4e1..aac183d 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
@@ -227,9 +227,9 @@
double x = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.X));
- double radius = ADoubleSerializerDeserializer.getDouble(outInput0
- .getByteArray(), ACircleSerializerDeserializer
- .getCenterPointCoordinateOffset(Coordinate.X));
+ double radius = ADoubleSerializerDeserializer.getDouble(
+ outInput0.getByteArray(),
+ ACircleSerializerDeserializer.getRadiusOffset());
value = x - radius;
}
@@ -238,9 +238,9 @@
double y = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.Y));
- double radius = ADoubleSerializerDeserializer.getDouble(outInput0
- .getByteArray(), ACircleSerializerDeserializer
- .getCenterPointCoordinateOffset(Coordinate.Y));
+ double radius = ADoubleSerializerDeserializer.getDouble(
+ outInput0.getByteArray(),
+ ACircleSerializerDeserializer.getRadiusOffset());
value = y - radius;
}
@@ -249,9 +249,9 @@
double x = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.X));
- double radius = ADoubleSerializerDeserializer.getDouble(outInput0
- .getByteArray(), ACircleSerializerDeserializer
- .getCenterPointCoordinateOffset(Coordinate.X));
+ double radius = ADoubleSerializerDeserializer.getDouble(
+ outInput0.getByteArray(),
+ ACircleSerializerDeserializer.getRadiusOffset());
value = x + radius;
}
@@ -260,9 +260,9 @@
double y = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.Y));
- double radius = ADoubleSerializerDeserializer.getDouble(outInput0
- .getByteArray(), ACircleSerializerDeserializer
- .getCenterPointCoordinateOffset(Coordinate.Y));
+ double radius = ADoubleSerializerDeserializer.getDouble(
+ outInput0.getByteArray(),
+ ACircleSerializerDeserializer.getRadiusOffset());
value = y + radius;
}